예제 #1
0
    public ClosedFormIKSample(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 ClosedFormIKSolver uses an analytic solution to compute
      // IK for arbitrary long bone chains. It does not support bone rotation limits.
      _ikSolver = new ClosedFormIKSolver
      {
        SkeletonPose = _meshNode.SkeletonPose,

        // The chain starts at the upper arm.
        RootBoneIndex = 13,

        // The chain ends at the hand bone.
        TipBoneIndex = 15,

        // The offset from the hand center to the hand origin.
        TipOffset = new Vector3F(0.1f, 0, 0),
      };
    }
예제 #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 ClosedFormIKSolver uses an analytic solution to compute
              // IK for arbitrary long bone chains. It does not support bone rotation limits.
              _ikSolver = new ClosedFormIKSolver
              {
            SkeletonPose = _skeletonPose,

            // The chain starts at the upper arm.
            RootBoneIndex = 13,

            // The chain ends at the hand bone.
            TipBoneIndex = 15,

            // The offset from the hand center to the hand origin.
            TipOffset = new Vector3F(0.1f, 0, 0),
              };

              base.LoadContent();
        }