the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "..\Minecraft.World\net.minecraft.world.entity.ambient.h"
3#include "BatModel.h"
4#include "ModelPart.h"
5
6BatModel::BatModel() : Model()
7{
8 texWidth = 64;
9 texHeight = 64;
10
11 head = new ModelPart(this, 0, 0);
12 head->addBox(-3, -3, -3, 6, 6, 6);
13
14 ModelPart *rightEar = new ModelPart(this, 24, 0);
15 rightEar->addBox(-4, -6, -2, 3, 4, 1);
16 head->addChild(rightEar);
17 ModelPart *leftEar = new ModelPart(this, 24, 0);
18 leftEar->bMirror = true;
19 leftEar->addBox(1, -6, -2, 3, 4, 1);
20 head->addChild(leftEar);
21
22 body = new ModelPart(this, 0, 16);
23 body->addBox(-3, 4, -3, 6, 12, 6);
24 body->texOffs(0, 34)->addBox(-5, 16, 0, 10, 6, 1);
25
26 rightWing = new ModelPart(this, 42, 0);
27 rightWing->addBox(-12, 1, 1.5f, 10, 16, 1);
28 rightWingTip = new ModelPart(this, 24, 16);
29 rightWingTip->setPos(-12, 1, 1.5f);
30 rightWingTip->addBox(-8, 1, 0, 8, 12, 1);
31
32 leftWing = new ModelPart(this, 42, 0);
33 leftWing->bMirror = true;
34 leftWing->addBox(2, 1, 1.5f, 10, 16, 1);
35 leftWingTip = new ModelPart(this, 24, 16);
36 leftWingTip->bMirror = true;
37 leftWingTip->setPos(12, 1, 1.5f);
38 leftWingTip->addBox(0, 1, 0, 8, 12, 1);
39
40 body->addChild(rightWing);
41 body->addChild(leftWing);
42 rightWing->addChild(rightWingTip);
43 leftWing->addChild(leftWingTip);
44
45 // 4J added - compile now to avoid random performance hit first time cubes are rendered
46 // 4J Stu - Not just performance, but alpha+depth tests don't work right unless we compile here
47 head->compile(1.0f/16.0f);
48 body->compile(1.0f/16.0f);
49 rightWing->compile(1.0f/16.0f);
50 leftWing->compile(1.0f/16.0f);
51 rightWingTip->compile(1.0f/16.0f);
52 leftWingTip->compile(1.0f/16.0f);
53 rightEar->compile(1.0f/16.0f);
54 leftEar->compile(1.0f/16.0f);
55}
56
57int BatModel::modelVersion()
58{
59 return 36;
60}
61
62void BatModel::render(shared_ptr<Entity> entity, float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled)
63{
64 shared_ptr<Bat> bat = dynamic_pointer_cast<Bat>(entity);
65 if (bat->isResting())
66 {
67 float rad = 180 / PI;
68 head->xRot = xRot / rad;
69 head->yRot = PI - yRot / rad;
70 head->zRot = PI;
71
72 head->setPos(0, -2, 0);
73 rightWing->setPos(-3, 0, 3);
74 leftWing->setPos(3, 0, 3);
75
76 body->xRot = PI;
77
78 rightWing->xRot = -PI * .05f;
79 rightWing->yRot = -PI * .40f;
80 rightWingTip->yRot = -PI * .55f;
81 leftWing->xRot = rightWing->xRot;
82 leftWing->yRot = -rightWing->yRot;
83 leftWingTip->yRot = -rightWingTip->yRot;
84 }
85 else
86 {
87 float rad = 180 / PI;
88 head->xRot = xRot / rad;
89 head->yRot = yRot / rad;
90 head->zRot = 0;
91
92 head->setPos(0, 0, 0);
93 rightWing->setPos(0, 0, 0);
94 leftWing->setPos(0, 0, 0);
95
96 body->xRot = PI * .25f + cos(bob * .1f) * .15f;
97 body->yRot = 0;
98
99 rightWing->yRot = cos(bob * 1.3f) * PI * .25f;
100 leftWing->yRot = -rightWing->yRot;
101 rightWingTip->yRot = rightWing->yRot * .5f;
102 leftWingTip->yRot = -rightWing->yRot * .5f;
103 }
104
105 head->render(scale, usecompiled);
106 body->render(scale, usecompiled);
107}