Added full implementation of Gizmos class

This commit is contained in:
Kah Wei 2022-11-09 10:22:11 +08:00
parent 41b7cb842c
commit 349f4a875b
3 changed files with 108 additions and 4 deletions

View File

@ -16,8 +16,54 @@ of DigiPen Institute of Technology is prohibited.
#include "SHpch.h"
// Primary Header
#include "Gizmos.hxx"
#include "Convert.hxx"
#include "Tools/SHDebugDraw.h"
// External Dependencies
namespace SHADE
{
/*---------------------------------------------------------------------------------*/
/* Public Properties */
/*---------------------------------------------------------------------------------*/
Color Gizmos::Color::get()
{
return defaultColor;
}
void Gizmos::Color::set(SHADE::Color color)
{
defaultColor = color;
}
/*---------------------------------------------------------------------------------*/
/* Debug Draw Functions */
/*---------------------------------------------------------------------------------*/
void Gizmos::DrawLine(Vector3 from, Vector3 to)
{
DrawLine(from, to, defaultColor);
}
void Gizmos::DrawLine(Vector3 from, Vector3 to, SHADE::Color color)
{
SHDebugDraw::Line(Convert::ToNative(color), Convert::ToNative(from), Convert::ToNative(to));
}
void Gizmos::DrawWireCube(Vector3 center, Vector3 extents)
{
DrawWireCube(center, extents, defaultColor);
}
void Gizmos::DrawWireCube(Vector3 center, Vector3 extents, SHADE::Color color)
{
SHDebugDraw::Cube(Convert::ToNative(color), Convert::ToNative(center), Convert::ToNative(extents));
}
void Gizmos::DrawWireSphere(Vector3 center, float radius)
{
DrawWireSphere(center, radius, defaultColor);
}
void Gizmos::DrawWireSphere(Vector3 center, float radius, SHADE::Color color)
{
SHDebugDraw::Sphere(Convert::ToNative(color), Convert::ToNative(center), radius);
}
}

View File

@ -26,20 +26,72 @@ namespace SHADE
public value class Gizmos abstract sealed
{
public:
/*-----------------------------------------------------------------------------*/
/* Public Properties */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Default colour that will be used for drawing debug primitives if the color
/// parameter is not specified.
/// </summary>
static property Color Color
{
SHADE::Color get();
void set(SHADE::Color color);
}
/*-----------------------------------------------------------------------------*/
/* Debug Draw Functions */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Renders a line between two points in world space.
/// Uses <see cref="Gizmos.Color">Color</see> to render.
/// </summary>
/// <param name="from">First point of the line.</param>
/// <param name="to">Second point of the line.</param>
static void DrawLine(Vector3 from, Vector3 to);
static void DrawLine(Vector3 from, Vector3 to, Color color);
/// <summary>
/// Renders a line between two points in world space.
/// </summary>
/// <param name="from">First point of the line.</param>
/// <param name="to">Second point of the line.</param>
/// <param name="color">Colour of the line.</param>
static void DrawLine(Vector3 from, Vector3 to, SHADE::Color color);
/// <summary>
/// Renders a wireframe cube centered around the position specified in world
/// space.
/// Uses <see cref="Gizmos.Color">Color</see> to render.
/// </summary>
/// <param name="center">Position where the cube wil be centered at.</param>
/// <param name="extents">Size of the rendered cube.</param>
static void DrawWireCube(Vector3 center, Vector3 extents);
static void DrawWireCube(Vector3 center, Vector3 extents, Color color);
/// <summary>
/// Renders a wireframe cube centered around the position specified in world
/// space.
/// </summary>
/// <param name="center">Position where the cube wil be centered at.</param>
/// <param name="extents">Size of the rendered cube.</param>
/// <param name="color">Colour of the cube.</param>
static void DrawWireCube(Vector3 center, Vector3 extents, SHADE::Color color);
/// <summary>
/// Renders a wireframe sphere centered around the position specified in world
/// space.
/// Uses <see cref="Gizmos.Color">Color</see> to render.
/// </summary>
/// <param name="center">Position where the sphere wil be centered at.</param>
/// <param name="radius">Radius of the rendered sphere.</param>
static void DrawWireSphere(Vector3 center, float radius);
static void DrawWireSphere(Vector3 center, float radius, Color color);
/// <summary>
/// Renders a wireframe sphere centered around the position specified in world
/// space.
/// </summary>
/// <param name="center">Position where the sphere wil be centered at.</param>
/// <param name="radius">Radius of the rendered sphere.</param>
/// <param name="color">Colour of the sphere.</param>
static void DrawWireSphere(Vector3 center, float radius, SHADE::Color color);
private:
/*-----------------------------------------------------------------------------*/
/* Data Members */
/*-----------------------------------------------------------------------------*/
Color defaultColor;
static SHADE::Color defaultColor = SHADE::Color::White;
};
}

View File

@ -36,4 +36,10 @@ public class RaccoonShowcase : Script
//Transform.LocalRotation = new Vector3(0.0f, rotation, 0.0f);
//Transform.LocalScale = new Vector3(System.Math.Abs(System.Math.Sin(scale.x)) * originalScale, System.Math.Abs(System.Math.Cos(scale.y)) * originalScale, System.Math.Abs(System.Math.Sin(scale.z)) * originalScale);
}
protected override void onDrawGizmos()
{
Gizmos.DrawLine(new Vector3(-1.0f, 0.0f, 0.0f), new Vector3(1.0f, 0.0f, 0.0f));
Gizmos.DrawLine(new Vector3(-1.0f, 1.0f, 0.0f), new Vector3(1.0f, 1.0f, 0.0f), Color.Red);
}
}