From 65a6231f235f6893ba7c259f90e51bd6971e4254 Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Thu, 5 Sep 2024 22:20:27 +0800 Subject: [PATCH] feat: grid uses own material --- thermion_dart/native/src/GridOverlay.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/thermion_dart/native/src/GridOverlay.cpp b/thermion_dart/native/src/GridOverlay.cpp index fa804f47..f7a358fd 100644 --- a/thermion_dart/native/src/GridOverlay.cpp +++ b/thermion_dart/native/src/GridOverlay.cpp @@ -7,7 +7,7 @@ #include #include -#include "material/gizmo.h" +#include "material/grid.h" #include "Log.hpp" namespace thermion_filament { @@ -76,13 +76,20 @@ GridOverlay::GridOverlay(Engine &engine) : _engine(engine) )); _gridEntity = entityManager.create(); - // _materialInstance = _material->createInstance(); - // _materialInstance->setParameter("color", math::float3{0.5f, 0.5f, 0.5f}); // Gray color for the grid + _material = Material::Builder() + .package(GRID_PACKAGE, GRID_GRID_SIZE) + .build(engine); + + _materialInstance = _material->createInstance(); + + _materialInstance->setParameter("maxDistance", 50.0f); // Adjust as needed + _materialInstance->setParameter("color", math::float3{0.5f, 0.5f, 0.5f}); // Gray color for the grid + RenderableManager::Builder(1) .boundingBox({{-gridSize * gridSpacing / 2, 0, -gridSize * gridSpacing / 2}, {gridSize * gridSpacing / 2, 0, gridSize * gridSpacing / 2}}) - // .material(0, _materialInstance) + .material(0, _materialInstance) .geometry(0, RenderableManager::PrimitiveType::LINES, vb, ib, 0, vertexCount) .priority(6) .layerMask(0xFF, 4)