#include #include "entities/camera.hpp" #include "plate.hpp" #include "rendering/gl_renderer.hpp" namespace Nimbin { void Plate::tick(double dt) { hover_phase += dt * 2.0; pos.y = base_pos.y + SDL_sin(hover_phase) * 0.05; if (pulse > 0.0) { pulse -= dt * 1.5; if (pulse < 0.0) pulse = 0.0; } was_active = active; } void Plate::draw(GlRenderer& gl, const Camera& cam, const Light& light) const { const float half_x = static_cast(shape.half_extents.x); const float half_y = static_cast(shape.half_extents.y); const float half_z = static_cast(shape.half_extents.z); Mat4 view = buildViewMat4(cam); Mat4 proj = gl.get_Projection(); Mat4 model = buildModelMat4(pos, yaw); Mat4 mvp = Mat4::mul(proj, Mat4::mul(view, model)); float boost = static_cast(active ? 1.0 : 0.6) + static_cast(pulse) * 0.4f; if (boost > 1.0f) boost = 1.0f; const float color_r = fill_color.r * boost; const float color_g = fill_color.g * boost; const float color_b = fill_color.b * boost; gl.set_Wireframe(false); gl.set_MVP (model, mvp); gl.set_NormalMat(model); gl.set_Light (light); gl.set_Color (color_r, color_g, color_b); gl.set_Emissive (color_r, color_g, color_b, boost); gl.draw_Box (half_x, half_y, half_z); gl.set_Emissive (0.0f, 0.0f, 0.0f, 0.0f); gl.set_Wireframe(false); gl.set_MVP (model, mvp); gl.set_Color (wire_color.r, wire_color.g, wire_color.b); gl.draw_Box (half_x, half_y, half_z); } } // namespace Nimbin