last one
This commit is contained in:
+8
-1
@@ -48,6 +48,11 @@ Character::Character() {
|
|||||||
|
|
||||||
void Character::Render(Shader& shader) {
|
void Character::Render(Shader& shader) {
|
||||||
if (!body || !body->rig || !body->animator) return;
|
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) {
|
if (body->animator->m_CurrentAnimation == nullptr) {
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++)
|
||||||
shader.SetMat4(("finalBonesMatrices[" + std::to_string(i) + "]").c_str(), glm::mat4(1.0f));
|
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++)
|
for (int i = 0; i < transforms.size(); i++)
|
||||||
shader.SetMat4(("finalBonesMatrices[" + std::to_string(i) + "]").c_str(), transforms[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)));
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "Rig.h"
|
#include "Rig.h"
|
||||||
#include "Object.h"
|
#include "Object.h"
|
||||||
#include "Animator.h"
|
#include "Animator.h"
|
||||||
|
#include "texture.h"
|
||||||
|
|
||||||
class CharacterBody;
|
class CharacterBody;
|
||||||
class BodyComponent;
|
class BodyComponent;
|
||||||
@@ -116,6 +117,8 @@ class Character : public Object, public Renderable {
|
|||||||
public:
|
public:
|
||||||
CharacterMind* mind = nullptr;
|
CharacterMind* mind = nullptr;
|
||||||
CharacterBody* body = 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();
|
Character();
|
||||||
void Render(Shader& shader) override;
|
void Render(Shader& shader) override;
|
||||||
|
|||||||
+4
-1
@@ -130,6 +130,7 @@ void Engine::Initiate()
|
|||||||
Texture* blanktex = new Texture("assets/blanktexture.png");
|
Texture* blanktex = new Texture("assets/blanktexture.png");
|
||||||
Texture* magic = new Texture("assets/itsmagicbitch.jpg");
|
Texture* magic = new Texture("assets/itsmagicbitch.jpg");
|
||||||
Texture* snowflake = new Texture("assets/snowflake.png");
|
Texture* snowflake = new Texture("assets/snowflake.png");
|
||||||
|
Texture* bluetex = new Texture("assets/bluetexture.png");
|
||||||
Texture* shockwavetex = new Texture("assets/shockwave.png");
|
Texture* shockwavetex = new Texture("assets/shockwave.png");
|
||||||
Texture* leontex = new Texture("assets/revolvertex.png");
|
Texture* leontex = new Texture("assets/revolvertex.png");
|
||||||
|
|
||||||
@@ -145,6 +146,7 @@ void Engine::Initiate()
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
Character* testcharacter = new Character();
|
Character* testcharacter = new Character();
|
||||||
testcharacter->name = "character";
|
testcharacter->name = "character";
|
||||||
|
testcharacter->skin = bluetex;
|
||||||
testcharacter->castshadow = true;
|
testcharacter->castshadow = true;
|
||||||
testcharacter->body->t.ScaleBy({ 0.7f, 2.5f, 0.7f });
|
testcharacter->body->t.ScaleBy({ 0.7f, 2.5f, 0.7f });
|
||||||
testcharacter->body->t.TranslateTo({ 0.0f, 10.0f, 0.0f });
|
testcharacter->body->t.TranslateTo({ 0.0f, 10.0f, 0.0f });
|
||||||
@@ -198,6 +200,7 @@ void Engine::Initiate()
|
|||||||
auto SpawnRemote = [&]() -> Character* {
|
auto SpawnRemote = [&]() -> Character* {
|
||||||
Character* c = new Character();
|
Character* c = new Character();
|
||||||
c->name = "remote";
|
c->name = "remote";
|
||||||
|
c->skin = bluetex;
|
||||||
c->castshadow = true;
|
c->castshadow = true;
|
||||||
c->body->t.ScaleBy({ 0.7f, 2.5f, 0.7f });
|
c->body->t.ScaleBy({ 0.7f, 2.5f, 0.7f });
|
||||||
c->body->SetRig(testrig);
|
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
|
// 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.
|
// 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
|
const double cubeLifetime = 30.0; // seconds before a cube despawns
|
||||||
float cubeCooldown = 0.0f;
|
float cubeCooldown = 0.0f;
|
||||||
// Cubes also rain from the sky on their own (host / offline only; clients see them via the stream)
|
// Cubes also rain from the sky on their own (host / offline only; clients see them via the stream)
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 70 B |
Reference in New Issue
Block a user