Beispiel #1
0
        public void Update(float dTime)
        {
            if (animate)
            {
                Vector3 pos = camera.Position;
                Vector3 dir = (animationTarget - pos).Normalized();
                pos += (animationTarget - animationTargetDistance * dir - pos) * 2f * dTime;

                Vector3 lookAt = camera.LookAt;
                Vector3 d      = animationTarget - lookAt;
                lookAt += d * 2f * dTime;

                camera.Relocate(pos, lookAt);

                if (d.Length < 0.1f)
                {
                    animate = false;
                }
                return;
            }


            if (moveForward)
            {
                movement.Z = 1.0f;
            }
            if (moveBackward)
            {
                movement.Z = -1.0f;
            }
            if (moveLeft)
            {
                movement.X = 1.0f;
            }
            if (moveRight)
            {
                movement.X = -1.0f;
            }

            //if (movement.Length > 1.0f) movement.Normalize();

            float speed = (fast ? MoveSpeedFast : MoveSpeed);

            camera.Move(dTime * movement.Z * speed);
            camera.Strafe(dTime * movement.X * speed);

            movement *= 0.8f * (1.0f - dTime);
        }