Пример #1
0
    public CcdIKSample(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 CCD method can solve long bone chains with 
      // limits. 
      _ikSolver = new CcdIKSolver
      {
        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),

        // We can set a bone gain less than 1 to get a "smoother" result in most cases -
        // at the cost of more iterations.
        //BoneGain = 0.9f,

        // This solver uses an iterative method and will make up to 100 iterations if necessary.
        NumberOfIterations = 10,

        // A method that applies bone limits.
        LimitBoneTransforms = LimitBoneTransform,
      };
    }
Пример #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 CCD method can solve long bone chains with
              // limits.
              _ikSolver = new CcdIKSolver
              {
            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),

            // We can set a bone gain less than 1 to get a "smoother" result in most cases -
            // at the cost of more iterations.
            //BoneGain = 0.9f,

            // This solver uses an iterative method and will make up to 100 iterations if necessary.
            NumberOfIterations = 10,

            // A method that applies bone limits.
            LimitBoneTransforms = LimitBoneTransform,
              };

              base.LoadContent();
        }