00001
00002 #ifndef _VRSODE_TRIANGLE_DATA_H_
00003 #define _VRSODE_TRIANGLE_DATA_H_
00004
00005 #include <vector>
00006 #include <vrs/vector.h>
00007 #include <vrs/sharedobj.h>
00008 #include <ode/ode.h>
00009
00010 namespace vrsode
00011 {
00012
00013 class TrimeshShape;
00014
00015 #define VO_TRIMESH_COORD_TYPE float
00016 #define VO_TRIMESH_INDEX_TYPE int
00017
00022 class TriangleData : public VRS::SharedObj
00023 {
00024 bool m_activeDataPool;
00025
00026 unsigned int m_vertexArraySize[2];
00027 unsigned int m_indexArraySize[2];
00028
00029 unsigned int m_vertexArrayFill[2];
00030 unsigned int m_indexArrayFill[2];
00031
00032 VO_TRIMESH_COORD_TYPE* m_vertexArray[2];
00033 VO_TRIMESH_INDEX_TYPE* m_indexArray[2];
00034
00035 VRS::SO<TrimeshShape> m_callbackShape;
00036 void (TrimeshShape::*m_callbackFunction)();
00037
00041 void cleanInactivePool();
00042
00043 public:
00049 TriangleData(unsigned int vertexCount, unsigned int indexCount);
00050
00051
00052 virtual ~TriangleData();
00053
00057 void addVertex(VRS::Vector3Base<VO_TRIMESH_COORD_TYPE>);
00058
00062 void addVertex(
00063 VO_TRIMESH_COORD_TYPE, VO_TRIMESH_COORD_TYPE, VO_TRIMESH_COORD_TYPE);
00064
00068 void addIndex(VRS::Vector3Base<VO_TRIMESH_INDEX_TYPE>);
00069
00073 void addIndex(
00074 VO_TRIMESH_INDEX_TYPE, VO_TRIMESH_INDEX_TYPE, VO_TRIMESH_INDEX_TYPE);
00075
00079 void addTriangle(VRS::Vector3Base<VO_TRIMESH_COORD_TYPE>,
00080 VRS::Vector3Base<VO_TRIMESH_COORD_TYPE>,
00081 VRS::Vector3Base<VO_TRIMESH_COORD_TYPE>);
00082
00086 void addTriangle(
00087 VO_TRIMESH_COORD_TYPE, VO_TRIMESH_COORD_TYPE, VO_TRIMESH_COORD_TYPE,
00088 VO_TRIMESH_COORD_TYPE, VO_TRIMESH_COORD_TYPE, VO_TRIMESH_COORD_TYPE,
00089 VO_TRIMESH_COORD_TYPE, VO_TRIMESH_COORD_TYPE, VO_TRIMESH_COORD_TYPE);
00090
00094 void addQuad(VRS::Vector3Base<VO_TRIMESH_COORD_TYPE>,
00095 VRS::Vector3Base<VO_TRIMESH_COORD_TYPE>,
00096 VRS::Vector3Base<VO_TRIMESH_COORD_TYPE>,
00097 VRS::Vector3Base<VO_TRIMESH_COORD_TYPE>);
00098
00102 void addQuad(
00103 VO_TRIMESH_COORD_TYPE, VO_TRIMESH_COORD_TYPE, VO_TRIMESH_COORD_TYPE,
00104 VO_TRIMESH_COORD_TYPE, VO_TRIMESH_COORD_TYPE, VO_TRIMESH_COORD_TYPE,
00105 VO_TRIMESH_COORD_TYPE, VO_TRIMESH_COORD_TYPE, VO_TRIMESH_COORD_TYPE,
00106 VO_TRIMESH_COORD_TYPE, VO_TRIMESH_COORD_TYPE, VO_TRIMESH_COORD_TYPE);
00107
00112 const std::vector<VRS::Vector3Base<double> > explicitVertexList() const;
00113
00119 const std::vector<VRS::Vector3Base<double> >
00120 explicitVertexListForLines() const;
00121
00125 VO_TRIMESH_COORD_TYPE* vertexArray();
00126
00130 VO_TRIMESH_INDEX_TYPE* indexArray();
00131
00135 unsigned int vertexCount() const;
00136
00140 unsigned int indexCount() const;
00141
00145 unsigned int triangleCount() const;
00146
00150 void createDebugCube();
00151
00155 void createDebugThing();
00156
00160 unsigned int sizeOfVertexStride();
00161
00165 unsigned int sizeOfTriangleStride();
00166
00170 void setGeometryChangeCallback(VRS::SO<TrimeshShape>,
00171 void (TrimeshShape::*)());
00172
00177 void reportGeometryChange();
00178
00182 void initDataUpdate(unsigned int vertexCount, unsigned int indexCount);
00183
00187 void initDataUpdateKeepCurrent();
00188
00192 void rollbackDataUpdate();
00193
00197 void commitDataUpdate();
00198
00202 VO_TRIMESH_COORD_TYPE* uncommittedVertexArray();
00203
00207 VO_TRIMESH_INDEX_TYPE* uncommittedIndexArray();
00208
00212 void dump();
00213
00219 void setVertexArrayFill(unsigned int fill);
00220
00226 void setIndexArrayFill(unsigned int fill);
00227
00228 };
00229
00230 }
00231
00232 #endif