Spaceship Movement

Started by
2 comments, last by Therion__ 15 years, 10 months ago
Hello, i got an mathematical problem with my game project. i work on an spaceship game and its abbout the rotation/angle thing. i got: view_r1= Yaw view_r2= Pitch view_r3= Roll i rotate the ship (view_r3) and when i pull back the stick the view_r1 and view_r2 should change the angle in the direction view_r3 is showing... annormal thing also on airplane simulations..but i cant get this to work //this code is not working/complete Wrong ... float ee1=(float) ((mouse_yy*0.2)*Math.sin(view_r3*3.141593/180)); float ee2=(float) ((mouse_yy*0.2)*Math.cos(view_r3*3.141593/180)); view_r1+=ee1; view_r2+=ee2; `... can somebody help me?
Advertisement
This seems to be right, though I warn you, you may not get the exact simulation you're looking for, i.e. the ship won't rotate a full 360 dg. about the axis (you'll see, I guess).

However, looking at the code, don't you think there should be sqrt(sqr(mouse_xx)+sqr(mouse_yy)) there instead of just mouse_yy? Maybe that's the problem.
I suppose to drop the usage of angles, and to use the orientation basis instead. Then change the basis by incremental rotations determined from the movement or deviation of the mouse.
thx for the reply

the mouse_yy was only a simple test

here what i use for the view

gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();

gl.glTranslatef(0.0f,0.0f,0.0f);
gl.glRotatef(-vr3, 0, 0, 1);
gl.glRotatef(-vr2, 1, 0, 0);
gl.glRotatef(-vr1, 0, 1, 0);

its hard to describe what i think what the solution can
be.(my english is not the best)

using a point with coordinates 0,1,10 (a little bit over the y)
then doing the rotation calculation.
after all the point must be in the place where the new
orientation must be..then only calculating the angles

but i didnt know how to do this


first problem:
gl.glRotatef(-vr3, 0, 0, 1);
gl.glRotatef(-vr2, 1, 0, 0);
gl.glRotatef(-vr1, 0, 1, 0);
how they are calculated (the formula)



This topic is closed to new replies.

Advertisement