-
Notifications
You must be signed in to change notification settings - Fork 85
/
Convert.java
161 lines (140 loc) · 4.17 KB
/
Convert.java
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
class ModelPart {
static java.util.ArrayList<ModelPart> parts = new java.util.ArrayList<>(20);
final String name;
ModelPart parent = null;
boolean mirror = false;
float x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0;
int u = 0, v = 0;
float bx = 0, by = 0, bz = 0, ba = 0, bb = 0, bc = 0;
float scale = 1;
static int wd = 64;
static int hg = 32;
boolean hadBox = false;
ModelPart(Convert c, String name) {
this(c, 0, 0, name);
}
ModelPart(Convert c, int u, int v, String name) {
this.name = name;
this.u = u;
this.v = v;
parts.add(this);
}
ModelPart(int wd, int hg, int u, int v, String name) {
this.name = name;
this.u = u;
this.v = v;
ModelPart.wd = wd;
ModelPart.hg = hg;
parts.add(this);
}
ModelPart setPos(float x, float y, float z) {
this.x = x;
this.y = y;
this.z = z;
return this;
}
ModelPart setRotationAngle(float x, float y, float z) {
this.rx = x;
this.ry = y;
this.rz = z;
return this;
}
ModelPart addChild(ModelPart p) {
p.parent = this;
return this;
}
ModelPart texOffs(int u, int v) {
this.u = u;
this.v = v;
return this;
}
ModelPart addBox(float x, float y, float z, float a, float b, float c) {
return addBox(x, y, z, a, b, c, 1);
}
ModelPart addBox(float x, float y, float z, float a, float b, float c, float _d) {
bx = x;
by = y;
bz = z;
ba = a;
bb = b;
bc = c;
scale = _d;
hadBox = true;
return this;
}
ModelPart addBox(float x, float y, float z, float a, float b, float c, float _d, boolean mirror) {
this.mirror = mirror;
bx = x;
by = y;
bz = z;
ba = a;
bb = b;
bc = c;
hadBox = true;
return this;
}
public String toString() {
String s = "";
String pName = parent == null ? "modelPartData" : parent.name;
if (scale != 1) {
s += "CubeDeformation deformation_" + name + " = new CubeDeformation(" + scale + "f);\n";
}
s += "PartDefinition " + name + " = ";
s += pName + ".addOrReplaceChild(\"" + name + "\", CubeListBuilder.create()\n";
if (this.mirror) s += ".mirror()\n";
s += ".texOffs(" + u + ", " + v + ")";
if (this.hadBox) {
s += "\n";
if (scale != 1)
s += ".addBox(" + bx + "f, " + by + "f, " + bz + "f, " + ba + "f, " + bb + "f, " + bc + "f, deformation_" + name + "),\n";
else s += ".addBox(" + bx + "f, " + by + "f, " + bz + "f, " + ba + "f, " + bb + "f, " + bc + "f),\n";
}
else {
s += ",\n";
}
if (x == 0 && y == 0 && z == 0 && rx == 0 && ry == 0 && rz == 0) {
s += "PartPose.ZERO";
}
else if (rx == 0 && ry == 0 && rz == 0) {
s += "PartPose.offset(" + x + "f, " + y + "f, " + z + "f)";
}
else {
s += "PartPose.offsetAndRotation(" + x + "f, " + y + "f, " + z + "f, \n" + rx + "f, " + ry + "f, " + rz + "f)";
}
s += ");";
return s;
}
public static void print() {
System.out.println("public static LayerDefinition getTexturedModelData() {");
System.out.println(" MeshDefinition modelData = new MeshDefinition();");
System.out.println(" PartDefinition modelPartData = modelData.getRoot();");
for (ModelPart p : parts) {
System.out.println(p);
System.out.println();
}
System.out.println("return LayerDefinition.create(modelData, " + wd + ", " + hg + ");");
System.out.println("}");
System.out.println();
System.out.println();
for (ModelPart p : parts) {
String pName = p.parent == null ? "modelPart" : p.parent.name;
System.out.println(p.name + " = " + pName + ".getChild(\"" + p.name + "\");");
}
}
}
ModelPart.print();
}
void setRotationAngle(ModelPart p, float x, float y, float z){
p.setRotationAngle(x, y, z);
}
public void c (){
float scale = 1;
ModelPart[] SHARDS = new ModelPart[4];
SHARDS[0] = new ModelPart(16, 16, 2, 4, "SHARDS[0]").addBox(-5.0F, 1.0F, -3.0F, 2.0F, 8.0F, 2.0F);
SHARDS[1] = new ModelPart(16, 16, 2, 4, "SHARDS[1]").addBox(3.0F, -1.0F, -1.0F, 2.0F, 8.0F, 2.0F);
SHARDS[2] = new ModelPart(16, 16, 2, 4, "SHARDS[2]").addBox(-1.0F, 0.0F, -5.0F, 2.0F, 4.0F, 2.0F);
SHARDS[3] = new ModelPart(16, 16, 2, 4, "SHARDS[3]").addBox(0.0F, 3.0F, 4.0F, 2.0F, 6.0F, 2.0F);
ModelPart CORE = new ModelPart(16, 16, 0, 0, "CORE");
CORE.addBox(-2.0F, -2.0F, -2.0F, 4.0F, 12.0F, 4.0F);
}
}