ewrtgf
This commit is contained in:
+2
-5
@@ -48,11 +48,6 @@ 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));
|
||||
@@ -63,7 +58,9 @@ void Character::Render(Shader& shader) {
|
||||
for (int i = 0; i < transforms.size(); i++)
|
||||
shader.SetMat4(("finalBonesMatrices[" + std::to_string(i) + "]").c_str(), transforms[i]);
|
||||
}
|
||||
shader.Set4F("colorOverride", colorOverride);
|
||||
// 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)));
|
||||
shader.Set4F("colorOverride", glm::vec4(0.0f)); // don't leak into other rig draws
|
||||
}
|
||||
+1
-2
@@ -8,7 +8,6 @@
|
||||
#include "Rig.h"
|
||||
#include "Object.h"
|
||||
#include "Animator.h"
|
||||
#include "texture.h"
|
||||
|
||||
class CharacterBody;
|
||||
class BodyComponent;
|
||||
@@ -117,8 +116,8 @@ class Character : public Object, public Renderable {
|
||||
public:
|
||||
CharacterMind* mind = nullptr;
|
||||
CharacterBody* body = nullptr;
|
||||
glm::vec4 colorOverride = glm::vec4(0.0f); // rgb + strength (0 = keep the rig's own texture)
|
||||
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;
|
||||
|
||||
+1
-3
@@ -130,7 +130,6 @@ 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");
|
||||
|
||||
@@ -146,7 +145,6 @@ 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 });
|
||||
@@ -200,7 +198,7 @@ void Engine::Initiate()
|
||||
auto SpawnRemote = [&]() -> Character* {
|
||||
Character* c = new Character();
|
||||
c->name = "remote";
|
||||
c->skin = bluetex;
|
||||
c->colorOverride = glm::vec4(0.1f, 0.3f, 1.0f, 1.0f); // blue
|
||||
c->castshadow = true;
|
||||
c->body->t.ScaleBy({ 0.7f, 2.5f, 0.7f });
|
||||
c->body->SetRig(testrig);
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 70 B |
@@ -39,6 +39,7 @@ uniform vec3 viewPos;
|
||||
|
||||
uniform sampler2DShadow shadowMap;
|
||||
uniform sampler2D tex;
|
||||
uniform vec4 colorOverride = vec4(0.0); // rgb replaces the texture colour when w > 0
|
||||
|
||||
float ShadowCalculation(vec4 fragposlightspace)
|
||||
{
|
||||
@@ -79,6 +80,8 @@ void main()
|
||||
discard;
|
||||
}
|
||||
|
||||
lightless.rgb = mix(lightless.rgb, colorOverride.rgb, colorOverride.w);
|
||||
|
||||
vec3 norm = normalize(normal);
|
||||
vec3 viewDir = normalize(viewPos - FragPos);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user