View Full Version : walkthrough
06-12-2000, 06:40 AM
couple of questions from the newbie:
Is there any semi-generic code to do the walkthrough I need? What variables will I need(xpos,ypos,zpos,xrot,yrot,zrot)? how do I rotate and translate to make it look nice? or should I be using LookAt? my scene is basically a square floor with lights that move to the music being played(if that makes any difference). This is my first project using OpenGL so any help would be great!
06-12-2000, 06:59 AM
I suppose you could use gluLookAt, but I think it's just as easy to use glRotate & glTranslate.
Anyway, if you use the later functions, you are correct. You will have to track the view origin and the view angles. Then you just apply the angles and origin, possibly something like this:
float vangles, vposition;
...set angles and position here...
glRotatef( -vangles, 1.0f, 0.0f, 0.0f );
glRotatef( -vangles, 0.0f, 1.0f, 0.0f );
glRotatef( -vangles, 0.0f, 0.0f, 1.0f );
glTranslatef( -vposition, -vposition, -vposition );
06-12-2000, 07:10 PM
okay, I think I get it.
I'm using Java and GL4Java to write my app.. this is what I've got:
float M_PI = 3.14159f;
gl.glTranslatef(0f, 0f, -15f); //set things back a bit
gl.glTranslatef(0f,0f,zpos); //for in out movement
if (left) gl.glRotatef(xrot*(M_PI*4), 0f, 1f, 0f);
if (right) gl.glRotatef(xrot*(M_PI*4), 0f, 1f, 0f);
now, this almost works. how might I go about fixing it?
thanks in advance!
06-13-2000, 08:24 AM
do I get the -I'm the biggest idiot- award? I realized, about 2 minutes after posting that last piece that it was only rotating if I was holding the left/right keys..that's where I was having trouble. I'm beggining to understand http://www.opengl.org/discussion_boards/ubb/smile.gif
..thanks for the help!
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.