sdl_runtime_compiler git · main
SDL3 game for running and compiling code at runtime
C++ 72.3% C 26.2%git clone https://git.christianimmanuel.de/sdl-graphics/sdl_runtime_compiler.gitwget https://git.christianimmanuel.de/sdl-graphics/sdl_runtime_compiler/archive/sdl_runtime_compiler.tar.gzsrc/entities/solid_box.hpp raw
#pragma once
#include "entities/camera.hpp"
#include "entities/game_object.hpp"
#include "rendering/gl_renderer.hpp"
#include "utils/light.hpp"
namespace
Nimbin
{
struct SolidBox : public GameObject
{
SDL_FColor fill_color { 0.55f, 0.55f, 0.75f, 1.0f };
SDL_FColor wire_color { 0.75f, 0.75f, 0.95f, 1.0f };
SolidBox(Vec3 centre,
Vec3 half_extents,
SDL_FColor fill = {0.55f, 0.55f, 0.75f, 1.0f},
SDL_FColor wire = {0.75f, 0.75f, 0.95f, 1.0f},
bool interactable_ = false)
: GameObject(
centre,
ObjectType::Prop,
CollisionShape{ half_extents },
RigidBody{ PhysicsMode::Static },
false, interactable_, true)
, fill_color(fill) , wire_color(wire)
{}
void draw(GlRenderer& gl, const Camera& cam, const Light& light) const override
{
const float hx = static_cast<float>(shape.half_extents.x);
const float hy = static_cast<float>(shape.half_extents.y);
const float hz = static_cast<float>(shape.half_extents.z);
Mat4 view = buildViewMat4 (cam);
Mat4 model = buildModelMat4 (pos, yaw);
Mat4 proj = gl.get_Projection();
Mat4 mvp = Mat4::mul (proj, Mat4::mul(view, model));
gl.set_Wireframe(false);
gl.set_MVP (model, mvp);
gl.set_NormalMat(model);
gl.set_Light (light);
gl.set_Color (fill_color.r, fill_color.g, fill_color.b);
gl.draw_Box (hx, hy, hz);
}
};
} // namespace Nimbin