PDA

View Full Version : walking on a planet - problem

HamsterofDeath
02-22-2004, 01:50 AM
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.

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 ?

HamsterofDeath
02-22-2004, 09:15 AM
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 ?

Cyranose
02-22-2004, 12:11 PM
Suggestion: use a single quaternion to represent the rotation of your planet.

jwatte
02-22-2004, 02:01 PM
Suggestion: learn basic 3D maths concepts before posting to the advanced OpenGL forum.

Start at http://skal.planet-d.net/demo/matrixfaq.htm

Cyranose
02-22-2004, 05:43 PM
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.

rgpc
02-23-2004, 12:12 AM
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.