Problems with not AABB Trigger object and Rigid Tri Mesh creation

Problems with not AABB Trigger object and Rigid Tri Mesh creation

Hi! Me again, some questions again...

1) I`m having some trouble with one relatively big rigid, marked as trigger and rotated at 45degrees. It looks like the collisions before the rigid is being passed to the "collision details" are AABB for the character to AABB for the trigger, so I`m getting some ugly results. How can I do that properly? (my character has to go through it)

2) Trouble creating a physics mesh from a 3d model too. I`m loading the model, pass the vertex and other data to a hkExtendedMeshShape, but the rigid model is different(buggy) from the original model. I`m loading a .3ds, but tried different formats and shapes (a simple cube too). I searched it a bit, and found that the indices should be set to 16 for simplier models and to 32 for more complex ones. Well, my app crashes if I try the wrong one, so I don`t think that`s the issue. Most probably I`m doing sth wrong with the mesh passes, so here`s the code I`m trying (not mine):
I cannot find out what Hk shape is best to use, so please recommend me one if posssible.

Member of the \"Why-why\" family
7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi burning_angel,

1) Couple of things on this first one? What type of "trigger" is it? It sounds like an hkpAabbPhantom, is that correct? If it is an aabb, how are you rotating it? They only have broadphase collision so everything will got through 3AxisSweep which only keeps track of AABBs.

Is your "character" a character proxy? a character rigid body?

Take a look at the Use Case/Character and Triggers demo. It should show how to get narrowphase triggers. You can also check out this post, for some info.

2) It looks to me like you are not keeping around your vertex and index data. Try having them as member variables of the class so they stick around. This is what some of our demos do. The hkpExtendedMeshShape doesn't copy that information, it just keeps pointers to it. So when those arrays get knocked off the stack, your mesh is going to be accessing junk data. hkpExtendedMeshShape with a Mopp is good for your meshes. You want to keep your mesh shapes stationary for the most part. Try to approximate moving bodies as convex hulls or shape primitives.

Let me know if that helps.


Developer Support Engineer

Hi Sean!

Before all, thanks for yor reply.

For my trigger problem it turned that the reason was my collector- I was using the SimpleShapePhantom collector from "CharacterPhantomInteractionDemo", not the point collector. Now everything works just as expected.

For my mesh problem I`ll try harder the next days and eventually will report back. (Currently working on sth else from the TODO list)

Member of the \"Why-why\" family

Yesterday I had some time to take a look at my mesh code. I`d messed up the vertices` coordinates. Now everything works as a charm.

Thank you once again. ;-)

Member of the \"Why-why\" family

Hello again,

Today I spend some time trying to load a .hkx file into my app, implemented the debugger and learned to use the Content Tools (or at least I think so). I`m using the code from the "Doors" demo, but game crashes at the line:

hkVersionUtil::updateToCurrentVersion(reader, hkVersionRegistry::getInstance());

I searched the forum and found and used the includes:

, tried some other codes from the forum too. I used the Doors.hkx, testlevel.hkx, simplel104.hkx (the original names may differ), tried some very basic levels of only static rigids and exported them from Max9, the settings from those .max files, and my app crashes every time, except when I`m using XML preset, but the loader kinda ignores all the rigids and creates just one plane, lying at the origin and that`s all. So once agian here is my question:

?) Which is the best way loading a .hkx scene with the constraints and dynamic rigids like when loading my game, and the world is initialized already. Some codes will be warmly welcomed. =D (checked the snapshot demo too)

I`m sorry for all those questions, but I`ll need some time to figure out the way Havok works and how to use it. So thanks for your patience. =)

Member of the \"Why-why\" family

Just updated to last Havok version.(The Content tools too.)

Ok, here`s the exact code I`m trying. Note that I`ve already created the havok world (m_world) in my havok::init() and this code is after that:

//hkString file("../media/levels/HkLevelBin.hkx");
hkString file("../media/levels/Doors.xml");
//hkBinaryPackfileReader reader;
hkXmlPackfileReader reader;
hkIstream infile( file.cString() );
HK_ASSERT( 0x215d080c, infile.isOk() );


hkVersionUtil::updateToCurrentVersion(reader, hkVersionRegistry::getInstance());

m_data = reader.getPackfileData();//<<@@@@@@@@@@@@@@@@@ CRASHES HERE

hkRootLevelContainer* container = static_cast( reader.getContents( hkRootLevelContainerClass.getName() ) );
HK_ASSERT2(0xa6451543, container != HK_NULL, "Could not load root level object" );

hkpPhysicsData* physicsData = static_cast( container->findObjectByType( hkpPhysicsDataClass.getName() ) );
HK_ASSERT2(0xa6451544, physicsData, "Could not find physics data in root level object" );
HK_ASSERT2(0xa6451535, physicsData->getWorldCinfo() != HK_NULL, "No physics cinfo in loaded file - cannot create a hkpWorld" );

m_world = new hkpWorld( *physicsData->getWorldCinfo() );


// Add all the loaded physics systems to the world.
for (int sys=0; sysgetPhysicsSystems().getSize(); sys++)
hkpPhysicsSystem* system = physicsData->getPhysicsSystems()[sys];

// Loop through all the rigid bodies, looking for doors, the player, and fixed
// objects. Set the collision filter accordingly.
for (int rb=0; rbgetRigidBodies().getSize(); rb++)
hkpRigidBody* rigidBody = system->getRigidBodies()[rb];
const char* name = rigidBody->getName();

if (rigidBody->isFixed())
rigidBody->setCollisionFilterInfo( hkpGroupFilter::calcFilterInfo(hkpGroupFilterSetup::LAYER_STATIC));



Member of the \"Why-why\" family


When you say it's crashing on that line, do you mean a true crash or just an assert? Can you send the callstack and/or assert message? If the crash is inside hkVersionUtils, a better plan than versioning at runtime would be to use the tool AssetCC to upgrade your files offline. Does the DoorsDemo work for you normally?

As for the best way to save out/load in your level is to do something like the world snapshot with contact points demo. That will minimize any jitter on load due to new contact points being found.


Leave a Comment

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