Procházet zdrojové kódy

Feature: Added a camera gizmo for previewing its frustum geometry

BearishSun před 8 roky
rodič
revize
bfd8b9069d

+ 1 - 0
Source/MBansheeEditor/MBansheeEditor.csproj

@@ -98,6 +98,7 @@
     <Compile Include="Windows\Inspector\InspectableRangedInt.cs" />
     <Compile Include="Windows\Inspector\Style\InspectableFieldStyleInfo.cs" />
     <Compile Include="Windows\LogWindow.cs" />
+    <Compile Include="Windows\Scene\Gizmos\CameraGizmo.cs" />
     <Compile Include="Windows\Scene\Gizmos\LightProbeVolumeGizmo.cs" />
     <Compile Include="Windows\Scene\Gizmos\ReflectionProbeGizmo.cs" />
     <Compile Include="Windows\Scene\Handles\HandleSliderSphere.cs" />

+ 34 - 0
Source/MBansheeEditor/Windows/Scene/Gizmos/CameraGizmo.cs

@@ -0,0 +1,34 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2017 Marko Pintera ([email protected]). All rights reserved. **********************//
+using BansheeEngine;
+
+namespace BansheeEditor
+{
+    /** @addtogroup Gizmos
+     *  @{
+     */
+
+    /// <summary>
+    /// Handles drawing of gizmos for the <see cref="Camera"/> component.
+    /// </summary>
+    internal class CameraGizmo
+    {
+        /// <summary>
+        /// Method called by the runtime when gizmos are meant to be drawn.
+        /// </summary>
+        /// <param name="camera">Camera to draw gizmos for.</param>
+        [DrawGizmo(DrawGizmoFlags.Selected)]
+        private static void Draw(Camera camera)
+        {
+            SceneObject so = camera.SceneObject;
+
+            Gizmos.Color = Color.Yellow;
+            Gizmos.Transform = Matrix4.TRS(Vector3.Zero, Quaternion.LookRotation(so.Rotation.Forward, so.Rotation.Up), Vector3.One);
+
+            Gizmos.DrawFrustum(so.Position, camera.AspectRatio, camera.FieldOfView, camera.NearClipPlane,
+                camera.FarClipPlane);
+        }
+    }
+
+    /** @} */
+}