summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
Diffstat (limited to 'inc')
-rw-r--r--inc/model_instance.hpp13
-rw-r--r--inc/palette.hpp7
-rw-r--r--inc/renderable.hpp2
-rw-r--r--inc/scene.hpp10
4 files changed, 20 insertions, 12 deletions
diff --git a/inc/model_instance.hpp b/inc/model_instance.hpp
index 059d3a5..997e9a6 100644
--- a/inc/model_instance.hpp
+++ b/inc/model_instance.hpp
@@ -5,17 +5,18 @@
#include "renderable.hpp"
#include <tonc.h>
-class ModelInstance : Renderable {
+class ModelInstance : public Renderable {
private:
+ std::shared_ptr<Mesh> m_mesh;
FIXED m_scale;
- VECTOR m_rotation; // though technically "FIXED"'s, these are simply s32's
- // where [0, 2pi] -> [0, 0xFFFF] in the x,y,z axes
+ VECTOR m_rot; // though technically "FIXED"'s, these are simply s32's
+ // where [0, 2pi] -> [0, 0xFFFF] in the x,y,z axes
VECTOR m_pos;
- std::shared_ptr<Mesh> m_mesh;
-
public:
- void render(std::shared_ptr<Scene> scene_context);
+ ModelInstance(std::shared_ptr<Mesh> mesh, FIXED scale, VECTOR m_rotation,
+ VECTOR m_pos);
+ virtual void render(std::shared_ptr<Scene> scene_context);
};
#endif // MODEL_INSTANCE_HPP
diff --git a/inc/palette.hpp b/inc/palette.hpp
index 1850835..e45e9cf 100644
--- a/inc/palette.hpp
+++ b/inc/palette.hpp
@@ -10,11 +10,12 @@ constexpr std::uint8_t pal_len = 255;
constexpr std::uint16_t cube_colors[6] = {CLR_WHITE, CLR_YELLOW, CLR_RED,
CLR_ORANGE, CLR_BLUE, CLR_GREEN};
-constexpr void put_palette(std::uint16_t *palette_address) {
+void put_palette(std::uint16_t *palette_address) {
toncset16(palette_address, CLR_BLACK, 1);
- toncset16(palette_address + 1, CLR_WHITE, 1);
+ for (std::uint32_t i = 0; i < 6; ++i)
+ toncset16(palette_address + i + 1, cube_colors[i], 1);
+ // TODO: PALETTE GRADIENT IN ALPHA DIMENSION (BRIGHTNESS)
}
-
}; // namespace palette
#endif // PALETTE_HPP
diff --git a/inc/renderable.hpp b/inc/renderable.hpp
index 7f72e51..83b7596 100644
--- a/inc/renderable.hpp
+++ b/inc/renderable.hpp
@@ -7,7 +7,7 @@ class Scene;
class Renderable {
public:
- virtual void render(std::shared_ptr<Scene> scene_context);
+ virtual void render(std::shared_ptr<Scene> scene_context) = 0;
};
#endif
diff --git a/inc/scene.hpp b/inc/scene.hpp
index 8e286db..05cdac0 100644
--- a/inc/scene.hpp
+++ b/inc/scene.hpp
@@ -2,13 +2,14 @@
#define SCENE_HPP
#include "model_instance.hpp"
+#include "renderable.hpp"
#include "vector.hpp"
#include <cstdint>
#include <tonc.h>
class Scene {
public:
- usu::vector<Renderable> renderables;
+ usu::vector<std::shared_ptr<Renderable>> renderables;
std::tuple<std::uint16_t, std::uint16_t>
viewport_dimension; // <width, height>
std::tuple<std::uint16_t, std::uint16_t> scene_dimension;
@@ -16,8 +17,13 @@ public:
FIXED z_plane;
Scene();
- void render();
POINT project_2d(VECTOR vertex);
+ POINT viewport_to_scene(POINT p);
+ void draw_line(POINT p0, POINT p1, std::uint8_t pal_idx);
+ static inline void render(std::shared_ptr<Scene> scene_ctx) {
+ for (std::shared_ptr<Renderable> renderable : scene_ctx->renderables)
+ renderable->render(scene_ctx);
+ }
};
#endif // SCENE_HPP