* Bring back the cube shading, but with fixed lighting.

This commit is contained in:
iProgramInCpp
2023-08-07 12:21:32 +03:00
parent b77d42b04a
commit 6c1a54e3f0
11 changed files with 60 additions and 10 deletions

View File

@@ -53,13 +53,11 @@ void Cube::addBox(float x, float y, float z, int d, int e, int f, float g)
m_faces[4] = PolygonQuad(&m_verts[1], &m_verts[0], &m_verts[3], &m_verts[2], m + f, n + f, m + f + d, n + f + e); // z1 face
m_faces[5] = PolygonQuad(&m_verts[4], &m_verts[5], &m_verts[6], &m_verts[7], m + f + d + f, n + f, m + f + d + f + d, n + f + e); // z2 face
#ifdef ENH_ENTITY_SHADING
m_faces[0].setColor(0.6f, 0.6f, 0.6f);
m_faces[1].setColor(0.6f, 0.6f, 0.6f);
m_faces[4].setColor(0.8f, 0.8f, 0.8f);
m_faces[5].setColor(0.8f, 0.8f, 0.8f);
m_faces[3].setColor(0.5f, 0.5f, 0.5f);
#endif
if (field_18)
{
@@ -85,11 +83,7 @@ void Cube::compile(float f)
void Cube::draw()
{
#ifdef ENH_ENTITY_SHADING
drawArrayVT(m_buffer, 36, sizeof(Tesselator::Vertex));
#else
drawArrayVTC(m_buffer, 36, sizeof(Tesselator::Vertex));
#endif
}
void Cube::drawSlow(float f)
@@ -217,6 +211,21 @@ void Cube::translateTo(float f)
if (field_C != 0.0f) glRotatef(field_C * c, 1.0f, 0.0f, 0.0f);
}
void Cube::setBrightness(float f)
{
if (m_brightness != f)
m_bCompiled = false;
m_brightness = f;
m_faces[0].setColor(0.6f * f, 0.6f * f, 0.6f * f);
m_faces[1].setColor(0.6f * f, 0.6f * f, 0.6f * f);
m_faces[2].setColor(1.0f * f, 1.0f * f, 1.0f * f);
m_faces[3].setColor(0.5f * f, 0.5f * f, 0.5f * f);
m_faces[4].setColor(0.8f * f, 0.8f * f, 0.8f * f);
m_faces[5].setColor(0.8f * f, 0.8f * f, 0.8f * f);
}
void Cube::setPos(float x, float y, float z)
{
m_posX = x;

View File

@@ -27,6 +27,7 @@ public:
void setPos(float x, float y, float z);
void setTexOffs(int a, int b);
void translateTo(float f);
void setBrightness(float f);
public:
float m_posX = 0.0f;
@@ -45,6 +46,7 @@ public:
bool m_bCompiled = false;
int field_2C0 = 0;
GLuint m_buffer = 0;
float m_brightness = 1.0f;
static float c;
};

View File

