Camera issues

Started by
3 comments, last by foniks munkee 20 years, 10 months ago
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]
Advertisement
first translate then rotate it
otherwise you rotate it around the origin and then translate it to his local coordinate system
http://www.8ung.at/basiror/theironcross.html
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]
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.
f@dzhttp://festini.device-zero.de
Yeah - your right. Thanks

This topic is closed to new replies.

Advertisement