00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GEE_GEOMETRY_H
00021 #define GEE_GEOMETRY_H
00022
00023 #include <gee_config.h>
00024 #include <gee_enums.h>
00025 #include <gee_id.h>
00026 #include <gee_interval.h>
00027 #include <gee_material.h>
00028
00029 #include <vee_color.h>
00030 #include <vee_garbage.h>
00031 #include <vee_vector3.h>
00032 #include <vee_matrix4.h>
00033
00034 class GEE_Bounded;
00035 class GEE_Containment;
00036 class GEE_Mover;
00037 class GEE_ReColor;
00038 class GEE_Renderer;
00039 class GEE_World;
00040
00041 class VEE_BoundingBox;
00042
00047 class GEE_Geometry : public VEE_Garbage, public GEE_IdContainer
00048 {
00049 public:
00050 GEE_Geometry(VEE_GarbageBin *bin = 0);
00051 virtual ~GEE_Geometry();
00052
00053 virtual GEE_Geometry * clone() const;
00054 virtual GEE_Geometry * copy(GEE_World *target, id_remap * remap) const;
00055 virtual void erase();
00056 virtual bool eraseData(GEE_Containment *);
00057 virtual bool intersects(GEE_Containment *);
00058 virtual void selectVertices(GEE_Containment *,
00059 uint mask,
00060 uint values);
00061 virtual void selectFaces(GEE_Containment *,
00062 uint mask,
00063 uint values);
00064 virtual bool colorData(GEE_ReColor *);
00065 virtual bool moveData(GEE_Mover *);
00066 virtual void render(GEE_Renderer *);
00067 virtual bool getBoundingBox(VEE_BoundingBox *);
00068 virtual bool move(const VEE_Vector3 & offset);
00069 virtual void setMaterial(const GEE_Material &m);
00070 virtual bool read(GEE_Io * );
00071 virtual bool write(GEE_Io *);
00072 virtual bool finalizeRead();
00073
00074 bool readBasics(GEE_Io *);
00075 bool writeBasics(GEE_Io *);
00076
00077 bool readFile(const char *);
00078 bool writeFile(const char *);
00079
00080 void copyBasics(const GEE_Geometry &);
00081
00082 GEE_id_t group() const { return m_group; }
00083 GEE_id_t masterGroup() const;
00084 void setGroup(GEE_id_t g) { m_group = g; }
00085
00086
00091 GEE_id_t generation() const { return m_generation; }
00092
00094 void incrementGeneration(GEE_id_t add = 1)
00095 { if(m_generation >= 0) m_generation += add; }
00096
00097 void setGeneration(GEE_id_t g) { m_generation = g; }
00098
00099 void attachEditor() { m_editorCount++; }
00100 void detachEditor()
00101 { if(m_editorCount) m_editorCount--; incrementGeneration(); }
00102 int editorCount() const { return m_editorCount; }
00103
00104 void setMaterialName(const std::string &mat);
00105 void setMaterialName(const char *mat);
00107 const std::string & materialName() const { return m_materialName; }
00108
00109 GEE_Material & material() { return m_material; }
00110
00111 bool visible() const { return m_visible; }
00112 void setVisible(bool v) { m_visible = v; }
00113
00114 VEE_Matrix4d & transformation() { return m_transformation; }
00115 const VEE_Matrix4d & transformation() const { return m_transformation; }
00116 void setTransformation(const VEE_Matrix4d &t) { m_transformation = t; }
00117 void getWorldTransformation(VEE_Matrix4d *) const;
00118 void getWorldTransformation(VEE_Matrix4 *) const;
00119 void getWorldTransformations(VEE_Matrix4d *, VEE_Matrix4d *, bool *) const;
00120 void getWorldTransformations(VEE_Matrix4 *, VEE_Matrix4 *, bool *) const;
00121 void centralize();
00122
00123 void setWorld(GEE_World *w) { m_world = w; }
00124
00125 uint selectionState() const { return m_selectionState; }
00126 virtual void setSelectionState(uint s);
00127 inline void setNearlySelected(bool s);
00128 inline void setSelected(bool s);
00129 bool isSelected() const { return m_selectionState & GEE_SELECT_BIT; }
00130
00131 static GEE_Geometry * readGeometry(GEE_Io * );
00132 static GEE_Geometry * create(const char *);
00133 static void init();
00134
00135 protected:
00136
00137 bool intersectsBounded(GEE_Bounded *,
00138 VEE_BoundingBox * myBounds,
00139 const VEE_Matrix4 & myWorldTransform);
00140
00141 GEE_World *m_world;
00142
00144 int m_editorCount;
00145 GEE_id_t m_generation;
00146 GEE_id_t m_group;
00147 GEE_Material m_material;
00148 std::string m_materialName;
00149 bool m_visible;
00150 uint m_selectionState;
00151 private:
00152 VEE_Matrix4d m_transformation;
00153
00154 };
00155
00156
00157 inline void GEE_Geometry::setNearlySelected(bool s)
00158 {
00159 setSelectionState(s ?
00160 m_selectionState |= GEE_NEARLY_SELECT_BIT :
00161 m_selectionState &= ~GEE_NEARLY_SELECT_BIT);
00162 }
00163
00164 inline void GEE_Geometry::setSelected(bool s)
00165 {
00166 setSelectionState(s ?
00167 m_selectionState |= GEE_SELECT_BIT :
00168 m_selectionState &= ~GEE_SELECT_BIT);
00169 }
00170
00171 #endif