glLoadIdentity();
glTranslatef (-cam_pos[0], -cam_pos[1], -cam_pos[2]);
glRotatef (cam_rot[0], 1.0f, 0.0f, 0.0f);
glRotatef (cam_rot[1], 0.0f, 1.0f, 0.0f);
glRotatef (cam_rot[2], 0.0f, 0.0f, 1.0f);
glTranslatef (obj_pos[0], obj_pos[1], obj_pos[2]);
glRotatef(obj_rot[0], 1.0f, 0.0f, 0.0f);
glRotatef(obj_rot[1], 0.0f, 1.0f, 0.0f);
glRotatef(obj_rot[2], 0.0f, 0.0f, 1.0f);
glBegin(...);
glVertex3f(vert_pos[0], vert_pos[1],vert_pos[2]);
...etc
glEnd()
This code gives wrong results though. Does anyone know what I'm doing wrong? I can't use tutorial 10 because I want to move and rotate the camera, and draw the objects relative to the camera.
moving through space
I'm making a small and simple 3D game, but I'm habing difficulties to walk around in space. I made a structure which holds the position and the rotation of my camera. I also have a structure which holds the position and rotation of my object. To draw this, I tried this code :
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement