From db41d43345ea73cf7c1bbb29448e52ffb822e3e0 Mon Sep 17 00:00:00 2001 From: vimene Date: Tue, 13 Jan 2026 02:04:52 +0100 Subject: added textures for the hardware renderer - removed "using" directive in .hpp - reverse order of arguments for quaternion rotation, i.e. q.rot(v) instead of v.rot(q), where q is a quaterinon and v a vector - pass the inverse of the view matrix to render_and_present_frame, to allow light calculation in shaders (we used to just pass the matrix of the quaternion of the transformation, i.e. discard scaling and translations) - added another mesh and texture (viking_room) for testing purposes - added transparent background option - added Quaternion::look_towards(), which is the equivalent of Matrix4::look_at() but only for rotations - various improvement to .obj parsing - load texture coordinates from .obj file - merged duplicate vertices in Mesh::linearize_indices() --- src/fb/chfb.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/fb/chfb.cpp') diff --git a/src/fb/chfb.cpp b/src/fb/chfb.cpp index 9f293ed..7341015 100644 --- a/src/fb/chfb.cpp +++ b/src/fb/chfb.cpp @@ -8,6 +8,7 @@ using namespace engine::fb; using + engine::math::Vector2, engine::math::Vector3, engine::o3d::VertexData, engine::o3d::Camera; @@ -31,10 +32,8 @@ void CharacterFrameBuffer::clear() { char brightness_chars[] = " `.-':_,^=;><+!rc*/z?sLTv)J7(|Fi{C}fI31tlu[neoZ5Yxjya]2ESwqkP6h9d4VpOGbUAKXHm8RD#$Bg0MNWQ%&@"; extern Camera* camera; -void CharacterFrameBuffer::draw_point(int x, int y, const Vector3& loc, const VertexData& vd, const Vector3& normal) { - (void) loc; - (void) vd; - auto v = normal.rot(camera->transform.rot.conjugate()); +void CharacterFrameBuffer::draw_point(int x, int y, const Vector3& /* loc */, const Vector3& normal, const Vector2& /* uv */, const VertexData& /* vd */) { + auto v = camera->transform.rot.conjugate().rot(normal).normalize(); float light = .1f + (v.z < 0.f ? 0.f : v.z) * .9f; std::uint32_t c = (int) (light * static_cast(sizeof(brightness_chars) - 1)); chars_vector[x + y * w] = brightness_chars[c]; -- cgit v1.2.3