Main Page   Class Hierarchy   Compound List   File List   Compound Members  

Building.h

00001 //
00002 // Building.h
00003 //
00004 // Implements the vtBuilding class which represents a single building.
00005 //
00006 // Copyright (c) 2001 Virtual Terrain Project
00007 // Free for all uses, see license.txt for details.
00008 //
00009 
00010 #ifndef BUILDINGH
00011 #define BUILDINGH
00012 
00013 #include "MathTypes.h"
00014 #include "Selectable.h"
00015 
00016 enum WallType
00017 {
00018     WALL_FLAT, WALL_SIDING, WALL_GLASS
00019 };
00020 enum RoofType
00021 {
00022     ROOF_FLAT, ROOF_SHED, ROOF_GABLE, ROOF_HIP, NUM_ROOFTYPES
00023 };
00024 
00025 enum BldShape
00026 {
00027     SHAPE_RECTANGLE,
00028     SHAPE_CIRCLE,
00029     SHAPE_POLY,
00030     NUM_BLDSHAPES
00031 };
00032 
00033 enum BldColor
00034 {
00035     BLD_BASIC,
00036     BLD_ROOF,
00037     BLD_MOULDING
00038 };
00039 
00040 class vtWall
00041 {
00042 public:
00043     void Set(int iDoors, int iWindows, WallType m_Type);
00044 
00045     int     m_iDoors;
00046     int     m_iWindows;
00047     WallType m_Type;
00048 };
00049 
00050 #define MAX_WALLS   24  // the largest number of walls
00051                         // (largest number of points in a poly-shaped building)
00052 
00053 class vtStory
00054 {
00055 public:
00056     vtStory();
00057     vtStory(const vtStory &from) { *this = from; }
00058     ~vtStory();
00059 
00060     // assignment operator
00061     vtStory &operator=(const vtStory &v);
00062 
00063     void DeleteWalls();
00064     void SetWalls(int n);
00065 
00066     Array<vtWall *> m_Wall;
00067 //  float   m_fHeight;  // TODO
00068 };
00069 
00070 class vtBuilding : public Selectable
00071 {
00072 public:
00073     vtBuilding();
00074     ~vtBuilding();
00075 
00076     // copy
00077     vtBuilding &operator=(const vtBuilding &v);
00078 
00079     // center of the building
00080     void SetLocation(double x, double y);
00081     void SetLocation(const DPoint2 &p) { m_EarthPos = p; }
00082     DPoint2 GetLocation() const { return m_EarthPos; }
00083 
00084     //depth will be set to the greater of the 2 values.
00085     void SetRectangle(float fWidth, float fDepth);
00086     void GetRectangle(float &fWidth, float &fDepth) const
00087     {
00088         fWidth = m_fWidth;
00089         fDepth = m_fDepth;
00090     }
00091     void SetRadius(float fRad) { m_fRadius = fRad; }
00092     float GetRadius() const { return m_fRadius; }
00093 
00094     void SetFootprint(DLine2 &dl);
00095     DLine2 &GetFootprint() { return m_Footprint; }
00096 
00097     void SetColor(BldColor which, RGBi col);
00098     RGBi GetColor(BldColor which);
00099 
00100     void SetRotation(float fRadians);
00101     void GetRotation(float &fRadians) const { fRadians = m_fRotation; }
00102 
00103     void SetShape(BldShape s) { m_BldShape = s; }
00104     BldShape GetShape() { return m_BldShape; }
00105 
00106     void SetStories(int i);
00107     int GetStories() const { return m_Story.GetSize(); }
00108 
00109     DRECT GetExtents();
00110     void SetCenterFromPoly();
00111     void Offset(DPoint2 &p);
00112     void RectToPoly();
00113 
00114     RoofType    m_RoofType;
00115     bool        m_bMoulding;
00116     bool        m_bElevated;
00117 
00118 protected:
00119     //colors
00120     RGBi        m_Color;            // overall building color
00121     RGBi        m_RoofColor;        // roof color
00122     RGBi        m_MouldingColor;    // color of trim
00123 
00124     // information about each story
00125     Array<vtStory *> m_Story;
00126 
00127     // fields that affect placement
00128     DPoint2     m_EarthPos;         // location of building center
00129     float       m_fRotation;        // in Radians
00130 
00131     // fields that affect size
00132     BldShape    m_BldShape;
00133 
00134     // size of base (for rectanguloid buildings)
00135     float       m_fWidth, m_fDepth; // in meters
00136 
00137     // radius (for cylindroid buildings)
00138     float       m_fRadius;
00139     
00140     // footprint (for polygonal buildings)
00141     DLine2      m_Footprint;
00142 
00143 private:
00144     void DeleteStories();
00145     void RebuildWalls();
00146 };
00147 
00148 typedef vtBuilding *vtBuildingPtr;
00149 
00150 #endif

Generated at Fri Aug 17 14:40:42 2001 for vtdata library by doxygen1.2.4 written by Dimitri van Heesch, © 1997-2000