public Matrix4(Quaternion rot) { Matrix4 m = IDENTITY; Matrix3 rotationMatrix = rot.ToRotationMatrix(); m.AssignMatrix3(rotationMatrix); this = m; }
private void spin(Degree deg) { Mogre.Quaternion orient1 = control.Actor.GlobalOrientationQuaternion; Mogre.Vector3 rkAxis = new Mogre.Vector3(); Degree rfAngle = new Degree(); orient1.ToRotationMatrix().ToAxisAngle(out rkAxis, out rfAngle); Mogre.Quaternion orient2 = new Quaternion(new Radian(deg), new Mogre.Vector3(0, 1, 0)); //control.Actor.GlobalOrientationQuaternion = orient2; //setOrient(orient2); setOrient(orient2); }
public void MakeTransform(Vector3 position, Vector3 scale, Quaternion orientation) { Matrix3 rotationMatrix = orientation.ToRotationMatrix(); Matrix3 zero = Matrix3.ZERO; zero.m00 = scale.x; zero.m11 = scale.y; zero.m22 = scale.z; AssignMatrix3(rotationMatrix * zero); SetTrans(position); m30 = 0.0f; m31 = 0.0f; m32 = 0.0f; m33 = 1f; }
/// <summary>Building an inverse Matrix4 from orientation / scale / position. As makeTransform except it build the inverse given the same data as makeTransform, so performing -translation, -rotate, 1/scale in that order. </summary> public void MakeInverseTransform(Vector3 position, Vector3 scale, Quaternion orientation) { Vector3 negposition = -position; Vector3 negscale = new Vector3(1f / scale.x, 1f / scale.y, 1f / scale.z); Quaternion quaternion = orientation.Inverse(); Vector3 vector3_3 = negposition * negscale; Vector3 v = quaternion * vector3_3; Matrix3 rotationMatrix = quaternion.ToRotationMatrix(); Matrix3 zero = Matrix3.ZERO; zero.m00 = negscale.x; zero.m11 = negscale.y; zero.m22 = negscale.z; AssignMatrix3(zero * rotationMatrix); SetTrans(v); m30 = 0.0f; m31 = 0.0f; m32 = 0.0f; m33 = 1f; }