diff --git a/platforms/windows/projects/Client/Client.vcxproj b/platforms/windows/projects/Client/Client.vcxproj
index 2582f9a..a5fbca3 100644
--- a/platforms/windows/projects/Client/Client.vcxproj
+++ b/platforms/windows/projects/Client/Client.vcxproj
@@ -253,7 +253,9 @@
+
+
@@ -315,9 +317,9 @@
-
-
-
+
+
+
@@ -351,7 +353,9 @@
+
+
@@ -413,9 +417,9 @@
-
-
-
+
+
+
diff --git a/platforms/windows/projects/Client/Client.vcxproj.filters b/platforms/windows/projects/Client/Client.vcxproj.filters
index 8f32a16..7abf4df 100644
--- a/platforms/windows/projects/Client/Client.vcxproj.filters
+++ b/platforms/windows/projects/Client/Client.vcxproj.filters
@@ -365,14 +365,20 @@
Header Files\Player\Input
-
- Header Files\Renderer
+
+ Header Files
-
- Header Files\Renderer
+
+ Header Files
-
- Header Files\GUI\Components
+
+ Header Files
+
+
+ Header Files\Model
+
+
+ Header Files\Model
@@ -655,14 +661,20 @@
Source Files\Player\Input
-
- Source Files\Renderer
+
+ Source Files
-
- Source Files\Renderer
+
+ Source Files
-
- Source Files\GUI\Components
+
+ Source Files
+
+
+ Source Files\Model
+
+
+ Source Files\Model
\ No newline at end of file
diff --git a/source/client/model/Cube.cpp b/source/client/model/Cube.cpp
index 0f9dfd8..62127a9 100644
--- a/source/client/model/Cube.cpp
+++ b/source/client/model/Cube.cpp
@@ -9,29 +9,23 @@
#include "Cube.hpp"
#include "renderer/GL/GL.hpp"
-const float Cube::c = 180.0f / float(M_PI);
+#define MUL_DEG_TO_RAD (180.0f / float(M_PI))
-Cube::Cube(int a, int b)
-{
- m_posX = m_posY = m_posZ = 0.0f;
- m_rotX = m_rotY = m_rotZ = 0.0f;
-
- field_18 = false;
- field_19 = true;
- field_1A = false;
- m_bCompiled = false;
- field_2C0 = 0;
- m_buffer = 0;
- m_brightness = 1.0f;
-
- field_2B4 = a;
- field_2B8 = b;
-}
-
-void Cube::addBox(float x, float y, float z, int d, int e, int f, float g)
+Cube::Cube(ModelPart* a2, int a3, int a4, float x, float y, float z, int d, int e, int f, float g)
{
float x1 = x, y1 = y, z1 = z;
float x2 = x + float(d), y2 = y + float(e), z2 = z + float(f);
+
+ field_29C = x1;
+ field_2A0 = y1;
+ field_2A4 = z1;
+ field_2A8 = x2;
+ field_2AC = y2;
+ field_2B0 = z2;
+
+ if (a2->field_18)
+ std::swap(x1, x2);
+
x1 -= g;
y1 -= g;
z1 -= g;
@@ -39,9 +33,6 @@ void Cube::addBox(float x, float y, float z, int d, int e, int f, float g)
y2 += g;
z2 += g;
- if (field_18)
- std::swap(x1, x2);
-
m_verts[0] = VertexPT(x1, y1, z1, 0.0f, 0.0f);
m_verts[1] = VertexPT(x2, y1, z1, 0.0f, 8.0f);
m_verts[2] = VertexPT(x2, y2, z1, 8.0f, 8.0f);
@@ -50,8 +41,8 @@ void Cube::addBox(float x, float y, float z, int d, int e, int f, float g)
m_verts[5] = VertexPT(x2, y1, z2, 0.0f, 8.0f);
m_verts[6] = VertexPT(x2, y2, z2, 8.0f, 8.0f);
m_verts[7] = VertexPT(x1, y2, z2, 8.0f, 0.0f);
-
- int m = field_2B4, n = field_2B8;
+
+ int m = a3, n = a4;
m_faces[0] = PolygonQuad(&m_verts[5], &m_verts[1], &m_verts[2], &m_verts[6], m + f + d, n + f, m + f + d + f, n + f + e); // x2 face
m_faces[1] = PolygonQuad(&m_verts[0], &m_verts[4], &m_verts[7], &m_verts[3], m, n + f, m + f, n + f + e); // x1 face
@@ -60,143 +51,20 @@ 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)
+ if (a2->field_18)
{
for (int i = 0; i < 6; i++)
m_faces[i].mirror();
}
}
-void Cube::compile(float scale)
+void Cube::compile(Tesselator& t, float scale)
{
- if (m_bCompiled)
- xglDeleteBuffers(1, &m_buffer);
-
- xglGenBuffers(1, &m_buffer);
-
- Tesselator& t = Tesselator::instance;
- t.begin();
-
for (int i = 0; i < 6; i++)
m_faces[i].render(t, scale);
-
- t.end(m_buffer);
- m_bCompiled = true;
}
-void Cube::draw()
+void Cube::setId(const std::string& s)
{
-#ifdef ENH_ENTITY_SHADING
- drawArrayVTC(m_buffer, 36, sizeof(Tesselator::Vertex));
-#else
- drawArrayVT(m_buffer, 36, sizeof(Tesselator::Vertex));
-#endif
-}
-
-void Cube::drawSlow(float scale)
-{
- Tesselator& t = Tesselator::instance;
- t.begin();
-
- for (int i = 0; i < 6; i++)
- m_faces[i].render(t, scale);
-
- t.draw();
-}
-
-void Cube::render(float scale)
-{
- if (field_1A)
- return;
-
- if (!field_19)
- return;
-
- if (!m_bCompiled)
- compile(scale);
-
- if (!hasDefaultRot())
- {
- glPushMatrix();
-
- translateRotTo(scale);
- draw();
-
- glPopMatrix();
- }
- else if (!hasDefaultPos())
- {
- translatePosTo(scale);
- draw();
- translatePosTo(-scale);
- }
- else
- {
- draw();
- }
-}
-
-void Cube::translatePosTo(float scale)
-{
- glTranslatef(m_posX * scale, m_posY * scale, m_posZ * scale);
-}
-
-void Cube::translateRotTo(float scale)
-{
- glTranslatef(m_posX * scale, m_posY * scale, m_posZ * scale);
- if (m_rotZ != 0) glRotatef(m_rotZ * c, 0, 0, 1);
- if (m_rotY != 0) glRotatef(m_rotY * c, 0, 1, 0);
- if (m_rotX != 0) glRotatef(m_rotX * c, 1, 0, 0);
-}
-
-void Cube::translateTo(float scale)
-{
- if (field_1A)
- return;
-
- if (!field_19)
- return;
-
- if (!hasDefaultRot())
- translateRotTo(scale);
- else if (!hasDefaultPos())
- translatePosTo(scale);
-}
-
-void Cube::setBrightness(float b)
-{
- if (m_brightness != b)
- m_bCompiled = false;
-
- m_brightness = b;
-
-#ifdef ENH_ENTITY_SHADING
- m_faces[0].setColor(0.6f * b, 0.6f * b, 0.6f * b);
- m_faces[1].setColor(0.6f * b, 0.6f * b, 0.6f * b);
- m_faces[2].setColor(1.0f * b, 1.0f * b, 1.0f * b);
- m_faces[3].setColor(0.5f * b, 0.5f * b, 0.5f * b);
- m_faces[4].setColor(0.8f * b, 0.8f * b, 0.8f * b);
- m_faces[5].setColor(0.8f * b, 0.8f * b, 0.8f * b);
-#endif
-}
-
-void Cube::setPos(float x, float y, float z)
-{
- m_posX = x;
- m_posY = y;
- m_posZ = z;
-}
-
-void Cube::setTexOffs(int a, int b)
-{
- field_2B4 = a;
- field_2B8 = b;
+ m_id = s;
}
diff --git a/source/client/model/Cube.hpp b/source/client/model/Cube.hpp
index 0169127..3a2f9e1 100644
--- a/source/client/model/Cube.hpp
+++ b/source/client/model/Cube.hpp
@@ -9,48 +9,27 @@
#pragma once
#include "PolygonQuad.hpp"
+#include "ModelPart.hpp"
+
+class ModelPart;
class Cube
{
public:
- Cube(int, int);
+ Cube(ModelPart*, int, int, float, float, float, int, int, int, float);
- void addBox(float a, float b, float c, int d, int e, int f, float g = 0);
- // @TODO: void addTexBox(float a, float b, float c, int d, int e, int f, int g); -- No xrefs
- void compile(float scale);
- void draw();
- void drawSlow(float scale);
- void render(float scale);
- void setPos(float x, float y, float z);
- void setTexOffs(int a, int b);
- void translateTo(float scale);
- void setBrightness(float brightness);
-
-private:
- bool hasDefaultPos() { return m_posX == 0 && m_posY == 0 && m_posZ == 0; }
- bool hasDefaultRot() { return m_rotX == 0 && m_rotY == 0 && m_rotZ == 0; }
- void translatePosTo(float scale);
- void translateRotTo(float scale);
+ void compile(Tesselator& t, float scale);
+ void setId(const std::string& s);
public:
- float m_posX;
- float m_posY;
- float m_posZ;
- float m_rotX;
- float m_rotY;
- float m_rotZ;
- bool field_18;
- bool field_19;
- bool field_1A;
VertexPT m_verts[8];
PolygonQuad m_faces[6];
- int field_2B4;
- int field_2B8;
- bool m_bCompiled;
- int field_2C0;
- GLuint m_buffer;
- float m_brightness;
-
- static const float c;
+ std::string m_id;
+ float field_29C;
+ float field_2A0;
+ float field_2A4;
+ float field_2A8;
+ float field_2AC;
+ float field_2B0;
};
diff --git a/source/client/model/HumanoidModel.cpp b/source/client/model/HumanoidModel.cpp
index 90d9bbc..8ce933d 100644
--- a/source/client/model/HumanoidModel.cpp
+++ b/source/client/model/HumanoidModel.cpp
@@ -10,52 +10,47 @@
#include "client/app/Minecraft.hpp"
HumanoidModel::HumanoidModel(float a, float b):
+ Model(64, 32),
m_head(0, 0),
m_body(16, 16),
- m_armL(40, 16),
- m_armR(40, 16),
- m_legL(0, 16),
- m_legR(0, 16)
+ m_arm1(40, 16),
+ m_arm2(40, 16),
+ m_leg1(0, 16),
+ m_leg2(0, 16)
{
- field_10BC = false;
- field_10BD = false;
- field_10BE = false;
+ field_234 = 0;
+
+ m_head.setModel(this);
+ m_body.setModel(this);
+ m_arm1.setModel(this);
+ m_arm2.setModel(this);
+ m_leg1.setModel(this);
+ m_leg2.setModel(this);
m_head.addBox(-4, -8, -4, 8, 8, 8, a);
m_head.setPos(0, b, 0);
m_body.addBox(-4, 0, -2, 8, 12, 4);
m_body.setPos(0, b, 0);
- m_armL.addBox(-3, -2, -2, 4, 12, 4, a);
- m_armL.setPos(-5, b + 2, 0);
- m_armR.field_18 = true;
- m_armR.addBox(-1, -2, -2, 4, 12, 4, a);
- m_armR.setPos(5, b + 2, 0);
- m_legL.addBox(-2, 0, -2, 4, 12, 4, a);
- m_legL.setPos(-2, b + 12, 0);
- m_legR.field_18 = true;
- m_legR.addBox(-2, 0, -2, 4, 12, 4, a);
- m_legR.setPos(2, b + 12, 0);
-}
-
-void HumanoidModel::_logGraphics()
-{
- Matrix m;
-
- if (Minecraft::customDebugId == 1)
- {
- // @NOTE: I think most of this function was ifdef'd/commented out
- m.fetchGL(GL_MODELVIEW_MATRIX);
- }
+ m_arm1.addBox(-3, -2, -2, 4, 12, 4, a);
+ m_arm1.setPos(-5, b + 2, 0);
+ m_arm2.field_18 = true;
+ m_arm2.addBox(-1, -2, -2, 4, 12, 4, a);
+ m_arm2.setPos(5, b + 2, 0);
+ m_leg1.addBox(-2, 0, -2, 4, 12, 4, a);
+ m_leg1.setPos(-2, b + 12, 0);
+ m_leg2.field_18 = true;
+ m_leg2.addBox(-2, 0, -2, 4, 12, 4, a);
+ m_leg2.setPos(2, b + 12, 0);
}
void HumanoidModel::onGraphicsReset()
{
m_head.m_bCompiled = false;
m_body.m_bCompiled = false;
- m_armL.m_bCompiled = false;
- m_armR.m_bCompiled = false;
- m_legL.m_bCompiled = false;
- m_legR.m_bCompiled = false;
+ m_arm1.m_bCompiled = false;
+ m_arm2.m_bCompiled = false;
+ m_leg1.m_bCompiled = false;
+ m_leg2.m_bCompiled = false;
}
void HumanoidModel::render(float a, float b, float c, float d, float e, float f)
@@ -63,11 +58,10 @@ void HumanoidModel::render(float a, float b, float c, float d, float e, float f)
setupAnim(a, b, c, d, e, f);
m_head.render(f);
m_body.render(f);
- m_armL.render(f);
- m_armR.render(f);
- m_legL.render(f);
- m_legR.render(f);
- _logGraphics();
+ m_arm1.render(f);
+ m_arm2.render(f);
+ m_leg1.render(f);
+ m_leg2.render(f);
}
void HumanoidModel::setupAnim(float a2, float a3, float a4, float a5, float a6, float a7)
@@ -80,84 +74,84 @@ void HumanoidModel::setupAnim(float a2, float a3, float a4, float a5, float a6,
if (m_head.m_rotX > 1.0f)
m_head.m_rotX = 1.0f;
float v12 = (a2 * 0.6662f) + 3.1416f;
- m_armL.m_rotX = (Mth::cos(v12) * 2.0f * a3) * 0.5f;
- m_armR.m_rotX = Mth::cos(a2 * 0.6662f) * 2.0f * a3 * 0.5f; // @HUH: multiplying by 2 and also by 1/2
- m_armL.m_rotZ = 0.0f;
- m_armR.m_rotZ = 0.0f;
- m_legL.m_rotX = (Mth::cos(a2 * 0.6662f) * 1.4f) * a3;
- m_legR.m_rotX = (Mth::cos(v12) * 1.4f) * a3;
- m_legL.m_rotY = 0.0f;
- m_legR.m_rotY = 0.0f;
+ m_arm1.m_rotX = (Mth::cos(v12) * 2.0f * a3) * 0.5f;
+ m_arm2.m_rotX = Mth::cos(a2 * 0.6662f) * 2.0f * a3 * 0.5f; // @HUH: multiplying by 2 and also by 1/2
+ m_arm1.m_rotZ = 0.0f;
+ m_arm2.m_rotZ = 0.0f;
+ m_leg1.m_rotX = (Mth::cos(a2 * 0.6662f) * 1.4f) * a3;
+ m_leg2.m_rotX = (Mth::cos(v12) * 1.4f) * a3;
+ m_leg1.m_rotY = 0.0f;
+ m_leg2.m_rotY = 0.0f;
if (field_8)
{
float v15 = (3.1416f * -0.5f) * 0.4f;
- m_armL.m_rotX += v15;
- m_armR.m_rotX += v15;
+ m_arm1.m_rotX += v15;
+ m_arm2.m_rotX += v15;
float v16 = (3.1416f * -0.5f) * 0.8f;
- m_legL.m_rotX = v16;
- m_legR.m_rotX = v16;
- m_legL.m_rotY = (3.1416f * 0.5f) * 0.2f;
- m_legR.m_rotY = (3.1416f * -0.5f) * 0.2f;
+ m_leg1.m_rotX = v16;
+ m_leg2.m_rotX = v16;
+ m_leg1.m_rotY = (3.1416f * 0.5f) * 0.2f;
+ m_leg2.m_rotY = (3.1416f * -0.5f) * 0.2f;
}
- if (field_10BC)
- m_armR.m_rotX = ((3.1416f * 0.5f) * -0.2f) + (m_armR.m_rotX * 0.5f);
- if (field_10BD)
- m_armL.m_rotX = ((3.1416f * 0.5f) * -0.2f) + (m_armL.m_rotX * 0.5f);
+ if (field_234)
+ m_arm2.m_rotX = ((3.1416f * 0.5f) * -0.2f) + (m_arm2.m_rotX * 0.5f);
+ if (field_235)
+ m_arm1.m_rotX = ((3.1416f * 0.5f) * -0.2f) + (m_arm1.m_rotX * 0.5f);
- m_armL.m_rotY = 0.0f;
- m_armR.m_rotY = 0.0f;
+ m_arm1.m_rotY = 0.0f;
+ m_arm2.m_rotY = 0.0f;
if (field_4 > -9990.0f)
{
m_body.m_rotY = Mth::sin(Mth::sqrt(field_4) * 3.1416f * 2.0f) * 0.2f;
- m_armL.m_posZ = 5.0f * Mth::sin(m_body.m_rotY);
- m_armL.m_posX = -5.0f * Mth::cos(m_body.m_rotY);
- m_armR.m_posZ = -5.0f * Mth::sin(m_body.m_rotY);
- m_armR.m_posX = 5.0f * Mth::cos(m_body.m_rotY);
- m_armL.m_rotY = m_armL.m_rotY + m_body.m_rotY;
- m_armR.m_rotY = m_armR.m_rotY + m_body.m_rotY;
+ m_arm1.m_posZ = 5.0f * Mth::sin(m_body.m_rotY);
+ m_arm1.m_posX = -5.0f * Mth::cos(m_body.m_rotY);
+ m_arm2.m_posZ = -5.0f * Mth::sin(m_body.m_rotY);
+ m_arm2.m_posX = 5.0f * Mth::cos(m_body.m_rotY);
+ m_arm1.m_rotY = m_arm1.m_rotY + m_body.m_rotY;
+ m_arm2.m_rotY = m_arm2.m_rotY + m_body.m_rotY;
float o = 1.0f - field_4;
- m_armR.m_rotX += m_body.m_rotY;
- m_armL.m_rotX -= -((m_head.m_rotX - 0.7f) * Mth::sin(3.1416f * field_4)) * 0.75f + Mth::sin((1.0f - o * o * o * o) * 3.1416f) * 1.2f;
- m_armL.m_rotY += m_body.m_rotY * 2.0f;
- m_armL.m_rotZ = Mth::sin(field_4 * 3.1416f) * -0.4f;
+ m_arm2.m_rotX += m_body.m_rotY;
+ m_arm1.m_rotX -= -((m_head.m_rotX - 0.7f) * Mth::sin(3.1416f * field_4)) * 0.75f + Mth::sin((1.0f - o * o * o * o) * 3.1416f) * 1.2f;
+ m_arm1.m_rotY += m_body.m_rotY * 2.0f;
+ m_arm1.m_rotZ = Mth::sin(field_4 * 3.1416f) * -0.4f;
}
- if (field_10BE) // sneaking?
+ if (m_bSneaking)
{
m_body.m_rotX = 0.5f;
- m_armL.m_rotX += 0.4f;
- m_armR.m_rotX += 0.4f;
- m_legL.m_posZ = 4.0f;
- m_legR.m_posZ = 4.0f;
- m_legL.m_posY = 9.0f;
- m_legR.m_posY = 9.0f;
+ m_arm1.m_rotX += 0.4f;
+ m_arm2.m_rotX += 0.4f;
+ m_leg1.m_posZ = 4.0f;
+ m_leg2.m_posZ = 4.0f;
+ m_leg1.m_posY = 9.0f;
+ m_leg2.m_posY = 9.0f;
m_head.m_posY = 1.0f;
}
else
{
m_body.m_rotX = 0.0f;
- m_legL.m_posZ = 0.0f;
+ m_leg1.m_posZ = 0.0f;
m_head.m_posY = 0.0f;
- m_legR.m_posZ = 0.0f;
- m_legL.m_posY = 12.0f;
- m_legR.m_posY = 12.0f;
+ m_leg2.m_posZ = 0.0f;
+ m_leg1.m_posY = 12.0f;
+ m_leg2.m_posY = 12.0f;
}
- m_armL.m_rotZ += Mth::cos(a4 * 0.09f) * 0.05f + 0.05f;
- m_armR.m_rotZ -= Mth::cos(a4 * 0.09f) * 0.05f + 0.05f;
- m_armL.m_rotX += Mth::sin(a4 * 0.067f) * 0.05f;
- m_armR.m_rotX += Mth::sin(a4 * 0.067f) * -0.05f;
+ m_arm1.m_rotZ += Mth::cos(a4 * 0.09f) * 0.05f + 0.05f;
+ m_arm2.m_rotZ -= Mth::cos(a4 * 0.09f) * 0.05f + 0.05f;
+ m_arm1.m_rotX += Mth::sin(a4 * 0.067f) * 0.05f;
+ m_arm2.m_rotX += 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_arm1.setBrightness(f);
+ m_arm2.setBrightness(f);
+ m_leg1.setBrightness(f);
+ m_leg2.setBrightness(f);
m_body.setBrightness(f);
m_head.setBrightness(f);
}
diff --git a/source/client/model/HumanoidModel.hpp b/source/client/model/HumanoidModel.hpp
index 18479b6..1b81c59 100644
--- a/source/client/model/HumanoidModel.hpp
+++ b/source/client/model/HumanoidModel.hpp
@@ -14,7 +14,6 @@ class HumanoidModel : public Model
{
public:
HumanoidModel(float a, float b);
- void _logGraphics();
// @TODO - No xrefs: void render(HumanoidModel* a, float f);
void onGraphicsReset() override;
@@ -23,10 +22,11 @@ public:
void setBrightness(float) override;
public:
- // @TODO: swap armL and armR.. Steve punches with the right hand.
- Cube m_head, m_body, m_armL, m_armR, m_legL, m_legR;
- bool field_10BC;
- bool field_10BD;
- bool field_10BE;
+ bool field_20 = false;
+ ModelPart m_head, m_body, m_arm1, m_arm2, m_leg1, m_leg2;
+ bool field_234;
+ bool field_235;
+ bool m_bSneaking;
+ bool field_237;
};
diff --git a/source/client/model/Model.cpp b/source/client/model/Model.cpp
index afcbf44..cd63183 100644
--- a/source/client/model/Model.cpp
+++ b/source/client/model/Model.cpp
@@ -8,10 +8,16 @@
#include "Model.hpp"
-Model::Model()
+Model::Model(int width, int height)
{
field_4 = 0.0f;
field_8 = false;
+ m_textureWidth = width;
+ m_textureHeight = height;
+}
+
+Model::~Model()
+{
}
void Model::onGraphicsReset()
diff --git a/source/client/model/Model.hpp b/source/client/model/Model.hpp
index 79b9a09..0c173d0 100644
--- a/source/client/model/Model.hpp
+++ b/source/client/model/Model.hpp
@@ -11,11 +11,13 @@
#include "Cube.hpp"
class Mob;
+class ModelPart;
class Model
{
public:
- Model();
+ Model(int width, int height);
+ virtual ~Model();
virtual void onGraphicsReset();
virtual void prepareMobModel(Mob*, float, float, float);
virtual void render(float, float, float, float, float, float);
@@ -25,4 +27,7 @@ public:
public:
float field_4;
bool field_8;
+ int m_textureWidth;
+ int m_textureHeight;
+ std::vector m_parts;
};
diff --git a/source/client/model/ModelPart.cpp b/source/client/model/ModelPart.cpp
new file mode 100644
index 0000000..55d60c6
--- /dev/null
+++ b/source/client/model/ModelPart.cpp
@@ -0,0 +1,271 @@
+/********************************************************************
+ Minecraft: Pocket Edition - Decompilation Project
+ Copyright (C) 2023 iProgramInCpp
+
+ The following code is licensed under the BSD 1 clause license.
+ SPDX-License-Identifier: BSD-1-Clause
+ ********************************************************************/
+#include "ModelPart.hpp"
+#include "renderer/GL/GL.hpp"
+
+#define MUL_DEG_TO_RAD (180.0f / float(M_PI)) // formerly known as Cube::c
+
+ModelPart::ModelPart(int a, int b)
+{
+ m_pModel = nullptr;
+ field_40 = a;
+ field_44 = b;
+ _init();
+}
+
+ModelPart::ModelPart(const std::string& baseId)
+{
+ m_pModel = nullptr;
+ field_34 = baseId;
+ field_40 = 0;
+ field_44 = 0;
+ _init();
+}
+
+ModelPart::~ModelPart()
+{
+ clear();
+}
+
+void ModelPart::_init()
+{
+ m_posX = m_posY = m_posZ = 0;
+ m_rotX = m_rotY = m_rotZ = 0;
+ m_buffer = 0;
+ m_textureWidth = 64.0f;
+ m_textureHeight = 32.0f;
+ field_4C = 0;
+ field_18 = false;
+ field_48 = true;
+ field_49 = false;
+ m_bCompiled = false;
+}
+
+void ModelPart::addChild(ModelPart* pPart)
+{
+ m_pChildren.push_back(pPart);
+}
+
+void ModelPart::addBox(float a, float b, float c, int d, int e, int f, float g)
+{
+ Cube* pCube = new Cube(this, field_40, field_44, a, b, c, d, e, f, g);
+ m_pCubes.push_back(pCube);
+}
+
+void ModelPart::addBox(const std::string& id, float a, float b, float c, int d, int e, int f, float g)
+{
+ Cube* pCube = new Cube(this, field_40, field_44, a, b, c, d, e, f, g);
+ pCube->setId(field_34 + "." + id);
+ m_pCubes.push_back(pCube);
+}
+
+void ModelPart::clear()
+{
+ for (size_t i = 0; i < m_pCubes.size(); i++)
+ delete m_pCubes[i];
+
+ // N.B. does not clear children
+ m_pCubes.clear();
+}
+
+void ModelPart::compile(float scale)
+{
+ Tesselator& t = Tesselator::instance;
+ xglGenBuffers(1, &m_buffer);
+ t.begin();
+ t.color(255, 255, 255, 255);
+
+ // @HUH: Recompiling every cube six times??
+#ifdef ORIGINAL_CODE
+ for (int i = 0; i < 6; i++)
+ {
+#endif
+
+ for (size_t i = 0; i < m_pCubes.size(); i++)
+ {
+ m_pCubes[i]->compile(t, scale);
+ }
+
+#ifdef ORIGINAL_CODE
+ }
+#endif
+
+ t.end(m_buffer);
+ m_bCompiled = true;
+}
+
+void ModelPart::draw()
+{
+ drawArrayVT(this->m_buffer, 36 * m_pCubes.size(), sizeof(Tesselator::Vertex));
+}
+
+void ModelPart::drawSlow(float scale)
+{
+ Tesselator& t = Tesselator::instance;
+ t.begin();
+
+ for (size_t i = 0; i < m_pCubes.size(); i++)
+ {
+ for (int f = 0; f < 6; f++)
+ m_pCubes[i]->m_faces[f].render(t, scale);
+ }
+
+ t.draw();
+}
+
+void ModelPart::mimic(ModelPart* pPart)
+{
+ m_posX = pPart->m_posX;
+ m_posY = pPart->m_posY;
+ m_posZ = pPart->m_posZ;
+ m_rotX = pPart->m_rotX;
+ m_rotY = pPart->m_rotY;
+ m_rotZ = pPart->m_rotZ;
+}
+
+void ModelPart::translatePosTo(float scale)
+{
+ glTranslatef(m_posX * scale, m_posY * scale, m_posZ * scale);
+}
+
+void ModelPart::translateRotTo(float scale)
+{
+ glTranslatef(m_posX * scale, m_posY * scale, m_posZ * scale);
+ if (m_rotZ != 0) glRotatef(m_rotZ * MUL_DEG_TO_RAD, 0, 0, 1);
+ if (m_rotY != 0) glRotatef(m_rotY * MUL_DEG_TO_RAD, 0, 1, 0);
+ if (m_rotX != 0) glRotatef(m_rotX * MUL_DEG_TO_RAD, 1, 0, 0);
+}
+
+void ModelPart::render(float scale)
+{
+ if (field_49)
+ return;
+
+ if (!field_48)
+ return;
+
+ if (!m_bCompiled)
+ compile(scale);
+
+ if (!hasDefaultRot())
+ {
+ glPushMatrix();
+
+ translateRotTo(scale);
+ draw();
+
+ glPopMatrix();
+ }
+ else if (!hasDefaultPos())
+ {
+ translatePosTo(scale);
+ draw();
+ translatePosTo(-scale);
+ }
+ else
+ {
+ draw();
+ }
+}
+
+void ModelPart::renderHorrible(float scale)
+{
+ if (field_49)
+ return;
+
+ if (!field_48)
+ return;
+
+ if (!m_bCompiled)
+ compile(scale);
+
+ if (!hasDefaultRot())
+ {
+ glPushMatrix();
+
+ translateRotTo(scale);
+ drawSlow(scale);
+
+ glPopMatrix();
+ }
+ else if (!hasDefaultPos())
+ {
+ translatePosTo(scale);
+ drawSlow(scale);
+ translatePosTo(-scale);
+ }
+ else
+ {
+ drawSlow(scale);
+ }
+}
+
+void ModelPart::renderRollable(float scale)
+{
+ if (field_49)
+ return;
+
+ if (!field_48)
+ return;
+
+ if (!m_bCompiled)
+ compile(scale);
+
+ glPushMatrix();
+ translatePosTo(scale);
+
+ translateRotTo(scale);
+ draw();
+
+ glPopMatrix();
+}
+
+void ModelPart::setModel(Model* pModel)
+{
+ m_pModel = pModel;
+ pModel->m_parts.push_back(this);
+ setTexSize(pModel->m_textureWidth, pModel->m_textureHeight);
+}
+
+void ModelPart::setPos(float x, float y, float z)
+{
+ m_posX = x;
+ m_posY = y;
+ m_posZ = z;
+}
+
+void ModelPart::setTexSize(int width, int height)
+{
+ m_textureWidth = float(width);
+ m_textureHeight = float(height);
+}
+
+void ModelPart::texOffs(int a, int b)
+{
+ field_40 = a;
+ field_44 = b;
+}
+
+void ModelPart::translateTo(float scale)
+{
+ if (field_49)
+ return;
+
+ if (!field_48)
+ return;
+
+ if (!hasDefaultRot())
+ translateRotTo(scale);
+ else if (!hasDefaultPos())
+ translatePosTo(scale);
+}
+
+void ModelPart::setBrightness(float brightness)
+{
+ //no op
+}
diff --git a/source/client/model/ModelPart.hpp b/source/client/model/ModelPart.hpp
new file mode 100644
index 0000000..95baa5f
--- /dev/null
+++ b/source/client/model/ModelPart.hpp
@@ -0,0 +1,71 @@
+/********************************************************************
+ Minecraft: Pocket Edition - Decompilation Project
+ Copyright (C) 2023 iProgramInCpp
+
+ The following code is licensed under the BSD 1 clause license.
+ SPDX-License-Identifier: BSD-1-Clause
+ ********************************************************************/
+#pragma once
+
+#include
+#include "Cube.hpp"
+#include "Model.hpp"
+
+class Cube;
+class Model;
+
+class ModelPart
+{
+public:
+ ModelPart(int, int);
+ ModelPart(const std::string&);
+ ~ModelPart();
+
+ void addChild(ModelPart*);
+ void addBox(float a, float b, float c, int d, int e, int f, float g = 0);
+ void addBox(const std::string& id, float a, float b, float c, int d, int e, int f, float g = 0);
+ void clear();
+ void compile(float scale);
+ void draw();
+ void drawSlow(float scale);
+ void mimic(ModelPart* pPart);
+ void render(float scale);
+ void renderHorrible(float scale);
+ void renderRollable(float scale);
+ void setModel(Model* pModel);
+ void setPos(float x, float y, float z);
+ void setTexSize(int, int);
+ void texOffs(int a, int b);
+ void translateTo(float scale);
+ void setBrightness(float brightness);
+
+private:
+ void _init();
+ bool hasDefaultPos() { return m_posX == 0 && m_posY == 0 && m_posZ == 0; }
+ bool hasDefaultRot() { return m_rotX == 0 && m_rotY == 0 && m_rotZ == 0; }
+ void translatePosTo(float scale);
+ void translateRotTo(float scale);
+
+public:
+ float m_posX;
+ float m_posY;
+ float m_posZ;
+ float m_rotX;
+ float m_rotY;
+ float m_rotZ;
+ bool field_18;
+ std::vector m_pCubes;
+ std::vector m_pChildren;
+ std::string field_34;
+ float m_textureWidth;
+ float m_textureHeight;
+ int field_40;
+ int field_44;
+ bool field_48;
+ bool field_49;
+ bool m_bCompiled;
+ int field_4C;
+ GLuint m_buffer;
+ Model* m_pModel;
+};
+
diff --git a/source/client/model/QuadrupedModel.cpp b/source/client/model/QuadrupedModel.cpp
new file mode 100644
index 0000000..efecfb8
--- /dev/null
+++ b/source/client/model/QuadrupedModel.cpp
@@ -0,0 +1,7 @@
+/********************************************************************
+ Minecraft: Pocket Edition - Decompilation Project
+ Copyright (C) 2023 iProgramInCpp
+
+ The following code is licensed under the BSD 1 clause license.
+ SPDX-License-Identifier: BSD-1-Clause
+ ********************************************************************/
diff --git a/source/client/model/QuadrupedModel.hpp b/source/client/model/QuadrupedModel.hpp
new file mode 100644
index 0000000..efecfb8
--- /dev/null
+++ b/source/client/model/QuadrupedModel.hpp
@@ -0,0 +1,7 @@
+/********************************************************************
+ Minecraft: Pocket Edition - Decompilation Project
+ Copyright (C) 2023 iProgramInCpp
+
+ The following code is licensed under the BSD 1 clause license.
+ SPDX-License-Identifier: BSD-1-Clause
+ ********************************************************************/
diff --git a/source/client/renderer/entity/EntityRenderDispatcher.cpp b/source/client/renderer/entity/EntityRenderDispatcher.cpp
index c5fac5c..d3e4c84 100644
--- a/source/client/renderer/entity/EntityRenderDispatcher.cpp
+++ b/source/client/renderer/entity/EntityRenderDispatcher.cpp
@@ -123,9 +123,9 @@ void EntityRenderDispatcher::render(Entity* entity, float a, float b, float c, f
{
#ifndef ORIGINAL_CODE
if (pRenderer == &m_HumanoidMobRenderer)
- m_HumanoidMobRenderer.m_pHumanoidModel->field_10BE = entity->isSneaking();
+ m_HumanoidMobRenderer.m_pHumanoidModel->m_bSneaking = entity->isSneaking();
else
- m_HumanoidMobRenderer.m_pHumanoidModel->field_10BE = false;
+ m_HumanoidMobRenderer.m_pHumanoidModel->m_bSneaking = false;
#endif
pRenderer->render(entity, a, b, c, d, e);
diff --git a/source/client/renderer/entity/HumanoidMobRenderer.cpp b/source/client/renderer/entity/HumanoidMobRenderer.cpp
index 9ce347e..ebf4f28 100644
--- a/source/client/renderer/entity/HumanoidMobRenderer.cpp
+++ b/source/client/renderer/entity/HumanoidMobRenderer.cpp
@@ -30,7 +30,7 @@ void HumanoidMobRenderer::additionalRendering(Mob* mob, float f)
ItemInstance inst(itemID, 1, 0);
glPushMatrix();
- m_pHumanoidModel->m_armL.translateTo(0.0625f);
+ m_pHumanoidModel->m_arm1.translateTo(0.0625f);
glTranslatef(-0.0625f, 0.4375f, 0.0625f);
if (itemID <= C_MAX_TILES && TileRenderer::canRender(Tile::tiles[itemID]->getRenderShape()))
{
@@ -69,5 +69,5 @@ 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);
+ m_pHumanoidModel->m_arm1.render(0.0625f);
}
diff --git a/source/client/renderer/entity/TripodCameraRenderer.cpp b/source/client/renderer/entity/TripodCameraRenderer.cpp
index 6c28561..df4a651 100644
--- a/source/client/renderer/entity/TripodCameraRenderer.cpp
+++ b/source/client/renderer/entity/TripodCameraRenderer.cpp
@@ -11,10 +11,10 @@
TripodCameraRenderer::TripodCameraRenderer() :
m_tile(),
- m_cube(0, 0)
+ m_modelPart(0, 0)
{
- m_cube.addBox(-4.0f, -4.0f, -6.0f, 8, 8, 10);
- m_cube.m_posY = 11.0f;
+ m_modelPart.addBox(-4.0f, -4.0f, -6.0f, 8, 8, 10);
+ m_modelPart.m_posY = 11.0f;
field_4 = 0.5f;
}
@@ -30,8 +30,8 @@ void TripodCameraRenderer::render(Entity* entity, float x, float y, float z, flo
{
glPushMatrix();
glTranslatef(x, y, z);
- m_cube.m_rotX = 0.017453f * (180.0f + 0.5f * entity->m_pitch);
- m_cube.m_rotY = -0.017453f * entity->m_yaw;
+ m_modelPart.m_rotX = 0.017453f * (180.0f + 0.5f * entity->m_pitch);
+ m_modelPart.m_rotY = -0.017453f * entity->m_yaw;
Tesselator& t = Tesselator::instance;
t.color(1.0f, 1.0f, 1.0f);
@@ -45,8 +45,8 @@ void TripodCameraRenderer::render(Entity* entity, float x, float y, float z, flo
t.draw();
bindTexture("item/camera.png");
- m_cube.setBrightness(brightness);
- m_cube.render(0.0625f);
+ m_modelPart.setBrightness(brightness);
+ m_modelPart.render(0.0625f);
Entity* pHREntity = m_pDispatcher->m_pMinecraft->m_hitResult.m_pEnt;
@@ -64,7 +64,7 @@ void TripodCameraRenderer::render(Entity* entity, float x, float y, float z, flo
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// @TODO FIX: With ENH_ENTITY_SHADING on, the cube is fully opaque.
glColor4f(0.5f, 0.5f, 0.5f, 0.5f);
- m_cube.render(0.0625f);
+ m_modelPart.renderHorrible(0.0625f);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glDisable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
diff --git a/source/client/renderer/entity/TripodCameraRenderer.hpp b/source/client/renderer/entity/TripodCameraRenderer.hpp
index 4108a68..16246b8 100644
--- a/source/client/renderer/entity/TripodCameraRenderer.hpp
+++ b/source/client/renderer/entity/TripodCameraRenderer.hpp
@@ -32,6 +32,6 @@ public:
public:
TileRenderer m_renderer;
TripodTile m_tile;
- Cube m_cube;
+ ModelPart m_modelPart;
};