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)

{

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 ?

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 ?