[ODE] Correct usage of a TriMesh

David Walters hidden.asbestos at googlemail.com
Sat Aug 26 01:12:01 MST 2006


> I want to create a TriMesh that contains complicated immovable physics
> objects much like the interior of a building.  I have physics proxy objects
> in my data files so I want to create tri-meshes out of these.  The FAQ says
> that I should only create a geom only and not a rigid body.
>
>
> So is the following all I would need to do:
>
> dGeomTriMeshDataBuildSimple(id, vertices, VertexCount, indices,
> indices_count);
>
> How do I position this TriMesh?


Okay, you're half-way there. The procedure is a s follows:

* Call 'dGeomTriMeshDataCreate' to create an id for the trimesh shape
data container.
* Use 'dGeomTriMeshDataBuildSimple' to configure the shape data
container with your specific trimesh layout, etc.

* Then call 'dCreateTriMesh' using the id you created which will make
a geom bound to this trimesh id. This will then allow you to position
your trimesh in the world.



> Do I need to explicity destroy this geom or is this done automatically in
> dSpaceDestroy?

I'm not sure if dSpaceDestroy will destroy geoms, my engine uses the
following destructor well before dSpaceDestroy is ever called. Note
that I'm manually destroying the trimesh data here, which I'm pretty
sure is the right way to do it.


//-----------------------------------------------------------------------------
// FcCollisionObject::~FcCollisionObject
//-----------------------------------------------------------------------------
FcCollisionObject::~FcCollisionObject()
{
	// Destroy tri-mesh?
	if ( dGeomGetClass( m_geom ) == dTriMeshClass )
	{
		// Get the trimesh id.
		dTriMeshDataID trimesh = dGeomTriMeshGetTriMeshDataID( m_geom );

		// Destroy the temporal coherence cache
		dGeomTriMeshClearTCCache( m_geom );

		// Destroy the mesh.
		dGeomTriMeshDataDestroy( trimesh );
	}

	// Destroy geometries.
	dGeomDestroy( m_geom );
	m_geom = NULL;
}



Hope this is helpful
Regards,
Dave


More information about the ODE mailing list