@@ -160,6 +160,16 @@ void HumanoidModel::setupAnim(float a2, float a3, float a4, float a5, float a6,
m_armR.field_C += Mth::sin(a4 * 0.067f) * -0.05f;
}
void HumanoidModel::setBrightness(float f)
{
m_armL.setBrightness(f);
m_armR.setBrightness(f);
m_legL.setBrightness(f);
m_legR.setBrightness(f);
m_body.setBrightness(f);
m_head.setBrightness(f);
}
/* Keeping the original around just in case:
void HumanoidModel::setupAnim(float a2, float a3, float a4, float a5, float a6, float a7)

View File

@@ -21,6 +21,7 @@ public:
void render(float, float, float, float, float, float) override;
void renderHorrible(float, float, float, float, float, float) override;
void setupAnim(float, float, float, float, float, float) override;
void setBrightness(float) override;
public:
// @TODO: swap armL and armR.. Steve punches with the right hand.

View File

@@ -32,3 +32,7 @@ void Model::setupAnim(float, float, float, float, float, float)
{
}
void Model::setBrightness(float)
{
}

View File

@@ -20,6 +20,7 @@ public:
virtual void render(float, float, float, float, float, float);
virtual void renderHorrible(float, float, float, float, float, float);
virtual void setupAnim(float, float, float, float, float, float);
virtual void setBrightness(float);
public:
float field_4 = 0.0f;

View File

@@ -30,7 +30,7 @@ void FallingTileRenderer::render(Entity* entity, float x, float y, float z, floa
// Render the base
#ifdef ENH_SHADE_HELD_TILES
#define ARGPATCH , 1.0f
#define ARGPATCH , entity->getBrightness(0.0f)
#else
#define ARGPATCH
#endif

View File

@@ -8,6 +8,7 @@
#include "HumanoidMobRenderer.hpp"
#include "EntityRenderDispatcher.hpp"
#include "Minecraft.hpp"
#include "client/renderer/ItemInHandRenderer.hpp"
#include "client/renderer/TileRenderer.hpp"
#include "world/entity/Player.hpp"
@@ -66,6 +67,7 @@ void HumanoidMobRenderer::onGraphicsReset()
void HumanoidMobRenderer::renderHand()
{
m_pHumanoidModel->field_4 = 0;
m_pHumanoidModel->setBrightness(m_pDispatcher->m_pMinecraft->m_pMobPersp->getBrightness(1.0f));
m_pHumanoidModel->setupAnim(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0625f);
m_pHumanoidModel->m_armL.render(0.0625f);
}

View File

@@ -95,6 +95,7 @@ void MobRenderer::render(Entity* entity, float x, float y, float z, float unused
bindTexture("mob/char.png");
glEnable(GL_ALPHA_TEST);
m_pModel->setBrightness(entity->getBrightness(1.0f));
m_pModel->prepareMobModel(pMob, x2, x1, f);
m_pModel->render(x2, x1, fBob, aYaw - fSmth, aPitch, 0.059375f);
additionalRendering(pMob, f);

View File

@@ -10,7 +10,7 @@
#include "Minecraft.hpp"
TripodCameraRenderer::TripodCameraRenderer() :
m_tile(0, 243, Material::plant),
m_tile(),
m_cube(0, 0)
{
m_cube.addBox(-4.0f, -4.0f, -6.0f, 8, 8, 10);
@@ -36,12 +36,16 @@ void TripodCameraRenderer::render(Entity* entity, float x, float y, float z, flo
Tesselator& t = Tesselator::instance;
t.color(1.0f, 1.0f, 1.0f);
float brightness = entity->getBrightness(1.0f);
bindTexture("gui/items.png");
t.begin();
m_renderer.tesselateCrossTexture(&m_tile, 0, -0.5f, -0.5f, -0.5f);
//m_renderer.tesselateCrossTexture(&m_tile, 0, -0.5f, -0.5f, -0.5f);
m_renderer.renderTile(&m_tile, 0, brightness);
t.draw();
bindTexture("item/camera.png");
m_cube.setBrightness(brightness);
m_cube.render(0.0625f);
Entity* pHREntity = m_pDispatcher->m_pMinecraft->m_hitResult.m_pEnt;
@@ -68,3 +72,12 @@ void TripodCameraRenderer::render(Entity* entity, float x, float y, float z, flo
glPopMatrix();
}
TripodTile::TripodTile() : Tile(0, 243, Material::plant)
{
}
int TripodTile::getRenderShape()
{
return SHAPE_CROSS;
}

View File

@@ -13,6 +13,13 @@
#include "world/tile/Tile.hpp"
#include "world/entity/TripodCamera.hpp"
class TripodTile : public Tile
{
public:
TripodTile();
int getRenderShape() override;
};
class TripodCameraRenderer : public EntityRenderer
{
public:
@@ -24,7 +31,7 @@ public:
public:
TileRenderer m_renderer;
Tile m_tile;
TripodTile m_tile;
Cube m_cube;
};