From ac982a2b21798a8be6caaf3feebe24b1dfb8f1a0 Mon Sep 17 00:00:00 2001 From: john Date: Sun, 18 Oct 2026 12:57:14 -0400 Subject: [PATCH] last one --- Character.cpp | 9 ++++++++- Character.h | 3 +++ Engine.cpp | 5 ++++- assets/bluetexture.png | Bin 0 -> 70 bytes 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 assets/bluetexture.png diff --git a/Character.cpp b/Character.cpp index 71e0163..8370de7 100644 --- a/Character.cpp +++ b/Character.cpp @@ -48,6 +48,11 @@ Character::Character() { void Character::Render(Shader& shader) { if (!body || !body->rig || !body->animator) return; + if (skin) { + glActiveTexture(GL_TEXTURE1); + glBindTexture(GL_TEXTURE_2D, skin->ID); + shader.SetInt("tex", 1); + } if (body->animator->m_CurrentAnimation == nullptr) { for (int i = 0; i < 100; i++) shader.SetMat4(("finalBonesMatrices[" + std::to_string(i) + "]").c_str(), glm::mat4(1.0f)); @@ -58,5 +63,7 @@ void Character::Render(Shader& shader) { for (int i = 0; i < transforms.size(); i++) shader.SetMat4(("finalBonesMatrices[" + std::to_string(i) + "]").c_str(), transforms[i]); } - body->rig->Render(shader, body->t.GetTranslationMatrix() * body->t.GetRotationMatrix()); + // body->t's scale is the hitbox only; the rig is drawn at visualScale so it fills that hitbox + body->rig->Render(shader, body->t.GetTranslationMatrix() * body->t.GetRotationMatrix() + * glm::scale(glm::mat4(1.0f), glm::vec3(visualScale))); } \ No newline at end of file diff --git a/Character.h b/Character.h index f5ce6ff..736df60 100644 --- a/Character.h +++ b/Character.h @@ -8,6 +8,7 @@ #include "Rig.h" #include "Object.h" #include "Animator.h" +#include "texture.h" class CharacterBody; class BodyComponent; @@ -116,6 +117,8 @@ class Character : public Object, public Renderable { public: CharacterMind* mind = nullptr; CharacterBody* body = nullptr; + float visualScale = 1.4f; // rig is ~1.8 tall natively; hitbox is 2.5 + Texture* skin = nullptr; // optional: bound while drawing the rig Character(); void Render(Shader& shader) override; diff --git a/Engine.cpp b/Engine.cpp index d367485..52b6e90 100644 --- a/Engine.cpp +++ b/Engine.cpp @@ -130,6 +130,7 @@ void Engine::Initiate() Texture* blanktex = new Texture("assets/blanktexture.png"); Texture* magic = new Texture("assets/itsmagicbitch.jpg"); Texture* snowflake = new Texture("assets/snowflake.png"); + Texture* bluetex = new Texture("assets/bluetexture.png"); Texture* shockwavetex = new Texture("assets/shockwave.png"); Texture* leontex = new Texture("assets/revolvertex.png"); @@ -145,6 +146,7 @@ void Engine::Initiate() // ------------------------------------------------------------------------ Character* testcharacter = new Character(); testcharacter->name = "character"; + testcharacter->skin = bluetex; testcharacter->castshadow = true; testcharacter->body->t.ScaleBy({ 0.7f, 2.5f, 0.7f }); testcharacter->body->t.TranslateTo({ 0.0f, 10.0f, 0.0f }); @@ -198,6 +200,7 @@ void Engine::Initiate() auto SpawnRemote = [&]() -> Character* { Character* c = new Character(); c->name = "remote"; + c->skin = bluetex; c->castshadow = true; c->body->t.ScaleBy({ 0.7f, 2.5f, 0.7f }); c->body->SetRig(testrig); @@ -468,7 +471,7 @@ void Engine::Initiate() // Cubes (E). Whoever hosts (or an offline player) owns and simulates them and decides when they // despawn; LAN clients only ask the host for one and draw the poses it streams back. - const float cubeCooldownTime = 0.5f; // seconds between cubes per player + const float cubeCooldownTime = 0.1f; // seconds between cubes per player const double cubeLifetime = 30.0; // seconds before a cube despawns float cubeCooldown = 0.0f; // Cubes also rain from the sky on their own (host / offline only; clients see them via the stream) diff --git a/assets/bluetexture.png b/assets/bluetexture.png new file mode 100644 index 0000000000000000000000000000000000000000..dbe3cfe2704436b41328e5d2ab03b2079d341248 GIT binary patch literal 70 zcmeAS@N?(olHy`uVBq!ia0vp^j3CUx1|;Q0k92}1TpU9x<|JR}`1N0&fn@_zW6t%R QYCs7FPgg&ebxsLQ0M<