Thanks for the quick response Michael. Here is my update method:
/**
* Handles renders
*/
private function update(dt:Number):void
{
// recalculate the movement (this just takes inputs and populates)
// the _tempRot Vector with dt * _angularSpeed
updateMovementRotation(dt);
// reset quaternions
clearQuat(_tempRotQuat);
clearQuat(_tempYawQuat);
clearQuat(_tempPitchQuat);
clearQuat(_tempRollQuat);
// recalculate temp quaternions
_tempPitchQuat.fromAxisAngle(Vector3D.X_AXIS, _tempRot.x);
_tempYawQuat.fromAxisAngle(Vector3D.Y_AXIS, _tempRot.y);
_tempRollQuat.fromAxisAngle(Vector3D.Z_AXIS, _tempRot.z);
// apply quaternion rotations
_tempRotQuat.multiply(_tempRotQuat, _tempPitchQuat);
_tempRotQuat.multiply(_tempRotQuat, _tempYawQuat);
_tempRotQuat.multiply(_tempRotQuat, _tempRollQuat);
// apply to current rotation
_camRot.multiply(_camRot, _tempRotQuat);
// clear cam mat and update with the new rotation
_target = _camRot.rotatePoint(Vector3D.Z_AXIS);
_up =_camRot.rotatePoint(Vector3D.Y_AXIS);
// apply look at to new target and up
lookAt(_target, _up);
}
I'm sure I'm doing lots wrong, I haven't looked at Quaternions since
University and I can't remember how they work!! I just know they will
get rid of the dreaded Gimbal Lock,
Thanks,
James
On Apr 30, 12:00 pm, Michael Iv <[email protected]> wrote:
> If you can post the full code of your quaternion operation may be I can help
> then .
>
> Sent from my iPhone
>
> On Apr 30, 2011, at 1:52 PM, vangojames <[email protected]> wrote:
>
>
>
>
>
>
>
> > Hi guys,
>
> > Please help me. I'm really stuck at trying to implement a Quaternion
> > based free camera. My current approach is this:
>
> > ON EACH UPDATE::
>
> > - Get yaw pitch and roll increase
> > - Create quaternions for yaw, pitch and roll (for example
> > Quaternion.fromAxisAngle(Vector3D.X_AXIS, pitch))
> > - Multiply together in order pitch * yaw * roll to get new temp
> > quaternion
> > - Multiply cameraRotation quaternion by this new temp quaternion
> > - Calculate target by doing
> > cameraRotation.rotatePoint(Vector3D.Z_AXIS);
> > - Calculate up by doing cameraRotation.rotatePoint(Vector3D.Y_AXIS);
> > - lookAt(trget, up)
>
> > Needless to say this doesn't work. I just get the tiniest amount of
> > movement and it isn't what is expected at all. Would someone be able
> > to explain the correct approach?
>
> > Thanks!!
>
> > James