Extracting angles from a view matrix

Started by
1 comment, last by Travisty 18 years ago
As the title suggests, I’m having troubles extracting my current camera angles from my view matrix. The code I'm using now looks like this: D3DVECTOR Angles; Float hyp = sqrtf(View._13 * View._13 + View._23 * View._23 + View._33 * View._33 ); Angles.x = atan2f( View._13, View._33 ) * 180 / PI; Angles.y = atan2f( View._23, hyp) * 180 / PI; Angles.z = 0.0f; I’ve tried many different things and read up on countless tutorials and this the closest I’ve got. Angles.x seems to be working fine, but Angles.y is way off. Any help on the matter of even a source to read up on would be greatly appreciated. Thanks! -Trav
Advertisement
Maybe you could clarify what exactly you mean by camera angles? Angles relative to what exactly? Are you trying to find the points of your frustum? Please clarify exactly what you're trying to do
I'm making a mod for my Half-Life2 server and one of the power-ups I’m trying to implement is an aim helper. In order to do so I need yaw, pitch, and roll angles (relative to 0,0,0…where 90 pitch is straight up, and 180 yaw is looking opposite to 0) in degrees to plug into Half-Life2’s SDK function that sets your aiming direction. I’m using D3DXMatrixLookAtLH to build a view matrix looking at the target from my current location, now I just need at way to extract the view angles. I’ve already been able to test and set the yaw angle just fine using the code above, now I just need to find the pitch value in my matrix. Then I’ll be able to find the angles’ offset between the current camera position and the target, divide it by a modifier, and add that to the camera position to create a slow aiming effect.

This topic is closed to new replies.

Advertisement