If you define a q from the current matrix and have a tmp matrix for your rotation, you can define a second q2 from this tmp matrix and multiply them after you have rotated, the resulting q3.matrix will be the matrix that you expect without the gimbal_lock issue.
Mesh rotation around local axis (reloaded)Software: Away3D 4.x |
||
|
||
alihm, Jr. Member
Posted: 26 October 2012 03:34 PM Total Posts: 49 [ # 17 ] Actually it’s very easy. If you want the camera to smoothly follow the aircraft you can do something like this:
var _qCam:Quaternion = new Quaternion(); If you want to rotate around the aircraft you can clone the aircraft’s transform matrix to a dummy object and rotate it as you want then use it as target quaternion, and camera will smoothly slerp to that orientation without any gimbal lock. Hope it helps. |
||
Miha003, Newbie
Posted: 27 October 2012 11:00 AM Total Posts: 26 [ # 18 ] alihm thank you so much. That si the kind of answer I needed. ‘slerp’ and ‘moveBackward’ do the trick. Here is my current implementation(In case anyone else has similar problems)
_iniMatrix : Matrix3D = mesh.transform.clone();
- perform the rotation of the ship by appending needed rotations to the ship’s rotation matrix.
matrix3D = _iniMatrix.clone(); The 1st mesh.transform right after the up vector rotation is very important to update the mesh right and forward vector. Otherwise the more you rotate, the more you can see the errors because of working with obsolete vectors.
var _qCam:Quaternion = new Quaternion(); Please reply if this solution is wrong, or it can be improved. |