Files
cuber/scenes/cornell_box.hpp
portersky 6bfde6c6fb feat: add Cornell Box scene with orbit camera
- gfx::pipeline gains bind_vec3/bind_float for passing arbitrary
  uniforms to shaders (used for light position/color)
- scene base gains on_mouse_drag virtual hook; cuber.cpp polls
  left-mouse delta each frame and forwards it to the active scene
- cornell_box scene: 5-wall room (red/green/white), two pre-rotated
  white boxes with proportions from the original paper, an unlit
  ceiling light panel, and a point-light Lambert shader
- left-click drag orbits the camera around the scene origin;
  pitch is clamped to ±80° to prevent gimbal flip
- key 3 / --scene cornell_box selects the scene
2026-05-11 16:35:26 +02:00

33 lines
788 B
C++

#pragma once
#include "glm/glm.hpp"
#include "cbt/scene.hpp"
#include "cbt/gfx.hpp"
namespace cbt::scenes {
class cornell_box final : public scene {
public:
auto init() -> bool override;
auto update(float delta_time) -> void override;
auto render(int width, int height) -> void override;
auto on_mouse_drag(double dx, double dy) -> void override;
private:
gfx::pipeline m_scene_pipeline;
gfx::pipeline m_light_pipeline;
gfx::pipeline m_post_pipeline;
gfx::render_target m_rt{0, 0};
float m_yaw = 0.0f; // degrees, horizontal orbit
float m_pitch = 0.0f; // degrees, vertical orbit
float m_radius = 4.0f;
auto build_scene_pipeline() -> bool;
auto build_light_pipeline() -> bool;
auto build_post_pipeline() -> bool;
};
}