360 3d rotation + fly in camera look direction

Software: Away3D 4.x

gazuraz, Newbie
Posted: 28 March 2013 06:42 PM   Total Posts: 5

Hey. Basically I am totally stuck whit this problem, and I am trying to find an answer for several months. I am trying to create a fly controller for mesh object. The idea is to simulate a first person 360*360*360 controller, similar whit regular first person controller but with additional dimension. If user looks up, the plane should go up and if user looks down the plane will go down.

So far I have came up whit this.

camera.+= Math.sin(camera.rotationX Math.PI 180)*(Math.sin(camera.rotationY Math.PI /180)-Math.cos(camera.rotationZ Math.PI 180));
   
camera.-= Math.cos(camera.rotationY Math.PI 180)*(Math.sin(camera.rotationZ Math.PI 180)-Math.cos(camera.rotationX Math.PI 180));
   
camera.+= Math.sin(camera.rotationYMath.PI/180); 

how ever there is a problem. This formula works OK until I one point and than just goes bananas. When I perform a couple of loops, the fly gets uncontrollable and the camera goes backward, or side by… Any ideas? I am going crazy whit this one…

   

_kihu, Jr. Member
Posted: 29 March 2013 10:10 AM   Total Posts: 43   [ # 1 ]

Might be the infamous gimbal lock. Search this term on the forum and google. Quaternions are used to deal with it, you might find a complete algorithm somewhere.

   

gazuraz, Newbie
Posted: 29 March 2013 01:36 PM   Total Posts: 5   [ # 2 ]

I have finaly found one of the problem. When mesh rotationX is 0 and when I perform the rotationY increase the mesh will perform something similar to camera.yaw();
However if mesh rotationX = 90 and I increase the rotationY the mesh will not perform the yaw(). Instead it will perform the roll(); ) Obviously the rotation of objects is not related to previous object position or relative rotation. Regardless of the object rotation the increase of any rotation will be performed as absolute increase. That means that any object rotating around y axis will use the wold axis instead of the objects. I do not know if this makes seance to anybody.

   

gazuraz, Newbie
Posted: 29 March 2013 01:42 PM   Total Posts: 5   [ # 3 ]

so, the idea is to create a

yaw, roll, pitch, moveForward,  moveBackward, moveLeft, moveRight methods for mesh object and they should do the same as camera methods. Thanks for the tip about gumball lock. I will look at it.

   

_kihu, Jr. Member
Posted: 29 March 2013 01:42 PM   Total Posts: 43   [ # 4 ]

Yup, gimbal lock http://en.wikipedia.org/wiki/File:Gimbal_lock_airplane.gif

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X