durban
09-11-2005, 05:49 PM
Hello, I'm pretty new to DirectX and I still haven't gathered how all the functions work yet. My question lies in Transforming from Model Space to Screen space then adjusting a Meshes position from screen space coordinates. Here's some code:
_device->GetTransform(D3DTS_PROJECTION, &proj);
_device->GetTransform(D3DTS_VIEW, &view);
GetCursorPos(&ptCursor);
ScreenToClient(GetCapture(), &ptCursor);
numVerts = mesh->_mesh->GetNumVertices();
fvf = mesh->_mesh->GetFVF();
vertSize = D3DXGetFVFVertexSize(fvf);
mesh->_mesh->LockVertexBuffer(0, &ptr)
for( DWORD i=0; i<numVerts; i++ )
{
D3DXVECTOR3* vPtr = (D3DXVECTOR3*)ptr;
D3DXVECTOR3 temp;
D3DXVec3TransformCoord(&temp, vPtr, &view); // Is this right?
D3DXVec3TransformCoord(&temp, vPtr, &proj); // as well as this?
vPtr->x += temp.x*ptCursor.x; // this doesn't work
}
I read a post here that said you multiply the Vertex by the view matrix, then the projection matrix...
_device->GetTransform(D3DTS_PROJECTION, &proj);
_device->GetTransform(D3DTS_VIEW, &view);
GetCursorPos(&ptCursor);
ScreenToClient(GetCapture(), &ptCursor);
numVerts = mesh->_mesh->GetNumVertices();
fvf = mesh->_mesh->GetFVF();
vertSize = D3DXGetFVFVertexSize(fvf);
mesh->_mesh->LockVertexBuffer(0, &ptr)
for( DWORD i=0; i<numVerts; i++ )
{
D3DXVECTOR3* vPtr = (D3DXVECTOR3*)ptr;
D3DXVECTOR3 temp;
D3DXVec3TransformCoord(&temp, vPtr, &view); // Is this right?
D3DXVec3TransformCoord(&temp, vPtr, &proj); // as well as this?
vPtr->x += temp.x*ptCursor.x; // this doesn't work
}
I read a post here that said you multiply the Vertex by the view matrix, then the projection matrix...