Jump to content

  • Log In with Google      Sign In   
  • Create Account


Setting the camera without glulookat?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 28 November 1999 - 12:34 AM

In opengl, How do I set the camera without using glulookat???

Sponsor:

#2 Jonathan   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 November 1999 - 01:47 PM

I'm not one hundred percent sure of this, but I believe it goes something like this. At the beginning of your frame, clear out your modelview matrix. Then scale and translate that matrix by the inverse(i.e. negative) values of where your camera is. So if it's located at (5, 10, -5) and looking down the x axis in the positive direction(90, 0, 0), you'd just do this:

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslate(-5, -10, 5);
glRotate(-90, 0, 0, 1);

And then do all your drawing. That should do the trick I might have the translate and rotate backwards though...

Jonathan


#3 TheMummy   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 November 1999 - 11:50 PM

I usually do my camera settings that way

void display() // at this point GL_MATRIXMODE is set
{
...//Clear buffers...
glPushMatrix();
glTranslatef(-playerXpos,-playerYpos,-playerZpos);
glRotatef(LookUpDownAngle,-1,0,0);
glRotatef(LookLeftRightAngle,0,0,-1);
// Draw all objects in cameraview
glPopMatrix();

...
}

player_pos is the actual position of your cam in world coordinates. LookUpDownAngle and LookLeftRight is the direction your cam is looking at. When you know how to use a matrix you can use the OpenGL function:
void glMultMatrixd(
const GLdouble *m
);
m is the 4x4 Matrix (double in this case)


#4 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 18 November 1999 - 11:49 PM

Thanks for that

#5 TheMummy   Members   -  Reputation: 122

Like
Likes
Like

Posted 28 November 1999 - 12:34 AM

Sorry, I made a mistake in the code above.
I hope it is ok now ;-).

void display() // at this point GL_MATRIXMODE is set
{
...
//Clear buffers...
glPushMatrix();
glRotatef(LookUpDownAngle,-1,0,0);
glRotatef(LookLeftRightAngle,0,0,-1); glTranslatef(-playerXpos,-playerYpos,-playerZpos);

// Draw all objects in cameraview
glPopMatrix();

...
}





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS