Sign in to follow this  
vecchia

Get world camera matrix from view camera matrix

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?

[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;[/code]

Share this post


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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this