public SkeletonVisualization(IntermediateSkeleton skeleton, RetargetingService retargetingService, Transform RootBone, Dictionary <string, MJointType> bonenameMap, string AvatarID, GameObject gameJointPrefab)
        {
            //this.anim = anim;

            this.RootBone    = RootBone;
            this.bonenameMap = bonenameMap.Invert();

            this.skeleton = skeleton;
            this.AvatarID = AvatarID;

            this.retargetingService = retargetingService;

            root = new ISVisualizationJoint((RJoint)skeleton.GetRoot(this.AvatarID), RootBone, this.bonenameMap);
            //root.AlignAvatar(anim);
            root.CreateGameObjSkel(gameJointPrefab);
            //root.SetToZero(this.AvatarID);
        }
示例#2
0
        public void TestRootPosition()
        {
            MAvatarDescription   desc     = IntermediateSkeleton.GenerateFromDescriptionFile("TestAvatar");
            IntermediateSkeleton skeleton = new IntermediateSkeleton();

            skeleton.InitializeAnthropometry(desc);
            List <double> rotationValues = new List <double>()
            {
                0, 0, 0, 0.86041, -0.01303, 0.50383, 0.07533,                    //S1L5
                0.00000, 0.00000, 0.00000, 1.00000, 0.00000, 0.00000, 0.00000,   // T12L12
                0.00000, 0.00000, 0.00000, 1.00000, 0.00000, 0.00000, 0.00000,   // T1T2
                0.00000, 0.00000, 0.00000, 1.00000, 0.00000, 0.00000, 0.00000,   //C4C5
                0.00000, 0.00000, 0.00000, 0.98890, 0.04908, -0.13945, -0.01508, // Head
                0.00000, 0.00000, 0.00000, 0.74914, -0.35251, 0.02895, 0.56007,  // LeftShoulder
                0.98560, 0.11136, -0.00962, 0.12689,                             // Left ELbow
                0.96542, -0.01250, 0.25953, 0.02139,                             // Left Wrist
                0.00000, 0.00000, 0.00000, 0.74411, 0.10420, 0.26279, -0.60530,
                0.95158, 0.28073, 0.07735, -0.09850,                             // Right Elbow
                0.99256, -0.00379, 0.11897, -0.02548,                            // right wrist
                0.94999, -0.28306, 0.12805, 0.03154,                             // Left hip
                0.97503, 0.22205, 0.00000, -0.00001,                             // Knee
                0.99439, -0.07404, 0.06580, 0.03709,                             // Ankle
                1.00000, 0.00000, 0.00000, 0.00000,                              // Toes
                0.99694, 0.07053, -0.02371, 0.02406,                             // Right Hip
                0.91716, 0.39852, 0.00000, 0.00000,                              // Knee
                0.99076, -0.12976, 0.02501, 0.03048,                             // Ankle
                1.00000, 0.00000, 0.00000, 0.00000
            };                                                                   // Toes
            MAvatarPostureValues values = new MAvatarPostureValues(desc.AvatarID, rotationValues);

            skeleton.SetChannelData(values);
            MVector3 pos = skeleton.GetGlobalJointPosition(desc.AvatarID, MJointType.S1L5Joint);
            MVector3 gt  = skeleton.GetRoot(desc.AvatarID).GetMJoint().Position;

            gt = new MVector3(gt.X + rotationValues[0], gt.Y + rotationValues[1], gt.Z + rotationValues[2]);
            System.Console.WriteLine("pos: {0}, {1}, {2}", pos.X, pos.Y, pos.Z);
            System.Console.WriteLine("gt: {0}, {1}, {2}", gt.X, gt.Y, gt.Z);
            Assert.IsTrue(System.Math.Abs(pos.X - gt.X) < 0.001);
            Assert.IsTrue(System.Math.Abs(pos.Y - gt.Y) < 0.001);
            Assert.IsTrue(System.Math.Abs(pos.Z - gt.Z) < 0.001);
        }