From f4a7739a40c095e0c837d78d00f13a1ef47d3a11 Mon Sep 17 00:00:00 2001 From: Elizabeth Hunt Date: Sat, 25 Nov 2023 17:05:01 -0700 Subject: cube foo init --- src/scene.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/scene.cpp') diff --git a/src/scene.cpp b/src/scene.cpp index e69de29..b52553a 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -0,0 +1,29 @@ +#include "scene.hpp" +#include + +Scene::Scene() { + directional_light = {0, 0, -1}; + viewport_dimension = {2, 3}; + scene_dimension = {SCREEN_WIDTH, SCREEN_HEIGHT}; + + z_plane = int2fx(1); +} + +void Scene::render() { + auto this_ptr = std::make_shared(this); + for (auto renderable : renderables) { + renderable.render(this_ptr); + } +} + +POINT Scene::project_2d(VECTOR vertex) { + POINT pt = {0, 0}; + + if (vertex.z != 0) { + pt.x = fxdiv(z_plane, vertex.z); + pt.y = fxmul(vertex.y, pt.x); + pt.x = fxmul(vertex.x, pt.x); + } + + return pt; +} -- cgit v1.3