Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: walking on a planet - problem

  1. #1
    Junior Member Regular Contributor
    Join Date
    Dec 2002
    Posts
    156

    walking on a planet - problem

    the basic idea is to translate the camera to the height where the player is standing, and then spin the planet according to the players position.

    Code :
       public void setAngledView(GL gl,GLU glu)
       {
          gl.glLoadIdentity();
          V3D pos = followThisObject.getPos();
          //view
          gl.glRotatef(-followThisObject.getDegreesY(),1,0,0);
          gl.glRotatef(-followThisObject.getDegreesX(),0,1,0);
          //height
          gl.glTranslatef(0,-pos.getLength(),0);
          float spinX = Sphere.getSpinX(pos);
          float spinZ = Sphere.getSpinZ(pos);
     
          //buggy, spin planet      gl.glRotatef((float)(Math.toDegrees(spinX)),1,0,0);
          gl.glRotatef((float)(Math.toDegrees(spinZ)),0,0,1);
       }
    if i leave the last line out, the planet rotates correctly around the x-axis (0-360 degrees).
    if i leave the other line out, it spins correctly around the z-axis (0-180 degrees)

    if i combine them, the should-be-a-line line becomes a curve that gets more sharp the farther i go.

    what's wrong ?
    go vegan

  2. #2
    Junior Member Regular Contributor
    Join Date
    Dec 2002
    Posts
    156

    Re: walking on a planet - problem

    if i combine them, the should-be-a-line line becomes a curve that gets more sharp the farther i go.

    that means :
    if i look at a random point and walk forward, the direction of where i'm walking changes to the left or right (depends on my position and view) instead of staying a line.

    the angles given to the rotate-functions are correct, so the bug is hidden in the rotate-functions....but what is causing it ?
    go vegan

  3. #3
    Junior Member Regular Contributor
    Join Date
    May 2003
    Location
    New York
    Posts
    194

    Re: walking on a planet - problem

    Suggestion: use a single quaternion to represent the rotation of your planet.

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,411

    Re: walking on a planet - problem

    Suggestion: learn basic 3D maths concepts before posting to the advanced OpenGL forum.

    Start at http://skal.planet-d.net/demo/matrixfaq.htm
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

  5. #5
    Junior Member Regular Contributor
    Join Date
    May 2003
    Location
    New York
    Posts
    194

    Re: walking on a planet - problem

    Originally posted by jwatte:
    Suggestion: learn basic 3D maths concepts before posting to the advanced OpenGL forum.

    Start at http://skal.planet-d.net/demo/matrixfaq.htm
    I'm assuming your comment is for Hamster, but while it's not a very advanced question, there's no need to be rude.

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Melbourne,Victoria,Australia
    Posts
    748

    Re: walking on a planet - problem

    Originally posted by Cyranose:
    I'm assuming your comment is for Hamster, but while it's not a very advanced question, there's no need to be rude.
    Personally I think that posting in an inappropriate forum is rude, while telling someone that they are posting in an inappropriate forum, and giving them somewhere where they can find the information they need, is not rude.

    Jon could have just said "This is a basic maths question and doesn't belong in this forum". But instead he decided to give HamsterOfDeath a link to look at.

    Moderators, please move this thread.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •