Jump to content
  • Advertisement
Sign in to follow this  

Get world camera matrix from view camera matrix

This topic is 2509 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

Hi,
I need to pick up an object with the mouse, how can I get the camera world matrix from the view camera matrix to use it in this code?

D3DXMatrixInverse(&matrixInverse, NULL, &(worldMatrix * viewMatrix));

rayDirection.x = xAngle * matrixInverse._11 + yAngle * matrixInverse._21 + zAngle * matrixInverse._31;
rayDirection.y = xAngle * matrixInverse._12 + yAngle * matrixInverse._22 + zAngle * matrixInverse._32;
rayDirection.z = xAngle * matrixInverse._13 + yAngle * matrixInverse._23 + zAngle * matrixInverse._33;

rayOrigin.x = matrixInverse._41;
rayOrigin.y = matrixInverse._42;
rayOrigin.z = matrixInverse._43;

Share this post


Link to post
Share on other sites
Advertisement
The world and view matrices are completely unrelated, there's no way to derive one from the other. It's like saying you need a 2D coordinate and you have the X coordinate and asking how to get the Y coordinate.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!