the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 83 lines 2.7 kB view raw
1#include "stdafx.h" 2#include "VillagerModel.h" 3#include "..\Minecraft.World\Mth.h" 4#include "ModelPart.h" 5 6 7void VillagerModel::_init(float g, float yOffset, int xTexSize, int yTexSize) 8{ 9 head = (new ModelPart(this))->setTexSize(xTexSize, yTexSize); 10 head->setPos(0, 0 + yOffset, 0); 11 head->texOffs(0, 0)->addBox(-4, -10, -4, 8, 10, 8, g); 12 13 nose = (new ModelPart(this))->setTexSize(xTexSize, yTexSize); 14 nose->setPos(0, yOffset - 2, 0); 15 nose->texOffs(24, 0)->addBox(-1, -1, -6, 2, 4, 2, g); 16 head->addChild(nose); 17 18 body = (new ModelPart(this))->setTexSize(xTexSize, yTexSize); 19 body->setPos(0, 0 + yOffset, 0); 20 body->texOffs(16, 20)->addBox(-4, 0, -3, 8, 12, 6, g); 21 body->texOffs(0, 38)->addBox(-4, 0, -3, 8, 18, 6, g + 0.5f); 22 23 arms = (new ModelPart(this))->setTexSize(xTexSize, yTexSize); 24 arms->setPos(0, 0 + yOffset + 2, 0); 25 arms->texOffs(44, 22)->addBox(-6 - 2, -2, -2, 4, 8, 4, g); 26 arms->texOffs(44, 22)->addBox(6 - 2, -2, -2, 4, 8, 4, g); 27 arms->texOffs(40, 38)->addBox(-4, 2, -2, 8, 4, 4, g); 28 29 leg0 = (new ModelPart(this, 0, 22))->setTexSize(xTexSize, yTexSize); 30 leg0->setPos(-2, 12 + yOffset, 0); 31 leg0->addBox(-2, 0, -2, 4, 12, 4, g); // Leg0 32 33 leg1 = (new ModelPart(this, 0, 22))->setTexSize(xTexSize, yTexSize); 34 leg1->bMirror = true; 35 leg1->setPos(2, 12 + yOffset, 0); 36 leg1->addBox(-2, 0, -2, 4, 12, 4, g); // Leg1 37 38 // 4J added - compile now to avoid random performance hit first time cubes are rendered 39 // 4J Stu - Not just performance, but alpha+depth tests don't work right unless we compile here 40 41 head->compile(1.0f/16.0f); 42 body->compile(1.0f/16.0f); 43 arms->compile(1.0f/16.0f); 44 leg0->compile(1.0f/16.0f); 45 leg1->compile(1.0f/16.0f); 46} 47 48VillagerModel::VillagerModel(float g) : Model() 49{ 50 _init(g, 0, 64, 64); 51} 52 53VillagerModel::VillagerModel(float g, float yOffset, int xTexSize, int yTexSize) : Model() 54{ 55 _init(g, yOffset, xTexSize, yTexSize); 56} 57 58void VillagerModel::render(shared_ptr<Entity> entity, float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled) 59{ 60 setupAnim(time, r, bob, yRot, xRot, scale, entity); 61 62 head->render(scale,usecompiled); 63 body->render(scale,usecompiled); 64 leg0->render(scale,usecompiled); 65 leg1->render(scale,usecompiled); 66 arms->render(scale,usecompiled); 67} 68 69void VillagerModel::setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, shared_ptr<Entity> entity, unsigned int uiBitmaskOverrideAnim) 70{ 71 head->yRot = yRot / (float) (180 / PI); 72 head->xRot = xRot / (float) (180 / PI); 73 74 arms->y = 3; 75 arms->z = -1; 76 arms->xRot = -0.75f; 77 78 leg0->xRot = ((float) Mth::cos(time * 0.6662f) * 1.4f) * r * 0.5f; 79 leg1->xRot = ((float) Mth::cos(time * 0.6662f + PI) * 1.4f) * r * 0.5f; 80 leg0->yRot = 0; 81 leg1->yRot = 0; 82} 83