Exemplo n.º 1
0
    public TwoJointIKSample(Microsoft.Xna.Framework.Game game)
      : base(game)
    {
      var modelNode = ContentManager.Load<ModelNode>("Dude/Dude");
      _meshNode = modelNode.GetSubtree().OfType<MeshNode>().First().Clone();
      _meshNode.PoseLocal = new Pose(new Vector3F(0, 0, 0));
      SampleHelper.EnablePerPixelLighting(_meshNode);
      GraphicsScreen.Scene.Children.Add(_meshNode);

      // Create the IK solver. The TwoJointIkSolver is usually used for arms and legs.
      // it modifies two bones and supports limits for the second bone. 
      _ikSolver = new TwoJointIKSolver
      {
        SkeletonPose = _meshNode.SkeletonPose,

        // The chain starts at the upper leg.
        RootBoneIndex = 54,

        // The second bone modified bone is the lower leg.
        HingeBoneIndex = 55,

        // The chain ends at the foot bone.
        TipBoneIndex = 56,

        // The direction of the hinge axis (in bone space).
        HingeAxis = -Vector3F.UnitZ,

        // The hinge limits.
        MinHingeAngle = 0,
        MaxHingeAngle = ConstantsF.PiOver2,

        // The offset from the ankle to the bottom of the foot.
        TipOffset = new Vector3F(0.23f, 0, 0),
      };
    }
Exemplo n.º 2
0
        protected override void LoadContent()
        {
            _model = Game.Content.Load<Model>("Dude");
              var additionalData = (Dictionary<string, object>)_model.Tag;
              var skeleton = (Skeleton)additionalData["Skeleton"];
              _skeletonPose = SkeletonPose.Create(skeleton);

              // Create the IK solver. The TwoJointIkSolver is usually used for arms and legs.
              // it modifies two bones and supports limits for the second bone.
              _ikSolver = new TwoJointIKSolver
              {
            SkeletonPose = _skeletonPose,

            // The chain starts at the upper leg.
            RootBoneIndex = 54,

            // The second bone modified bone is the lower leg.
            HingeBoneIndex = 55,

            // The chain ends at the foot bone.
            TipBoneIndex = 56,

            // The direction of the hinge axis (in bone space).
            HingeAxis = -Vector3F.UnitZ,

            // The hinge limits.
            MinHingeAngle = 0,
            MaxHingeAngle = ConstantsF.PiOver2,

            // The offset from the ankle to the bottom of the foot.
            TipOffset = new Vector3F(0.23f, 0, 0),
              };

              base.LoadContent();
        }