diff --git a/assets/scene.blend b/assets/scene.blend index cd4761b..1364395 100644 --- a/assets/scene.blend +++ b/assets/scene.blend @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:41ba57a844b0436beed7f41a2ec804b9fa8b58e3809e6fba5181c5c42b711478 -size 16405769 +oid sha256:bb00bcd432a1380d925bec21896b8fc5d03f5cf828c7081e56e7813383b7bb70 +size 15915245 diff --git a/assets/scene.glb b/assets/scene.glb index fe23400..0e3e0c9 100644 --- a/assets/scene.glb +++ b/assets/scene.glb @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1e2ae295c30e9008808b575fd251d3fc2cdbd882e5d7e9b9bba84d087ea1712b -size 5679556 +oid sha256:c75a3989a2bc1edcead17eb35e26d800b66f43d53f21a9cccde5ae7830c040ef +size 1876068 diff --git a/src/graphics/mesh/arrays.cpp b/src/graphics/mesh/arrays.cpp index f937645..87a6d87 100644 --- a/src/graphics/mesh/arrays.cpp +++ b/src/graphics/mesh/arrays.cpp @@ -5,6 +5,7 @@ #include #include "../shader.hpp" +#include "../../util/streams.hpp" #include "arrays.hpp" #include "font.hpp" @@ -41,3 +42,17 @@ void Arrays::vertex_attrib_pointers() glEnableVertexAttribArray(6); } +std::ostream& Arrays::operator<<(std::ostream& os, const Vertex& v) +{ + os << "Vertex{"; + os << "texid=" << v.texid << ", "; + os << "texpos=" << v.texpos << ", "; + os << "pos=" << v.pos << ", "; + os << "normal=" << v.normal << ", "; + os << "colour=" << v.colour << ", "; + os << "material=" << v.material << ", "; + os << "transform_id=" << v.transform_id; + os << "}"; + return os; +} + diff --git a/src/graphics/mesh/arrays.hpp b/src/graphics/mesh/arrays.hpp index a0ca692..8377346 100644 --- a/src/graphics/mesh/arrays.hpp +++ b/src/graphics/mesh/arrays.hpp @@ -2,6 +2,7 @@ #pragma once #include +#include namespace Sim::Graphics::Arrays { @@ -18,6 +19,8 @@ struct Vertex constexpr bool operator==(const Vertex&) const = default; + friend std::ostream& operator<<(std::ostream& os, const Vertex& v); + } __attribute__((packed)); void vertex_attrib_pointers(); diff --git a/src/graphics/mesh/mesh.cpp b/src/graphics/mesh/mesh.cpp index 1e74d49..f532171 100644 --- a/src/graphics/mesh/mesh.cpp +++ b/src/graphics/mesh/mesh.cpp @@ -5,6 +5,7 @@ #include "../camera.hpp" #include "../input/focus.hpp" #include "../../util/math.hpp" +#include "../../util/streams.hpp" #include @@ -328,3 +329,33 @@ Mesh Mesh::to_lines() const return m; } +std::ostream& Sim::Graphics::operator<<(std::ostream& os, const Mesh& m) +{ + os << "Mesh(\n"; + os << " Vertices(\n"; + + for(int i = 0; i < m.vertices.size(); i++) + { + os << " " << m.vertices[i] << "\n"; + } + + os << " )\n"; + + for(int i = 0; i < m.indices.size(); i += 3) + { + os << " " << m.indices[i] << " " << m.indices[i + 1] << " " << m.indices[i + 2] << "\n"; + } + + os << " Transforms(\n"; + + for(int i = 0; i < m.transforms.size(); i++) + { + os << " " << m.transforms[i] << "\n"; + } + + os << " )\n"; + os << ")\n"; + + return os; +} + diff --git a/src/graphics/mesh/mesh.hpp b/src/graphics/mesh/mesh.hpp index c8ba105..1cd7081 100644 --- a/src/graphics/mesh/mesh.hpp +++ b/src/graphics/mesh/mesh.hpp @@ -45,6 +45,8 @@ struct Mesh ss << header << item; load_text(ss.str().c_str(), size); } + + friend std::ostream& operator<<(std::ostream& os, const Mesh& m); }; }; diff --git a/src/graphics/window.cpp b/src/graphics/window.cpp index 2074112..d4ee3f8 100644 --- a/src/graphics/window.cpp +++ b/src/graphics/window.cpp @@ -94,7 +94,7 @@ void remesh_static() gm_scene.set(mesh, GL_STATIC_DRAW, false); g_scene_transforms = std::move(mesh.transforms); - std::cout << "Remeshed static\n"; + std::cout << "Total triangles: " << mesh.indices.size() / 3 << "\n"; } void render_shadow_map() @@ -177,6 +177,8 @@ void Window::create() g_scene.add(model.load("cb")); g_scene.add(model.load("hw")); g_scene.bake_transforms(); + + std::cout << "Static scene triangles: " << g_scene.indices.size() / 3 << "\n"; Camera::init(model); diff --git a/src/util/streams.hpp b/src/util/streams.hpp index 9b51e71..8e8ff7c 100644 --- a/src/util/streams.hpp +++ b/src/util/streams.hpp @@ -5,6 +5,39 @@ #include #include +namespace glm +{ + +template +std::ostream& operator<<(std::ostream& o, const glm::vec& v) +{ + o << "{"; + + for(int i = 0; i < N - 1; i++) + { + o << v[i] << ", "; + } + + o << v[N - 1] << "}"; + return o; +} + +template +std::ostream& operator<<(std::ostream& o, const glm::mat& m) +{ + o << "{"; + + for(int i = 0; i < N - 1; i++) + { + o << " " << m[i] << ", "; + } + + o << " " << m[N - 1] << "}"; + return o; +} + +}; + namespace Sim::Util::Streams { @@ -23,31 +56,3 @@ std::ostream& show_units(std::ostream& o, double v); }; -template -std::ostream& operator<<(std::ostream& o, const glm::vec& v) -{ - o << "{"; - - for(int i = 0; i < N - 1; i++) - { - o << v[i] << ", "; - } - - o << v[N - 1] << "}"; - return o; -} - -template -std::ostream& operator<<(std::ostream& o, const glm::mat& m) -{ - o << "{\n"; - - for(int i = 0; i < N - 1; i++) - { - o << " " << m[i] << ",\n"; - } - - o << " " << m[N - 1] << "}"; - return o; -} -