btTriangleMesh debug draw

Kavarna
Posts: 2
Joined: Mon May 29, 2017 1:35 pm

btTriangleMesh debug draw

Post by Kavarna »

My first topic here! :D

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
This is the way I want to debug

Code: Select all

	setDebugMode( DBG_DrawWireframe );
And here is the call to the debugger

Code: Select all

	m_pWorld->debugDrawObject( btTransform::getIdentity( ), TorusShape,
			btVector3( 1, 1, 1 ) );
	// I also draw the Torus here
Am I missing something here?
How should I create a custom 3D Mesh?
You do not have the required permissions to view the files attached to this post.