source: GTP/trunk/Lib/Illum/IBRBillboardCloudTrees/OGRE/include/BBC/BBCSubEntity.h @ 751

Revision 751, 3.5 KB checked in by igarcia, 18 years ago (diff)
Line 
1#ifndef _BBCSUBENTITY_H
2#define _BBCSUBENTITY_H
3
4#include <BBCPrerequisites.h>
5
6namespace BBC {
7 
8class _BBCExport UniqueVertex
9{
10public:
11    Ogre::Vector3 position;
12    Ogre::Vector3 normal;
13    Ogre::Vector3 uv[OGRE_MAX_TEXTURE_COORD_SETS];
14    Ogre::RGBA colour;
15    // The index of the next component with the same base details
16    // but with some variation
17    size_t nextIndex;
18
19    UniqueVertex();
20    bool operator==(const UniqueVertex& rhs) const;
21
22};
23
24typedef std::vector<UniqueVertex> UniqueVertexList;
25
26// Fordward declaration
27class SubEntity;
28
29namespace boost
30{
31    void intrusive_ptr_add_ref(SubEntity * p);
32    void intrusive_ptr_release(SubEntity * p);
33};
34
35class _BBCExport SubEntity
36{
37  private:
38    long references;
39
40    friend void boost::intrusive_ptr_add_ref(SubEntity * p);
41
42    friend void boost::intrusive_ptr_release(SubEntity * p);
43
44  protected:
45
46        typedef std::vector<unsigned short int> TextureCoordSetsDimensions;
47
48        typedef std::vector<Ogre::Vector3> Indices;
49
50        UniqueVertexList mUniqueVertexList;
51
52        TextureCoordSetsDimensions mTextureCoordSetsDimensions;
53       
54        Indices mIndices;
55       
56        bool mHasTangents;
57       
58        bool mHasVertexColours;
59       
60        bool mHasNormals;
61
62        bool mHasTextureCoords;
63
64        Ogre::String mName;
65
66        Ogre::String mMaterialName;
67
68        Ogre::AxisAlignedBox mAABBox;
69       
70  public:
71
72    SubEntity();
73
74    virtual ~SubEntity();
75
76        void enableTangents(bool value);
77       
78        bool hasTangents();
79
80        void enableNormals(bool value);
81
82        bool hasNormals();
83
84        void enableTextureCoords(bool value);
85
86        bool hasVertexColours();
87
88        void enableVertexColours(bool value);
89
90        void setVertexColour(unsigned int index, Ogre::RGBA value);
91
92        Ogre::RGBA getVertexColour(unsigned int index);
93
94        unsigned int getNumTexCoordSets();
95
96        unsigned int getTexCoordDimensions(unsigned int value);
97
98        void addTextureCoordSet(unsigned int numTexCoords);
99
100        unsigned int getNumTexCoords();
101
102        unsigned int getNumVertices();
103
104        void setPosition(unsigned int index, Ogre::Vector3 value);
105
106        Ogre::Vector3 getPosition(unsigned int index);
107
108        void setNormal(unsigned int index, Ogre::Vector3 value);
109
110        Ogre::Vector3 getNormal(unsigned int index);
111
112        void setTexCoord(unsigned int index, unsigned int set, Ogre::Vector3 value);
113
114        Ogre::Vector3 getTexCoord(unsigned int index, unsigned int set, unsigned int value);   
115
116        void addFaceVerticesIDs(Ogre::Vector3 value);
117
118        void removeFaceVerticesIDs(unsigned int value);
119
120        Ogre::Vector3 getFaceVerticesIDs(unsigned int value);
121
122        unsigned int getNumFaces();
123
124        Ogre::String getName();
125
126        void setName(Ogre::String value);
127
128        Ogre::String getMaterialName();
129
130        void setMaterialName(Ogre::String value);
131
132        UniqueVertexList* getUniqueVertices();
133
134        void addUniqueVertex(UniqueVertex uniqueVertex);
135
136        void removeUniqueVertex(unsigned int index);
137
138        UniqueVertex getUniqueVertex(unsigned int index);
139
140        const Ogre::AxisAlignedBox &getAABBox();
141
142        void setAABBox(Ogre::AxisAlignedBox box);
143
144        void generateAABBox();
145
146        const char *GetClassName(void) const;
147
148};
149
150// class specific addref/release implementation
151// the two function overloads must be in the boost namespace on most compilers:
152namespace boost
153{
154  inline void intrusive_ptr_add_ref(SubEntity * p)
155  {
156    // increment reference count of object *p
157    ++(p->references);
158  }
159
160
161
162  inline void intrusive_ptr_release(SubEntity * p)
163  {
164   // decrement reference count, and delete object when reference count reaches 0
165   if (--(p->references) == 0)
166     delete p;
167  }
168} // namespace boost
169
170typedef ::boost::intrusive_ptr<SubEntity> SubEntityPtr;
171
172}
173#endif
Note: See TracBrowser for help on using the repository browser.