Jump to content
  • Advertisement
Sign in to follow this  

SImple stuff question, mesh moving

This topic is 5067 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!