Jump to content
  • Advertisement
Sign in to follow this  

[HAVOK] Loading a hkpShape from File

This topic is 2789 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


I currently try to add Havok Physics to my space action game. Now I want to load collision models for my ships from files to use them as Shapes.

My question is now: How to load a file (*.hkt or *.hkx) and use it's geometry? Which implementation of hkpShape is appropriate for this usage?

thanks for your help


Share this post

Link to post
Share on other sites
I only load an entire physics system from file - so a rigid body with a shape etc...

You'll still have to get the shape from the rigid body or something like that, I think there is a demo which shows you how to load a shape only from file (one of the character rigid body demos I think).

I'm not sure if my method is suitable for this, as I never loaded shapes only from files.

Assert(m_world && "NXPHavokMain::GetRigidBodyByName");

hkObjectResource* loadedData = hkSerializeUtil::loadOnHeap(file.c_str());
Assert(loadedData && "NXPHavokMain::CreatePhysicsSystemFromFile");

hkRootLevelContainer* root=loadedData->stealContents<hkRootLevelContainer>();
Assert(root && "NXPHavokMain::CreatePhysicsSystemFromFile");

hkpPhysicsData* pd=static_cast<hkpPhysicsData*>(root->findObjectByType(hkpPhysicsDataClass.getName()));
Assert(pd && "NXPHavokMain::CreatePhysicsSystemFromFile");


for(int i=0;i<pd->getPhysicsSystems().getSize();++i)


delete loadedData; // 'loadedData' no longer owns the data and may now be destroyed

About which is appropriate: anything that isn't a "mesh" (that isn't concave).
Maybe you could get away by using just primitives (box, sphere,...) or make a simple convex mesh.

Share this post

Link to post
Share on other sites
OK, if I interprete your code snippet correctly, I could store the whole physical data belonging to an object in a hkt file and load it in order to use it as a physical representation of this object.

And the hkpPhysicsSystem includes the RigidBody, which I need to get transformation data?

Share this post

Link to post
Share on other sites
Correct, you can load an entire physics rigid body with shape and other stuff if you need (constraints, etc...) this way.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!