So, I tried to create a collision shape from a btTriangleMesh then draw it's wireframe.
It's not as easy as it sounds
So, basically, here's what I've tried so far
Code: Select all
auto Vertices = m_Graphics->GetTorus( )->GetVertices( ); // Took them straight from the Rendering Engine
auto Indices = m_Graphics->GetTorus( )->GetIndices( ); // Took them straight from the Rendering Engine
unsigned int TriangleCount = Indices.size( ) / 3;
btTriangleMesh * TorusMesh = new btTriangleMesh( true, false );
for ( unsigned int i = 0; i < TriangleCount; ++i ) // Create triangles in TorusMesh
{
TorusMesh->addTriangle( btVector3( // First Point
Vertices[ Indices[ i * 3 ] ].Position.x,
Vertices[ Indices[ i * 3 ] ].Position.y,
Vertices[ Indices[ i * 3 ] ].Position.z ), btVector3( // Second Point
Vertices[ Indices[ i * 3 + 1 ] ].Position.x,
Vertices[ Indices[ i * 3 + 1 ] ].Position.y,
Vertices[ Indices[ i * 3 + 1 ] ].Position.z ), btVector3( // Third Point
Vertices[ Indices[ i * 3 + 2 ] ].Position.x,
Vertices[ Indices[ i * 3 + 2 ] ].Position.y,
Vertices[ Indices[ i * 3 + 2 ] ].Position.z ) );
}
btCollisionShape* TorusShape = new btBvhTriangleMeshShape( TorusMesh, false, true ); // Create a collision shape
Code: Select all
setDebugMode( DBG_DrawWireframe );
Code: Select all
m_pWorld->debugDrawObject( btTransform::getIdentity( ), TorusShape,
btVector3( 1, 1, 1 ) );
// I also draw the Torus here
How should I create a custom 3D Mesh?