예제 #1
0
        protected override void UpdateObject(Microsoft.Xna.Framework.GameTime gt, PloobsEngine.Cameras.ICamera cam, IWorld world)
        {
            // Tell the animation player to compute the latest bone transform matrices.
            SkinnedModel.AnimationPlayer.UpdateBoneTransforms(gt.ElapsedGameTime, true);

            Matrix[] boneTransforms = new Matrix[SkinnedModel.SkinningData.BindPose.Count];
            // Copy the transforms into our own array, so we can safely modify the values.
            SkinnedModel.AnimationPlayer.GetBoneTransforms().CopyTo(boneTransforms, 0);

            // Modify the transform matrices for the head and upper-left arm bones.
            int headIndex = SkinnedModel.SkinningData.BoneIndices["Head"];

            ///some bone manipulation
            headRotation += step;
            if (headRotation > 0.7f || headRotation < -0.7f)
            {
                step *= -1;
            }

            Matrix headTransform = Matrix.CreateRotationX(headRotation);

            boneTransforms[headIndex] = headTransform * boneTransforms[headIndex];

            // Tell the animation player to recompute the world and skin matrices.
            SkinnedModel.AnimationPlayer.UpdateWorldTransforms(Matrix.Identity, boneTransforms);
            SkinnedModel.AnimationPlayer.UpdateSkinTransforms();

            ForwardSkinnedShader.SetBones(SkinnedModel.AnimationPlayer.GetSkinTransforms());
            base.UpdateObject(gt, cam, world);
        }
예제 #2
0
 public SkinnedIObject(GraphicFactory factory, String modelName, IPhysicObject phyobj)
 {
     this.Modelo          = SkinnedModel = new SkinnedModel(factory, modelName);
     ForwardSkinnedShader = new ForwardSkinnedShader();
     this.Material        = new ForwardMaterial(ForwardSkinnedShader);
     this.PhysicObject    = phyobj;
     IObjectAttachment    = new List <IObjectAttachment>();
     Name = modelName;
 }