Jump to content
  • Advertisement
Sign in to follow this  
Travisty

Extracting angles from a view matrix

This topic is 4595 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!