From fc4842ed6dc0ca78468d300e5464c9003373edd4 Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Tue, 17 Dec 2024 14:07:29 +0800 Subject: [PATCH] chore: remove colors from Gizmo --- thermion_dart/native/include/Globals.hpp | 11 +++++++++++ thermion_dart/native/src/scene/Gizmo.cpp | 18 +++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 thermion_dart/native/include/Globals.hpp diff --git a/thermion_dart/native/include/Globals.hpp b/thermion_dart/native/include/Globals.hpp new file mode 100644 index 00000000..04835024 --- /dev/null +++ b/thermion_dart/native/include/Globals.hpp @@ -0,0 +1,11 @@ +#include "math.h" + +namespace thermion { + using namespace filament; + constexpr math::float3 AXIS_COLORS[3] { + math::float3{1.0f, 0.0f, 0.0f}, // X + math::float3{0.0f, 1.0f, 0.0f}, // Y + math::float3{0.0f, 0.0f, 1.0f}, // Z + }; + +} \ No newline at end of file diff --git a/thermion_dart/native/src/scene/Gizmo.cpp b/thermion_dart/native/src/scene/Gizmo.cpp index d552fa34..9a690a6f 100644 --- a/thermion_dart/native/src/scene/Gizmo.cpp +++ b/thermion_dart/native/src/scene/Gizmo.cpp @@ -7,13 +7,12 @@ #include +#include "Globals.hpp" +#include "Log.hpp" +#include "material/gizmo.h" #include "scene/Gizmo.hpp" #include "scene/SceneManager.hpp" -#include "material/gizmo.h" - -#include "Log.hpp" - namespace thermion { @@ -82,7 +81,8 @@ namespace thermion auto instance = _source->createInstance(&materialInstance, 1); TRACE("Created Gizmo axis glTF instance with head entity %d", instance->getEntity()); - materialInstance->setParameter("baseColorFactor", inactiveColors[axis]); + auto color = filament::math::float4(AXIS_COLORS[axis], 0.5f); + materialInstance->setParameter("baseColorFactor", color); materialInstance->setParameter("scale", _scale); auto hitTestEntity = instance->findEntityByName("HitTest"); @@ -179,8 +179,8 @@ namespace thermion if (renderableInstance.isValid()) { auto *materialInstance = rm.getMaterialInstanceAt(renderableInstance, 0); - math::float4 baseColor = activeColors[axis]; - materialInstance->setParameter("baseColorFactor", baseColor); + auto color = filament::math::float4(AXIS_COLORS[axis], 1.0f); + materialInstance->setParameter("baseColorFactor", color); } } } @@ -202,8 +202,8 @@ namespace thermion if (renderableInstance.isValid()) { auto *materialInstance = rm.getMaterialInstanceAt(renderableInstance, 0); - math::float4 baseColor = inactiveColors[axis]; - materialInstance->setParameter("baseColorFactor", baseColor); + auto color = filament::math::float4(AXIS_COLORS[axis], 0.5f); + materialInstance->setParameter("baseColorFactor", color); } } }