Archived

This topic is now archived and is closed to further replies.

Camera issues

This topic is 5316 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This code creates a cube that can rotate around the world origin, by tranlating the cube X units away then rotating it. The problem is that it rotates around it's own object coordinates.. How can I prevent this second rotation from occuring?
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();

    // Viewing transformation
    gluLookAt(0.0f, 0.0f, -5.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);

    glRotatef(YSpeed, 0.0f, 1.0f, 0.0f);
    glTranslatef(1.0f, 0.0f, 0.0f);
    glCallList(Cube);

    glutSwapBuffers();
  
[edited by - foniks munkee on May 27, 2003 5:44:49 AM]

Share this post


Link to post
Share on other sites
Thanks - but not quite what I meant.

I have a cube, but I want it to rotate around a world origin, while the same face of the cube faces the camera. I am having trouble working out how I get an object to orbit another origin (not the models origin).

[EDIT] - to make it a little clearer, kind of like the way the moon rotates around the earth (the world origin), yet the same side always faces the earth. What is happening here is that my rotate which rotates the object around the world origin, also affects the orientation around it's own origin.

[edited by - foniks munkee on May 27, 2003 6:01:58 AM]

Share this post


Link to post
Share on other sites
this sounds a little confusing. the code above will do exactly that. rotate the cube around the origin and have the same point face the cube. if you want what i think you want then you should just add an rotation of the object in the other direction after translating.

Share this post


Link to post
Share on other sites