inversing a matrix in d3d

Started by
3 comments, last by Anddos 14 years, 10 months ago
i am reading a tut online and it says , when you inverse the viewmatrix , the result becomes the world matrix?
:)
Advertisement
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.
ok , i think i understand now
:)
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.
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
:)

This topic is closed to new replies.

Advertisement