1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
#include "stdafx.h"
#include "SpiderModel.h"
#include "..\Minecraft.World\Mth.h"
#include "ModelPart.h"
SpiderModel::SpiderModel() : Model()
{
float g = 0;
int yo = 18+6-9;
head = new ModelPart(this, 32, 4);
head->addBox(-4, -4, -8, 8, 8, 8, g); // Head
head->setPos(0, static_cast<float>(0 + yo), -3);
body0 = new ModelPart(this, 0, 0);
body0->addBox(-3, -3, -3, 6, 6, 6, g); // Body
body0->setPos(0,static_cast<float>(yo), 0);
body1 = new ModelPart(this, 0, 12);
body1->addBox(-5, -4, -6, 10, 8, 12, g); // Body
body1->setPos(0, static_cast<float>(0 + yo), 3 + 6);
leg0 = new ModelPart(this, 18, 0);
leg0->addBox(-15, -1, -1, 16, 2, 2, g); // Leg0
leg0->setPos(-4, static_cast<float>(0 + yo), 2);
leg1 = new ModelPart(this, 18, 0);
leg1->addBox(-1, -1, -1, 16, 2, 2, g); // Leg1
leg1->setPos(4, static_cast<float>(0 + yo), 2);
leg2 = new ModelPart(this, 18, 0);
leg2->addBox(-15, -1, -1, 16, 2, 2, g); // Leg2
leg2->setPos(-4, static_cast<float>(0 + yo), 1);
leg3 = new ModelPart(this, 18, 0);
leg3->addBox(-1, -1, -1, 16, 2, 2, g); // Leg3
leg3->setPos(4, static_cast<float>(0 + yo), 1);
leg4 = new ModelPart(this, 18, 0);
leg4->addBox(-15, -1, -1, 16, 2, 2, g); // Leg0
leg4->setPos(-4, static_cast<float>(0 + yo), 0);
leg5 = new ModelPart(this, 18, 0);
leg5->addBox(-1, -1, -1, 16, 2, 2, g); // Leg1
leg5->setPos(4, static_cast<float>(0 + yo), 0);
leg6 = new ModelPart(this, 18, 0);
leg6->addBox(-15, -1, -1, 16, 2, 2, g); // Leg2
leg6->setPos(-4, static_cast<float>(0 + yo), -1);
leg7 = new ModelPart(this, 18, 0);
leg7->addBox(-1, -1, -1, 16, 2, 2, g); // Leg3
leg7->setPos(4, static_cast<float>(0 + yo), -1);
// 4J added - compile now to avoid random performance hit first time cubes are rendered
head->compile(1.0f/16.0f);
body0->compile(1.0f/16.0f);
body1->compile(1.0f/16.0f);
leg0->compile(1.0f/16.0f);
leg1->compile(1.0f/16.0f);
leg2->compile(1.0f/16.0f);
leg3->compile(1.0f/16.0f);
leg4->compile(1.0f/16.0f);
leg5->compile(1.0f/16.0f);
leg6->compile(1.0f/16.0f);
leg7->compile(1.0f/16.0f);
}
void SpiderModel::render(shared_ptr<Entity> entity, float time, float r, float bob, float yRot, float xRot, float scale, bool usecompiled)
{
setupAnim(time, r, bob, yRot, xRot, scale, entity);
head->render(scale,usecompiled);
body0->render(scale,usecompiled);
body1->render(scale,usecompiled);
leg0->render(scale,usecompiled);
leg1->render(scale,usecompiled);
leg2->render(scale,usecompiled);
leg3->render(scale,usecompiled);
leg4->render(scale,usecompiled);
leg5->render(scale,usecompiled);
leg6->render(scale,usecompiled);
leg7->render(scale,usecompiled);
}
void SpiderModel::setupAnim(float time, float r, float bob, float yRot, float xRot, float scale, shared_ptr<Entity> entity, unsigned int uiBitmaskOverrideAnim)
{
head->yRot = yRot / (float) (180 / PI);
head->xRot = xRot / (float) (180 / PI);
float sr = (float) PI / 4.0f;
leg0->zRot = -sr;
leg1->zRot = sr;
leg2->zRot = -sr * 0.74f;
leg3->zRot = sr * 0.74f;
leg4->zRot = -sr * 0.74f;
leg5->zRot = sr * 0.74f;
leg6->zRot = -sr;
leg7->zRot = sr;
float ro = -(float) PI / 2.0f * 0;
float ur = (float) PI / 8.0f;
leg0->yRot = +ur * 2.0f + ro;
leg1->yRot = -ur * 2.0f - ro;
leg2->yRot = +ur * 1.0f + ro;
leg3->yRot = -ur * 1.0f - ro;
leg4->yRot = -ur * 1.0f + ro;
leg5->yRot = +ur * 1.0f - ro;
leg6->yRot = -ur * 2.0f + ro;
leg7->yRot = +ur * 2.0f - ro;
float c0 = -((float) Mth::cos(time * 0.6662f * 2 + PI * 2 * 0 / 4.0f) * 0.4f) * r;
float c1 = -((float) Mth::cos(time * 0.6662f * 2 + PI * 2 * 2 / 4.0f) * 0.4f) * r;
float c2 = -((float) Mth::cos(time * 0.6662f * 2 + PI * 2 * 1 / 4.0f) * 0.4f) * r;
float c3 = -((float) Mth::cos(time * 0.6662f * 2 + PI * 2 * 3 / 4.0f) * 0.4f) * r;
float s0 = abs((float)Mth::sin(time * 0.6662f + PI * 2 * 0 / 4.0f) * 0.4f) * r;
float s1 = abs((float)Mth::sin(time * 0.6662f + PI * 2 * 2 / 4.0f) * 0.4f) * r;
float s2 = abs((float)Mth::sin(time * 0.6662f + PI * 2 * 1 / 4.0f) * 0.4f) * r;
float s3 = abs((float)Mth::sin(time * 0.6662f + PI * 2 * 3 / 4.0f) * 0.4f) * r;
leg0->yRot += +c0;
leg1->yRot += -c0;
leg2->yRot += +c1;
leg3->yRot += -c1;
leg4->yRot += +c2;
leg5->yRot += -c2;
leg6->yRot += +c3;
leg7->yRot += -c3;
leg0->zRot += +s0;
leg1->zRot += -s0;
leg2->zRot += +s1;
leg3->zRot += -s1;
leg4->zRot += +s2;
leg5->zRot += -s2;
leg6->zRot += +s3;
leg7->zRot += -s3;
}
|