PDA

View Full Version : Total Beginner needing soem help

ninja770
12-27-2000, 08:10 PM
Ok I'm a total and 100% beginner to OpenGL. I know a little C++ and i've only completed one small program with help from glut. Heres my problem(Dont laugh if its stupid im new to 3d and 2d for that matter)... Im trying to make a simple program where there is a box... and you are a "spaceship"(yeah its a little corny hehe). now basically you press buttons and you move around the box in the same manner as a spaceshipe would do(you press buttons to turn up/down/left/right and you press buttons to go forward/backward). Well ive used all the combinations of glRotate glTransform glPushmatrix and glPopMatrix and i just cant get it to work correctly. the rotation is fine but whenever i use the backward/forward functions...instead of going backward and forward, it moves the object closer and farther. i know its just a logic mistake but am i going about it wrong? how should i go about doing movement in 3d space. Im lost can someone help?

12-28-2000, 09:53 PM
You wrote "instead of going backward and forward, it moves the object closer and farther.". Is this not what you want? It should look that way if you are moving...

NeHe has some tutorials withmoving in a 3D world: http://nehe.gamedev.net/

ninja770
01-02-2001, 12:02 PM
well yes i want it to move "closer and farther" but by saying that i meant that if hit the forward key the box just comes in closer to me... no matter waht the angle. oh yeah tahnx alot for the tutors link http://www.opengl.org/discussion_boards/ubb/smile.gif

Thaellin
01-03-2001, 04:43 AM
It sounds like you're moving the camera with a "forward: z-=movement, backward: z+=movement" logic. This works well so long as you do not turn the spaceship.

What you need to do is track the spaceship position and facing yourself. When you move, move 'movement' units along the vector your ship is facing. When you rotate, update the 'facing' vector.