Matrix4 evalRotation(float time) { // Evaluate LWChannelEnvelope h_env = Motion.Channel(LWChannel.H); LWChannelEnvelope p_env = Motion.Channel(LWChannel.P); LWChannelEnvelope b_env = Motion.Channel(LWChannel.B); float h = (h_env != null) ? h = h_env.eval(time) : 0.0f; float p = (p_env != null) ? p = p_env.eval(time) : 0.0f; float b = (b_env != null) ? b = b_env.eval(time) : 0.0f; Matrix4 rotation = Matrix4.Identity; #if true Quaternion q = new Quaternion(Vector3.UnitZ, -b); q *= new Quaternion(Vector3.UnitX, -p); q *= new Quaternion(Vector3.UnitY, -h); Matrix4.CreateFromQuaternion(ref q, out rotation); //last_rotation = q; #else last_rotation.rotateYMatrix(h); last_rotation.rotateX(p); last_rotation.rotateZ(b); #endif if (parentObject != null) { rotation = parentObject.evalRotation(time) * rotation; } return(rotation); }
public Vector3 evalPosition(float time) { // Evaluate LWChannelEnvelope x_env = Motion.Channel(LWChannel.X); LWChannelEnvelope y_env = Motion.Channel(LWChannel.Y); LWChannelEnvelope z_env = Motion.Channel(LWChannel.Z); double x = (x_env != null) ? x = x_env.eval(time) : 0.0; double y = (y_env != null) ? y = y_env.eval(time) : 0.0; double z = (z_env != null) ? z = z_env.eval(time) : 0.0; Vector3 position = new Vector3(x, y, z); if (ParentObject != null) { position = ParentObject.evalRotation(time) * position; position += ParentObject.evalPosition(time); } position += evalPivot(time); return(position); }