diff --git a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHDebugDrawSystem.cpp b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHDebugDrawSystem.cpp index 883e4894..daa6a23d 100644 --- a/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHDebugDrawSystem.cpp +++ b/SHADE_Engine/src/Graphics/MiddleEnd/Interface/SHDebugDrawSystem.cpp @@ -323,7 +323,7 @@ namespace SHADE static const SHMeshData SPHERE = SHPrimitiveGenerator::Sphere(); for (const auto& idx : SPHERE.Indices) { - spherePoints.emplace_back(SPHERE.VertexPositions[idx]); + spherePoints.emplace_back(SPHERE.VertexPositions[idx] * radius); } } drawLineSet(storage, color, spherePoints.begin(), spherePoints.end()); diff --git a/SHADE_Managed/src/Components/Component.hxx b/SHADE_Managed/src/Components/Component.hxx index 5ffa3952..e52ab3a7 100644 --- a/SHADE_Managed/src/Components/Component.hxx +++ b/SHADE_Managed/src/Components/Component.hxx @@ -97,7 +97,7 @@ namespace SHADE /// /// Removes all Scripts of the specified type from this GameObject. /// - /// Type of PLushieScripts to remove. + /// Type of Scripts to remove. generic where T : ref class, Script void RemoveScript(); diff --git a/SHADE_Managed/src/Editor/Editor.cxx b/SHADE_Managed/src/Editor/Editor.cxx index 2afe9697..54200c1e 100644 --- a/SHADE_Managed/src/Editor/Editor.cxx +++ b/SHADE_Managed/src/Editor/Editor.cxx @@ -414,19 +414,10 @@ namespace SHADE generic Attribute Editor::hasAttribute(System::Reflection::FieldInfo^ field) { - array^ attributes = field->GetCustomAttributes(true); - for each (System::Object^ attrib in attributes) + array^ attributes = field->GetCustomAttributes(Attribute::typeid, false); + if (attributes->Length > 0) { - try - { - Attribute attribute = safe_cast(attrib); - if (attribute != nullptr) - return attribute; - } - catch (System::InvalidCastException^) - { - continue; - } + return safe_cast(attributes[0]); } // Failed to find return Attribute{}; diff --git a/SHADE_Managed/src/Editor/Editor.hxx b/SHADE_Managed/src/Editor/Editor.hxx index 6b59589a..109842b5 100644 --- a/SHADE_Managed/src/Editor/Editor.hxx +++ b/SHADE_Managed/src/Editor/Editor.hxx @@ -39,10 +39,10 @@ namespace SHADE /// The Entity to render the Scripts of. static void RenderScriptsInInspector(Entity entity); /// - /// Renders a dropdown button that allows for the addition of PlushieScripts - /// onto the specified Entity. + /// Renders a dropdown button that allows for the addition of Scripts onto the + /// specified Entity. /// - /// The Entity to add PlushieScripts to. + /// The Entity to add Scripts to. static void RenderScriptAddButton(Entity entity); /*-----------------------------------------------------------------------------*/ diff --git a/SHADE_Managed/src/Engine/EngineInterface.hxx b/SHADE_Managed/src/Engine/EngineInterface.hxx index 4fd8f7b3..37ded4eb 100644 --- a/SHADE_Managed/src/Engine/EngineInterface.hxx +++ b/SHADE_Managed/src/Engine/EngineInterface.hxx @@ -20,7 +20,7 @@ namespace SHADE { /// /// Static class that contains the functions for interfacing with the core - /// PlushieEngine written in C++ for managing the lifecycle of managed code. + /// SHADE Engine written in C++ for managing the lifecycle of managed code. /// private ref class EngineInterface abstract sealed { diff --git a/SHADE_Managed/src/Engine/GameObject.hxx b/SHADE_Managed/src/Engine/GameObject.hxx index 030b917c..02a0ed4f 100644 --- a/SHADE_Managed/src/Engine/GameObject.hxx +++ b/SHADE_Managed/src/Engine/GameObject.hxx @@ -210,7 +210,7 @@ namespace SHADE /// /// Removes all Scripts of the specified type from this GameObject. /// - /// Type of PLushieScripts to remove. + /// Type of Scripts to remove. generic where T : ref class, Script void RemoveScript(); diff --git a/SHADE_Managed/src/Math/Vector2.cxx b/SHADE_Managed/src/Math/Vector2.cxx index 42080d60..8242a11c 100644 --- a/SHADE_Managed/src/Math/Vector2.cxx +++ b/SHADE_Managed/src/Math/Vector2.cxx @@ -276,4 +276,4 @@ namespace SHADE { return !(lhs == rhs); } -} // namespace PlushieAPI::Mathematics \ No newline at end of file +} diff --git a/SHADE_Managed/src/Math/Vector3.cxx b/SHADE_Managed/src/Math/Vector3.cxx index 83adbb38..f2286aa7 100644 --- a/SHADE_Managed/src/Math/Vector3.cxx +++ b/SHADE_Managed/src/Math/Vector3.cxx @@ -294,4 +294,4 @@ namespace SHADE { return Vector3(vec); } -} // namespace PlushieAPI::Mathematics \ No newline at end of file +} diff --git a/SHADE_Managed/src/Math/Vector3.hxx b/SHADE_Managed/src/Math/Vector3.hxx index 4cdf653e..189f2930 100644 --- a/SHADE_Managed/src/Math/Vector3.hxx +++ b/SHADE_Managed/src/Math/Vector3.hxx @@ -439,4 +439,5 @@ namespace SHADE /// Vector2 to convert from. static explicit operator Vector3(Vector2 vec); }; -} // namespace PlushieAPI::Mathematics +} + diff --git a/SHADE_Managed/src/Scripts/Script.cxx b/SHADE_Managed/src/Scripts/Script.cxx index bd6d7bef..9d6cadb8 100644 --- a/SHADE_Managed/src/Scripts/Script.cxx +++ b/SHADE_Managed/src/Scripts/Script.cxx @@ -3,8 +3,7 @@ \author Tng Kah Wei, kahwei.tng, 390009620 \par email: kahwei.tng\@digipen.edu \date Oct 28, 2021 -\brief Contains the definition of the functions for the PlushieScript managed - class. +\brief Contains the definition of the functions for the Script managed class. Note: This file is written in C++17/CLI. diff --git a/SHADE_Managed/src/Scripts/ScriptStore.hxx b/SHADE_Managed/src/Scripts/ScriptStore.hxx index c151392f..23440f3d 100644 --- a/SHADE_Managed/src/Scripts/ScriptStore.hxx +++ b/SHADE_Managed/src/Scripts/ScriptStore.hxx @@ -36,7 +36,7 @@ namespace SHADE /// /// /// Type of script to add. - /// This needs to be a default constructable PlushieScript. + /// This needs to be a default constructable Script. /// /// The entity to add a script to. /// Reference to the script added. diff --git a/SHADE_Managed/src/Utility/DisposableAssemblyLoadContext.cxx b/SHADE_Managed/src/Utility/DisposableAssemblyLoadContext.cxx index ebf2e987..e19c4d06 100644 --- a/SHADE_Managed/src/Utility/DisposableAssemblyLoadContext.cxx +++ b/SHADE_Managed/src/Utility/DisposableAssemblyLoadContext.cxx @@ -33,4 +33,4 @@ namespace SHADE { return nullptr; } -} // namespace PlushieAPI \ No newline at end of file +} diff --git a/SHADE_Managed/src/Utility/DisposableAssemblyLoadContext.hxx b/SHADE_Managed/src/Utility/DisposableAssemblyLoadContext.hxx index 433dd85e..14d612b3 100644 --- a/SHADE_Managed/src/Utility/DisposableAssemblyLoadContext.hxx +++ b/SHADE_Managed/src/Utility/DisposableAssemblyLoadContext.hxx @@ -36,4 +36,4 @@ namespace SHADE /*-----------------------------------------------------------------------------*/ System::Reflection::Assembly^ Load(System::Reflection::AssemblyName^ assemblyName) override; }; -} // namespace PlushieAPI \ No newline at end of file +} diff --git a/SHADE_Managed/src/Utility/Gizmos.cxx b/SHADE_Managed/src/Utility/Gizmos.cxx new file mode 100644 index 00000000..21636a5d --- /dev/null +++ b/SHADE_Managed/src/Utility/Gizmos.cxx @@ -0,0 +1,69 @@ +/************************************************************************************//*! +\file Gizmos.cxx +\author Tng Kah Wei, kahwei.tng, 390009620 +\par email: kahwei.tng\@digipen.edu +\date Nov 8, 2022 +\brief Contains the definition of the functions for the Convert managed static + class. + + Note: This file is written in C++17/CLI. + +Copyright (C) 2022 DigiPen Institute of Technology. +Reproduction or disclosure of this file or its contents without the prior written consent +of DigiPen Institute of Technology is prohibited. +*//*************************************************************************************/ +// Precompiled Headers +#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); + } +} diff --git a/SHADE_Managed/src/Utility/Gizmos.hxx b/SHADE_Managed/src/Utility/Gizmos.hxx new file mode 100644 index 00000000..1878d867 --- /dev/null +++ b/SHADE_Managed/src/Utility/Gizmos.hxx @@ -0,0 +1,97 @@ +/************************************************************************************//*! +\file Gizmos.hxx +\author Tng Kah Wei, kahwei.tng, 390009620 +\par email: kahwei.tng\@digipen.edu +\date Nov 8, 2022 +\brief Contains the definition of the Gizmos static class and the + declaration of its functions. + + Note: This file is written in C++17/CLI. + +Copyright (C) 2022 DigiPen Institute of Technology. +Reproduction or disclosure of this file or its contents without the prior written consent +of DigiPen Institute of Technology is prohibited. +*//*************************************************************************************/ +#pragma once + +// Project Includes +#include "Math/Vector3.hxx" +#include "Graphics/Color.hxx" + +namespace SHADE +{ + /// + /// Provides functions for implementing debug drawing. + /// + public value class Gizmos abstract sealed + { + public: + /*-----------------------------------------------------------------------------*/ + /* Public Properties */ + /*-----------------------------------------------------------------------------*/ + /// + /// Default colour that will be used for drawing debug primitives if the color + /// parameter is not specified. + /// + static property Color Color + { + SHADE::Color get(); + void set(SHADE::Color color); + } + /*-----------------------------------------------------------------------------*/ + /* Debug Draw Functions */ + /*-----------------------------------------------------------------------------*/ + /// + /// Renders a line between two points in world space. + /// Uses Color to render. + /// + /// First point of the line. + /// Second point of the line. + static void DrawLine(Vector3 from, Vector3 to); + /// + /// Renders a line between two points in world space. + /// + /// First point of the line. + /// Second point of the line. + /// Colour of the line. + static void DrawLine(Vector3 from, Vector3 to, SHADE::Color color); + /// + /// Renders a wireframe cube centered around the position specified in world + /// space. + /// Uses Color to render. + /// + /// Position where the cube wil be centered at. + /// Size of the rendered cube. + static void DrawWireCube(Vector3 center, Vector3 extents); + /// + /// Renders a wireframe cube centered around the position specified in world + /// space. + /// + /// Position where the cube wil be centered at. + /// Size of the rendered cube. + /// Colour of the cube. + static void DrawWireCube(Vector3 center, Vector3 extents, SHADE::Color color); + /// + /// Renders a wireframe sphere centered around the position specified in world + /// space. + /// Uses Color to render. + /// + /// Position where the sphere wil be centered at. + /// Radius of the rendered sphere. + static void DrawWireSphere(Vector3 center, float radius); + /// + /// Renders a wireframe sphere centered around the position specified in world + /// space. + /// + /// Position where the sphere wil be centered at. + /// Radius of the rendered sphere. + /// Colour of the sphere. + static void DrawWireSphere(Vector3 center, float radius, SHADE::Color color); + + private: + /*-----------------------------------------------------------------------------*/ + /* Data Members */ + /*-----------------------------------------------------------------------------*/ + static SHADE::Color defaultColor = SHADE::Color::White; + }; +} diff --git a/TempScriptsFolder/RaccoonShowcase.cs b/TempScriptsFolder/RaccoonShowcase.cs index da0b89d2..4583a699 100644 --- a/TempScriptsFolder/RaccoonShowcase.cs +++ b/TempScriptsFolder/RaccoonShowcase.cs @@ -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); + } } \ No newline at end of file