Sign in to follow this  
Anddos

inversing a matrix in d3d

Recommended Posts

No.

The view matrix transforms points from world space to view (eye/camera) space. The inverse of the view matrix will undo that same transformation, that is, transform points from view space to world space.

Share this post


Link to post
Share on other sites
They might have meant that the inverse of the view matrix will, in general, be the world (model) matrix for the object with which the virtual camera is associated (provided there is such an object). But to simply say that 'the inverse of the view matrix is the world matrix' doesn't make much sense.

Share this post


Link to post
Share on other sites
so this is my picking function to get the cursor in to the world matrix,


void Pick(D3DXMATRIX View,D3DXMATRIX matProj)
{
POINT point;
RECT rect;
GetCursorPos(&point);

HWND D3DWin = FindWindow(NULL,"Our Direct3D Program");
ScreenToClient(D3DWin,&point);
GetWindowRect(D3DWin,&rect);

float w = (float)rect.right;
float h = (float)rect.bottom;

float x = (2.0f*point.x/w - 1.0f) / matProj(0,0);
float y = (-2.0f*point.y/h + 1.0f) / matProj(1,1);

D3DXVECTOR3 origin(0.0f,0.0f,0.0f);
D3DXVECTOR3 dir(x,y,1.0f);

D3DXMATRIX invView;
D3DXMatrixInverse(&invView,0,&View);

D3DXVECTOR3 originW;
D3DXVECTOR3 dirW;
D3DXVec3TransformCoord(&originW, &origin,&invView);
D3DXVec3TransformNormal(&dirW,&dir,&invView);
D3DXVec3Normalize(&dirW,&dirW);

}



can anyone tell me if i am on the right path

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