Пример #1
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Update this Entity's view direction, which will indicate how it's drawn.
        /// </summary>
        public void updateDirectionView(Vector3 directionVector)
        {
            // Project as unit vector onto XZ plane
            directionVector.Y = 0.0f;
            directionVector   = Vector3.Normalize(directionVector);

            // Grab cosine of angle between vector and -Z axis (north/south axis)
            float cosTheta = Vector3.Dot(-Vector3.UnitZ, directionVector);

            if (Math.Abs(cosTheta) < 0.0005f)
            {
                cosTheta = 0.000f;
            }

            // Find angle and update direction
            float theta = (float)Math.Acos(cosTheta);

            if (directionVector.X > 0.0f)
            {
                theta = (float)(Math.PI + (Math.PI - theta));
            }
            _directionView = GameLevelManager.directionViewFromAngle(theta);
        }
Пример #2
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Update the direction enum, which indicates where the camera
 /// is pointing
 /// </summary>
 protected void updateDirection()
 {
     _dir = GameLevelManager.directionViewFromAngle(_rotationZ);
 }