Link between Rigid Bodies and Mesh on tagfile

Link between Rigid Bodies and Mesh on tagfile

Hi everyone,When loading havok binary tagfileI have not able to find a direct link between a rb and it associated mesh.I find this piece of code in the demos :

//Get physics datahkpPhysicsData* physicsData = static_cast( m_contents->findObjectByType( hkpPhysicsDataClass.getName() ) )//get World InfophysicsData->getWorldCinfo();//Get all physics system which contains all rb, phantoms, ...physicsData->getPhysicsSystems();//Do batch add to the worldm_world->addPhysicsSystem;

But in my own implementation I don't use the same thing as I wrap each rb into a class like this :

class rbCustom
{
   hkpRigidBody *myRigidBody;
   int graphicId; //Use for synchronization between Havok and graphics Engine
   ....
};

More generally how to load objects and its dependancies (Ex: rb->mesh->material->texture,...) efficiently.Can you share your knowledge ?Any help is welcomeThanks in advance

5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Can somebody help me ??

You can get the shape from a rigidbody via rigidBody->getCollidable()->getShape(). If you exported this as a "mesh" then it should be hkpExtendedMeshShape.That said, using the same mesh for physics and graphics is not ideal. Graphics meshes are commonly complex, whereas you want your physics shape to be as simple as possible. Often you will want to export the physics shape in an optimized format such as a MOPP, or substitute meshes for boxes or spheres where precise collision is not necessary.An easy way to associate a loaded hkpRigidBody and it's mesh is via the name field in the modler. hkpRigidbody::getName() returns the same name that was set the modler. You can use this to associate an exported graphics mesh with it's rigid body. Just get all the physics systems like in the post above, and then loop over each of the rigid bodies checking for a specific name.Another simple method is to export a single rigid body per scene, and use the file name as the name of the mesh. Then you can export the graphics mesh with the same or similiar name, and load them together.For effiency you may want to look in to making a baking toolchain that combines your meshes into your own special optimized, interleaved file format.I hope this helps,Tyler

Thanks veryhelpful for me.

For effiency you may want to look in to making a baking toolchain that combines your meshes into your own special optimized, interleaved file format.

What do you mean ? Create a custom filter on the content tools chain

(This step is a little more advanced.)It is typically done outside our content tools via some custom standalone tool(s). Which is probably simpler than creating a custom filter for the content tools. At this stage is where you might do other baking steps like texture compression, scene lighting, scene graph processing, etc.Cheers,Tyler

Leave a Comment

Please sign in to add a comment. Not a member? Join today