View Full Version : Total Beginner needing soem help
12-27-2000, 09: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?
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/
01-02-2001, 01: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
01-03-2001, 05: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.
Is this helpful?
01-06-2001, 12:11 AM
yup... use some trig http://www.opengl.org/discussion_boards/ubb/smile.gif
01-06-2001, 10:38 AM
yeah thanx, i see now. but... grrr this was what i was afraid of. the idea of rotating and translating everything myself kinda scared me off but i guess its best i should do so. but will my perspective settings change if I do all the calculations without using glrotate, and gltranslate? and also im not a math wiz... and i dont really know any formulas for accurate rotation. do you know of any ways of doing this while using any of the gl functions? I have an adobe acrobat version of the redbook... is there anything in there anything in there that may be of use?
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.