//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
//**************** Copyright (c) 2016 Marko Pintera (marko.pintera@gmail.com). All rights reserved. **********************//
using System.Runtime.CompilerServices;
using bs;
using System;
namespace bs.Editor
{
/** @addtogroup Handles
* @{
*/
///
/// Contains various method that can be used for drawing handles. These methods should only be called from
/// method or its overrides.
///
public sealed class HandleDrawing
{
///
/// Determines the color that will be used on any following draw method.
///
public static Color Color
{
set { Internal_SetColor(ref value); }
}
///
/// Determines the world transform that will be applied to any following draw method.
///
public static Matrix4 Transform
{
set { Internal_SetTransform(ref value); }
}
///
/// Layer bitfield that controls whether a handle is considered visible in a specific camera. Handle layer
/// must match camera layer in order for the camera to render it.
///
public static UInt64 Layer
{
set { Internal_SetLayer(value); }
}
///
/// Draws an axis aligned solid cube.
///
/// World coordinates of the center of the cube.
/// Extents defining the half-size of the cube in each dimension.
/// Uniform scale to apply on top of the existing transform. Primarily used for maintaining
/// handle size regardless of distance from camera.
public static void DrawCube(Vector3 position, Vector3 extents, float size = 1.0f)
{
Internal_DrawCube(ref position, ref extents, size);
}
///
/// Draws a solid sphere.
///
/// World coordinates of the center of the sphere.
/// Sphere radius.
/// Uniform scale to apply on top of the existing transform. Primarily used for maintaining
/// handle size regardless of distance from camera.
public static void DrawSphere(Vector3 position, float radius, float size = 1.0f)
{
Internal_DrawSphere(ref position, radius, size);
}
///
/// Draws an axis aligned wireframe cube.
///
/// World coordinates of the center of the cube.
/// Extents defining the half-size of the cube in each dimension.
/// Uniform scale to apply on top of the existing transform. Primarily used for maintaining
/// handle size regardless of distance from camera.
public static void DrawWireCube(Vector3 position, Vector3 extents, float size = 1.0f)
{
Internal_DrawWireCube(ref position, ref extents, size);
}
///
/// Draws a wireframe sphere.
///
/// World coordinates of the center of the sphere.
/// Sphere radius.
/// Uniform scale to apply on top of the existing transform. Primarily used for maintaining
/// handle size regardless of distance from camera.
public static void DrawWireSphere(Vector3 position, float radius, float size = 1.0f)
{
Internal_DrawWireSphere(ref position, radius, size);
}
///
/// Draws a solid cone.
///
/// Location of the cone base (center of the cone disc).
/// Normal pointing from the base to the cone point.
/// Distance from the origin to the cone point.
/// Radius of the cone disc.
/// Uniform scale to apply on top of the existing transform. Primarily used for maintaining
/// handle size regardless of distance from camera.
public static void DrawCone(Vector3 coneBase, Vector3 normal, float height, float radius, float size = 1.0f)
{
Internal_DrawCone(ref coneBase, ref normal, height, radius, size);
}
///
/// Draws a 3D line.
///
/// Starting point for the line.
/// Ending point for the line.
/// Uniform scale to apply on top of the existing transform. Primarily used for maintaining
/// handle size regardless of distance from camera.
public static void DrawLine(Vector3 start, Vector3 end, float size = 1.0f)
{
Internal_DrawLine(ref start, ref end, size);
}
///
/// Draws a solid double-sided disc.
///
/// Center of the disc.
/// Normal towards which to orient the disc.
/// Radius of the disc.
/// Uniform scale to apply on top of the existing transform. Primarily used for maintaining
/// handle size regardless of distance from camera.
public static void DrawDisc(Vector3 position, Vector3 normal, float radius, float size = 1.0f)
{
Internal_DrawDisc(ref position, ref normal, radius, size);
}
///
/// Draws a wireframe disc.
///
/// Center of the disc.
/// Normal towards which to orient the disc.
/// Radius of the disc.
/// Uniform scale to apply on top of the existing transform. Primarily used for maintaining
/// handle size regardless of distance from camera.
public static void DrawWireDisc(Vector3 position, Vector3 normal, float radius, float size = 1.0f)
{
Internal_DrawWireDisc(ref position, ref normal, radius, size);
}
///
/// Draws a solid double-sided arc.
///
/// Center of the disc out of which the arc is cut out of.
/// Normal towards which to orient the arc.
/// Radius of the disc out of which the arc is cut out of.
/// Angle at which the arc starts.
/// Length of the arc.
/// Uniform scale to apply on top of the existing transform. Primarily used for maintaining
/// handle size regardless of distance from camera.
public static void DrawArc(Vector3 position, Vector3 normal, float radius, Degree startAngle, Degree amountAngle,
float size = 1.0f)
{
Internal_DrawArc(ref position, ref normal, radius, ref startAngle, ref amountAngle, size);
}
///
/// Draws a wireframe arc.
///
/// Center of the disc out of which the arc is cut out of.
/// Normal towards which to orient the arc.
/// Radius of the disc out of which the arc is cut out of.
/// Angle at which the arc starts.
/// Length of the arc.
/// Uniform scale to apply on top of the existing transform. Primarily used for maintaining
/// handle size regardless of distance from camera.
public static void DrawWireArc(Vector3 position, Vector3 normal, float radius, Degree startAngle,
Degree amountAngle, float size = 1.0f)
{
Internal_DrawWireArc(ref position, ref normal, radius, ref startAngle, ref amountAngle, size);
}
///
/// Draws a single-sided rectangle in 3D.
///
/// Determines the position, orientation and size of the rectangle.
/// Uniform scale to apply on top of the existing transform. Primarily used for maintaining
/// handle size regardless of distance from camera.
public static void DrawRect(Rect3 area, float size = 1.0f)
{
Vector3 center = area.Center;
Vector3 axisHorz = area.AxisHorz;
Vector3 axisVert = area.AxisVert;
Internal_DrawRect(ref center, ref axisHorz, ref axisVert, area.ExtentHorz, area.ExtentVert, size);
}
///
/// Draws camera aligned text at the specified position.
///
/// World position to center the text on.
/// String to draw.
/// Font used for drawing the characters.
/// Size of the characters, in points.
public static void DrawText(Vector3 position, string text, Font font = null, int fontSize = 16)
{
IntPtr scriptFont = IntPtr.Zero;
if (font != null)
scriptFont = font.GetCachedPtr();
Internal_DrawText(ref position, text, scriptFont, fontSize);
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_SetColor(ref Color color);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_SetTransform(ref Matrix4 transform);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_SetLayer(UInt64 layer);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawCube(ref Vector3 position, ref Vector3 extents, float size);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawSphere(ref Vector3 position, float radius, float size);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawWireCube(ref Vector3 position, ref Vector3 extents, float size);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawWireSphere(ref Vector3 position, float radius, float size);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawCone(ref Vector3 coneBase, ref Vector3 normal, float height, float radius, float size);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawLine(ref Vector3 start, ref Vector3 end, float size);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawDisc(ref Vector3 position, ref Vector3 normal, float radius, float size);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawWireDisc(ref Vector3 position, ref Vector3 normal, float radius, float size);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawArc(ref Vector3 position, ref Vector3 normal, float radius, ref Degree startAngle, ref Degree amountAngle, float size);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawWireArc(ref Vector3 position, ref Vector3 normal, float radius, ref Degree startAngle, ref Degree amountAngle, float size);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawRect(ref Vector3 center, ref Vector3 axisH, ref Vector3 axisV, float extentH, float extentV, float size);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawText(ref Vector3 position, string text, IntPtr font, int fontSize);
}
/** @} */
}