md2 movement

Started by
6 comments, last by Derilect101 22 years, 8 months ago
Just a quick question I have an Md2 model loaded all animated all nice and such but maybe its obvious and I''m not seeing it cuz I haven''t slept in 24 hours how do you move the model actually like move it 18 units along the x axis and not move the rest of my scenery? I''ve been using glPushMatrix() and Pop not sure if thats the right thing to do and if so what order should I do it in like move camera push it the move the model and draw terrain the pop it or what I''m all tired and confuzzled!
Advertisement
Hi there!

I had the same problem with MD2 models. So, I put the x, y and z coordinates on my "Render" function as arguments. Then, inside this function, I changed the position of EVERY vertex, based upon the passed x, y and z values.
It''s a bit expensive, but with the todays hardware, you shouldn''t have no problems.

If you didn''t understand my answer, feel free to e-mail me.

Cristián Ramírez (gameovercl)
ICQ #38991565
Viña del Mar
CHILE
Hi there!

I had the same problem with MD2 models. So, I put the x, y and z coordinates on my "Render" function as arguments. Then, inside this function, I changed the position of EVERY vertex, based upon the passed x, y and z values.
It''s a bit expensive, but with the todays hardware, you shouldn''t have no problems.

If you didn''t understand my answer, feel free to e-mail me.

Cristián Ramírez (gameovercl)
ICQ #38991565
Viña del Mar
CHILE
No!!!! there''s no need guys!!!!

Read up about your matrices - try the Red Book for starters.

all you have to do is:


void Render() {

ClearOpenGL(); // clear col & depth
Set3DProjection(); // perspective proj
SetCamera(); // rotate your cam then translate
DrawWorld(); // draw world relative to camera

glPushMatrix(); // save current matrix
glTranslatef(); // translate to the MD2 position
glRotatef(); // rotate as necessary
DrawMD2Model(); // NOW draw MD2
glPopMatrix(); // restore matrix

Set2DProjection(); // draw fonts & HUD
SwapBuffers();
}

hope this helps!!!
feel free to ask for further clarification.
Draw the geometry
glPushMatrix();
glTranslatef(x,y,z); // set models xyz in the world
glRotatef(a,x,y,z); // rotate model
DrawModel(&md2); // draw the model
glPopMatrix();

works fine for me
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
Thanks guys I thought about doing the multiplying each vertex but I thought that would''ve been to expensive to use and had to be a better way and I did read the red book about it thats where why I started using the push and pop matrix functions I just didn''t really know the order to well but that seems to work I was just rendering my world after doing the model thats what happens after 24 hours of no sleep btw could I just move all the models at one point and only still have to push the matrix once for the camera and world? Just curious I''m gonna try it but I wont be home till later. Thanks again!!!
hehe BLZBub, beat me by 43 seconds
-----------------------"When I have a problem on an Nvidia, I assume that it is my fault. With anyone else's drivers, I assume it is their fault" - John Carmack
Its the thought that counts hehehe Thanks your post helped too you verified thats a good way of doing it see not a total loss

This topic is closed to new replies.

Advertisement