Changing object origin

Changing object origin

danep's picture

In short, I am wondering if there is a method of changing an object's origin, so that when functions such as getPosition or setForce are called, they return the position of a certain point on the object or apply a force to a certain point on the object, rather than the center of the object.

Specifically, I am developing an application using the Novint Falcon, a 3D haptic device, for input. For the sake of explanation let's pretend it's a golf simulation, and we are using a long box to represent a golf club. We call getPosition() on the box and use the difference between the position of the box and the position of the Falcon to calculate a force. We then applyForce() back to the box. The problem is that the force is calculated with respect to and applied to the origin (center) of the box. Of course in the real world one holds the end of a club, not the middle! So instead of using the center of the box to calculate position and apply force, we should really use one end of it. I see three solutions to this:

  1. Use the position and orientation of the club to manually calculate the position of a point on it, which involves some heavy math, especially considering that velocity and force transformations are much more complex than simple position transformations
  2. Relocate the origin to the end of the club (preferred, I think this would work if such a feature exists)
  3. Attach a massless object rigidly to the end of the club and use this object instead of the box for purposes of calculations and control (hackish but easy)

Obviously I am very new to Havok, so any guidance is appreciated!

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
sean.thurston's picture

Hi danep,

There is going to be a difference between setting the position and setting the center of mass. I don't think that you can change where the local space origin, the position, is within an object. You can change the center of mass of the object. The center of mass is used in the force calculations. The position is used more often in doing collision detection calculations. There is the hkpRigidBody::setCenterOfMassLocal(), hkpRigidBody::applyPointImpulse(), and the hkpRigidBody::applyForce(const hkReal deltaTime, const hkVector4 &force, const hkVector4 &p). I think these are the methods that you are looking for.

If you are exporting your golf club physics asset from a modeler then setting the center of mass to the exact right location should be easy. You can check out the Havok Content Tools->3dsMax Tools->Tutorial: More on Rigid Bodies (I just picked one of the modelers to give the docs location).

Let me know if that is what you were looking for.

Thanks,
Sean

Developer Support Engineer Havok www.havok.com
danep's picture

Thanks a lot for the response! Although it might be a bit hackish, I found the easiest solution was to create a control object in a separate collision group from the club and constrain it to the club in ball-and-socket fashion.

Login to leave a comment.