mirror of
https://github.com/celisej567/mcpe.git
synced 2026-09-17 20:10:23 +03:00
migrate ALMOST everything from source tree into client
This commit is contained in:
231
source/client/model/Cube.cpp
Normal file
231
source/client/model/Cube.cpp
Normal file
@@ -0,0 +1,231 @@
|
||||
/********************************************************************
|
||||
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 "Cube.hpp"
|
||||
|
||||
float Cube::c = 180.0f / float(M_PI);
|
||||
|
||||
Cube::Cube(int a, int b)
|
||||
{
|
||||
field_2B4 = a;
|
||||
field_2B8 = b;
|
||||
}
|
||||
|
||||
void Cube::addBox(float a, float b, float c, int d, int e, int f)
|
||||
{
|
||||
addBox(a, b, c, d, e, f, 0.0f);
|
||||
}
|
||||
|
||||
void Cube::addBox(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);
|
||||
x1 -= g;
|
||||
y1 -= g;
|
||||
z1 -= g;
|
||||
x2 += 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);
|
||||
m_verts[3] = VertexPT(x1, y2, z1, 8.0f, 0.0f);
|
||||
m_verts[4] = VertexPT(x1, y1, z2, 0.0f, 0.0f);
|
||||
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;
|
||||
|
||||
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
|
||||
m_faces[2] = PolygonQuad(&m_verts[5], &m_verts[4], &m_verts[0], &m_verts[1], m + f, n, m + f + d, n + f); // up face
|
||||
m_faces[3] = PolygonQuad(&m_verts[2], &m_verts[3], &m_verts[7], &m_verts[6], m + f + d, n, m + f + d + d, n + f); // down face
|
||||
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)
|
||||
{
|
||||
for (int i = 0; i < 6; i++)
|
||||
m_faces[i].mirror();
|
||||
}
|
||||
}
|
||||
|
||||
void Cube::compile(float f)
|
||||
{
|
||||
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, f, m_buffer);
|
||||
|
||||
t.end(m_buffer);
|
||||
m_bCompiled = true;
|
||||
}
|
||||
|
||||
void Cube::draw()
|
||||
{
|
||||
#ifdef ENH_ENTITY_SHADING
|
||||
drawArrayVTC(m_buffer, 36, sizeof(Tesselator::Vertex));
|
||||
#else
|
||||
drawArrayVT(m_buffer, 36, sizeof(Tesselator::Vertex));
|
||||
#endif
|
||||
}
|
||||
|
||||
void Cube::drawSlow(float f)
|
||||
{
|
||||
Tesselator& t = Tesselator::instance;
|
||||
t.begin();
|
||||
|
||||
for (int i = 0; i < 6; i++)
|
||||
m_faces[i].render(t, f, m_buffer);
|
||||
|
||||
t.draw();
|
||||
}
|
||||
|
||||
void Cube::render(float f)
|
||||
{
|
||||
if (field_1A)
|
||||
return;
|
||||
|
||||
if (!field_19)
|
||||
return;
|
||||
|
||||
if (!m_bCompiled)
|
||||
compile(f);
|
||||
|
||||
if (field_C == 0.0f && field_10 == 0.0f && field_14 == 0.0f)
|
||||
{
|
||||
if (m_posX == 0.0f && m_posY == 0 && m_posZ == 0)
|
||||
{
|
||||
draw();
|
||||
return;
|
||||
}
|
||||
|
||||
glTranslatef( m_posX * f, m_posY * f, m_posZ * f);
|
||||
draw();
|
||||
glTranslatef(-m_posX * f, -m_posY * f, -m_posZ * f);
|
||||
return;
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
glTranslatef(m_posX * f, m_posY * f, m_posZ * f);
|
||||
if (field_14 != 0.0f) glRotatef(field_14 * c, 0.0f, 0.0f, 1.0f);
|
||||
if (field_10 != 0.0f) glRotatef(field_10 * c, 0.0f, 1.0f, 0.0f);
|
||||
if (field_C != 0.0f) glRotatef(field_C * c, 1.0f, 0.0f, 0.0f);
|
||||
draw();
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void Cube::renderRollable(float f)
|
||||
{
|
||||
if (field_1A)
|
||||
return;
|
||||
|
||||
if (!field_19)
|
||||
return;
|
||||
|
||||
if (!m_bCompiled)
|
||||
compile(f);
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
glTranslatef(m_posX * f, m_posY * f, m_posZ * f);
|
||||
if (field_14 != 0.0f) glRotatef(field_14 * c, 0.0f, 0.0f, 1.0f);
|
||||
if (field_10 != 0.0f) glRotatef(field_10 * c, 0.0f, 1.0f, 0.0f);
|
||||
if (field_C != 0.0f) glRotatef(field_C * c, 1.0f, 0.0f, 0.0f);
|
||||
draw();
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void Cube::renderHorrible(float f)
|
||||
{
|
||||
if (field_1A)
|
||||
return;
|
||||
|
||||
if (!field_19)
|
||||
return;
|
||||
|
||||
if (field_C == 0.0f && field_10 == 0.0f && field_14 == 0.0f)
|
||||
{
|
||||
if (m_posX == 0.0f && m_posY == 0 && m_posZ == 0)
|
||||
{
|
||||
drawSlow(f);
|
||||
return;
|
||||
}
|
||||
|
||||
glTranslatef( m_posX * f, m_posY * f, m_posZ * f);
|
||||
drawSlow(f);
|
||||
glTranslatef(-m_posX * f, -m_posY * f, -m_posZ * f);
|
||||
return;
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
|
||||
glTranslatef(m_posX * f, m_posY * f, m_posZ * f);
|
||||
if (field_14 != 0.0f) glRotatef(field_14 * c, 0.0f, 0.0f, 1.0f);
|
||||
if (field_10 != 0.0f) glRotatef(field_10 * c, 0.0f, 1.0f, 0.0f);
|
||||
if (field_C != 0.0f) glRotatef(field_C * c, 1.0f, 0.0f, 0.0f);
|
||||
drawSlow(f);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void Cube::translateTo(float f)
|
||||
{
|
||||
if (field_1A)
|
||||
return;
|
||||
|
||||
if (!field_19)
|
||||
return;
|
||||
|
||||
if (field_C == 0.0f && field_10 == 0.0f && field_14 == 0.0f)
|
||||
{
|
||||
if (m_posX == 0.0f && m_posY == 0 && m_posZ == 0)
|
||||
return;
|
||||
|
||||
glTranslatef( m_posX * f, m_posY * f, m_posZ * f);
|
||||
return;
|
||||
}
|
||||
|
||||
glTranslatef(m_posX * f, m_posY * f, m_posZ * f);
|
||||
if (field_14 != 0.0f) glRotatef(field_14 * c, 0.0f, 0.0f, 1.0f);
|
||||
if (field_10 != 0.0f) glRotatef(field_10 * c, 0.0f, 1.0f, 0.0f);
|
||||
if (field_C != 0.0f) glRotatef(field_C * c, 1.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
51
source/client/model/Cube.hpp
Normal file
51
source/client/model/Cube.hpp
Normal file
@@ -0,0 +1,51 @@
|
||||
/********************************************************************
|
||||
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 "PolygonQuad.hpp"
|
||||
|
||||
class Cube
|
||||
{
|
||||
public:
|
||||
Cube(int, int);
|
||||
|
||||
void addBox(float a, float b, float c, int d, int e, int f);
|
||||
void addBox(float a, float b, float c, int d, int e, int f, float g);
|
||||
// @TODO: void addTexBox(float a, float b, float c, int d, int e, int f, int g); -- No xrefs
|
||||
void compile(float f);
|
||||
void draw();
|
||||
void drawSlow(float f);
|
||||
void render(float f);
|
||||
void renderHorrible(float f);
|
||||
void renderRollable(float f);
|
||||
void setPos(float x, float y, float z);
|
||||
void setTexOffs(int a, int b);
|
||||
void translateTo(float f);
|
||||
|
||||
public:
|
||||
float m_posX = 0.0f;
|
||||
float m_posY = 0.0f;
|
||||
float m_posZ = 0.0f;
|
||||
float field_C = 0.0f;
|
||||
float field_10 = 0.0f;
|
||||
float field_14 = 0.0f;
|
||||
bool field_18 = false;
|
||||
bool field_19 = true;
|
||||
bool field_1A = false;
|
||||
VertexPT m_verts[8];
|
||||
PolygonQuad m_faces[6];
|
||||
int field_2B4 = 0;
|
||||
int field_2B8 = 0;
|
||||
bool m_bCompiled = false;
|
||||
int field_2C0 = 0;
|
||||
GLuint m_buffer = 0;
|
||||
|
||||
static float c;
|
||||
};
|
||||
|
||||
268
source/client/model/HumanoidModel.cpp
Normal file
268
source/client/model/HumanoidModel.cpp
Normal file
@@ -0,0 +1,268 @@
|
||||
/********************************************************************
|
||||
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 "HumanoidModel.hpp"
|
||||
#include "Minecraft.hpp"
|
||||
|
||||
HumanoidModel::HumanoidModel(float a, float b):
|
||||
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_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);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
void HumanoidModel::renderHorrible(float a, float b, float c, float d, float e, float f)
|
||||
{
|
||||
setupAnim(a, b, c, d, e, f);
|
||||
m_head.renderHorrible(f);
|
||||
m_body.renderHorrible(f);
|
||||
m_armL.renderHorrible(f);
|
||||
m_armR.renderHorrible(f);
|
||||
m_legL.renderHorrible(f);
|
||||
m_legR.renderHorrible(f);
|
||||
_logGraphics();
|
||||
}
|
||||
|
||||
void HumanoidModel::setupAnim(float a2, float a3, float a4, float a5, float a6, float a7)
|
||||
{
|
||||
//a6 = pitch, a5 = yaw-ish
|
||||
m_head.field_10 = a5 * 0.017453f;
|
||||
m_head.field_C = a6 * 0.017453f;
|
||||
if (m_head.field_C < -1.0f)
|
||||
m_head.field_C = -1.0f;
|
||||
if (m_head.field_C > 1.0f)
|
||||
m_head.field_C = 1.0f;
|
||||
float v12 = (a2 * 0.6662f) + 3.1416f;
|
||||
m_armL.field_C = (Mth::cos(v12) * 2.0f * a3) * 0.5f;
|
||||
m_armR.field_C = Mth::cos(a2 * 0.6662f) * 2.0f * a3 * 0.5f; // @HUH: multiplying by 2 and also by 1/2
|
||||
m_armL.field_14 = 0.0f;
|
||||
m_armR.field_14 = 0.0f;
|
||||
m_legL.field_C = (Mth::cos(a2 * 0.6662f) * 1.4f) * a3;
|
||||
m_legR.field_C = (Mth::cos(v12) * 1.4f) * a3;
|
||||
m_legL.field_10 = 0.0f;
|
||||
m_legR.field_10 = 0.0f;
|
||||
|
||||
if (field_8)
|
||||
{
|
||||
float v15 = (3.1416f * -0.5f) * 0.4f;
|
||||
m_armL.field_C += v15;
|
||||
m_armR.field_C += v15;
|
||||
float v16 = (3.1416f * -0.5f) * 0.8f;
|
||||
m_legL.field_C = v16;
|
||||
m_legR.field_C = v16;
|
||||
m_legL.field_10 = (3.1416f * 0.5f) * 0.2f;
|
||||
m_legR.field_10 = (3.1416f * -0.5f) * 0.2f;
|
||||
}
|
||||
|
||||
if (field_10BC)
|
||||
m_armR.field_C = ((3.1416f * 0.5f) * -0.2f) + (m_armR.field_C * 0.5f);
|
||||
if (field_10BD)
|
||||
m_armL.field_C = ((3.1416f * 0.5f) * -0.2f) + (m_armL.field_C * 0.5f);
|
||||
|
||||
m_armL.field_10 = 0.0f;
|
||||
m_armR.field_10 = 0.0f;
|
||||
|
||||
if (field_4 > -9990.0f)
|
||||
{
|
||||
m_body.field_10 = Mth::sin(Mth::sqrt(field_4) * 3.1416f * 2.0f) * 0.2f;
|
||||
m_armL.m_posZ = 5.0f * Mth::sin(m_body.field_10);
|
||||
m_armL.m_posX = -5.0f * Mth::cos(m_body.field_10);
|
||||
m_armR.m_posZ = -5.0f * Mth::sin(m_body.field_10);
|
||||
m_armR.m_posX = 5.0f * Mth::cos(m_body.field_10);
|
||||
m_armL.field_10 = m_armL.field_10 + m_body.field_10;
|
||||
m_armR.field_10 = m_armR.field_10 + m_body.field_10;
|
||||
float o = 1.0f - field_4;
|
||||
m_armR.field_C += m_body.field_10;
|
||||
m_armL.field_C -= -((m_head.field_C - 0.7f) * Mth::sin(3.1416f * field_4)) * 0.75f + Mth::sin((1.0f - o * o * o * o) * 3.1416f) * 1.2f;
|
||||
m_armL.field_10 += m_body.field_10 * 2.0f;
|
||||
m_armL.field_14 = Mth::sin(field_4 * 3.1416f) * -0.4f;
|
||||
}
|
||||
|
||||
if (field_10BE) // sneaking?
|
||||
{
|
||||
m_body.field_C = 0.5f;
|
||||
m_armL.field_C += 0.4f;
|
||||
m_armR.field_C += 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_head.m_posY = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_body.field_C = 0.0f;
|
||||
m_legL.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_armL.field_14 += Mth::cos(a4 * 0.09f) * 0.05f + 0.05f;
|
||||
m_armR.field_14 -= Mth::cos(a4 * 0.09f) * 0.05f + 0.05f;
|
||||
m_armL.field_C += Mth::sin(a4 * 0.067f) * 0.05f;
|
||||
m_armR.field_C += Mth::sin(a4 * 0.067f) * -0.05f;
|
||||
}
|
||||
|
||||
/* Keeping the original around just in case:
|
||||
|
||||
void HumanoidModel::setupAnim(float a2, float a3, float a4, float a5, float a6, float a7)
|
||||
{
|
||||
this->m_head.field_10 = a5 * 0.017453f;
|
||||
float v11 = a6 * 0.017453f;
|
||||
if ((a6 * 0.017453f) <= 1.0f)
|
||||
{
|
||||
if (v11 < -1.0f)
|
||||
v11 = -1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
v11 = 1.0f;
|
||||
}
|
||||
this->m_head.field_C = v11;
|
||||
float v12 = (a2 * 0.6662f) + 3.1416f;
|
||||
float v13 = Mth::cos(v12);
|
||||
this->m_armL.field_C = ((v13 + v13) * a3) * 0.5f;
|
||||
float v14 = Mth::cos(a2 * 0.6662f);
|
||||
this->m_armR.field_C = ((v14 + v14) * a3) * 0.5f;
|
||||
this->m_armL.field_14 = 0.0f;
|
||||
this->m_armR.field_14 = 0.0f;
|
||||
this->m_legL.field_C = (Mth::cos(a2 * 0.6662f) * 1.4f) * a3;
|
||||
this->m_legR.field_C = (Mth::cos(v12) * 1.4f) * a3;
|
||||
this->m_legL.field_10 = 0.0f;
|
||||
this->m_legR.field_10 = 0.0f;
|
||||
if (this->field_8)
|
||||
{
|
||||
float v15 = (3.1416f * -0.5f) * 0.4f;
|
||||
this->m_armL.field_C = this->m_armL.field_C + v15;
|
||||
this->m_armR.field_C = this->m_armR.field_C + v15;
|
||||
float v16 = (3.1416f * -0.5f) * 0.8f;
|
||||
this->m_legL.field_C = v16;
|
||||
this->m_legR.field_C = v16;
|
||||
this->m_legL.field_10 = (3.1416f * 0.5f) * 0.2f;
|
||||
this->m_legR.field_10 = (3.1416f * -0.5f) * 0.2f;
|
||||
}
|
||||
if (this->field_10BC)
|
||||
this->m_armR.field_C = ((3.1416f * 0.5f) * -0.2f) + (this->m_armR.field_C * 0.5f);
|
||||
if (this->field_10BD)
|
||||
this->m_armL.field_C = ((3.1416f * 0.5f) * -0.2f) + (this->m_armL.field_C * 0.5f);
|
||||
|
||||
this->m_armL.field_10 = 0.0f;
|
||||
this->m_armR.field_10 = 0.0f;
|
||||
if (field_4 > -9990.0f)
|
||||
{
|
||||
float v22 = Mth::sqrt(field_4);
|
||||
float v23 = Mth::sin((v22 * 3.1416f) + (v22 * 3.1416f));
|
||||
this->m_body.field_10 = v23 * 0.2f;
|
||||
float v24 = Mth::sin(v23 * 0.2f) * 5.0f;
|
||||
float bf10_1 = this->m_body.field_10;
|
||||
this->m_armL.m_posZ = v24;
|
||||
float v26 = Mth::cos(bf10_1) * -5.0f;
|
||||
float bf10_2 = this->m_body.field_10;
|
||||
this->m_armL.m_posX = v26;
|
||||
float v28 = Mth::sin(bf10_2) * -5.0f;
|
||||
float bf10_3 = this->m_body.field_10;
|
||||
this->m_armR.m_posZ = v28;
|
||||
this->m_armR.m_posX = Mth::cos(bf10_3) * 5.0f;
|
||||
float bf10_4 = this->m_body.field_10;
|
||||
this->m_armL.field_10 = this->m_armL.field_10 + bf10_4;
|
||||
this->m_armR.field_10 = this->m_armR.field_10 + bf10_4;
|
||||
float v31 = this->m_armR.field_C + bf10_4;
|
||||
float v32 = 1.0f - this->field_4;
|
||||
this->m_armR.field_C = v31;
|
||||
float v33 = Mth::sin((1.0f - ((v32 * v32) * (v32 * v32))) * 3.1416f);
|
||||
float v34 = Mth::sin(3.1416f * this->field_4);
|
||||
float bf10_times_2 = this->m_body.field_10 + this->m_body.field_10;
|
||||
this->m_armL.field_C = this->m_armL.field_C - ((-((this->m_head.field_C - 0.7f) * v34) * 0.75f) + (v33 * 1.2f));
|
||||
float v36 = this->m_armL.field_10 + bf10_times_2;
|
||||
float v37 = this->field_4 * 3.1416f;
|
||||
this->m_armL.field_10 = v36;
|
||||
this->m_armL.field_14 = Mth::sin(v37) * -0.4f;
|
||||
}
|
||||
if (this->field_10BE)
|
||||
{
|
||||
m_body.field_C = 0.5f;
|
||||
m_armL.field_C += 0.4f;
|
||||
m_armR.field_C += 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_head.m_posY = 1.0f;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_body.field_C = 0.0f;
|
||||
m_legL.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;
|
||||
}
|
||||
|
||||
float v18 = this->m_armL.field_14;
|
||||
this->m_armL.field_14 = v18 + ((Mth::cos(a4 * 0.09f) * 0.05f) + 0.05f);
|
||||
float v19 = this->m_armR.field_14;
|
||||
this->m_armR.field_14 = v19 - ((Mth::cos(a4 * 0.09f) * 0.05f) + 0.05f);
|
||||
float v20 = this->m_armL.field_C;
|
||||
this->m_armL.field_C = v20 + (Mth::sin(a4 * 0.067f) * 0.05f);
|
||||
float v21 = this->m_armR.field_C;
|
||||
this->m_armR.field_C = v21 + (Mth::sin(a4 * 0.067f) * -0.05f);
|
||||
}
|
||||
*/
|
||||
32
source/client/model/HumanoidModel.hpp
Normal file
32
source/client/model/HumanoidModel.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/********************************************************************
|
||||
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 "Model.hpp"
|
||||
|
||||
class HumanoidModel : public Model
|
||||
{
|
||||
public:
|
||||
HumanoidModel(float a, float b);
|
||||
void _logGraphics();
|
||||
// @TODO - No xrefs: void render(HumanoidModel* a, float f);
|
||||
|
||||
void onGraphicsReset() override;
|
||||
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;
|
||||
|
||||
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 = false;
|
||||
bool field_10BD = false;
|
||||
bool field_10BE = false;
|
||||
};
|
||||
|
||||
34
source/client/model/Model.cpp
Normal file
34
source/client/model/Model.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/********************************************************************
|
||||
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 "Model.hpp"
|
||||
|
||||
void Model::onGraphicsReset()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Model::prepareMobModel(Mob*, float, float, float)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Model::render(float, float, float, float, float, float)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Model::renderHorrible(float, float, float, float, float, float)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Model::setupAnim(float, float, float, float, float, float)
|
||||
{
|
||||
|
||||
}
|
||||
26
source/client/model/Model.hpp
Normal file
26
source/client/model/Model.hpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/********************************************************************
|
||||
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 "Cube.hpp"
|
||||
#include "Mob.hpp"
|
||||
|
||||
class Model
|
||||
{
|
||||
public:
|
||||
virtual void onGraphicsReset();
|
||||
virtual void prepareMobModel(Mob*, float, float, float);
|
||||
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);
|
||||
|
||||
public:
|
||||
float field_4 = 0.0f;
|
||||
bool field_8 = false;
|
||||
};
|
||||
75
source/client/model/PolygonQuad.cpp
Normal file
75
source/client/model/PolygonQuad.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/********************************************************************
|
||||
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 "PolygonQuad.hpp"
|
||||
|
||||
PolygonQuad::PolygonQuad(VertexPT* a, VertexPT* b, VertexPT* c, VertexPT* d)
|
||||
{
|
||||
m_verts[0] = *a;
|
||||
m_verts[1] = *b;
|
||||
m_verts[2] = *c;
|
||||
m_verts[3] = *d;
|
||||
}
|
||||
|
||||
PolygonQuad::PolygonQuad(VertexPT* a, VertexPT* b, VertexPT* c, VertexPT* d, float u1, float v1, float u2, float v2)
|
||||
{
|
||||
m_verts[0] = *a;
|
||||
m_verts[1] = *b;
|
||||
m_verts[2] = *c;
|
||||
m_verts[3] = *d;
|
||||
|
||||
m_verts[0].setUV(u2, v1);
|
||||
m_verts[1].setUV(u1, v1);
|
||||
m_verts[2].setUV(u1, v2);
|
||||
m_verts[3].setUV(u2, v2);
|
||||
}
|
||||
|
||||
PolygonQuad::PolygonQuad(VertexPT* a, VertexPT* b, VertexPT* c, VertexPT* d, int u1i, int v1i, int u2i, int v2i)
|
||||
{
|
||||
constexpr float C_F1 = 0.0015625f, C_F2 = 0.003125f;
|
||||
m_verts[0] = *a;
|
||||
m_verts[1] = *b;
|
||||
m_verts[2] = *c;
|
||||
m_verts[3] = *d;
|
||||
|
||||
m_verts[0].setUV(float(u2i) / 64.0f - C_F1, float(v1i) / 32.0f + C_F2);
|
||||
m_verts[1].setUV(float(u1i) / 64.0f + C_F1, float(v1i) / 32.0f + C_F2);
|
||||
m_verts[2].setUV(float(u1i) / 64.0f + C_F1, float(v2i) / 32.0f - C_F2);
|
||||
m_verts[3].setUV(float(u2i) / 64.0f - C_F1, float(v2i) / 32.0f - C_F2);
|
||||
}
|
||||
|
||||
void PolygonQuad::flipNormal()
|
||||
{
|
||||
m_bFlipNormals = true;
|
||||
}
|
||||
|
||||
void PolygonQuad::mirror()
|
||||
{
|
||||
std::swap(m_verts[0], m_verts[3]);
|
||||
std::swap(m_verts[1], m_verts[2]);
|
||||
}
|
||||
|
||||
void PolygonQuad::render(Tesselator& t, float scale, int unused)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
VertexPT& v = m_verts[i];
|
||||
#ifdef ENH_ENTITY_SHADING
|
||||
t.color(m_color);
|
||||
#endif
|
||||
t.vertexUV(scale * v.x, scale * v.y, scale * v.z, v.u, v.v);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENH_ENTITY_SHADING
|
||||
void PolygonQuad::setColor(float r, float g, float b)
|
||||
{
|
||||
int ru = int(255 * r), gu = int(255 * g), bu = int(255 * g);
|
||||
m_color = bu | (gu << 8) | (ru << 16);
|
||||
}
|
||||
#endif
|
||||
39
source/client/model/PolygonQuad.hpp
Normal file
39
source/client/model/PolygonQuad.hpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/********************************************************************
|
||||
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 <utility>
|
||||
#include "VertexPT.hpp"
|
||||
#include "Tesselator.hpp"
|
||||
#include "Utils.hpp" // to configure 1 thing
|
||||
|
||||
class PolygonQuad
|
||||
{
|
||||
public:
|
||||
PolygonQuad() {};
|
||||
PolygonQuad(VertexPT* a, VertexPT* b, VertexPT* c, VertexPT* d);
|
||||
PolygonQuad(VertexPT* a, VertexPT* b, VertexPT* c, VertexPT* d, float u1, float v1, float u2, float v2);
|
||||
PolygonQuad(VertexPT* a, VertexPT* b, VertexPT* c, VertexPT* d, int u1i, int v1i, int u2i, int v2i);
|
||||
|
||||
void flipNormal();
|
||||
void mirror();
|
||||
void render(Tesselator& t, float scale, int unused);
|
||||
|
||||
#ifdef ENH_ENTITY_SHADING
|
||||
void setColor(float r, float g, float b);
|
||||
#endif
|
||||
|
||||
private:
|
||||
VertexPT m_verts[4];
|
||||
bool m_bFlipNormals = false;
|
||||
|
||||
#ifdef ENH_ENTITY_SHADING
|
||||
int m_color = 0xFFFFFF;
|
||||
#endif
|
||||
};
|
||||
Reference in New Issue
Block a user