using System;
using System.Runtime.CompilerServices;
using BansheeEngine;
namespace BansheeEditor
{
///
/// Provides functionality for drawing gizmos. This class should only be used in methods defined with
/// attribute.
///
public class Gizmos
{
///
/// Determines the color that will be used on any following draw method.
///
public static Color Color
{
get
{
Color value;
Internal_GetColor(out value);
return value;
}
set
{
Internal_SetColor(ref value);
}
}
///
/// Determines the world transform that will be applied to any following draw method.
///
public static Matrix4 Transform
{
get
{
Matrix4 value;
Internal_GetTransform(out value);
return value;
}
set
{
Internal_SetTransform(ref 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.
public static void DrawCube(Vector3 position, Vector3 extents)
{
Internal_DrawCube(ref position, ref extents);
}
///
/// Draws a solid sphere.
///
/// World coordinates of the center of the sphere.
/// Sphere radius.
public static void DrawSphere(Vector3 position, float radius)
{
Internal_DrawSphere(ref position, radius);
}
///
/// 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.
public static void DrawWireCube(Vector3 position, Vector3 extents)
{
Internal_DrawWireCube(ref position, ref extents);
}
///
/// Draws a wireframe sphere.
///
/// World coordinates of the center of the sphere.
/// Sphere radius.
public static void DrawWireSphere(Vector3 position, float radius)
{
Internal_DrawWireSphere(ref position, radius);
}
///
/// Draws a 3D line.
///
/// Starting point for the line.
/// Ending point for the line.
public static void DrawLine(Vector3 start, Vector3 end)
{
Internal_DrawLine(ref start, ref end);
}
///
/// Draws a wireframe disc.
///
/// Center of the disc.
/// Normal towards which to orient the disc.
/// Radius of the disc.
public static void DrawWireDisc(Vector3 position, Vector3 normal, float radius)
{
Internal_DrawWireDisc(ref position, ref normal, radius);
}
///
/// 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.
public static void DrawWireArc(Vector3 position, Vector3 normal, float radius, Degree startAngle, Degree amountAngle)
{
Internal_DrawWireArc(ref position, ref normal, radius, startAngle.Degrees, amountAngle.Degrees);
}
///
/// Draws a wireframe camera frustum.
///
/// Origin of the frustum (place where the camera origin would normally be).
/// Aspect radio (width/height).
/// Horizontal field of view.
/// Distance from the origin to the near plane.
/// Distance from the origin to the far plane.
public static void DrawFrustum(Vector3 position, float aspect, Degree FOV, float near, float far)
{
Internal_DrawFrustum(ref position, aspect, ref FOV, near, far);
}
///
/// Draws a texture as a camera-facing quad at a specific position.
///
/// World position of the center of the quad the texture will be drawn on.
/// Texture to draw.
/// If true the icon will remain consistent size regardless of distance from camera.
/// If false normal perspective foreshortening effect will occurr.
public static void DrawIcon(Vector3 position, SpriteTexture image, bool fixedScale)
{
Internal_DrawIcon(ref position, image, fixedScale);
}
///
/// 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 size = 16)
{
IntPtr scriptFont = IntPtr.Zero;
if (font != null)
scriptFont = font.GetCachedPtr();
Internal_DrawText(ref position, text, scriptFont, size);
}
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_SetColor(ref Color color);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_GetColor(out Color color);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_SetTransform(ref Matrix4 transform);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_GetTransform(out Matrix4 transform);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawCube(ref Vector3 position, ref Vector3 extents);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawSphere(ref Vector3 position, float radius);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawWireCube(ref Vector3 position, ref Vector3 extents);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawWireSphere(ref Vector3 position, float radius);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawLine(ref Vector3 start, ref Vector3 end);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawWireDisc(ref Vector3 position, ref Vector3 normal, float radius);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawWireArc(ref Vector3 position, ref Vector3 normal, float radius,
float startAngle, float amountAngle);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawFrustum(ref Vector3 position, float aspect, ref Degree FOV, float near, float far);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawIcon(ref Vector3 position, SpriteTexture image, bool fixedScale);
[MethodImpl(MethodImplOptions.InternalCall)]
private static extern void Internal_DrawText(ref Vector3 position, string text, IntPtr font, int size);
}
}