Jump to content
  • Advertisement
Sign in to follow this  
vecchia

Get world camera matrix from view camera matrix

This topic is 2596 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
The world matrix is whatever you specified in SetTransform(D3DTS_WORLD, ...) or in your shader for the world matrix.

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!