Back to index

supertuxkart  0.5+dfsg1
Public Member Functions | Private Attributes
btTriangleMesh Class Reference

btTriangleMesh provides storage for a concave triangle mesh. It can be used as data for the btTriangleMeshShape. It allows either 32bit or 16bit indices, and 4 (x-y-z-w) or 3 (x-y-z) component vertices. btTriangleMesh will duplicate/keep all mesh data. If you prefer, you can avoid using btTriangleMesh and directly use btTriangleIndexVertexArray or derive your own class from btStridingMeshInterface. This allows to share render and collision meshes. More...

#include <btTriangleMesh.h>

Collaboration diagram for btTriangleMesh:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 btTriangleMesh (bool use32bitIndices=true, bool use4componentVertices=true)
bool getUse32bitIndices () const
bool getUse4componentVertices () const
void addTriangle (const btVector3 &vertex0, const btVector3 &vertex1, const btVector3 &vertex2)
int getNumTriangles () const
virtual void preallocateVertices (int numverts)
virtual void preallocateIndices (int numindices)

Private Attributes

btAlignedObjectArray< btVector3m_4componentVertices
btAlignedObjectArray< float > m_3componentVertices
btAlignedObjectArray< int > m_32bitIndices
btAlignedObjectArray< short int > m_16bitIndices
bool m_use32bitIndices
bool m_use4componentVertices

Detailed Description

btTriangleMesh provides storage for a concave triangle mesh. It can be used as data for the btTriangleMeshShape. It allows either 32bit or 16bit indices, and 4 (x-y-z-w) or 3 (x-y-z) component vertices. btTriangleMesh will duplicate/keep all mesh data. If you prefer, you can avoid using btTriangleMesh and directly use btTriangleIndexVertexArray or derive your own class from btStridingMeshInterface. This allows to share render and collision meshes.

Definition at line 28 of file btTriangleMesh.h.


Constructor & Destructor Documentation

btTriangleMesh::btTriangleMesh ( bool  use32bitIndices = true,
bool  use4componentVertices = true 
)

Definition at line 20 of file btTriangleMesh.cpp.

:m_use32bitIndices(use32bitIndices),
m_use4componentVertices(use4componentVertices)
{
       btIndexedMesh meshIndex;
       meshIndex.m_numTriangles = 0;
       meshIndex.m_numVertices = 0;
       meshIndex.m_indexType = PHY_INTEGER;
       meshIndex.m_triangleIndexBase = 0;
       meshIndex.m_triangleIndexStride = 3*sizeof(int);
       meshIndex.m_vertexBase = 0;
       meshIndex.m_vertexStride = sizeof(btVector3);
       m_indexedMeshes.push_back(meshIndex);

       if (m_use32bitIndices)
       {
              m_indexedMeshes[0].m_numTriangles = m_32bitIndices.size()/3;
              m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_32bitIndices[0];
              m_indexedMeshes[0].m_indexType = PHY_INTEGER;
              m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(int);
       } else
       {
              m_indexedMeshes[0].m_numTriangles = m_16bitIndices.size()/3;
              m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_16bitIndices[0];
              m_indexedMeshes[0].m_indexType = PHY_SHORT;
              m_indexedMeshes[0].m_triangleIndexStride = 3*sizeof(short int);
       }

       if (m_use4componentVertices)
       {
              m_indexedMeshes[0].m_numVertices = m_4componentVertices.size();
              m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_4componentVertices[0];
              m_indexedMeshes[0].m_vertexStride = sizeof(btVector3);
       } else
       {
              m_indexedMeshes[0].m_numVertices = m_3componentVertices.size()/3;
              m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0];
              m_indexedMeshes[0].m_vertexStride = 3*sizeof(btScalar);
       }


}

Here is the call graph for this function:


Member Function Documentation

void btTriangleMesh::addTriangle ( const btVector3 vertex0,
const btVector3 vertex1,
const btVector3 vertex2 
)

Definition at line 64 of file btTriangleMesh.cpp.

{
       m_indexedMeshes[0].m_numTriangles++;
       m_indexedMeshes[0].m_numVertices+=3;

       if (m_use4componentVertices)
       {
              m_4componentVertices.push_back(vertex0);
              m_4componentVertices.push_back(vertex1);
              m_4componentVertices.push_back(vertex2);
              m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_4componentVertices[0];
       } else
       {
              m_3componentVertices.push_back(vertex0.getX());
              m_3componentVertices.push_back(vertex0.getY());
              m_3componentVertices.push_back(vertex0.getZ());

              m_3componentVertices.push_back(vertex1.getX());
              m_3componentVertices.push_back(vertex1.getY());
              m_3componentVertices.push_back(vertex1.getZ());

              m_3componentVertices.push_back(vertex2.getX());
              m_3componentVertices.push_back(vertex2.getY());
              m_3componentVertices.push_back(vertex2.getZ());
              m_indexedMeshes[0].m_vertexBase = (unsigned char*)&m_3componentVertices[0];
       }

       if (m_use32bitIndices)
       {
              int curIndex = m_32bitIndices.size();
              m_32bitIndices.push_back(curIndex++);
              m_32bitIndices.push_back(curIndex++);
              m_32bitIndices.push_back(curIndex++);
              m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_32bitIndices[0];
       } else
       {
              int curIndex = m_16bitIndices.size();
              m_16bitIndices.push_back(curIndex++);
              m_16bitIndices.push_back(curIndex++);
              m_16bitIndices.push_back(curIndex++);
              m_indexedMeshes[0].m_triangleIndexBase = (unsigned char*) &m_16bitIndices[0];
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 108 of file btTriangleMesh.cpp.

{
       if (m_use32bitIndices)
       {
              return m_32bitIndices.size() / 3;
       }
       return m_16bitIndices.size() / 3;
}

Here is the call graph for this function:

bool btTriangleMesh::getUse32bitIndices ( ) const [inline]

Definition at line 42 of file btTriangleMesh.h.

              {
                     return m_use32bitIndices;
              }

Definition at line 47 of file btTriangleMesh.h.

virtual void btTriangleMesh::preallocateIndices ( int  numindices) [inline, virtual]

Definition at line 57 of file btTriangleMesh.h.

{(void) numindices;}
virtual void btTriangleMesh::preallocateVertices ( int  numverts) [inline, virtual]

Definition at line 56 of file btTriangleMesh.h.

{(void) numverts;}

Member Data Documentation

Definition at line 34 of file btTriangleMesh.h.

Definition at line 33 of file btTriangleMesh.h.

Definition at line 31 of file btTriangleMesh.h.

Definition at line 30 of file btTriangleMesh.h.

Definition at line 35 of file btTriangleMesh.h.

Definition at line 36 of file btTriangleMesh.h.


The documentation for this class was generated from the following files: