コード例 #1
0
 /// <summary>
 /// Sets a sprite's BlSprite#Matrix to the current camera position and orientation. You could use this to
 /// implement a HUD, for example. Note: This only works correctly if the sprite has no parent (and is thus drawn
 /// directly) or it's parents are untransformed. If all you want is to set the sprite's position (but NOT orientation)
 /// to the camera, then set the sprite's Matrix.Translation = graphics.#Eye
 /// </summary>
 /// <param name="sprite">The sprite that should be connected to the camera</param>
 public void SetSpriteToCamera(BlSprite sprite)
 {
     sprite.Matrix.Translation = Eye;
     sprite.Matrix.Forward     = CameraForwardNormalized;
     sprite.Matrix.Up          = CameraUp;
     sprite.Matrix.Right       = CameraRight;
 }
コード例 #2
0
        /// <summary>
        /// Informs the auto-clipping code of an object that should be visible within the clipping limits. This is
        /// mainly for internal use. Application code should control clipping with NearClip and FarClip.
        /// </summary>
        /// <param name="s">The sprite that should be included in the auto-clipping code</param>
        public void ExtendClippingTo(BlSprite s)
        {
            var near = s.CamDistance - s.BoundSphere.Value.Radius;
            var far  = s.CamDistance + s.BoundSphere.Value.Radius;

            var distDif = s.CamDistance - s.PrevCamDistance;

            if (distDif > 0)
            {
                far += 1.2 * distDif;
            }
            else
            {
                near += 1.2 * distDif;
            }

            if (MaxCamDistance < far)
            {
                MaxCamDistance = far;
            }

            if (MinCamDistance > near)
            {
                MinCamDistance = near;
            }

            if (MinCamDistance < 1e-38)
            {
                MinCamDistance = 1e-38;
            }

            //Console.WriteLine("{0} {1} {2}", s.Name, s.CamDistance, s.BoundSphere.Value.Radius);
        }
コード例 #3
0
 /// <summary>
 /// Sets the camera position and orientation to the current position and orientation of a sprite. You could
 /// use for cockpit view, for example. Note that the camera will lag sprite movement unless the following is done:
 /// For every frame you must first calculate the sprite's position and orientation, call this function, and then draw everything.
 /// </summary>
 /// <param name="sprite">The sprite that the camera should be connected to</param>
 public void SetCameraToSprite(BlSprite sprite)
 {
     TargetEye    = sprite.Matrix.Translation;
     Eye          = TargetEye;
     TargetLookAt = sprite.Matrix.Forward;
     LookAt       = TargetLookAt;
     CameraUp     = sprite.Matrix.Up;
 }
コード例 #4
0
        /// <summary>
        /// Returns the window coordinates of the specified sprite.
        /// </summary>
        /// <param name="sprite">The sprite to get the window coordinates of</param>
        /// <returns>The window coordinates of the sprite, in pixels</returns>
        public Vector3 GetWindowCoordinates(BlSprite sprite)
        {
            if (BlDebug.ShowThreadWarnings && CreationThread != Thread.CurrentThread.ManagedThreadId)
            {
                throw new Exception(String.Format("BlGraphicsDeviceManager.GetWindowCoordinates() was called by thread {0} instead of thread {1}", Thread.CurrentThread.ManagedThreadId, CreationThread));
            }

            return(GraphicsDevice.Viewport.Project(Vector3.Zero, Projection, View, sprite.AbsoluteMatrix));
        }
コード例 #5
0
ファイル: BlWindow3D.cs プロジェクト: bluecats/Blotch3D
 /// <summary>
 /// Used internally
 /// </summary>
 /// <param name="s"></param>
 public void FrameProcSpritesRemove(BlSprite s)
 {
     try
     {
         FrameProcSpritesMutex.WaitOne();
         FrameProcSprites.Remove(s);
     }
     finally
     {
         FrameProcSpritesMutex.ReleaseMutex();
     }
 }