Skip to main content
GameDev.net gamedev.net
🔒 Locked

minor problem meshs

Started by RogueCoder Jul 29, 2006 at 9:27 PM 1 replies 700+ views
Original Post
RogueCoder
RogueCoder
I have some problems with my code in respect to moveing a mesh "tank" around a map. there is no collision detection or anything. very simple code at the moment (lol well not simple for me i'm just learning) i can get the map to move :P but not the tank i don't get it :P Everything below is just cut sections from different parts of my code but are relavent to each other i didn't add my xfile loading code if you think that is relavent plese tell me i appreciate any help anyone could give me. i'm still just starting out.
Quote:
D3DXVECTOR3 TankPosition(-100.0f, 0.0f, 0.0f); D3DXMatrixTranslation(&MapObjWorldMatrices, 0.0f, 0.0f, 0.0f); D3DXMatrixTranslation(&TankObjWorldMatrices, TankPosition.x, TankPosition.y, TankPosition.z); if( ::GetAsyncKeyState(VK_LEFT) & 0x8000f ) TankPosition.x -= 50.0f * timeDelta; if( ::GetAsyncKeyState(VK_RIGHT) & 0x8000f ) TankPosition.x += 50.0f * timeDelta; if( ::GetAsyncKeyState(VK_UP) & 0x8000f ) TankPosition.z -= 50.0f * timeDelta; if( ::GetAsyncKeyState(VK_DOWN) & 0x8000f ) TankPosition.z += 50.0f * timeDelta; device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x0100000, 1.0f, 0); device->BeginScene(); D3DXMATRIX W; D3DXMatrixTranslation(&W, TankPosition.x, TankPosition.y, TankPosition.z); device->SetTransform(D3DTS_WORLD, &W); for(int i = 0; i < MapMtrls.size(); i++) { device->SetTransform(D3DTS_WORLD, &MapObjWorldMatrices); device->SetMaterial(&MapMtrls); device->SetTexture(0, MapTextures); Map->DrawSubset(i); } for(int i = 0; i < TankMtrls.size(); i++) { device->SetTransform(D3DTS_WORLD, &TankObjWorldMatrices); device->SetMaterial(&TankMtrls); device->SetTexture(0, TankTextures); Tank->DrawSubset(i); } device->EndScene();
Not as Rogue as one would think .....
grill8
grill8
Hello friend,

Well I only got a short look at your code but there appears to be places where there are multiple WORLD matrix transforms attempting to be set simultaneously, or at least that is the intent. Remember, there can only be 1 of each of the transform matrices set at anytime. So basically, when you render (subset/mesh) it is going to render using the most current world transform matrice that has been set. In other words, when you set a WORLD transform it will overwrite the previous one. So.... your tank world transform is being covered up by the next WORLD matrix transform that is set 2 lines of code later.

In lamans terms....If you set a WORLD matrix, and then set a different WORLD matrix, only the absolutely last set WORLD matrix will be used. That holds for the other matrices as well.

Hope that helps,
Your friend, Jeremy
RogueCoder
RogueCoder
Thanks mate

appreciate that peice of info :D.

this will sound really silly then i'm sure

but how can i specify the poistion the mesh takes within 3d space first

because i thought that was what i was doing.

If you could look at the whole code much appreciated (not alot there)

(i hope this url works .... can u add attachments on this forum ?)

http://www.codeguru.com/forum/attachment.php?attachmentid=16775
Not as Rogue as one would think .....

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.