1. ## walkthrough

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!

2. ## Re: walkthrough

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[3], vposition[3];

...set angles and position here...

glRotatef( -vangles[0], 1.0f, 0.0f, 0.0f );
glRotatef( -vangles[1], 0.0f, 1.0f, 0.0f );
glRotatef( -vangles[2], 0.0f, 0.0f, 1.0f );

glTranslatef( -vposition[0], -vposition[1], -vposition[2] );

3. ## Re: walkthrough

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.glMatrixMode(GL_MODELVIEW);
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);
renderScene();

now, this almost works. how might I go about fixing it?

4. ## Re: walkthrough

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

..thanks for the help!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•