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 "ModelPart.h"
3#include "..\Minecraft.World\net.minecraft.world.entity.animal.h"
4#include "..\Minecraft.World\Mth.h"
5#include "OzelotModel.h"
6
7const float OzelotModel::xo = 0;
8const float OzelotModel::yo = 16;
9const float OzelotModel::zo = -9;
10
11const float OzelotModel::headWalkY = -1 + yo;
12const float OzelotModel::headWalkZ = 0 + zo;
13const float OzelotModel::bodyWalkY = -4 + yo;
14const float OzelotModel::bodyWalkZ = -1 + zo;
15const float OzelotModel::tail1WalkY = -1 + yo;
16const float OzelotModel::tail1WalkZ = 17 + zo;
17const float OzelotModel::tail2WalkY = 4 + yo;
18const float OzelotModel::tail2WalkZ = 23 + zo;
19const float OzelotModel::backLegY = 2.f + yo;
20const float OzelotModel::backLegZ = 14 + zo;
21const float OzelotModel::frontLegY = -2.2f + yo;
22const float OzelotModel::frontLegZ = 4.f + zo;
23
24OzelotModel::OzelotModel()
25{
26 state = WALK_STATE;
27
28 setMapTex(L"head.main", 0, 0);
29 setMapTex(L"head.nose", 0, 24);
30 setMapTex(L"head.ear1", 0, 10);
31 setMapTex(L"head.ear2", 6, 10);
32
33 head = new ModelPart(this, L"head");
34 head->addBox(L"main", -2.5f, -2, -3, 5, 4, 5);
35 head->addBox(L"nose", -1.5f, 0, -4, 3, 2, 2);
36 head->addBox(L"ear1", -2, -3, 0, 1, 1, 2);
37 head->addBox(L"ear2", 1, -3, 0, 1, 1, 2);
38 head->setPos(0 + xo, headWalkY, headWalkZ);
39
40 body = new ModelPart(this, 20, 0);
41 body->addBox(-2, 3, -8, 4, 16, 6, 0);
42 body->setPos(0 + xo, bodyWalkY, bodyWalkZ);
43
44 tail1 = new ModelPart(this, 0, 15);
45 tail1->addBox(-0.5f, 0, 0, 1, 8, 1);
46 tail1->xRot = 0.9f;
47 tail1->setPos(0 + xo, tail1WalkY, tail1WalkZ);
48
49 tail2 = new ModelPart(this, 4, 15);
50 tail2->addBox(-0.5f, 0, 0, 1, 8, 1);
51 tail2->setPos(0 + xo, tail2WalkY, tail2WalkZ);
52
53 backLegL = new ModelPart(this, 8, 13);
54 backLegL->addBox(-1, 0, 1, 2, 6, 2);
55 backLegL->setPos(1.1f + xo, backLegY, backLegZ);
56
57 backLegR = new ModelPart(this, 8, 13);
58 backLegR->addBox(-1, 0, 1, 2, 6, 2);
59 backLegR->setPos(-1.1f + xo, backLegY, backLegZ);
60
61 frontLegL = new ModelPart(this, 40, 0);
62 frontLegL->addBox(-1, 0, 0, 2, 10, 2);
63 frontLegL->setPos(1.2f + xo, frontLegY, frontLegZ);
64
65 frontLegR = new ModelPart(this, 40, 0);
66 frontLegR->addBox(-1, 0, 0, 2, 10, 2);
67 frontLegR->setPos(-1.2f + xo, frontLegY, frontLegZ);
68
69
70 // 4J added - compile now to avoid random performance hit first time cubes are rendered
71 head->compile(1.0f/16.0f);
72 body->compile(1.0f/16.0f);
73 tail1->compile(1.0f/16.0f);
74 tail2->compile(1.0f/16.0f);
75 backLegL->compile(1.0f/16.0f);
76 backLegR->compile(1.0f/16.0f);
77 backLegL->compile(1.0f/16.0f);
78 backLegR->compile(1.0f/16.0f);
79}
80
81void OzelotModel::render(shared_ptr<Entity> entity, float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled)
82{
83 setupAnim(time, r, bob, yRot, xRot, scale);
84 if (young)
85 {
86 float ss = 2.0f;
87 glPushMatrix();
88 glScalef(1.5f / ss, 1.5f / ss, 1.5f / ss);
89 glTranslatef(0, 10 * scale, 4 * scale);
90 head->render(scale, usecompiled);
91 glPopMatrix();
92 glPushMatrix();
93 glScalef(1 / ss, 1 / ss, 1 / ss);
94 glTranslatef(0, 24 * scale, 0);
95 body->render(scale, usecompiled);
96 backLegL->render(scale, usecompiled);
97 backLegR->render(scale, usecompiled);
98 frontLegL->render(scale, usecompiled);
99 frontLegR->render(scale, usecompiled);
100 tail1->render(scale, usecompiled);
101 tail2->render(scale, usecompiled);
102 glPopMatrix();
103 }
104 else
105 {
106 head->render(scale, usecompiled);
107 body->render(scale, usecompiled);
108 tail1->render(scale, usecompiled);
109 tail2->render(scale, usecompiled);
110 backLegL->render(scale, usecompiled);
111 backLegR->render(scale, usecompiled);
112 frontLegL->render(scale, usecompiled);
113 frontLegR->render(scale, usecompiled);
114 }
115}
116
117void OzelotModel::render(OzelotModel *model, float scale, bool usecompiled)
118{
119 head->yRot = model->head->yRot;
120 head->xRot = model->head->xRot;
121 head->y = model->head->y;
122 head->x = model->head->x;
123 body->yRot = model->body->yRot;
124 body->xRot = model->body->xRot;
125
126 tail1->yRot = model->body->yRot;
127 tail1->y = model->body->y;
128 tail1->x = model->body->x;
129 tail1->render(scale, usecompiled);
130
131 tail2->yRot = model->body->yRot;
132 tail2->y = model->body->y;
133 tail2->x = model->body->x;
134 tail2->render(scale, usecompiled);
135
136 backLegL->xRot = model->backLegL->xRot;
137 backLegR->xRot = model->backLegR->xRot;
138 backLegL->render(scale, usecompiled);
139 backLegR->render(scale, usecompiled);
140
141 frontLegL->xRot = model->frontLegL->xRot;
142 frontLegR->xRot = model->frontLegR->xRot;
143 frontLegL->render(scale, usecompiled);
144 frontLegR->render(scale, usecompiled);
145
146 head->render(scale, usecompiled);
147 body->render(scale, usecompiled);
148}
149
150void OzelotModel::setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, unsigned int uiBitmaskOverrideAnim)
151{
152 head->xRot = xRot / (float) (180 / PI);
153 head->yRot = yRot / (float) (180 / PI);
154
155 if (state == SITTING_STATE)
156 {
157
158 }
159 else
160 {
161 body->xRot = 90 / (float) (180 / PI);
162 if (state == SPRINT_STATE)
163 {
164 backLegL->xRot = ((float) Mth::cos(time * 0.6662f) * 1.f) * r;
165 backLegR->xRot = ((float) Mth::cos(time * 0.6662f + 0.3f) * 1.f) * r;
166 frontLegL->xRot = ((float) Mth::cos(time * 0.6662f + PI + 0.3f) * 1.f) * r;
167 frontLegR->xRot = ((float) Mth::cos(time * 0.6662f + PI) * 1.f) * r;
168 tail2->xRot = 0.55f * PI + 0.1f * PI * Mth::cos(time) * r;
169 }
170 else
171 {
172 backLegL->xRot = ((float) Mth::cos(time * 0.6662f) * 1.f) * r;
173 backLegR->xRot = ((float) Mth::cos(time * 0.6662f + PI) * 1.f) * r;
174 frontLegL->xRot = ((float) Mth::cos(time * 0.6662f + PI) * 1.f) * r;
175 frontLegR->xRot = ((float) Mth::cos(time * 0.6662f) * 1.f) * r;
176
177 if (state == WALK_STATE) tail2->xRot = 0.55f * PI + 0.25f * PI * Mth::cos(time) * r;
178 else tail2->xRot = 0.55f * PI + 0.15f * PI * Mth::cos(time) * r;
179 }
180 }
181}
182
183void OzelotModel::prepareMobModel(shared_ptr<Mob> mob, float time, float r, float a)
184{
185 shared_ptr<Ozelot> ozelot = dynamic_pointer_cast<Ozelot>(mob);
186
187 body->y = bodyWalkY;
188 body->z = bodyWalkZ;
189 head->y = headWalkY;
190 head->z = headWalkZ;
191 tail1->y = tail1WalkY;
192 tail1->z = tail1WalkZ;
193 tail2->y = tail2WalkY;
194 tail2->z = tail2WalkZ;
195 frontLegL->y = frontLegR->y = frontLegY;
196 frontLegL->z = frontLegR->z = frontLegZ;
197 backLegL->y = backLegR->y = backLegY;
198 backLegL->z = backLegR->z = backLegZ;
199 tail1->xRot = 0.9f;
200
201 if (ozelot->isSneaking())
202 {
203 body->y += 1;
204 head->y += 2;
205 tail1->y += 1;
206 tail2->y += -4;
207 tail2->z += 2;
208 tail1->xRot = 0.5f * PI;
209 tail2->xRot = 0.5f * PI;
210 state = SNEAK_STATE;
211 }
212 else if (ozelot->isSprinting())
213 {
214 tail2->y = tail1->y;
215 tail2->z += 2;
216 tail1->xRot = 0.5f * PI;
217 tail2->xRot = 0.5f * PI;
218 state = SPRINT_STATE;
219 }
220 else if (ozelot->isSitting())
221 {
222 body->xRot = 45 / (float) (180 / PI);
223 body->y += -4;
224 body->z += 5;
225 head->y += -3.3f;
226 head->z += 1;
227
228 tail1->y += 8;
229 tail1->z += -2;
230 tail2->y += 2;
231 tail2->z += -0.8f;
232 tail1->xRot = PI * 0.55f;
233 tail2->xRot = PI * 0.85f;
234
235 frontLegL->xRot = frontLegR->xRot = -PI * 0.05f;
236 frontLegL->y = frontLegR->y = frontLegY + 2;
237 frontLegL->z = frontLegR->z = -7;
238
239 backLegL->xRot = backLegR->xRot = -PI * 0.5f;
240 backLegL->y = backLegR->y = backLegY + 3;
241 backLegL->z = backLegR->z = backLegZ - 4;
242 state = SITTING_STATE;
243 }
244 else
245 {
246 state = WALK_STATE;
247 }
248}