From 3c433c28581b862cbf0a8dac2631e0a77195ca53 Mon Sep 17 00:00:00 2001 From: iProgramInCpp Date: Tue, 5 Dec 2023 21:50:03 +0200 Subject: [PATCH] * Add ChickenRenderer --- source/client/model/ChickenModel.cpp | 109 ++++++++++++++++++ source/client/model/ChickenModel.hpp | 30 +++++ .../renderer/entity/ChickenRenderer.cpp | 22 ++++ .../renderer/entity/ChickenRenderer.hpp | 18 +++ .../entity/EntityRenderDispatcher.cpp | 7 +- .../entity/EntityRenderDispatcher.hpp | 3 +- 6 files changed, 187 insertions(+), 2 deletions(-) diff --git a/source/client/model/ChickenModel.cpp b/source/client/model/ChickenModel.cpp index e69de29..964d644 100644 --- a/source/client/model/ChickenModel.cpp +++ b/source/client/model/ChickenModel.cpp @@ -0,0 +1,109 @@ +/******************************************************************** + 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 "ChickenModel.hpp" +#include "common/Mth.hpp" + +ChickenModel::ChickenModel() : + Model(64, 32), + m_head(0, 0), + m_unknown(0, 0), + m_body(0, 9), + m_leg1(26, 0), + m_leg2(26, 0), + m_wing1(24, 13), + m_wing2(24, 13), + m_beak(14, 0), + m_wattle(14, 4) // Yes, it's called a wattle. Look it up. +{ + m_head.setModel(this); + m_beak.setModel(this); + m_wattle.setModel(this); + m_body.setModel(this); + m_leg1.setModel(this); + m_leg2.setModel(this); + m_wing1.setModel(this); + m_wing2.setModel(this); + + m_head.addBox(-2, -6, -2, 4, 6, 3); + m_head.setPos(0, 15, -4); + m_beak.addBox(-2, -4, -4, 4, 2, 2, 0); + m_beak.setPos(0, 15, -4); + m_wattle.addBox(-1, -2, -3, 2, 2, 2, 0); + m_wattle.setPos(0, 15, -4); + m_body.addBox(-3, -4, -3, 6, 8, 6, 0); + m_body.setPos(0, 16, 0); + m_leg1.addBox(-1, 0, -3, 3, 5, 3); + m_leg1.setPos(-2, 19, 1); + m_leg2.addBox(-1, 0, -3, 3, 5, 3); + m_leg2.setPos(1, 19, 1); + m_wing1.addBox(0, 0, -3, 1, 4, 6); + m_wing1.setPos(-4, 13, 0); + m_wing2.addBox(-1, 0, -3, 1, 4, 6); + m_wing2.setPos(4, 13, 0); +} + +ChickenModel::~ChickenModel() +{ +} + +void ChickenModel::render(float a, float b, float c, float d, float e, float f) +{ + setupAnim(a, b, c, d, e, f); + + if (m_bIsBaby) + { + glPushMatrix(); + glTranslatef(0.0f, f * 5.0f, f * 2.0f); + m_head.render(f); + m_beak.render(f); + m_wattle.render(f); + glPopMatrix(); + glPushMatrix(); + glScalef(0.5f, 0.5f, 0.5f); + glTranslatef(0.0f, f * 24.0f, 0.0f); + m_body.render(f); + m_leg1.render(f); + m_leg2.render(f); + m_wing1.render(f); + m_wing2.render(f); + glPopMatrix(); + } + else + { + m_head.render(f); + m_beak.render(f); + m_wattle.render(f); + m_body.render(f); + m_leg1.render(f); + m_leg2.render(f); + m_wing1.render(f); + m_wing2.render(f); + } +} + +void ChickenModel::setupAnim(float a, float b, float c, float d, float e, float f) +{ + // TODO: Why do I need to invert the rotation again? + float rotX = e / (float)(-180.0f / 3.1416f); + m_head.m_rotX = -rotX; + m_beak.m_rotX = -rotX; + m_wattle.m_rotX = -rotX; + + float rotY = d / (float)(180.0f / 3.1416f); + m_head.m_rotY = rotY; + m_beak.m_rotY = rotY; + m_wattle.m_rotY = rotY; + + m_body.m_rotX = 90.0f / (float)(180.0f / 3.1416f); + m_wing1.m_rotZ = c; + m_wing2.m_rotZ = -c; + + float footAng = (Mth::cos(a * 0.6662f) * 1.4f) * b; + m_leg1.m_rotX = footAng; + m_leg2.m_rotX = -footAng; +} \ No newline at end of file diff --git a/source/client/model/ChickenModel.hpp b/source/client/model/ChickenModel.hpp index e69de29..0027ed7 100644 --- a/source/client/model/ChickenModel.hpp +++ b/source/client/model/ChickenModel.hpp @@ -0,0 +1,30 @@ +/******************************************************************** + 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 ChickenModel : public Model +{ +public: + ChickenModel(); + ~ChickenModel(); + void render(float, float, float, float, float, float) override; + void setupAnim(float, float, float, float, float, float) override; + +private: + ModelPart m_head; + ModelPart m_unknown; + ModelPart m_body; + ModelPart m_leg1; + ModelPart m_leg2; + ModelPart m_wing1; + ModelPart m_wing2; + ModelPart m_beak; + ModelPart m_wattle; +}; diff --git a/source/client/renderer/entity/ChickenRenderer.cpp b/source/client/renderer/entity/ChickenRenderer.cpp index e69de29..3e62df4 100644 --- a/source/client/renderer/entity/ChickenRenderer.cpp +++ b/source/client/renderer/entity/ChickenRenderer.cpp @@ -0,0 +1,22 @@ +/******************************************************************** + 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 "ChickenRenderer.hpp" + +ChickenRenderer::ChickenRenderer(Model* pModel, float f) : MobRenderer(pModel, f) +{ +} + +ChickenRenderer::~ChickenRenderer() +{ +} + +float ChickenRenderer::getBob(Mob*, float) +{ + // TODO + return 0.0f; +} diff --git a/source/client/renderer/entity/ChickenRenderer.hpp b/source/client/renderer/entity/ChickenRenderer.hpp index e69de29..ebf0f10 100644 --- a/source/client/renderer/entity/ChickenRenderer.hpp +++ b/source/client/renderer/entity/ChickenRenderer.hpp @@ -0,0 +1,18 @@ +/******************************************************************** + 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 "MobRenderer.hpp" + +class ChickenRenderer : public MobRenderer +{ +public: + ChickenRenderer(Model*, float); + ~ChickenRenderer(); + float getBob(Mob*, float); +}; diff --git a/source/client/renderer/entity/EntityRenderDispatcher.cpp b/source/client/renderer/entity/EntityRenderDispatcher.cpp index 37f0fb6..9b644ec 100644 --- a/source/client/renderer/entity/EntityRenderDispatcher.cpp +++ b/source/client/renderer/entity/EntityRenderDispatcher.cpp @@ -12,6 +12,7 @@ #include "client/model/PigModel.hpp" #include "client/model/CowModel.hpp" +#include "client/model/ChickenModel.hpp" EntityRenderDispatcher* EntityRenderDispatcher::instance; float EntityRenderDispatcher::xOff, EntityRenderDispatcher::yOff, EntityRenderDispatcher::zOff; @@ -19,7 +20,8 @@ float EntityRenderDispatcher::xOff, EntityRenderDispatcher::yOff, EntityRenderDi EntityRenderDispatcher::EntityRenderDispatcher() : m_HumanoidMobRenderer(new HumanoidModel(0.0f, 0.0f), 0.0f), m_PigRenderer(new PigModel(0.0f), 0.0f), - m_CowRenderer(new CowModel, 0.0f) + m_CowRenderer(new CowModel, 0.0f), + m_ChickenRenderer(new ChickenModel, 0.0f) { m_pItemInHandRenderer = nullptr; m_pTextures = nullptr; @@ -34,6 +36,7 @@ EntityRenderDispatcher::EntityRenderDispatcher() : m_HumanoidMobRenderer.init(this); m_PigRenderer.init(this); m_CowRenderer.init(this); + m_ChickenRenderer.init(this); // TODO @@ -80,6 +83,8 @@ EntityRenderer* EntityRenderDispatcher::getRenderer(int renderType) return &m_ItemRenderer; case RENDER_CAMERA: return &m_CameraRenderer; + case RENDER_CHICKEN: + return &m_ChickenRenderer; case RENDER_COW: return &m_CowRenderer; case RENDER_PIG: diff --git a/source/client/renderer/entity/EntityRenderDispatcher.hpp b/source/client/renderer/entity/EntityRenderDispatcher.hpp index 0aa139b..5dd58c9 100644 --- a/source/client/renderer/entity/EntityRenderDispatcher.hpp +++ b/source/client/renderer/entity/EntityRenderDispatcher.hpp @@ -16,6 +16,7 @@ #include "FallingTileRenderer.hpp" #include "PigRenderer.hpp" #include "CowRenderer.hpp" +#include "ChickenRenderer.hpp" class Minecraft; class Font; @@ -46,7 +47,7 @@ public: HumanoidMobRenderer m_HumanoidMobRenderer; PigRenderer m_PigRenderer; CowRenderer m_CowRenderer; - //ChickenRenderer m_ChickenRenderer; + ChickenRenderer m_ChickenRenderer; TntRenderer m_TntRenderer; //padding?? ItemRenderer m_ItemRenderer;