Exemplo n.º 1
0
        public void Update(GameTime gameTime, float currentPhase /*, Vector3 headPos*/, float shipAngle)
        {
            Vector2 offset = Tunnel.GetTunnelOffset(currentPhase);

            this.position = Vector3.Transform(this.up * distanceFromCentre, Matrix.CreateRotationZ(shipAngle)) + new Vector3(-offset.X, offset.Y, 0.0f);
            Matrix cameraRotation = Matrix.CreateRotationZ(shipAngle + (float)Math.PI);

            this.rotatedUp = Vector3.Transform(this.up, cameraRotation);
            Vector3 direction = Tunnel.GetTunnelDirection(currentPhase);

            direction.X = -direction.X;

            //Matrix headRotationMatrix = Matrix.CreateFromAxisAngle(this.up, (float)Math.Atan(headPos.X));
            //Vector3 newHeadPos = new Vector3(-1.0f * headPos.X, -1.0f * headPos.Y, 1.0f * headPos.Z);
            //newHeadPos = Vector3.Transform(newHeadPos, headRotationMatrix * cameraRotation);
            //newHeadPos.X *= headMovementScaleFactor.X;
            //newHeadPos.Y *= headMovementScaleFactor.Y;
            //newHeadPos.Z *= headMovementScaleFactor.Z;

            //projects to a point far in the distance
            Vector3 down = new Vector3(0.0f, -(lookAheadDistance * (float)Math.Tan(lookDownAngleDegrees * (float)Math.PI / 180.0f)), 0.0f);

            this.cameraLookAt = position + (direction * lookAheadDistance) + Vector3.Transform(down, cameraRotation);

            //this.cameraLookAt = Vector3.Transform(this.cameraLookAt, cameraRotation * Matrix.CreateRotationX(lookDownAngleDegrees * (float)(Math.PI / 180)));
            View = Matrix.CreateLookAt(this.position /*+ newHeadPos*/, this.cameraLookAt, this.rotatedUp);
        }
Exemplo n.º 2
0
        public void Update(GameTime gameTime, float change, float tiltAngle)
        {
            _tiltRotation = tiltAngle;

            Angle += change;

            Vector3 direction = Tunnel.GetTunnelDirection(_tunnel.CurrentPhase + _zDistance);

            _position = new Vector3(0.0f, _distanceFromCenter, _zDistance);
            _position = Vector3.Transform(_position, Matrix.CreateRotationZ(Angle));
            Matrix m = _world * Matrix.CreateRotationZ(Angle - _tiltRotation);

            m.Translation  = _position + _tunnel.GetTunnelCentrePos(_zDistance);
            World          = m;
            _tiltRotation *= 0.9f;
            // update position
            base.Update(gameTime);
        }
Exemplo n.º 3
0
        public void Update(GameTime gameTime, float change, float tiltAngle)
        {
            _tiltRotation = tiltAngle;

            Angle += change;
            Vector3 direction = Tunnel.GetTunnelDirection(_tunnel.CurrentPhase + _zDistance);

            //Matrix orientation = Matrix.CreateFromYawPitchRoll((float)Math.Atan(direction.X), (float)Math.Atan(-direction.Y), 0/*(Angle /*+ (float)Math.PI - this.rollAngle*/);

            _position = new Vector3(0.0f, _distanceFromCenter, _zDistance);
            _position = Vector3.Transform(_position, Matrix.CreateRotationZ(Angle));
            Matrix m = _world * Matrix.CreateRotationZ(Angle - _tiltRotation);

            m.Translation  = _position + _tunnel.GetTunnelCentrePos(_zDistance);
            World          = m;
            _tiltRotation *= 0.9f;
            // update position
            base.Update(gameTime);
        }
Exemplo n.º 4
0
        public float DeltaPhase(GameTime gameTime)
        {
            Vector3 currentDirection  = Tunnel.GetTunnelDirection(this.currentPhase);
            float   distanceTravelled = (float)gameTime.ElapsedGameTime.TotalMilliseconds * this.speed / 1000.0f;
            float   deltaDistance     = distanceTravelled / (float)Tunnel.deltaResolution;

            Vector3 deltaPosition;
            Vector3 currentPosition = new Vector3(Tunnel.GetTunnelOffset(this.currentPhase), this.currentPhase);

            for (int i = 0; i < deltaResolution; i++)
            {
                deltaPosition = currentDirection * deltaDistance;
                Vector2 realXY = Tunnel.GetTunnelOffset(currentPhase + deltaPosition.Z);
                deltaPosition.X  = realXY.X;
                deltaPosition.Y  = realXY.Y;
                currentPosition += deltaPosition;
            }

            return(currentPosition.Z - currentPhase);
        }