feat: rescale gizmo based on distance from camera

This commit is contained in:
Nick Fisher
2024-08-27 16:54:40 +08:00
parent 0e3b014c2c
commit 12b61e8767

View File

@@ -20,6 +20,7 @@
#include "material/gizmo.h" #include "material/gizmo.h"
#include "Aabb2.h" #include "Aabb2.h"
#include "ThermionDartApi.h"
namespace thermion_filament { namespace thermion_filament {
@@ -31,8 +32,10 @@ class Gizmo {
enum Axis { X, Y, Z}; enum Axis { X, Y, Z};
public: public:
Gizmo(Engine& engine); Gizmo(Engine& engine, View *view, Scene *scene);
void updateTransform(Camera& camera, const Viewport& vp); ~Gizmo();
void updateTransform();
void destroy(); void destroy();
Entity x() { Entity x() {
return _entities[0]; return _entities[0];
@@ -46,24 +49,37 @@ class Gizmo {
Entity center() { Entity center() {
return _entities[3]; return _entities[3];
}; };
View* view() {
return _view;
}
bool isActive() {
return _isActive;
}
void highlight(Entity entity); void highlight(Entity entity);
void unhighlight(); void unhighlight();
void pick(uint32_t x, uint32_t y, void (*callback)(EntityId entityId, int x, int y));
private: private:
Engine &_engine; Engine &_engine;
utils::Entity _entities[4]; View *_view;
Scene *_scene;
Camera *_camera;
utils::Entity _entities[4] = { utils::Entity(), utils::Entity(), utils::Entity(), utils::Entity() };
Material* _material; Material* _material;
MaterialInstance* _materialInstances[4]; MaterialInstance* _materialInstances[4];
math::float3 inactiveColors[3] { math::float4 inactiveColors[3] {
math::float3 { 0.75f, 0.0f, 0.0f }, math::float4 { 0.75f, 0.0f, 0.0f, 1.0f },
math::float3 { 0.0f, 0.75f, 0.0f }, math::float4 { 0.0f, 0.75f, 0.0f, 1.0f },
math::float3 { 0.0f, 0.0f, 0.75f }, math::float4 { 0.0f, 0.0f, 0.75f, 1.0f },
}; };
math::float3 activeColors[3] { math::float4 activeColors[3] {
math::float3 { 1.0f, 0.0f, 0.0f }, math::float4 { 1.0f, 0.0f, 0.0f, 1.0f },
math::float3 { 0.0f, 1.0f, 0.0f }, math::float4 { 0.0f, 1.0f, 0.0f, 1.0f },
math::float3 { 0.0f, 0.0f, 1.0f }, math::float4 { 0.0f, 0.0f, 1.0f, 1.0f },
}; };
bool _isActive = true;
}; };
} }