Advertisement

moving through space

Started by February 28, 2005 07:59 AM
0 comments, last by James Trotter 19 years, 6 months ago
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 :

	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.
Please don't crosspost. It should be enough to post it in one forum.

This topic is closed to new replies.

Advertisement