Meshes and Havok [newbie]

Meshes and Havok [newbie]

Hello,

This should be a rather simple problem to solve. I have a mesh that I want to add to my Havok world. I do not want to use Havok's Content tools to create a file and load it with Havok, instead I want to create a Havok shape at runtime and add it to the world. How can I do this? Unfortunately I have not been able to find enough information on Havok's classes (e.g. hkpExtendedMeshShape) to do this myself.

Any help is appreciated.

6 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

To put it simpler: I have the vertice data of my mesh. I am looking for a way to create a hkpRigidBody out of the data so that I may add it to my world.

I didn't find a straightforward example of this either. Section 4.4 Landscapes explains most of it, but falls a bit short. This example may help. Note that you must create an array of indexes from your vertex data:

hkpExtendedMeshShape* mesh = new hkpExtendedMeshShape();
hkpExtendedMeshShape::TrianglesSubpart part;
part.m_vertexBase = verts;
part.m_vertexStriding = sizeof(float)*3;
part.m_numVertices = verts_tot;
part.m_indexBase = tri_indexes;
part.m_indexStriding = sizeof( unsigned short)*3;
part.m_numTriangleShapes = tri_indexes_tot/3;
part.m_stridingType = hkpExtendedMeshShape::INDICES_INT16;
mesh->addTrianglesSubpart( part );
hkpRigidBodyCinfo rbCi;
rbCi.m_shape = mesh;
rbCi.m_motionType = hkpMotion::MOTION_FIXED;
rbCi.m_position.set( 0, 0, 0 );
hkpRigidBody* rb = new hkpRigidBody(rbCi);
physicsWorld->addEntity(rb);
mesh->removeReference();
rb->removeReference();

Hey guys,

You can also see this done by a24710 here.

Daniel

Thank you, quantumred and havokdaniel, for your prompt responses. Unfortunately I am running into a few issues. Havok does not seem to be complaining about the data that I give it, but the Visual Debugger shows that Havok is clearly not representing the mesh as I hope. If I load a really big mesh (such as a quake map, for instance) I can see some similarities in the shape.

I fear that the problem could be my indices or how I am formatting the indice and vertice arrays. My next request would be for someone to post a small example of filling an indice array and vertice array that will be used in TrianglesSubpart.

Thank you.

Nevermind, I have found the solution. As I feared, the error was that I was not setting up my index and vertex arrays correctly. Thank you again, quantumred and havokdaniel, for the samples that you have provided.

Connectez-vous pour laisser un commentaire.