Beispiel #1
0
 public void updateAnimation(GameTime gameTime)
 {
     if (animate)
     {
         skinnedAnimationPlayer.Update(gameTime);
     }
 }
        public void Update(GameTime time)
        {
            float ts = TimeScale * 6.0f * 0.0167f;

            if (ts > 0)
            {
                GameTime gameTime = new GameTime(TimeSpan.Zero, TimeSpan.FromSeconds(ts), TimeSpan.Zero, TimeSpan.FromSeconds(ts));

                if (!playingSkinned)
                {
                    skinnedPlayer.StartClip(skinnedClip, 1, TimeSpan.Zero);

                    rigidPlayer.StartClip(rigidClip, 1, TimeSpan.Zero);

                    playingSkinned = true;

                    if (skinnedRootPlayer != null && skinnedRootClip != null)
                    {
                        skinnedRootPlayer.StartClip(skinnedRootClip, 1, TimeSpan.Zero);
                    }
                    if (rigidRootPlayer != null && rigidRootClip != null)
                    {
                        rigidRootPlayer.StartClip(rigidRootClip, 1, TimeSpan.Zero);
                    }
                }

                // If we are playing skinned animations, update the players
                if (playingSkinned)
                {
                    if (skinnedRootPlayer != null)
                    {
                        skinnedRootPlayer.Update(gameTime);
                    }
                    if (rigidRootPlayer != null)
                    {
                        rigidRootPlayer.Update(gameTime);
                    }

                    skinnedPlayer.Update(gameTime);
                    rigidPlayer.Update(gameTime);
                }
            }
        }
Beispiel #3
0
        public Model3DSkinned(SceneContainer scene, Vector3 pos, Matrix rotation, Vector3 scale, String modelName, String clip)
            : base(scene, pos, rotation, scale)
        {
            this.scene     = scene;
            this.modelName = modelName;

            this.clip    = clip;
            this.animate = false;
            this.jumping = false;
            this.rising  = false;
            model        = scene.Game.Content.Load <Model>(modelName);

            // Look up our custom skinning information.
            skinningData = model.Tag as ModelData;

            if (skinningData != null)
            {
                if (skinningData.RootAnimationClips != null)
                {
                    rootAnimationPlayer = new RootAnimationPlayer();
                }
                if (skinningData.ModelAnimationClips != null)
                {
                    skinnedAnimationPlayer = new SkinnedAnimationPlayer(skinningData.BindPose, skinningData.InverseBindPose, skinningData.SkeletonHierarchy);
                    skinnedAnimationPlayer.StartClip(skinningData.ModelAnimationClips[clip]);
                    boneTransforms = skinnedAnimationPlayer.GetSkinTransforms();
                    skinnedAnimationPlayer.Update(new GameTime(new TimeSpan(), new TimeSpan(2)));
                }
            }
            bsLocal = new BoundingSphere();
            foreach (ModelMesh mesh in model.Meshes)
            {
                bsLocal = BoundingSphere.CreateMerged(bsLocal, mesh.BoundingSphere);
            }
            setObject(pos.X, pos.Y, pos.Z);
        }
        protected override void Update(GameTime gameTime)
        {
            // Get the current gamepad state and store the old
            lastGamePadState    = currentGamePadState;
            currentGamePadState = GamePad.GetState(PlayerIndex.One);

            lastKeyboardState    = currentKeyboardState;
            currentKeyboardState = Keyboard.GetState();

            // Allows the game to exit
            if (currentGamePadState.Buttons.Back == ButtonState.Pressed ||
                currentKeyboardState.IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // When the A button is pressed and we aren't playing the rigid animations, play them
            if ((IsNewButtonPress(Buttons.A) || IsNewKeyPress(Keys.A)) && playingRigid == false)
            {
                if (rigidPlayer != null && rigidClip != null)
                {
                    rigidPlayer.StartClip(rigidClip, 1, TimeSpan.Zero);
                    playingRigid = true;
                }

                if (rigidRootPlayer != null && rigidRootClip != null)
                {
                    rigidRootPlayer.StartClip(rigidRootClip, 1, TimeSpan.Zero);
                    playingRigid = true;
                }
            }

            // When the B button is pressed and we aren't playing the skinned animations, play them
            if ((IsNewButtonPress(Buttons.B) || IsNewKeyPress(Keys.B)) && playingSkinned == false)
            {
                if (skinnedPlayer != null && skinnedClip != null)
                {
                    skinnedPlayer.StartClip(skinnedClip, 1, TimeSpan.Zero);
                    playingSkinned = true;
                }

                if (skinnedRootPlayer != null && skinnedRootClip != null)
                {
                    skinnedRootPlayer.StartClip(skinnedRootClip, 1, TimeSpan.Zero);
                    playingSkinned = true;
                }
            }

            // If we are playing rigid animations, update the players
            if (playingRigid)
            {
                if (rigidRootPlayer != null)
                {
                    rigidRootPlayer.Update(gameTime);
                }

                if (rigidPlayer != null)
                {
                    rigidPlayer.Update(gameTime);
                }
            }

            // If we are playing skinned animations, update the players
            if (playingSkinned)
            {
                if (skinnedRootPlayer != null)
                {
                    skinnedRootPlayer.Update(gameTime);
                }

                if (skinnedPlayer != null)
                {
                    skinnedPlayer.Update(gameTime);
                }
            }

            base.Update(gameTime);
        }