//********************************** Banshee Engine (www.banshee3d.com) **************************************************// //**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************// using System; using System.Runtime.CompilerServices; using BansheeEngine; namespace BansheeEditor { /** @addtogroup Scene-Editor * @{ */ /// /// Contains information regarding object snapping. /// struct SnapData { /// /// The normal to the object surface at the snapping point. /// public Vector3 normal; /// /// The 3D position on the surface of the object /// public Vector3 position; } /// /// Handles rendering of the selection overlay and picking of objects in the target camera's view. /// internal sealed class SceneSelection : ScriptObject { /// /// Creates a new scene selection manager. /// /// Camera into which to render the selection overlay, and perform picking from. internal SceneSelection(Camera sceneCamera) { Internal_Create(this, sceneCamera.Native.GetCachedPtr()); } /// /// Queues selection overlay drawing for this frame. /// internal void Draw() { Internal_Draw(mCachedPtr); } /// /// Attempts to select a scene object under the pointer position. /// /// Position of the pointer relative to the scene camera viewport. /// Should this selection add to the existing selection, or replace it. /// An array of renderables that should not be rendered during scene picking. internal void PickObject(Vector2I pointerPos, bool controlHeld, SceneObject[] ignoreSceneObjects = null) { Internal_PickObject(mCachedPtr, ref pointerPos, controlHeld, ignoreSceneObjects); } /// /// Attempts to select a scene object in the specified area. /// /// Position of the pointer relative to the scene camera viewport. /// The screen area in which objects will be selected. /// Should this selection add to the existing selection, or replace it. /// An array of renderables that should not be rendered during scene picking. internal void PickObjects(Vector2I pointerPos, Vector2I area, bool controlHeld, SceneObject[] ignoreSceneObjects = null) { Internal_PickObjects(mCachedPtr, ref pointerPos, ref area, controlHeld, ignoreSceneObjects); } /// /// Returns the 3D position of an object under the cursor, along with the surface normal in that point. /// /// Position of the pointer relative to the scene camera viewport. /// An array of renderables that should not be rendered during scene picking. /// The position on the object surface and the normal in that point. internal SnapData Snap(Vector2I pointerPos, SceneObject[] ignoreSceneObjects = null) { SnapData data; Internal_Snap(mCachedPtr, ref pointerPos, out data, ignoreSceneObjects); return data; } [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_Create(SceneSelection managedInstance, IntPtr camera); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_Draw(IntPtr thisPtr); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_PickObject(IntPtr thisPtr, ref Vector2I pointerPos, bool controlHeld, SceneObject[] ignoreRenderables); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_PickObjects(IntPtr thisPtr, ref Vector2I pointerPos, ref Vector2I extents, bool controlHeld, SceneObject[] ignoreRenderables); [MethodImpl(MethodImplOptions.InternalCall)] private static extern void Internal_Snap(IntPtr thisPtr, ref Vector2I pointerPos, out SnapData data, SceneObject[] ignoreRenderables); } /** @} */ }