コード例 #1
0
ファイル: DebugRenderer.cs プロジェクト: Zolniu/DigitalRune
        /// <summary>
        /// Draws a view volume (viewing frustum).
        /// </summary>
        /// <param name="viewVolume">The view volume.</param>
        /// <param name="pose">The pose.</param>
        /// <param name="scale">The scale.</param>
        /// <param name="color">The color.</param>
        /// <param name="drawWireFrame">
        /// If set to <see langword="true"/> the wire-frame is drawn; otherwise the mesh is drawn with 
        /// solid faces.
        /// </param>
        /// <param name="drawOverScene">
        /// If set to <see langword="true"/> the object is drawn over the graphics scene (depth-test 
        /// disabled).
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="viewVolume"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="NotSupportedException">
        /// Drawing solid objects with disabled depth test is not yet supported.
        /// </exception>
        public void DrawViewVolume(ViewVolume viewVolume, Pose pose, Vector3F scale, Color color, bool drawWireFrame, bool drawOverScene)
        {
            if (viewVolume == null)
            throw new ArgumentNullException("viewVolume");

              if (!Enabled)
            return;

              float left = viewVolume.Left * scale.X;
              float right = viewVolume.Right * scale.X;
              float bottom = viewVolume.Bottom * scale.Y;
              float top = viewVolume.Top * scale.Y;
              float near = viewVolume.Near * scale.Z;
              float far = viewVolume.Far * scale.Z;
              DrawViewVolume(viewVolume is PerspectiveViewVolume, left, right, bottom, top, near, far, pose, color, drawWireFrame, drawOverScene);
        }
コード例 #2
0
    // Computes the bounding sphere of the given view frustum.
    private void GetBoundingSphere(ViewVolume viewVolume, out Vector3F center, out float radius)
    {
      float left = viewVolume.Left;
      float top = viewVolume.Top;
      float right = viewVolume.Right;
      float bottom = viewVolume.Bottom;
      float near = viewVolume.Near;
      float far = viewVolume.Far;

      _frustumCorners[0] = new Vector3F(left, top, -near);
      _frustumCorners[1] = new Vector3F(right, top, -near);
      _frustumCorners[2] = new Vector3F(left, bottom, -near);
      _frustumCorners[3] = new Vector3F(right, bottom, -near);

      float farOverNear = far / near;
      left *= farOverNear;
      top *= farOverNear;
      right *= farOverNear;
      bottom *= farOverNear;

      _frustumCorners[4] = new Vector3F(left, top, -far);
      _frustumCorners[5] = new Vector3F(right, top, -far);
      _frustumCorners[6] = new Vector3F(left, bottom, -far);
      _frustumCorners[7] = new Vector3F(right, bottom, -far);

      GeometryHelper.ComputeBoundingSphere(_frustumCorners, out radius, out center);
    }
コード例 #3
0
ファイル: DebugRenderer.cs プロジェクト: Zolniu/DigitalRune
        /// <overloads>
        /// <summary>
        /// Draws a view volume (viewing frustum).
        /// </summary>
        /// </overloads>
        /// 
        /// <summary>
        /// Draws a view volume (viewing frustum).
        /// </summary>
        /// <param name="viewVolume">The view volume.</param>
        /// <param name="pose">The pose.</param>
        /// <param name="color">The color.</param>
        /// <param name="drawWireFrame">
        /// If set to <see langword="true"/> the wire-frame is drawn; otherwise the mesh is drawn with 
        /// solid faces.
        /// </param>
        /// <param name="drawOverScene">
        /// If set to <see langword="true"/> the object is drawn over the graphics scene (depth-test 
        /// disabled).
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="viewVolume"/> is <see langword="null"/>.
        /// </exception>
        /// <exception cref="NotSupportedException">
        /// Drawing solid objects with disabled depth test is not yet supported.
        /// </exception>
        public void DrawViewVolume(ViewVolume viewVolume, Pose pose, Color color, bool drawWireFrame, bool drawOverScene)
        {
            if (viewVolume == null)
            throw new ArgumentNullException("viewVolume");

              DrawViewVolume(viewVolume is PerspectiveViewVolume, viewVolume.Left, viewVolume.Right, viewVolume.Bottom, viewVolume.Top, viewVolume.Near, viewVolume.Far, pose, color, drawWireFrame, drawOverScene);
        }