# Thread: walking on a planet - problem

1. ## 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)
{
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 ?

2. ## 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 ?

3. ## Re: walking on a planet - problem

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

4. ## 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

5. ## 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. ## 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.