Closed aferust closed 5 years ago
At first I thought it was a bug with DefaultEntityController
, but it seems that plane.rotation
is just being messed up. Entity.rotation
is a quaternion, so you can't simply modify its components. In your case, you update an angle, then create a quaternion from it:
float z;
z += degtorad(stepAngle * dt);
plane.rotation = rotationQuaternion(Axis.z, z);
If you want to work in axis-angle representation, it's better to store three angles and multiply their corresponding quaternions:
float z, y, z;
plane.rotation =
rotationQuaternion(Axis.x, x) *
rotationQuaternion(Axis.y, y) *
rotationQuaternion(Axis.z, z);
If you want to update a quaternion with an angular velocity, then it should be done like this:
Vector3f angularVelocity = Vector3f(dx, dy, dz);
plane.rotation += 0.5f * Quaternionf(angularVelocity, 0.0f) * plane.rotation * dt;
plane.rotation.normalize();
There should be helper methods for updating a rotation, I just haven't added them yet.
Yes, it needs some helper methods like: http://wiki.ogre3d.org/Euler+Angle+Class
I think camera has something like that already: /graphics/tbcamera.d
I want my plane to do a barrel roll. it does with following code. However, disruptions in scale also occurs. Is it a bug or, am I on a totally wrong way?