/// <summary> /// Returns the global rotation of the specified constraint /// </summary> /// <param name="constraint"></param> /// <param name="sceneAccess"></param> /// <returns></returns> public static MQuaternion GetGlobalRotation(this MGeometryConstraint constraint, MSceneAccess.Iface sceneAccess) { MTransform parentTransform = sceneAccess.GetTransformByID(constraint.ParentObjectID); if (parentTransform != null) { if (constraint.ParentToConstraint != null) { return(parentTransform.TransformRotation(constraint.ParentToConstraint.Rotation)); } else { return(parentTransform.Rotation); } } //No parent defined else { if (constraint.ParentToConstraint != null) { return(constraint.ParentToConstraint.Rotation); } } return(null); }
/// <summary> /// Performs the actual solving /// </summary> /// <param name="currentResult"></param> /// <param name="mmuResults"></param> /// <param name="timeSpan"></param> /// <returns></returns> public MSimulationResult Solve(MSimulationResult currentResult, List <MSimulationResult> mmuResults, float timeSpan) { List <MJointConstraint> jointConstraints = new List <MJointConstraint>(); foreach (MConstraint constraint in currentResult.Constraints) { if (constraint.JointConstraint != null) { jointConstraints.Add(constraint.JointConstraint); } if (constraint.PostureConstraint != null && constraint.PostureConstraint.JointConstraints != null) { jointConstraints.AddRange(constraint.PostureConstraint.JointConstraints); } } //Set the channel data this.skeletonAccess.SetChannelData(currentResult.Posture); foreach (MJointConstraint constraint in jointConstraints) { //Skip if joint is not considered if (!this.ConsideredTypes.Contains(constraint.JointType)) { continue; } MGeometryConstraint geometryConstraint = constraint.GeometryConstraint; //To do -> Further check the parent if (geometryConstraint.ParentToConstraint != null) { this.skeletonAccess.SetLocalJointPosition(currentResult.Posture.AvatarID, constraint.JointType, geometryConstraint.ParentToConstraint.Position); this.skeletonAccess.SetLocalJointRotation(currentResult.Posture.AvatarID, constraint.JointType, geometryConstraint.ParentToConstraint.Rotation); } } currentResult.Posture = this.skeletonAccess.RecomputeCurrentPostureValues(currentResult.Posture.AvatarID); return(currentResult); }