PDA

View Full Version : Moving camera position



TanjuOZgur
12-10-2003, 08:21 PM
Hi !

Anybody can lead me from where can I obtain the rotation and moving of camera poisition with mouse and keys ! (if possible , demo and source code will be wellcome )

Thnx!

514VOID
12-10-2003, 10:46 PM
void ArcBallRotate(float x,float y)
{
float n[3];

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

glRotatef(sqrt((double)(x*x+y*y))/1.5,y,-x,0.0);

n[0]=GlMode->ModelViewMatrix[12];
n[1]=GlMode->ModelViewMatrix[13];
n[2]=GlMode->ModelViewMatrix[14];

GlMode->ModelViewMatrix[12]=0.0;
GlMode->ModelViewMatrix[13]=0.0;
GlMode->ModelViewMatrix[14]=0.0;

glMultMatrixf((GLfloat*)&GlMode->ModelViewMatrix);

glGetFloatv(GL_MODELVIEW_MATRIX,GlMode->ModelViewMatrix);

GlMode->ModelViewMatrix[12]=n[0];
GlMode->ModelViewMatrix[13]=n[1];
GlMode->ModelViewMatrix[14]=n[2];

glLoadMatrixf(GlMode->ModelViewMatrix);
}

this might help, it rotates around the origin of the modelmatrix no matter the translation.

redfrog
12-11-2003, 09:02 PM
GlMode??? What is its type so that I can declare it and get the code building. I'm trying to get full 360 deg. flying in my open gl app.

TanjuOZgur
12-12-2003, 10:43 AM
I was about to ask the same question !


By the way , which way is more reasonable when you compare changing postion of camera with gluLookAt or as you do just scaling the image ?

Thnx for help!

jwatte
12-12-2003, 07:42 PM
How about asking this question on the beginner's forum? Or on a forum specific to your input mechanism or OS? Or perhaps just go to http://nehe.gamedev.net/ and download the appropriate tutorials?