Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

Shawn619

Member Since 17 Mar 2012
Offline Last Active Yesterday, 10:31 AM
-----

#5057408 Confusion About Rotating Camera Around Point

Posted by Shawn619 on 27 April 2013 - 11:35 PM

Just wondering how the components for eyeX, eyeY, eyeZ are derived

 

I'll give you an idea on how I would approach this assignment and answer your question at the same time.

For rotation, you say that your rotation method is working, instead of using the traditional glrotate, so i'll leave the rotation alone.

For translation, the first 3 components of gluLookAt are the position of your eye in world space, which you seem to have calculated correctly, assuming your rotation are correct.

The next 3 components are where your eye will be looking. So, in your scenario of an earth orbiting around a sun, assuming your sun in centered at the origin, these 3 components would be (0,0,0), which would have your eye looking towards the origin(at the sun). 

 

http://www.opengl.org/sdk/docs/man2/xhtml/gluLookAt.xml

 

Also, shouldn't

gluLookAt(eyeZ * cos(theta) * sin(phi), eyeZ * sin(theta), eyeZ * cos(theta) * cos(phi), 0, 0, 0, 0, 1, 0);

 

be

gluLookAt(eyeX * cos(theta) * sin(phi), eyeY * sin(theta), eyeZ * cos(theta) * cos(phi), 0, 0, 0, 0, 1, 0);



#5055893 Opengl - Light rotating around object (video)

Posted by Shawn619 on 22 April 2013 - 07:34 PM

I translate my object(soccer ball) -20z pixels away from the camera, keep the camera and rotating sphere(blue sphere=light, so you know where the light is) at origin, and rotate the light(represented by the sphere) around the origin to simulate moving light.

 

I think this short video(00:14) should clear things up:

*note: blue sphere=light, soccer ball=object, grey plane=flat ground

 

Why is my object acting as if it is at the origin, where the light is rotating around, but in reality it is -20z further away from the origin?

 

main function:

void drawScene() {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
 
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
 
 
 
    //lighting+sphere
    rot+=1.0f;
    glPushMatrix();
 
    //glTranslatef(0.0f, 0.0f, -20.0f);
    glRotatef(rot,0.0f,1.0f,0.0);
    glTranslatef(0.0f, 0.0f, 10.0f);
 
    initSceneLighting();//set position light[0] {0,0,0,1}
    drawSceneSphereLight();//blue sphere
    glPopMatrix();
 
    //soccer ball(object)
    glPushMatrix();
    glTranslatef(0.0f, 0.0f, -20.0f);
 
    glColor3f(1.0f,0.0f,0.0f);
    glCallList(soccerBall);
    glPopMatrix();
 
 
    //floor
    glPushMatrix();
 
    glColor3f(0.5f,0.5f,0.4f);
    drawSceneFloor();//grey ground
 
    glPopMatrix();
 
 
    glutSwapBuffers();
}



#4924852 5$ - 200x100 image

Posted by Shawn619 on 24 March 2012 - 03:56 AM

(Edited by mod. Not appropriate for Game Design forum. For Help Wanted posts, try the Classifieds.)


PARTNERS