Trouble with openGL

Hey guys I was doing some work and got stuck on a certain question, can anyone help me?
I'm trying to analyze a piece of code and just got stumped on the last question

Comprehension Task 4: How does the function orientMe() makes the rotation possible and in fact *easy*? For this, you need to understand how functions gluLookAt() and glRotatef() work.
Also, discuss what you would had to do if you did not have these nice and powerful functions, to rotate a 3D scene.

and this is the code:

//This function is responsible for rotating about the y and x axis
void orientMe(float yRotate, float xRotate) {

//Load the identity matrix
glLoadIdentity();

//Set the camera
gluLookAt(x, y, z,
x+lx,y+ly,z+lz,
0.0f,1.0f,0.0f);

//Rotate about the y axis by yRotate degrees
glRotatef(yRotate, 0.0f, 1.0f, 0.0f);

//Rotate about the x axis by xRotate degrees
glRotatef(xRotate, 1.0f, 0.f, 0.f);
}
//This function controls what happens when special keys are pressed
void specialKeys(int key, int x, int y) {

switch (key) {
case GLUT_KEY_LEFT : sideAngle += 15; orientMe(sideAngle,upAngle); break;
case GLUT_KEY_RIGHT : sideAngle += -15; orientMe(sideAngle,upAngle); break;
case GLUT_KEY_UP : upAngle += 15; orientMe(sideAngle,upAngle); break;
case GLUT_KEY_DOWN : upAngle += -15; orientMe(sideAngle,upAngle); break;
}
}
//This function controls what happens when normal keys are pressed
void normalKeys(unsigned char key, int x, int y) {
switch (key) {
case 27 : exit(0); break;
case 's' : z += 2;
orientMe(sideAngle,upAngle); break;
case 'w' : z -= 2;
orientMe(sideAngle,upAngle); break;
}
}

//Reset the angles and views
case RESET :
sideAngle = 0;
upAngle = 0;
x = 0.0f;
y = 0.0f;
z = 11.0f;
orientMe (sideAngle, upAngle);
break;


Thankss
Tiffany
Last edited on
which line you dont understand?
I dont understand how the orientMe() function makes it easier to rotate in this piece of code.

so I really dont know whats going on in the entire piece of code regarding how orientMe() works
1
2
3
4
5
6
7
8
9
10
11
12
13
14
void orientMe(float yRotate, float xRotate) {

//Load the identity matrix
glLoadIdentity();

//Set the camera
gluLookAt(x, y, z, x+lx,y+ly,z+lz, 0.0f,1.0f,0.0f);

//Rotate about the y axis by yRotate degrees
glRotatef(yRotate, 0.0f, 1.0f, 0.0f);

//Rotate about the x axis by xRotate degrees
glRotatef(xRotate, 1.0f, 0.f, 0.f);
}


orientMe function function just calling four functions.
1. To load matrix.
2. Set the camera.
3. Rotate about X axis
4. Rotate about Y axis.

all the above functions are updating/manipulating values stored in a matrix which represent a picture frame at given time.

we need to have code for the four function to give exact answer.
My professor only gave me these regarding the gluLookAt() and glRotatef()

http://www.opengl.org/resources/faq/technical/viewing.htm
http://www.opengl.org/sdk/docs/man/xhtml/gluLookAt.xml

it would be so great if you could look over them and help me because i can't understand any of this

thank you so much for helping :)
I don't see code for these functions in link given by you. If you provide the code here we will try to explain. Also please mark any specific piece of code or line where you got stuck.
Im sorry, but we weren't given the code for those functions we just had to find them online and I had trouble doing so sorry
You mean you have to implement those function. am i rite?

what code you have written uptill now?
Last edited on
No I didn't write any code, this exercise is they give us a piece of code and we have To answer the questiOn I have given about it
Last edited on
any body who has worked on matrix, please give some idea...
How to take a photograph. Hold the camera firmly in your hands, then move the world to align the target. Shoot.
ok can you answer this question please? i figured the rest out:

Also, discuss what you would had to do if you did not have these nice and powerful functions, to rotate a 3D scene.
Topic archived. No new replies allowed.