SImple stuff question, mesh moving

Started by
0 comments, last by Chupacabra151 19 years, 3 months ago
Please excuse me; I'm sure this question gets asked a lot. I'll give a quick description of my code to make this readable. I'm experimenting with loading a mesh (which I can do fine so far) and then moving it with the arrow keys. My game engine calls a GetInput() fxn to ... well .... get input right before calling the render fxn. The mesh is contained in a class with a "D3DXVECTOR Position" member, a "D3DXMATRIX Transform" matrix, and a "ID3DXMesh Mesh" member (pointer to instance, actually). When a "VK_UP," for example, is detected the Position vector's y coordinate it incremented. Other keys are handled as well in this section. After the position is incremented, the following code // Assume that the mesh containing structure is PlayerShip D3DXMatrixTranslation(&m_matTransform,m_vPosition.x,m_vPosition.y,m_vPosition.z); is applied to update the objects transform matrix. When its time to render, the succesion of events is Clear the backbuffer via ID3DD3vice::Clear() Call ID3DDevice::BeginScene() Call ID3DDevice::SetTransform(D3DTS_WORLD, &PlayerShip.Transform) Render the ship like so: { for (DWORD i=0; i < m_dwNumMaterials; i++) { g_pd3dDevice->SetMaterial( &m_pMaterials ); g_pd3dDevice->SetTexture( 0, m_pTextures ); m_pMesh->DrawSubset( i ); } } Set the world matrix to (0,0,0) Set the view matrix eye at (0,5,-15) and the Look at Point at (0,0,0) Set the projection matrix with the following code D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f ); Call ID3DDevice::EndScene() and ID3DDevice::Present() The result I get from the above code is that the position data member is incrememnted, but the ship does not seem to move. What I am trying to do in the above code is set the world matrix to the ship's new position, then render the ship, then return the world matrix to the origin to set up the view and the projection. I assumed that the effect would be to see the ship move relative to the camera, but so far it remains right in front of the camera. Can anyone tell me where I went wrong? Thank you very much. Chupacabra151
Advertisement
Never mind, I just figured out what was wrong. Thank you if you took the time.

This topic is closed to new replies.

Advertisement