示例#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);
        }
示例#2
0
        public static Vector3 GetTunnelDirection(float Phase)
        {
            float   deltaPhase      = 0.01f;
            Vector3 currentPosition = new Vector3(Tunnel.GetTunnelOffset(Phase), Phase);
            Vector3 newPosition     = new Vector3(Tunnel.GetTunnelOffset(Phase + deltaPhase), Phase + deltaPhase);

            return(Vector3.Normalize(newPosition - currentPosition));
            //return new Vector3(0.0f, 0.0f, 1.0f);
        }
示例#3
0
        public void ConstructCurves()
        {
            Vector2 offset;

            for (int i = 0; i <= vertices.GetUpperBound(0); i++)
            {
                offset = Tunnel.GetTunnelOffset(this.PhaseAtStart - vertices[i].Position.Z + this.ZAtStart);
                vertices[i].Position.X += offset.X;
                vertices[i].Position.Y += offset.Y;
            }
        }
示例#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);
        }
示例#5
0
        public Vector3 GetTunnelCentrePos(float deltaPhase)
        {
            Vector2 offset = Tunnel.GetTunnelOffset(this.currentPhase + deltaPhase);

            return(new Vector3(-offset.X, offset.Y, deltaPhase));
        }