Help in switching from PhysX to Havok

Help in switching from PhysX to Havok

Hello,

I really need help from those who previously used PhysX in their simulations.I need help in switching from PhysX to Havok.

I have abstract function in my physics class. It looks:

// Abstract joint creation function
NxJoint* CreateJoint( NxJointDesc &jointDesc );

// Abstract Actor creation function
NxActor* CreateActor( NxScene* scene, NxActorDescBase &actorDesc, class NxHandle* handle = NULL );

Are there any simlarabstract classes of joint creation in Havok? Which class can replace NxJoint(core joint/constraint class)and NxJointDesc(core abstaractivestructure which describes joint)? What about NxActor equivalent in Havok? (I think hkRigidBody can be, Am I right?)

Thanks!

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

Hi there

I'm not familiar at all with how PhysX works, but I can hopefully point out some of the Havok classes that I think match.

From your description, their 'joint' seems like our 'constraint' (Havok Physics -> Havok Dynamics -> Constraints). 'NxJoint' would then be our hkpConstraintInstance and 'jointDesc' the hkpConstraintData. The code to make a hinge constraint between rigid bodies bodyA and bodyB will look like this:

// Create the constraint data
hkpHingeConstraintData* hcd = new hkpHingeConstraintData();

... set the variables of hcd ...

// Create the constraint instance
hkpConstraintInstance* hingeConstraint = new hkpConstraintInstance( bodyA, bodyB, hcd );

// Add the constraint to the world
m_world->addConstraint( hingeConstraint );

// World now 'owns' constraint, constraint 'owns' hcd
constraint->removeReference();
hcd->removeReference();

I'm sure you can write a wrapper for that if you need one.

'NxActor' could well be like our rigid body - if that's what it is, then to create one you need an hkpRigidBodyCinfo, which contains the position, shape, mass etc., then create a rigid body with that Cinfo and add it to the world. The 'NxActorDescBase' would then be the analog of our hkpRigidBodyCinfo. I'm not sure what that NxHandle is about.

// Create shape
hkpShape* sphereShape = new hkpSphereShape( 0.5f );

// Create cinfo, set properties
hkpRigidBodyCinfo info;
info.m_position.set(0.0f, 0.0f, 0.0f);
info.m_shape = sphereShape;
info.m_motionType = hkpMotion::MOTION_FIXED;

// Create the rigid body
fixedBody = new hkpRigidBody(info);

// Add the rigid body to the world
m_world->addEntity(fixedBody);

// World now 'owns' fixedBody, fixedBody now 'owns' sphereShape
sphereShape->removeReference();
fixedBody->removeReference();

This is in the docs under Havok Physics -> Havok Dynamics -> Rigid Bodies. Also, see the demos under Physics/Api/Constraints for plenty of code examples.

Patrick Developer Support Engineer Havok www.havok.com

Leave a Comment

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