Example #1
0
        public void OnAnimate(ComponentAnimation animation, Vector3 position, ComponentTransform transform)
        {
            Matrix4 mat = Matrix4.CreateRotationX(animation.AnimateRotation.X * animation.Speed);

            mat *= Matrix4.CreateRotationY(animation.AnimateRotation.Y * animation.Speed);
            mat *= Matrix4.CreateRotationZ(animation.AnimateRotation.Z * animation.Speed);
            transform.Transform *= mat;
        }
Example #2
0
                public static JointAnimation Read(Stream str)
                {
                    JointAnimation anim = new JointAnimation();

                    anim.x = ComponentAnimation.Read(str);
                    anim.y = ComponentAnimation.Read(str);
                    anim.z = ComponentAnimation.Read(str);
                    return(anim);
                }
Example #3
0
                public static ComponentAnimation Read(Stream str)
                {
                    ComponentAnimation anim = new ComponentAnimation();

                    anim.scale       = Selection.Read(str);
                    anim.rotation    = Selection.Read(str);
                    anim.translation = Selection.Read(str);
                    return(anim);
                }
        private void Animation(ComponentPosition position, ComponentDirection direction, ComponentAnimation animation)
        {
            float currentTime = animation.CurrentTime;
            float period      = animation.Period;
            float dt          = SceneManager.dt;
            float timeOver    = 0.0f;

            currentTime += dt;

            if (currentTime > period)
            {
                timeOver = (currentTime - period) % period;
                animation.CurrentTime = timeOver;
            }
            else
            {
                animation.CurrentTime = currentTime;
            }

            AnimationType type = animation.Type;

            if (type == AnimationType.ROTATION_Y)
            {
                Matrix3 rot = Matrix3.CreateRotationY(DegreeToRadians(360 / period) * SceneManager.dt);
                direction.Direction = rot * direction.Direction;
            }
            else if (type == AnimationType.OSCILLATION_Y)
            {
                float   angle     = (currentTime / period) * 360;
                float   height    = (float)Math.Cos(angle / 180 * Math.PI);
                Vector3 positionV = position.Position;
                positionV.Y       = position.StartPosition.Y + animation.MaxHeight * (-(height - 1) / 2f);
                position.Position = positionV;
            }
        }