Gravity Gun

Gravity Gun

Technically this doesn't apply to JUST the gravity gun, but I just implemented the gravity gun into my little engine demo. Now since I'm using DirectX, I'm in the left hand co-ordinate system. If I pass the gravity gun my view transform as-is from DirectX, it doesn't work. Right now I have a little hack going on that corrects all the little bugs, but it still leaves some functionality out (like being able to grab objects in my vertical axis).Basically I'm wondering if anyone has implemented this before with DirectX, or if there is some wasy way for me to give it exactly what it wants.Thanks in advance,Daniel

publicaciones de 3 / 0 nuevos
Último envío
Para obtener más información sobre las optimizaciones del compilador, consulte el aviso sobre la optimización.
Best Reply

Generally, your chosen coordinate system should not matter since Havok is not inherently right or left handed. So long as you are consistent with your coordinate system everything should be fine.

hkpGravityGun however, does need to make an assumption about which direction is 'forward', and it happens to choose the X axis of the 'view frame' passed in. Here's an example of how to set up an hkTransform that will make hkpGravityGun happy:

void createGunViewFrame( hkTransform & gunViewTransformOut, hkVector4 const& characterPosition,

                      hkVector4 const& characterUp, hkVector4 const& characterForward )


	gunViewTransformOut.setTranslation( characterPosition );
	hkVector4 x = characterForward;

	hkVector4 y = characterUp;

	hkVector4 z;

	z.setCross(x, y); z.normalize3();

	y.setCross(z, x); y.normalize3();

	gunViewTransformOut.getRotation().setCols(x, y, z);


Hope that helps!

Thank you SO much Tyler. This worked flawlessly, and exactly how I wanted it to. I guess trying to pass it the DirectX view transform created a lot of inconsistensies.Once again, thank you.-Daniel

Deje un comentario

Por favor inicie sesión para agregar un comentario. ¿No es socio? Únase ya