- struct TVertex
- {
- float x,y,z;
- TVertex(){x=0;y=0;z=0;};
- void Set(float x_, float y_, float z_){x=x_;y=y_;z=z_;};
- TVertex& operator = (TVertex const& rhs) //Dem Linken die Rechten werte Zuweisen
- {
- TVertex tmp(rhs);
- this->x=tmp.x;
- this->y=tmp.y;
- this->z=tmp.z;
- return *this;
- };
- };
- struct ChildObject
- {
- public:
- bool Visible;
- std::string Name;
- std::vector<TPolygon> Polys;
- TVertex BoundingBox[7];
- void DrawBoundingBox_();
- void Draw();
- void CalculateBoundingBox();
- };
- void ChildObject::CalculateBoundingBox()
- {
- float MinX, MaxX, MinY, MaxY, MinZ, MaxZ;
- unsigned int x;
- MinX=0; MaxX=0; MinY=0; MaxY=0; MinZ=0; MaxZ=0;
- for(x=0; x<Polys.size()-1; x++)
- {
- if(Polys[x].vert->x < MinX) MinX = Polys[x].vert->x;
- if(Polys[x].vert->y < MinY) MinY = Polys[x].vert->y;
- if(Polys[x].vert->z < MinZ) MinZ = Polys[x].vert->z;
- if(Polys[x].vert->x > MaxX) MaxX = Polys[x].vert->x;
- if(Polys[x].vert->y > MaxY) MaxY = Polys[x].vert->y;
- if(Polys[x].vert->z > MaxZ) MaxZ = Polys[x].vert->z;
- }
- BoundingBox[0].Set(MinX,MinY,MinZ);
- BoundingBox[1].Set(MaxX,MinY,MinZ);
- BoundingBox[2].Set(MaxX,MinY,MaxZ);
- BoundingBox[3].Set(MinX,MinY,MaxZ);
- BoundingBox[4].Set(MinX,MaxY,MinZ);
- BoundingBox[5].Set(MaxX,MaxY,MinZ);
- BoundingBox[6].Set(MaxX,MaxY,MaxZ);
- BoundingBox[7].Set(MinX,MaxY,MaxZ);
- };
- struct MainObject : public ChildObject
- {
- public:
- vector<ChildObject> Childs;
- void DrawBoundingBox();
- };