Havok for 2d physics.

Havok for 2d physics.

Is it possible to use Havok in a 2d environment? I was thinking to disregard the z value when positioning things, but that wouldn't work. So is there any way to do this?

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

Hi benny53,

I haven't tried it myself but you could use the constraint kit to create a constraint which limits the degrees of freedom to keep it moving in 2 dimensions. If Z is going into your screen and Y is up, you'd probably constraint bodies so they don't rotate about X and Y: only Z. The movement would be constrained so it only moves along X and Y and not Z.

There are some Constraint Kit demos under Physics->Api->Constraints.

Another way of constraining the axial degrees of freedom is by changing the inertia tensor, but that won't help with constraining movement to a plane:

		// Adjust inertia tensor matrix to remove non-Z axis rotation (protects stability)
hkMatrix3 invInertiaMatrix;
invInertiaMatrix(0,0) = 0.0f;
invInertiaMatrix(1,1) = 0.0f;

This code should "constrain" the rotational degrees of freedom so it can only rotate about Z.

Hope this gives you somewhere to start :-)


It seems like the constraint kit path is the best choice. It seems like the most logical route at least.

You might get the best results using the inertia tensor to constrain the rotation and the constraint kit for positional constraining. You could get crazy and make fake contact points to constrain your objects to a plane too if you wanted to but let's keep it simple and see how it goes :-)

I'd go with a point-to-plane constraint, personally. Check out hkpPointToPlaneConstraintData and PointToPlaneDemo.cpp. You'll still want to take into account the inertia modifications that Daniel mentioned.

I've been meaning to put together a demo on this for a while; I'll try to do that this weekend if I get time. Anybody for a game of Pong? :)


Leave a Comment

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