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

moving an object

Started by marlow Dec 8, 2000 at 1:40 AM 0 replies 350+ views
Original Post
marlow
marlow
hi, I have a set of 3d objects on the screen, I want to move them just like you would a sprite, how is this achieved - is it by applying some translation matrix on the vertices for these objects? Any help is much appreciated.
BeRSeRKeR[DGT]
BeRSeRKeR[DGT]
Do you use D3D or OpenGL?
If you use D3D, before you draw you 3D object, you must specify its world matrix. For example:

D3DXMATRIX transMtx;
D3DXMatrixTranslation(&transMtx, 0.0f, 0.0f, 2.0f * lapsed_time);
pD3DDev->SetTransform(D3DTS_WORLD, &transMtx);
DrawObject();

With this code, you create a translation matrix that will move the object 2 world units per second along z axis. After that, you must set the world matrix with your translation matrix and draw the object.

If you use OpenGL you must use:

glTranslatef(0.0f, 0.0f, 2.0f * delta_time);
DrawObject();

I think that you must use glPushMatrix() and glPopMatrix() combination too..

I hope this help.

Topic Locked

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

Sign in to reply to this topic.