/// <summary> /// Returns the current posture values for the avatar by recomputing the values based on the internal hierarchy. /// </summary> /// <param name="avatarID"></param> /// <returns></returns> public MAvatarPostureValues GetCurrentPostureValues(string avatarID) { RJoint root = this.hierarchies[avatarID]; List <double> postureValues = root.GetAvatarPostureValues(); MAvatarPostureValues values = new MAvatarPostureValues(avatarID, postureValues); return(values); //return this.lastPostureValues[avatarID]; }
/// <summary> /// Retargets the global posture to the intermediate skeleton /// </summary> /// <param name="globalTarget"></param> /// <returns></returns> public MAvatarPostureValues RetargetToIntermediate(MAvatarPosture globalTarget) { RJoint root = ((RJoint)this.skeleton.GetRoot(globalTarget.AvatarID)); bool rootFound = false; foreach (MJoint j in globalTarget.Joints) { if (j.Type != MJointType.Undefined) { RJoint rj = ((RJoint)root.GetChild(j.Type)); rj.RetargetPositionToIS(j.Position, j.Rotation); rj.RetargetRotationToIS(j.Rotation); if (!rootFound) { rootFound = true; if (j.Type == MJointType.Root) { } else { MVector3 globalPos = rj.GetGlobalPosManually(); root.SetGlobalPosManually(new MVector3(globalPos.X, 0, globalPos.Z)); //rj.SetGlobalPosManually(new MVector3(0, globalPos.Y, 0)); } } } } root.RecomputeLocalTransformations(); MAvatarPostureValues ret = new MAvatarPostureValues(globalTarget.AvatarID, root.GetAvatarPostureValues()); return(ret); }