11 #include <osg/PrimitiveSet>
12 #include <osg/Geometry>
14 #include <osgText/Font>
15 #include <osgText/Text>
17 #ifdef AVOID_OSG_INDICES
22 #define FAB osg::Material::FRONT_AND_BACK
27 #define VT_TexCoords 4
28 #ifdef USE_OPENGL_BUFFER_OBJECTS
50 typedef osg::PrimitiveSet::Mode PrimType;
52 vtMesh(PrimType ePrimType,
int VertType,
int NumVertices);
55 void GetBoundBox(
FBox3 &box)
const;
58 void AddTri(
int p0,
int p1,
int p2);
59 void AddFan(
int p0,
int p1,
int p2 = -1,
int p3 = -1,
int p4 = -1,
int p5 = -1);
60 void AddFan(
int *idx,
int iNVerts);
61 void AddStrip(
int iNVerts,
unsigned short *pIndices);
64 void AddQuad(
int p0,
int p1,
int p2,
int p3);
67 #ifdef AVOID_OSG_INDICES
68 PrimType getPrimType()
const {
return m_PrimType; }
70 PrimType getPrimType()
const {
return (PrimType) getPrimSet()->getMode(); }
73 void SetMatIndex(
int i) { m_iMatIdx = i; }
74 int GetMatIndex()
const {
return m_iMatIdx; }
78 int AddVertexN(
float x,
float y,
float z,
float nx,
float ny,
float nz);
79 int AddVertexUV(
float x,
float y,
float z,
float u,
float v);
88 void AddStrip2(
int iNVerts,
int iStartIndex);
93 int res,
bool hemi =
false,
bool bNormalsIn =
false);
100 bool bTop =
true,
bool bBottom =
true,
bool bCentered =
true,
102 void CreateTetrahedron(
const FPoint3 ¢er,
float fRadius);
106 float z=0.0f,
bool bCentered=
false);
109 double theta1,
double theta2,
110 double r1,
double r2,
int res = 40);
112 int Axis1,
int Axis2,
int Axis3,
113 const FPoint2 &min1,
const FPoint2 &max1,
float fLevel,
float fTiling);
116 uint GetNumVertices()
const;
132 void SetVtxPUV(uint i,
const FPoint3 &pos,
float u,
float v)
148 int GetNumPrims()
const;
149 int GetNumIndices()
const {
return getVertexIndices()->getNumElements(); }
150 short GetIndex(
int i)
const {
return getIndices()->at(i); }
151 int GetPrimLen(
int i)
const {
return dynamic_cast<const osg::DrawArrayLengths*
>(getPrimitiveSet(0))->at(i); }
155 bool hasVertexNormals()
const {
return getNormalArray() != NULL; }
156 bool hasVertexColors()
const {
return getColorArray() != NULL; }
157 bool hasVertexTexCoords()
const {
return getTexCoordArray(0) != NULL; }
161 void _AddStripNormals();
162 void _AddPolyNormals();
163 void _AddTriangleNormals();
164 void _AddQuadNormals();
166 osg::PrimitiveSet *getPrimSet() {
return getPrimitiveSet(0); }
167 const osg::PrimitiveSet *getPrimSet()
const {
return getPrimitiveSet(0); }
170 osg::DrawArrays *getDrawArrays() {
return dynamic_cast<osg::DrawArrays*
>(getPrimitiveSet(0)); }
171 osg::DrawArrayLengths *getDrawArrayLengths() {
return dynamic_cast<osg::DrawArrayLengths*
>(getPrimitiveSet(0)); }
173 const osg::DrawArrays *getDrawArrays()
const {
return dynamic_cast<const osg::DrawArrays*
>(getPrimitiveSet(0)); }
174 const osg::DrawArrayLengths *getDrawArrayLengths()
const {
return dynamic_cast<const osg::DrawArrayLengths*
>(getPrimitiveSet(0)); }
176 osg::UIntArray *getIndices() {
return (osg::UIntArray*) getVertexIndices(); }
177 const osg::UIntArray *getIndices()
const {
return (
const osg::UIntArray*) getVertexIndices(); }
179 osg::Vec3Array *getVerts() {
return (osg::Vec3Array*) getVertexArray(); }
180 const osg::Vec3Array *getVerts()
const {
return (
const osg::Vec3Array*) getVertexArray(); }
182 osg::Vec3Array *getNormals() {
return (osg::Vec3Array*) getNormalArray(); }
183 const osg::Vec3Array *getNormals()
const {
return (
const osg::Vec3Array*) getNormalArray(); }
185 osg::Vec4Array *getColors() {
return (osg::Vec4Array*) getColorArray(); }
186 const osg::Vec4Array *getColors()
const {
return (
const osg::Vec4Array*) getColorArray(); }
188 osg::Vec2Array *getTexCoords() {
return (osg::Vec2Array*) getTexCoordArray(0); }
189 const osg::Vec2Array *getTexCoords()
const {
return (
const osg::Vec2Array*) getTexCoordArray(0); }
192 #ifdef AVOID_OSG_INDICES
208 vtTextMesh(osgText::Font *font,
float fSize = 1,
bool bCenter =
false);
211 void GetBoundBox(
FBox3 &box)
const;
214 void SetText(
const char *text);
217 void SetText(
const wchar_t *text);
219 void SetText(
const std::wstring &text);
234 void SetMatIndex(
int i) { m_iMatIdx = i; }
235 int GetMatIndex()
const {
return m_iMatIdx; }
243 #endif // VTOSG_MESHH