Revision 749ef882
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/helpers/FactoryCubit.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2020 Leszek Koltunski // |
|
3 |
// // |
|
4 |
// This file is part of Magic Cube. // |
|
5 |
// // |
|
6 |
// Magic Cube is free software: you can redistribute it and/or modify // |
|
7 |
// it under the terms of the GNU General Public License as published by // |
|
8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
9 |
// (at your option) any later version. // |
|
10 |
// // |
|
11 |
// Magic Cube is distributed in the hope that it will be useful, // |
|
12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
14 |
// GNU General Public License for more details. // |
|
15 |
// // |
|
16 |
// You should have received a copy of the GNU General Public License // |
|
17 |
// along with Magic Cube. If not, see <http://www.gnu.org/licenses/>. // |
|
18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
19 |
|
|
20 |
package org.distorted.helpers; |
|
21 |
|
|
22 |
import org.distorted.library.effect.VertexEffect; |
|
23 |
import org.distorted.library.effect.VertexEffectDeform; |
|
24 |
import org.distorted.library.effect.VertexEffectMove; |
|
25 |
import org.distorted.library.effect.VertexEffectRotate; |
|
26 |
import org.distorted.library.effect.VertexEffectScale; |
|
27 |
import org.distorted.library.mesh.MeshBase; |
|
28 |
import org.distorted.library.mesh.MeshJoined; |
|
29 |
import org.distorted.library.mesh.MeshPolygon; |
|
30 |
import org.distorted.library.type.Static1D; |
|
31 |
import org.distorted.library.type.Static3D; |
|
32 |
import org.distorted.library.type.Static4D; |
|
33 |
|
|
34 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
35 |
|
|
36 |
public class FactoryCubit |
|
37 |
{ |
|
38 |
private static final float SQ2 = (float)Math.sqrt(2); |
|
39 |
private static final float SQ3 = (float)Math.sqrt(3); |
|
40 |
private static final float SQ5 = (float)Math.sqrt(5); |
|
41 |
private static final float SQ6 = (float)Math.sqrt(6); |
|
42 |
|
|
43 |
private static final Static1D RADIUS = new Static1D(1); |
|
44 |
private static FactoryCubit mThis; |
|
45 |
|
|
46 |
// IVY |
|
47 |
static final float IVY_D = 0.003f; |
|
48 |
static final float IVY_C = 0.59f; |
|
49 |
static final float IVY_M = 0.35f; |
|
50 |
private static final int IVY_N = 8; |
|
51 |
|
|
52 |
// REX |
|
53 |
public static final float REX_D = 0.2f; |
|
54 |
|
|
55 |
// KILO / MEGAMINX |
|
56 |
public static final float SIN54 = (SQ5+1)/4; |
|
57 |
public static final float COS54 = (float)(Math.sqrt(10-2*SQ5)/4); |
|
58 |
public static final float SIN18 = (SQ5-1)/4; |
|
59 |
public static final float COS18 = (float)(0.25f*Math.sqrt(10.0f+2.0f*SQ5)); |
|
60 |
public static final float COS_HALFD= (float)(Math.sqrt(0.5f-0.1f*SQ5)); // cos(half the dihedral angle) |
|
61 |
public static final float SIN_HALFD= (float)(Math.sqrt(0.5f+0.1f*SQ5)); // sin(half the dihedral angle) |
|
62 |
public static final float DIHEDRAL1= (float)(Math.acos(-SQ5/5)*180/Math.PI); |
|
63 |
public static final float DIHEDRAL2= (float)((180/Math.PI)*Math.asin((2*SIN54*SIN54-1)/COS54) - 90); |
|
64 |
public static final float MINX_SC = 0.5f; |
|
65 |
|
|
66 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
67 |
|
|
68 |
private FactoryCubit() |
|
69 |
{ |
|
70 |
|
|
71 |
} |
|
72 |
|
|
73 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
74 |
|
|
75 |
public static FactoryCubit getInstance() |
|
76 |
{ |
|
77 |
if( mThis==null ) mThis = new FactoryCubit(); |
|
78 |
|
|
79 |
return mThis; |
|
80 |
} |
|
81 |
|
|
82 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
83 |
// H - height of the band in the middle |
|
84 |
// alpha - angle of the edge [0,90] |
|
85 |
// dist - often in a polygon the distance from edge to center is not 1, but something else. |
|
86 |
// This is the distance. |
|
87 |
// K - where to begin the second, much more flat part of the band. [0,1] |
|
88 |
// N - number of bands. N>=3 |
|
89 |
// |
|
90 |
// theory: two distinct parts to the band: |
|
91 |
// 1) (0,B) - steep |
|
92 |
// 2) (B,1) - flat |
|
93 |
// |
|
94 |
// In first part, we have y = g(x) ; in second - y = g(f(x)) where |
|
95 |
// |
|
96 |
// g(x) = sqrt( R^2 - (x-D)^2 ) - R*cos(alpha) |
|
97 |
// f(x) = ((D-B)/(1-B)*x + B*(1-D)/(1-B) |
|
98 |
// h(x) = R*(sin(alpha) - sin(x)) |
|
99 |
// R = H/(1-cos(alpha)) |
|
100 |
// D = H*sin(alpha) |
|
101 |
// B = h(K*alpha) |
|
102 |
// |
|
103 |
// The N points are taken at: |
|
104 |
// |
|
105 |
// 1) in the second part, there are K2 = (N-3)/3 such points |
|
106 |
// 2) in the first - K1 = (N-3) - K2 |
|
107 |
// 3) also, the 3 points 0,B,1 |
|
108 |
// |
|
109 |
// so we have the sequence A[i] of N points |
|
110 |
// |
|
111 |
// 0 |
|
112 |
// h((i+1)*(1-K)*alpha/(K1+1)) (i=0,1,...,K1-1) |
|
113 |
// B |
|
114 |
// (1-B)*(i+1)/(K2+1) + B (i=0,i,...,K2-1) |
|
115 |
// 1 |
|
116 |
|
|
117 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
118 |
|
|
119 |
private float f(float D, float B, float x) |
|
120 |
{ |
|
121 |
return ((D-B)*x + B*(1-D))/(1-B); |
|
122 |
} |
|
123 |
|
|
124 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
125 |
|
|
126 |
private float g(float R, float D, float x, float cosAlpha) |
|
127 |
{ |
|
128 |
float d = x-D; |
|
129 |
return (float)(Math.sqrt(R*R-d*d)-R*cosAlpha); |
|
130 |
} |
|
131 |
|
|
132 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
133 |
|
|
134 |
private float h(float R, float sinAlpha, float x) |
|
135 |
{ |
|
136 |
return R*(sinAlpha-(float)Math.sin(x)); |
|
137 |
} |
|
138 |
|
|
139 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
140 |
|
|
141 |
private float[] computeBands(float H, int alpha, float dist, float K, int N) |
|
142 |
{ |
|
143 |
float[] bands = new float[2*N]; |
|
144 |
|
|
145 |
bands[0] = 1.0f; |
|
146 |
bands[1] = 0.0f; |
|
147 |
|
|
148 |
float beta = (float)Math.atan(dist*Math.tan(Math.PI*alpha/180)); |
|
149 |
float sinBeta = (float)Math.sin(beta); |
|
150 |
float cosBeta = (float)Math.cos(beta); |
|
151 |
float R = cosBeta<1.0f ? H/(1.0f-cosBeta) : 0.0f; |
|
152 |
float D = R*sinBeta; |
|
153 |
float B = h(R,sinBeta,K*beta); |
|
154 |
|
|
155 |
if( D>1.0f ) |
|
156 |
{ |
|
157 |
for(int i=1; i<N; i++) |
|
158 |
{ |
|
159 |
bands[2*i ] = (float)(N-1-i)/(N-1); |
|
160 |
bands[2*i+1] = H*(1-bands[2*i]); |
|
161 |
} |
|
162 |
} |
|
163 |
else |
|
164 |
{ |
|
165 |
int K2 = (int)((N-3)*K); |
|
166 |
int K1 = (N-3)-K2; |
|
167 |
|
|
168 |
for(int i=0; i<=K1; i++) |
|
169 |
{ |
|
170 |
float angle = K*beta + (1-K)*beta*(K1-i)/(K1+1); |
|
171 |
float x = h(R,sinBeta,angle); |
|
172 |
bands[2*i+2] = 1.0f - x; |
|
173 |
bands[2*i+3] = g(R,D,x,cosBeta); |
|
174 |
} |
|
175 |
|
|
176 |
for(int i=0; i<=K2; i++) |
|
177 |
{ |
|
178 |
float x = (1-B)*(i+1)/(K2+1) + B; |
|
179 |
bands[2*K1+2 + 2*i+2] = 1.0f - x; |
|
180 |
bands[2*K1+2 + 2*i+3] = g(R,D,f(D,B,x),cosBeta); |
|
181 |
} |
|
182 |
} |
|
183 |
|
|
184 |
bands[2*N-2] = 0.0f; |
|
185 |
bands[2*N-1] = H; |
|
186 |
|
|
187 |
return bands; |
|
188 |
} |
|
189 |
|
|
190 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
191 |
|
|
192 |
private void roundCorners(MeshBase mesh, Static3D center, Static3D[] vertices, float strength, float regionRadius) |
|
193 |
{ |
|
194 |
Static4D reg= new Static4D(0,0,0,regionRadius); |
|
195 |
|
|
196 |
float centX = center.get0(); |
|
197 |
float centY = center.get1(); |
|
198 |
float centZ = center.get2(); |
|
199 |
|
|
200 |
for (Static3D vertex : vertices) |
|
201 |
{ |
|
202 |
float x = strength*(centX - vertex.get0()); |
|
203 |
float y = strength*(centY - vertex.get1()); |
|
204 |
float z = strength*(centZ - vertex.get2()); |
|
205 |
|
|
206 |
VertexEffect effect = new VertexEffectDeform(new Static3D(x,y,z), RADIUS, vertex, reg); |
|
207 |
mesh.apply(effect); |
|
208 |
} |
|
209 |
} |
|
210 |
|
|
211 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
212 |
|
|
213 |
MeshBase createFacesCube(int sizeIndex) |
|
214 |
{ |
|
215 |
MeshBase[] meshes = new MeshPolygon[6]; |
|
216 |
|
|
217 |
float E = 0.5f; |
|
218 |
int extraI, extraV, num; |
|
219 |
|
|
220 |
switch(sizeIndex) |
|
221 |
{ |
|
222 |
case 0 : num = 6; extraI = 2; extraV = 2; break; |
|
223 |
case 1 : num = 5; extraI = 2; extraV = 2; break; |
|
224 |
case 2 : num = 5; extraI = 1; extraV = 2; break; |
|
225 |
default: num = 4; extraI = 1; extraV = 1; break; |
|
226 |
} |
|
227 |
|
|
228 |
float[] vertices = { -E,-E, +E,-E, +E,+E, -E,+E }; |
|
229 |
float[] bands = computeBands(0.048f,35,E,0.7f,num); |
|
230 |
|
|
231 |
meshes[0] = new MeshPolygon(vertices,bands,extraI,extraV); |
|
232 |
meshes[0].setEffectAssociation(0,1,0); |
|
233 |
meshes[1] = meshes[0].copy(true); |
|
234 |
meshes[1].setEffectAssociation(0,2,0); |
|
235 |
meshes[2] = meshes[0].copy(true); |
|
236 |
meshes[2].setEffectAssociation(0,4,0); |
|
237 |
meshes[3] = meshes[0].copy(true); |
|
238 |
meshes[3].setEffectAssociation(0,8,0); |
|
239 |
meshes[4] = meshes[0].copy(true); |
|
240 |
meshes[4].setEffectAssociation(0,16,0); |
|
241 |
meshes[5] = meshes[0].copy(true); |
|
242 |
meshes[5].setEffectAssociation(0,32,0); |
|
243 |
|
|
244 |
return new MeshJoined(meshes); |
|
245 |
} |
|
246 |
|
|
247 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
248 |
|
|
249 |
MeshBase createFacesSkewbCorner() |
|
250 |
{ |
|
251 |
MeshBase[] meshes = new MeshBase[6]; |
|
252 |
|
|
253 |
float E = 0.5f; |
|
254 |
float F = SQ2/2; |
|
255 |
float G = SQ6/16; |
|
256 |
float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4}; |
|
257 |
float[] bands0 = computeBands(0.028f,35,E/3,0.7f,7); |
|
258 |
|
|
259 |
meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3); |
|
260 |
meshes[0].setEffectAssociation(0,1,0); |
|
261 |
meshes[1] = meshes[0].copy(true); |
|
262 |
meshes[1].setEffectAssociation(0,2,0); |
|
263 |
meshes[2] = meshes[0].copy(true); |
|
264 |
meshes[2].setEffectAssociation(0,4,0); |
|
265 |
|
|
266 |
float[] vertices1 = { -F/2,-2*G, F/2,-2*G, 3*F/8,-G, 1*F/8,G, 0,2*G }; |
|
267 |
float[] bands1 = computeBands(0,0,1,0,3); |
|
268 |
|
|
269 |
meshes[3] = new MeshPolygon(vertices1,bands1,1,5); |
|
270 |
meshes[3].setEffectAssociation(0,8,0); |
|
271 |
meshes[4] = meshes[3].copy(true); |
|
272 |
meshes[4].setEffectAssociation(0,16,0); |
|
273 |
meshes[5] = meshes[3].copy(true); |
|
274 |
meshes[5].setEffectAssociation(0,32,0); |
|
275 |
|
|
276 |
return new MeshJoined(meshes); |
|
277 |
} |
|
278 |
|
|
279 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
280 |
|
|
281 |
MeshBase createFacesSkewbFace() |
|
282 |
{ |
|
283 |
MeshBase[] meshes = new MeshBase[5]; |
|
284 |
|
|
285 |
float E = SQ2/4; |
|
286 |
float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E }; |
|
287 |
float[] bands0 = computeBands(0.051f,35,E/2,0.9f,7); |
|
288 |
|
|
289 |
meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3); |
|
290 |
meshes[0].setEffectAssociation(0,1,0); |
|
291 |
|
|
292 |
float[] vertices1 = { -E,-SQ3*E, -E*0.7f,-SQ3*E, +E*0.7f,-SQ3*E, +E,-SQ3*E, 0,0 }; |
|
293 |
float[] bands1 = computeBands(0,0,1,0,3); |
|
294 |
|
|
295 |
meshes[1] = new MeshPolygon(vertices1,bands1,0,0); |
|
296 |
meshes[1].setEffectAssociation(0,2,0); |
|
297 |
meshes[2] = meshes[1].copy(true); |
|
298 |
meshes[2].setEffectAssociation(0,4,0); |
|
299 |
meshes[3] = meshes[1].copy(true); |
|
300 |
meshes[3].setEffectAssociation(0,8,0); |
|
301 |
meshes[4] = meshes[1].copy(true); |
|
302 |
meshes[4].setEffectAssociation(0,16,0); |
|
303 |
|
|
304 |
return new MeshJoined(meshes); |
|
305 |
} |
|
306 |
|
|
307 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
308 |
|
|
309 |
MeshBase createFacesOcta() |
|
310 |
{ |
|
311 |
MeshBase[] meshes = new MeshPolygon[8]; |
|
312 |
|
|
313 |
float E = 0.75f; |
|
314 |
float F = 0.5f; |
|
315 |
float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3}; |
|
316 |
float[] bands = computeBands(0.05f,35,F,0.8f,6); |
|
317 |
|
|
318 |
meshes[0] = new MeshPolygon(vertices, bands, 2,2); |
|
319 |
meshes[0].setEffectAssociation(0,1,0); |
|
320 |
meshes[1] = meshes[0].copy(true); |
|
321 |
meshes[1].setEffectAssociation(0,2,0); |
|
322 |
meshes[2] = meshes[0].copy(true); |
|
323 |
meshes[2].setEffectAssociation(0,4,0); |
|
324 |
meshes[3] = meshes[0].copy(true); |
|
325 |
meshes[3].setEffectAssociation(0,8,0); |
|
326 |
meshes[4] = meshes[0].copy(true); |
|
327 |
meshes[4].setEffectAssociation(0,16,0); |
|
328 |
meshes[5] = meshes[0].copy(true); |
|
329 |
meshes[5].setEffectAssociation(0,32,0); |
|
330 |
meshes[6] = meshes[0].copy(true); |
|
331 |
meshes[6].setEffectAssociation(0,64,0); |
|
332 |
meshes[7] = meshes[0].copy(true); |
|
333 |
meshes[7].setEffectAssociation(0,128,0); |
|
334 |
|
|
335 |
return new MeshJoined(meshes); |
|
336 |
} |
|
337 |
|
|
338 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
339 |
|
|
340 |
MeshBase createFacesTetra() |
|
341 |
{ |
|
342 |
MeshBase[] meshes = new MeshBase[4]; |
|
343 |
|
|
344 |
float E = 0.75f; |
|
345 |
float F = 0.5f; |
|
346 |
float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3}; |
|
347 |
float[] bands = computeBands(0.05f,35,F,0.8f,6); |
|
348 |
|
|
349 |
meshes[0] = new MeshPolygon(vertices, bands, 2,2); |
|
350 |
meshes[0].setEffectAssociation(0,1,0); |
|
351 |
meshes[1] = meshes[0].copy(true); |
|
352 |
meshes[1].setEffectAssociation(0,2,0); |
|
353 |
meshes[2] = meshes[0].copy(true); |
|
354 |
meshes[2].setEffectAssociation(0,4,0); |
|
355 |
meshes[3] = meshes[0].copy(true); |
|
356 |
meshes[3].setEffectAssociation(0,8,0); |
|
357 |
|
|
358 |
return new MeshJoined(meshes); |
|
359 |
} |
|
360 |
|
|
361 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
362 |
|
|
363 |
MeshBase createFacesDino() |
|
364 |
{ |
|
365 |
MeshBase[] meshes = new MeshPolygon[4]; |
|
366 |
|
|
367 |
float E = 0.5f*SQ2; |
|
368 |
float F = 0.5f; |
|
369 |
float[] vertices0 = { -F,F/3, 0,-2*F/3, +F,F/3 }; |
|
370 |
float[] bands0 = computeBands(0.028f,30,F/3,0.8f,7); |
|
371 |
|
|
372 |
meshes[0] = new MeshPolygon(vertices0, bands0, 2, 5); |
|
373 |
meshes[0].setEffectAssociation(0,1,0); |
|
374 |
meshes[1] = meshes[0].copy(true); |
|
375 |
meshes[1].setEffectAssociation(0,2,0); |
|
376 |
|
|
377 |
float[] vertices1 = { -E/2,-E*(SQ3/6), E/2,-E*(SQ3/6), 0,E*(SQ3/3) }; |
|
378 |
float[] bands1 = computeBands(0.02f,45,F/3,0.2f,3); |
|
379 |
|
|
380 |
meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2); |
|
381 |
meshes[2].setEffectAssociation(0,4,0); |
|
382 |
meshes[3] = meshes[2].copy(true); |
|
383 |
meshes[3].setEffectAssociation(0,8,0); |
|
384 |
|
|
385 |
return new MeshJoined(meshes); |
|
386 |
} |
|
387 |
|
|
388 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
389 |
|
|
390 |
MeshBase createFacesHelicopterCorner() |
|
391 |
{ |
|
392 |
MeshBase[] meshes = new MeshBase[6]; |
|
393 |
|
|
394 |
float E = 0.5f; |
|
395 |
float F = SQ2/4; |
|
396 |
float G = 1.0f/12; |
|
397 |
float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4}; |
|
398 |
float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7); |
|
399 |
|
|
400 |
meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3); |
|
401 |
meshes[0].setEffectAssociation(0,1,0); |
|
402 |
meshes[1] = meshes[0].copy(true); |
|
403 |
meshes[1].setEffectAssociation(0,2,0); |
|
404 |
meshes[2] = meshes[0].copy(true); |
|
405 |
meshes[2].setEffectAssociation(0,4,0); |
|
406 |
|
|
407 |
float[] vertices1 = { -F,-G, 0,-G, +F,-G, 0,2*G }; |
|
408 |
float[] bands1 = computeBands(0.00f,0,0,0.0f,3); |
|
409 |
meshes[3] = new MeshPolygon(vertices1,bands1,1,5); |
|
410 |
meshes[3].setEffectAssociation(0,8,0); |
|
411 |
meshes[4] = meshes[3].copy(true); |
|
412 |
meshes[4].setEffectAssociation(0,16,0); |
|
413 |
meshes[5] = meshes[3].copy(true); |
|
414 |
meshes[5].setEffectAssociation(0,32,0); |
|
415 |
|
|
416 |
return new MeshJoined(meshes); |
|
417 |
} |
|
418 |
|
|
419 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
420 |
|
|
421 |
MeshBase createFacesHelicopterFace() |
|
422 |
{ |
|
423 |
MeshBase[] meshes = new MeshBase[4]; |
|
424 |
|
|
425 |
float E = 0.5f; |
|
426 |
float F = SQ2/4; |
|
427 |
float G = 1.0f/12; |
|
428 |
float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4}; |
|
429 |
float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7); |
|
430 |
|
|
431 |
meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3); |
|
432 |
meshes[0].setEffectAssociation(0,1,0); |
|
433 |
|
|
434 |
float[] vertices1 = { -F,-G, +F,-G, 0,2*G}; |
|
435 |
float[] bands1 = computeBands(0.01f,45,F,0.0f,3); |
|
436 |
|
|
437 |
meshes[1] = new MeshPolygon(vertices1, bands1, 1, 3); |
|
438 |
meshes[1].setEffectAssociation(0,2,0); |
|
439 |
|
|
440 |
float[] vertices2 = { -E/2,-F/3, +E/2,-F/3, 0,2*F/3}; |
|
441 |
|
|
442 |
meshes[2] = new MeshPolygon(vertices2, bands1, 1, 3); |
|
443 |
meshes[2].setEffectAssociation(0,4,0); |
|
444 |
meshes[3] = meshes[2].copy(true); |
|
445 |
meshes[3].setEffectAssociation(0,8,0); |
|
446 |
|
|
447 |
return new MeshJoined(meshes); |
|
448 |
} |
|
449 |
|
|
450 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
451 |
|
|
452 |
MeshBase createFacesRediEdge() |
|
453 |
{ |
|
454 |
MeshBase[] meshes = new MeshPolygon[6]; |
|
455 |
|
|
456 |
float F = 0.25f; |
|
457 |
float[] vertices0 = { -F,+F, -F,-F, 0, -2*F, +F,-F, +F,+F }; |
|
458 |
float[] bands0 = computeBands(0.038f,35,F,0.7f,7); |
|
459 |
|
|
460 |
meshes[0] = new MeshPolygon(vertices0, bands0, 2, 2); |
|
461 |
meshes[0].setEffectAssociation(0,1,0); |
|
462 |
meshes[1] = meshes[0].copy(true); |
|
463 |
meshes[1].setEffectAssociation(0,2,0); |
|
464 |
|
|
465 |
float[] bands1 = computeBands(0.02f,35,F/2,0.2f,3); |
|
466 |
float[] vertices1 = { -F/2, +F/2, -F/2, -1.5f*F, 1.5f*F, +F/2 }; |
|
467 |
|
|
468 |
meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2); |
|
469 |
meshes[2].setEffectAssociation(0,4,0); |
|
470 |
meshes[3] = meshes[2].copy(true); |
|
471 |
meshes[3].setEffectAssociation(0,8,0); |
|
472 |
|
|
473 |
float X = 0.25f*SQ2; |
|
474 |
float Y = SQ6/16; |
|
475 |
float[] vertices2 = { -X, Y, -1.5f*X, -Y, +1.5f*X, -Y, +X, Y }; |
|
476 |
|
|
477 |
meshes[4] = new MeshPolygon(vertices2, bands1, 1, 1); |
|
478 |
meshes[4].setEffectAssociation(0,16,0); |
|
479 |
meshes[5] = meshes[4].copy(true); |
|
480 |
meshes[5].setEffectAssociation(0,32,0); |
|
481 |
|
|
482 |
return new MeshJoined(meshes); |
|
483 |
} |
|
484 |
|
|
485 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
486 |
|
|
487 |
MeshBase createFacesRediCorner() |
|
488 |
{ |
|
489 |
MeshBase[] meshes = new MeshBase[6]; |
|
490 |
|
|
491 |
float E = 0.5f; |
|
492 |
float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E }; |
|
493 |
float[] bands0 = computeBands(0.06f,35,E,0.7f,6); |
|
494 |
|
|
495 |
meshes[0] = new MeshPolygon(vertices0,bands0,2,2); |
|
496 |
meshes[0].setEffectAssociation(0,1,0); |
|
497 |
meshes[1] = meshes[0].copy(true); |
|
498 |
meshes[1].setEffectAssociation(0,2,0); |
|
499 |
meshes[2] = meshes[0].copy(true); |
|
500 |
meshes[2].setEffectAssociation(0,4,0); |
|
501 |
|
|
502 |
float F = 0.5f; |
|
503 |
float X = 0.5f; |
|
504 |
float G = 0.72f; |
|
505 |
float[] vertices1 = { -E,+F, -E+X,0, -E,-F, -E*G,-F, +E*G,-F, +E,-F, +E-X,0, +E,+F, +E*G,+F, -E*G,+F }; |
|
506 |
float[] bands1 = computeBands(0.0f,0,1.0f,0.0f,2); |
|
507 |
|
|
508 |
meshes[3] = new MeshPolygon(vertices1,bands1,0,0); |
|
509 |
meshes[3].setEffectAssociation(0,8,0); |
|
510 |
meshes[4] = meshes[3].copy(true); |
|
511 |
meshes[4].setEffectAssociation(0,16,0); |
|
512 |
meshes[5] = meshes[3].copy(true); |
|
513 |
meshes[5].setEffectAssociation(0,32,0); |
|
514 |
|
|
515 |
return new MeshJoined(meshes); |
|
516 |
} |
|
517 |
|
|
518 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
519 |
|
|
520 |
MeshBase createFacesIvyCorner() |
|
521 |
{ |
|
522 |
MeshBase[] meshes = new MeshBase[6]; |
|
523 |
|
|
524 |
final float angle = (float)Math.PI/(2*IVY_N); |
|
525 |
final float CORR = 1.0f - 2*IVY_D; |
|
526 |
final float DIST = -0.5f*CORR + IVY_D; |
|
527 |
float[] vertices = new float[2*(IVY_N+1)+6]; |
|
528 |
|
|
529 |
vertices[0] = (0.5f-IVY_M) * IVY_C; |
|
530 |
vertices[1] = (DIST-IVY_M) * IVY_C; |
|
531 |
vertices[2] = (0.5f-IVY_M) * IVY_C; |
|
532 |
vertices[3] = (0.5f-IVY_M) * IVY_C; |
|
533 |
vertices[4] = (DIST-IVY_M) * IVY_C; |
|
534 |
vertices[5] = (0.5f-IVY_M) * IVY_C; |
|
535 |
|
|
536 |
for(int i=0; i<=IVY_N; i++) |
|
537 |
{ |
|
538 |
float ang = (IVY_N-i)*angle; |
|
539 |
float sin = (float)Math.sin(ang); |
|
540 |
float cos = (float)Math.cos(ang); |
|
541 |
|
|
542 |
vertices[2*i+6] = (CORR*(cos-0.5f)-IVY_M)*IVY_C; |
|
543 |
vertices[2*i+7] = (CORR*(sin-0.5f)-IVY_M)*IVY_C; |
|
544 |
} |
|
545 |
|
|
546 |
float[] bands0 = computeBands(+0.012f,20,0.2f,0.5f,7); |
|
547 |
float[] bands1 = computeBands(-0.100f,20,0.2f,0.0f,2); |
|
548 |
|
|
549 |
meshes[0] = new MeshPolygon(vertices,bands0,1,2); |
|
550 |
meshes[0].setEffectAssociation(0,1,0); |
|
551 |
meshes[1] = meshes[0].copy(true); |
|
552 |
meshes[1].setEffectAssociation(0,2,0); |
|
553 |
meshes[2] = meshes[0].copy(true); |
|
554 |
meshes[2].setEffectAssociation(0,4,0); |
|
555 |
meshes[3] = new MeshPolygon(vertices,bands1,1,2); |
|
556 |
meshes[3].setEffectAssociation(0,8,0); |
|
557 |
meshes[4] = meshes[3].copy(true); |
|
558 |
meshes[4].setEffectAssociation(0,16,0); |
|
559 |
meshes[5] = meshes[3].copy(true); |
|
560 |
meshes[5].setEffectAssociation(0,32,0); |
|
561 |
|
|
562 |
return new MeshJoined(meshes); |
|
563 |
} |
|
564 |
|
|
565 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
566 |
|
|
567 |
MeshBase createFacesIvyFace() |
|
568 |
{ |
|
569 |
MeshBase[] meshes = new MeshBase[2]; |
|
570 |
|
|
571 |
final float angle = (float)Math.PI/(2*IVY_N); |
|
572 |
final float CORR = 1.0f - 2*IVY_D; |
|
573 |
float[] vertices = new float[4*IVY_N]; |
|
574 |
|
|
575 |
for(int i=0; i<IVY_N; i++) |
|
576 |
{ |
|
577 |
float sin = (float)Math.sin(i*angle); |
|
578 |
float cos = (float)Math.cos(i*angle); |
|
579 |
|
|
580 |
vertices[2*i ] = CORR*(0.5f-cos); |
|
581 |
vertices[2*i+1 ] = CORR*(0.5f-sin); |
|
582 |
vertices[2*i +2*IVY_N] = CORR*(cos-0.5f); |
|
583 |
vertices[2*i+1+2*IVY_N] = CORR*(sin-0.5f); |
|
584 |
} |
|
585 |
|
|
586 |
float[] bands0 = computeBands(+0.03f,35,0.5f,0.5f,5); |
|
587 |
float[] bands1 = computeBands(-0.10f,45,0.5f,0.0f,2); |
|
588 |
|
|
589 |
meshes[0] = new MeshPolygon(vertices,bands0,0,0); |
|
590 |
meshes[0].setEffectAssociation(0,1,0); |
|
591 |
meshes[1] = new MeshPolygon(vertices,bands1,0,0); |
|
592 |
meshes[1].setEffectAssociation(0,2,0); |
|
593 |
|
|
594 |
return new MeshJoined(meshes); |
|
595 |
} |
|
596 |
|
|
597 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
598 |
|
|
599 |
MeshBase createFacesRexCorner() |
|
600 |
{ |
|
601 |
MeshBase[] meshes = new MeshBase[2]; |
|
602 |
|
|
603 |
float F = REX_D*SQ2; |
|
604 |
float G = (1-REX_D)*SQ2/2; |
|
605 |
float H = 0.1f; |
|
606 |
float J = +2*G/3 - H*G; |
|
607 |
|
|
608 |
float[] vertices = { -F/2, -G/3, +F/2, -G/3, H*F/2, J, -H*F/2, J}; |
|
609 |
|
|
610 |
float[] bands0 = computeBands(+0.016f,10,G/3,0.5f,5); |
|
611 |
float[] bands1 = computeBands(-0.230f,45,G/3,0.0f,2); |
|
612 |
|
|
613 |
meshes[0] = new MeshPolygon(vertices,bands0,1,1); |
|
614 |
meshes[0].setEffectAssociation(0,1,0); |
|
615 |
meshes[1] = new MeshPolygon(vertices,bands1,0,0); |
|
616 |
meshes[1].setEffectAssociation(0,2,0); |
|
617 |
|
|
618 |
return new MeshJoined(meshes); |
|
619 |
} |
|
620 |
|
|
621 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
622 |
|
|
623 |
MeshBase createFacesRexFace() |
|
624 |
{ |
|
625 |
MeshBase[] meshes = new MeshBase[2]; |
|
626 |
|
|
627 |
float[] vertices = { -REX_D,0.0f, 0.0f, -REX_D, +REX_D, 0.0f, 0.0f, +REX_D}; |
|
628 |
|
|
629 |
float[] bands0 = computeBands(0.016f,10,REX_D/2,0.5f,5); |
|
630 |
float[] bands1 = computeBands(0.000f,45,REX_D/2,0.0f,2); |
|
631 |
|
|
632 |
meshes[0] = new MeshPolygon(vertices,bands0,0,0); |
|
633 |
meshes[0].setEffectAssociation(0,1,0); |
|
634 |
meshes[1] = new MeshPolygon(vertices,bands1,0,0); |
|
635 |
meshes[1].setEffectAssociation(0,2,0); |
|
636 |
|
|
637 |
return new MeshJoined(meshes); |
|
638 |
} |
|
639 |
|
|
640 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
641 |
|
|
642 |
MeshBase createFacesRexEdge() |
|
643 |
{ |
|
644 |
MeshBase[] meshes = new MeshPolygon[6]; |
|
645 |
|
|
646 |
float E = 0.5f - REX_D; |
|
647 |
float F = 0.5f; |
|
648 |
float[] vertices0 = { -F,E/3, 0,-2*E/3, +F,E/3 }; |
|
649 |
float[] bands0 = computeBands(0.03f,27,F/3,0.8f,5); |
|
650 |
|
|
651 |
meshes[0] = new MeshPolygon(vertices0, bands0, 2, 3); |
|
652 |
meshes[0].setEffectAssociation(0,1,0); |
|
653 |
meshes[1] = meshes[0].copy(true); |
|
654 |
meshes[1].setEffectAssociation(0,2,0); |
|
655 |
|
|
656 |
float G = (float)Math.sqrt(E*E+F*F); |
|
657 |
float[] vertices1 = { -2*G/3, -E/3, G/3, -E/3, G/3, 2*E/3 }; |
|
658 |
float[] bands1 = computeBands(0.00f,45,G/3,0.2f,3); |
|
659 |
|
|
660 |
meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2); |
|
661 |
meshes[2].setEffectAssociation(0,4,0); |
|
662 |
meshes[3] = meshes[2].copy(true); |
|
663 |
meshes[3].setEffectAssociation(0,8,0); |
|
664 |
meshes[4] = meshes[2].copy(true); |
|
665 |
meshes[4].setEffectAssociation(0,16,0); |
|
666 |
meshes[5] = meshes[2].copy(true); |
|
667 |
meshes[5].setEffectAssociation(0,32,0); |
|
668 |
|
|
669 |
return new MeshJoined(meshes); |
|
670 |
} |
|
671 |
|
|
672 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
673 |
|
|
674 |
MeshBase createFacesKilominxCenter() |
|
675 |
{ |
|
676 |
MeshBase[] meshes = new MeshPolygon[6]; |
|
677 |
|
|
678 |
float X1= 0.5f*SIN54; |
|
679 |
float Y1= 0.5f*SIN_HALFD; |
|
680 |
float Y2= Y1 - 0.5f*COS54; |
|
681 |
float H = 0.5f* SIN54 /COS54 ; |
|
682 |
float X2= MINX_SC*H* SIN_HALFD; |
|
683 |
float Y3= MINX_SC*H/(2*COS_HALFD); |
|
684 |
float Y4= MINX_SC*H*(1/(2*COS_HALFD) - COS_HALFD); |
|
685 |
|
|
686 |
float[] vertices0 = { -X1, Y2, 0, -Y1, X1, Y2, 0, Y1 }; |
|
687 |
float[] bands0 = computeBands(0.04f,17,0.3f,0.2f,5); |
|
688 |
float[] vertices1 = { -X2, Y4, 0, -Y3, X2, Y4, 0, Y3 }; |
|
689 |
float[] bands1 = computeBands(0.00f, 0,0.25f,0.5f,2); |
|
690 |
|
|
691 |
meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1); |
|
692 |
meshes[0].setEffectAssociation(0, 1,0); |
|
693 |
meshes[1] = meshes[0].copy(true); |
|
694 |
meshes[1].setEffectAssociation(0, 2,0); |
|
695 |
meshes[2] = meshes[0].copy(true); |
|
696 |
meshes[2].setEffectAssociation(0, 4,0); |
|
697 |
meshes[3] = new MeshPolygon(vertices1, bands1, 0, 0); |
|
698 |
meshes[3].setEffectAssociation(0, 8,0); |
|
699 |
meshes[4] = meshes[3].copy(true); |
|
700 |
meshes[4].setEffectAssociation(0,16,0); |
|
701 |
meshes[5] = meshes[3].copy(true); |
|
702 |
meshes[5].setEffectAssociation(0,32,0); |
|
703 |
|
|
704 |
return new MeshJoined(meshes); |
|
705 |
} |
|
706 |
|
|
707 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
708 |
|
|
709 |
MeshBase createFacesMinxCorner(int numLayers) |
|
710 |
{ |
|
711 |
MeshBase[] meshes = new MeshPolygon[6]; |
|
712 |
|
|
713 |
float Y = COS54/(2*SIN54); |
|
714 |
|
|
715 |
float[] vertices0 = { -0.5f, 0.0f, 0.0f, -Y, 0.5f, 0.0f, 0.0f, Y }; |
|
716 |
|
|
717 |
int numBands0 = numLayers==3 ? 5 : 3; |
|
718 |
int numBands1 = numLayers==3 ? 2 : 2; |
|
719 |
float h = numLayers==3 ? 0.04f : 0.03f; |
|
720 |
int e = numLayers==3 ? 4 : 1; |
|
721 |
|
|
722 |
float[] bands0 = computeBands(h ,34,0.3f,0.2f, numBands0); |
|
723 |
float[] bands1 = computeBands(0.00f,34,0.3f,0.2f, numBands1); |
|
724 |
|
|
725 |
meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1); |
|
726 |
meshes[0].setEffectAssociation(0, 1,0); |
|
727 |
meshes[1] = meshes[0].copy(true); |
|
728 |
meshes[1].setEffectAssociation(0, 2,0); |
|
729 |
meshes[2] = meshes[0].copy(true); |
|
730 |
meshes[2].setEffectAssociation(0, 4,0); |
|
731 |
meshes[3] = new MeshPolygon(vertices0, bands1, 1, e); |
|
732 |
meshes[3].setEffectAssociation(0, 8,0); |
|
733 |
meshes[4] = meshes[3].copy(true); |
|
734 |
meshes[4].setEffectAssociation(0,16,0); |
|
735 |
meshes[5] = meshes[3].copy(true); |
|
736 |
meshes[5].setEffectAssociation(0,32,0); |
|
737 |
|
|
738 |
return new MeshJoined(meshes); |
|
739 |
} |
|
740 |
|
|
741 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
742 |
|
|
743 |
MeshBase createFacesKilominxEdge(int numLayers, float width, float height) |
|
744 |
{ |
|
745 |
MeshBase[] meshes = new MeshPolygon[6]; |
|
746 |
|
|
747 |
float D = height/COS18; |
|
748 |
float W = D*SIN18; |
|
749 |
float X1 = height/2; |
|
750 |
float Y1 = width/2; |
|
751 |
float Y2 = (width+W)/2; |
|
752 |
float X3 = D*SIN54; |
|
753 |
float Y3 = D*COS54; |
|
754 |
float X4 = height*SIN_HALFD; |
|
755 |
float Y4 = height*COS_HALFD; |
|
756 |
|
|
757 |
float[] vertices0 = { -X1,-Y1, X1, -Y1, X1, Y1+W,-X1, Y1 }; |
|
758 |
float[] vertices1 = { -X1,-Y2, X1, -Y2, X1, Y2+W,-X1, Y2 }; |
|
759 |
float[] vertices2 = { -X3, 0.0f, 0.0f, -Y3, X3, 0.0f, 0.0f, Y3 }; |
|
760 |
float[] vertices3 = { -X4, 0.0f, 0.0f, -Y4, X4, 0.0f, 0.0f, Y4 }; |
|
761 |
|
|
762 |
int numBands0 = numLayers<=5 ? 5 : 3; |
|
763 |
int numBands1 = numLayers<=5 ? 3 : 2; |
|
764 |
float h = numLayers<=5 ? 0.03f : 0.03f; |
|
765 |
|
|
766 |
float[] bands0 = computeBands(h ,34,0.2f,0.2f,numBands0); |
|
767 |
float[] bands1 = computeBands(0.01f,34,0.3f,0.2f,numBands1); |
|
768 |
|
|
769 |
meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1); |
|
770 |
meshes[0].setEffectAssociation(0, 1,0); |
|
771 |
meshes[1] = meshes[0].copy(true); |
|
772 |
meshes[1].setEffectAssociation(0, 2,0); |
|
773 |
meshes[2] = new MeshPolygon(vertices1, bands1, 0, 0); |
|
774 |
meshes[2].setEffectAssociation(0, 4,0); |
|
775 |
meshes[3] = meshes[2].copy(true); |
|
776 |
meshes[3].setEffectAssociation(0, 8,0); |
|
777 |
meshes[4] = new MeshPolygon(vertices2, bands1, 0, 0); |
|
778 |
meshes[4].setEffectAssociation(0,16,0); |
|
779 |
meshes[5] = new MeshPolygon(vertices3, bands1, 0, 0); |
|
780 |
meshes[5].setEffectAssociation(0,32,0); |
|
781 |
|
|
782 |
return new MeshJoined(meshes); |
|
783 |
} |
|
784 |
|
|
785 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
786 |
|
|
787 |
MeshBase createFacesMegaminxEdge(int numLayers, float width, float height) |
|
788 |
{ |
|
789 |
MeshBase[] meshes = new MeshPolygon[6]; |
|
790 |
|
|
791 |
float D = height/COS18; |
|
792 |
float W = D*SIN18; |
|
793 |
|
|
794 |
float Y1 = 0.5f*width; |
|
795 |
float Y2 = 0.5f*width + W; |
|
796 |
float Y3 = 0.5f*width + 2*W; |
|
797 |
float X2 = D*SIN54; |
|
798 |
float X1 = 0.5f*height; |
|
799 |
float Y4 = D*COS54; |
|
800 |
|
|
801 |
float[] vertices0 = { -X1, Y1, -X1, -Y1, X1, -Y2, X1, Y2 }; |
|
802 |
float[] vertices1 = { -X1, Y3, -X1, -Y3, X1, -Y2, X1, Y2 }; |
|
803 |
float[] vertices2 = { -X2, 0.0f, 0.0f, -Y4, X2, 0.0f, 0.0f, Y4 }; |
|
804 |
|
|
805 |
int numBands0 = numLayers==3 ? 5 : 3; |
|
806 |
int numBands1 = numLayers==3 ? 2 : 2; |
|
807 |
float h = numLayers==3 ? 0.03f : 0.03f; |
|
808 |
|
|
809 |
float[] bands0 = computeBands(h ,34,0.2f,0.2f,numBands0); |
|
810 |
float[] bands1 = computeBands(0.00f,34,0.3f,0.2f,numBands1); |
|
811 |
|
|
812 |
meshes[0] = new MeshPolygon(vertices0, bands0, 0, 0); |
|
813 |
meshes[0].setEffectAssociation(0, 1,0); |
|
814 |
meshes[1] = meshes[0].copy(true); |
|
815 |
meshes[1].setEffectAssociation(0, 2,0); |
|
816 |
meshes[2] = new MeshPolygon(vertices1, bands1, 0, 0); |
|
817 |
meshes[2].setEffectAssociation(0, 4,0); |
|
818 |
meshes[3] = meshes[2].copy(true); |
|
819 |
meshes[3].setEffectAssociation(0, 8,0); |
|
820 |
meshes[4] = new MeshPolygon(vertices2, bands1, 0, 0); |
|
821 |
meshes[4].setEffectAssociation(0,16,0); |
|
822 |
meshes[5] = meshes[4].copy(true); |
|
823 |
meshes[5].setEffectAssociation(0,32,0); |
|
824 |
|
|
825 |
return new MeshJoined(meshes); |
|
826 |
} |
|
827 |
|
|
828 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
829 |
|
|
830 |
MeshBase createFacesMegaminxCenter(int numLayers) |
|
831 |
{ |
|
832 |
MeshBase[] meshes = new MeshPolygon[2]; |
|
833 |
|
|
834 |
float R = 0.5f; |
|
835 |
float X1 = R*COS54; |
|
836 |
float Y1 = R*SIN54; |
|
837 |
float X2 = R*COS18; |
|
838 |
float Y2 = R*SIN18; |
|
839 |
|
|
840 |
float[] vertices0 = { -X1,+Y1, -X2,-Y2, 0.0f,-R, +X2,-Y2, +X1,+Y1 }; |
|
841 |
|
|
842 |
int numBands0 = numLayers==3 ? 4 : 3; |
|
843 |
int numBands1 = numLayers==3 ? 2 : 2; |
|
844 |
float h = numLayers==3 ? 0.04f : 0.04f; |
|
845 |
|
|
846 |
float[] bands0 = computeBands( h ,45, R/3,0.2f, numBands0); |
|
847 |
float[] bands1 = computeBands( 0.00f,34, R/3,0.2f, numBands1); |
|
848 |
|
|
849 |
meshes[0] = new MeshPolygon(vertices0, bands0, 0, 0); |
|
850 |
meshes[0].setEffectAssociation(0,1,0); |
|
851 |
meshes[1] = new MeshPolygon(vertices0, bands1, 0, 0); |
|
852 |
meshes[1].setEffectAssociation(0,2,0); |
|
853 |
|
|
854 |
return new MeshJoined(meshes); |
|
855 |
} |
|
856 |
|
|
857 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
858 |
|
|
859 |
private float[] createVertices(int A, int B) |
|
860 |
{ |
|
861 |
float E = 0.5f / Math.max(A,B); |
|
862 |
return new float[] { -A*E,-B*E, +A*E,-B*E, +A*E,+B*E, -A*E,+B*E }; |
|
863 |
} |
|
864 |
|
|
865 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
866 |
|
|
867 |
MeshBase createCuboid(int[] dimensions) |
|
868 |
{ |
|
869 |
int X = dimensions[0]; |
|
870 |
int Y = dimensions[1]; |
|
871 |
int Z = dimensions[2]; |
|
872 |
|
|
873 |
float[] verticesXY = createVertices(X,Y); |
|
874 |
float[] verticesXZ = createVertices(X,Z); |
|
875 |
float[] verticesYZ = createVertices(Z,Y); |
|
876 |
|
|
877 |
float defHeight = 0.048f; |
|
878 |
|
|
879 |
float[] bandsX = computeBands( defHeight/X,65,0.25f,0.5f,5); |
|
880 |
float[] bandsY = computeBands( defHeight/Y,65,0.25f,0.5f,5); |
|
881 |
float[] bandsZ = computeBands( defHeight/Z,65,0.25f,0.5f,5); |
|
882 |
|
|
883 |
MeshBase[] meshes = new MeshPolygon[6]; |
|
884 |
|
|
885 |
meshes[0] = new MeshPolygon(verticesYZ,bandsX,1,2); |
|
886 |
meshes[0].setEffectAssociation(0,1,0); |
|
887 |
meshes[1] = meshes[0].copy(true); |
|
888 |
meshes[1].setEffectAssociation(0,2,0); |
|
889 |
meshes[2] = new MeshPolygon(verticesXZ,bandsY,1,2); |
|
890 |
meshes[2].setEffectAssociation(0,4,0); |
|
891 |
meshes[3] = meshes[2].copy(true); |
|
892 |
meshes[3].setEffectAssociation(0,8,0); |
|
893 |
meshes[4] = new MeshPolygon(verticesXY,bandsZ,1,2); |
|
894 |
meshes[4].setEffectAssociation(0,16,0); |
|
895 |
meshes[5] = meshes[4].copy(true); |
|
896 |
meshes[5].setEffectAssociation(0,32,0); |
|
897 |
|
|
898 |
return new MeshJoined(meshes); |
|
899 |
} |
|
900 |
|
|
901 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
902 |
// EFFECTS |
|
903 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
904 |
|
|
905 |
VertexEffect[] createVertexEffectsCube() |
|
906 |
{ |
|
907 |
Static3D axisY = new Static3D(0,1,0); |
|
908 |
Static3D axisX = new Static3D(1,0,0); |
|
909 |
Static3D center = new Static3D(0,0,0); |
|
910 |
Static1D angle90 = new Static1D(90); |
|
911 |
Static1D angle180= new Static1D(180); |
|
912 |
Static1D angle270= new Static1D(270); |
|
913 |
|
|
914 |
VertexEffect[] effect = new VertexEffect[6]; |
|
915 |
|
|
916 |
effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f)); |
|
917 |
effect[1] = new VertexEffectRotate( angle180, axisX, center ); |
|
918 |
effect[2] = new VertexEffectRotate( angle90 , axisX, center ); |
|
919 |
effect[3] = new VertexEffectRotate( angle270, axisX, center ); |
|
920 |
effect[4] = new VertexEffectRotate( angle270, axisY, center ); |
|
921 |
effect[5] = new VertexEffectRotate( angle90 , axisY, center ); |
|
922 |
|
|
923 |
effect[0].setMeshAssociation(63,-1); // all 6 sides |
|
924 |
effect[1].setMeshAssociation(32,-1); // back |
|
925 |
effect[2].setMeshAssociation( 8,-1); // bottom |
|
926 |
effect[3].setMeshAssociation( 4,-1); // top |
|
927 |
effect[4].setMeshAssociation( 2,-1); // left |
|
928 |
effect[5].setMeshAssociation( 1,-1); // right |
|
929 |
|
|
930 |
return effect; |
|
931 |
} |
|
932 |
|
|
933 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
934 |
|
|
935 |
VertexEffect[] createVertexEffectsSkewbCorner() |
|
936 |
{ |
|
937 |
float E = 0.5f; |
|
938 |
|
|
939 |
Static3D axisX = new Static3D(1,0,0); |
|
940 |
Static3D axisY = new Static3D(0,1,0); |
|
941 |
Static3D axis0 = new Static3D(-SQ2/2,0,SQ2/2); |
|
942 |
Static3D axis1 = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3); |
|
943 |
Static1D angle1 = new Static1D(+90); |
|
944 |
Static1D angle2 = new Static1D(-90); |
|
945 |
Static1D angle3 = new Static1D(-15); |
|
946 |
Static1D angle4 = new Static1D((float)((180.0f/Math.PI)*Math.acos(SQ3/3))); |
|
947 |
Static1D angle5 = new Static1D(120); |
|
948 |
Static1D angle6 = new Static1D(240); |
|
949 |
Static3D center1= new Static3D(0,0,0); |
|
950 |
Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f); |
|
951 |
Static3D move1 = new Static3D(-E/4,-E/4,0); |
|
952 |
Static3D move2 = new Static3D(-0.5f+SQ2/4,-0.5f+SQ6/8,-0.5f); |
|
953 |
|
|
954 |
VertexEffect[] effect = new VertexEffect[10]; |
|
955 |
|
|
956 |
effect[0] = new VertexEffectMove(move1); |
|
957 |
effect[1] = new VertexEffectScale(new Static3D(1,1,-1)); |
|
958 |
effect[2] = new VertexEffectRotate(angle1,axisX,center1); |
|
959 |
effect[3] = new VertexEffectRotate(angle2,axisY,center1); |
|
960 |
effect[4] = new VertexEffectMove(move2); |
|
961 |
effect[5] = new VertexEffectRotate(angle1,axisX,center2); |
|
962 |
effect[6] = new VertexEffectRotate(angle3,axisY,center2); |
|
963 |
effect[7] = new VertexEffectRotate(angle4,axis0,center2); |
|
964 |
effect[8] = new VertexEffectRotate(angle5,axis1,center2); |
|
965 |
effect[9] = new VertexEffectRotate(angle6,axis1,center2); |
|
966 |
|
|
967 |
effect[0].setMeshAssociation( 7,-1); // meshes 0,1,2 |
|
968 |
effect[1].setMeshAssociation( 6,-1); // meshes 1,2 |
|
969 |
effect[2].setMeshAssociation( 2,-1); // mesh 1 |
|
970 |
effect[3].setMeshAssociation( 4,-1); // mesh 2 |
|
971 |
effect[4].setMeshAssociation(56,-1); // meshes 3,4,5 |
|
972 |
effect[5].setMeshAssociation(56,-1); // meshes 3,4,5 |
|
973 |
effect[6].setMeshAssociation(56,-1); // meshes 3,4,5 |
|
974 |
effect[7].setMeshAssociation(56,-1); // meshes 3,4,5 |
|
975 |
effect[8].setMeshAssociation(16,-1); // mesh 4 |
|
976 |
effect[9].setMeshAssociation(32,-1); // mesh 5 |
|
977 |
|
|
978 |
return effect; |
|
979 |
} |
|
980 |
|
|
981 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
982 |
|
|
983 |
VertexEffect[] createVertexEffectsSkewbFace() |
|
984 |
{ |
|
985 |
Static3D center = new Static3D(0,0,0); |
|
986 |
Static3D axisX = new Static3D(1,0,0); |
|
987 |
Static3D axisZ = new Static3D(0,0,1); |
|
988 |
float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3)); |
|
989 |
|
|
990 |
VertexEffect[] effect = new VertexEffect[6]; |
|
991 |
|
|
992 |
effect[0] = new VertexEffectRotate( new Static1D(angle), axisX, center); |
|
993 |
effect[1] = new VertexEffectRotate( new Static1D( 135), axisZ, center); |
|
994 |
effect[2] = new VertexEffectRotate( new Static1D( 45), axisZ, center); |
|
995 |
effect[3] = new VertexEffectRotate( new Static1D( -45), axisZ, center); |
|
996 |
effect[4] = new VertexEffectRotate( new Static1D( -135), axisZ, center); |
|
997 |
effect[5] = new VertexEffectMove( new Static3D(0,0,-0.5f) ); |
|
998 |
|
|
999 |
effect[0].setMeshAssociation(30,-1); // meshes 1,2,3,4 |
|
1000 |
effect[1].setMeshAssociation( 2,-1); // mesh 1 |
|
1001 |
effect[2].setMeshAssociation( 5,-1); // meshes 0,2 |
|
1002 |
effect[3].setMeshAssociation( 8,-1); // mesh 3 |
|
1003 |
effect[4].setMeshAssociation(16,-1); // mesh 4 |
|
1004 |
effect[5].setMeshAssociation(30,-1); // meshes 1,2,3,4 |
|
1005 |
|
|
1006 |
return effect; |
|
1007 |
} |
|
1008 |
|
|
1009 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1010 |
|
|
1011 |
VertexEffect[] createVertexEffectsOcta() |
|
1012 |
{ |
|
1013 |
Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3))); |
|
1014 |
Static1D angle1= new Static1D( 90); |
|
1015 |
Static1D angle2= new Static1D(180); |
|
1016 |
Static1D angle3= new Static1D(270); |
|
1017 |
Static3D move1 = new Static3D(0,SQ2/2-SQ3/3,0); |
|
1018 |
Static3D axisX = new Static3D(1,0,0); |
|
1019 |
Static3D axisY = new Static3D(0,1,0); |
|
1020 |
Static3D cent0 = new Static3D(0,0,0); |
|
1021 |
Static3D cent1 = new Static3D(0,SQ2/2,0); |
|
1022 |
Static3D flipY = new Static3D( 1,-1, 1); |
|
1023 |
Static3D scale = new Static3D( 1, 2*SQ3/3, 1); |
|
1024 |
|
|
1025 |
VertexEffect[] effect = new VertexEffect[7]; |
|
1026 |
|
|
1027 |
effect[0] = new VertexEffectScale(scale); |
|
1028 |
effect[1] = new VertexEffectMove(move1); |
|
1029 |
effect[2] = new VertexEffectRotate(alpha , axisX, cent1); |
|
1030 |
effect[3] = new VertexEffectRotate(angle1, axisY, cent0); |
|
1031 |
effect[4] = new VertexEffectRotate(angle2, axisY, cent0); |
|
1032 |
effect[5] = new VertexEffectRotate(angle3, axisY, cent0); |
|
1033 |
effect[6] = new VertexEffectScale(flipY); |
|
1034 |
|
|
1035 |
effect[3].setMeshAssociation ( 34,-1); // apply to meshes 1 & 5 |
|
1036 |
effect[4].setMeshAssociation ( 68,-1); // apply to meshes 2 & 6 |
|
1037 |
effect[5].setMeshAssociation (136,-1); // apply to meshes 3 & 7 |
|
1038 |
effect[6].setMeshAssociation (240,-1); // apply to meshes 4,5,6,7 |
|
1039 |
|
|
1040 |
return effect; |
|
1041 |
} |
|
1042 |
|
|
1043 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1044 |
|
|
1045 |
VertexEffect[] createVertexEffectsTetra() |
|
1046 |
{ |
|
1047 |
Static3D flipZ = new Static3D( 1, 1,-1); |
|
1048 |
Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3))); |
|
1049 |
Static1D angle1= new Static1D( 90); |
|
1050 |
Static1D angle2= new Static1D(180); |
|
1051 |
Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0); |
|
1052 |
Static3D axisX = new Static3D(1,0,0); |
|
1053 |
Static3D axisY = new Static3D(0,1,0); |
|
1054 |
Static3D axisZ = new Static3D(0,0,1); |
|
1055 |
Static3D cent0 = new Static3D(0,0,0); |
|
1056 |
Static3D cent1 = new Static3D(0,SQ2/4,0); |
|
1057 |
Static3D scale = new Static3D( 1, 2*SQ3/3, 1); |
|
1058 |
|
|
1059 |
VertexEffect[] effect = new VertexEffect[7]; |
|
1060 |
|
|
1061 |
effect[0] = new VertexEffectScale(scale); |
|
1062 |
effect[1] = new VertexEffectRotate(angle2, axisZ, cent0); |
|
1063 |
effect[2] = new VertexEffectMove(move1); |
|
1064 |
effect[3] = new VertexEffectRotate(alpha , axisX, cent1); |
|
1065 |
effect[4] = new VertexEffectScale(flipZ); |
|
1066 |
effect[5] = new VertexEffectRotate(angle1, axisY, cent0); |
|
1067 |
effect[6] = new VertexEffectRotate(angle2, axisZ, cent0); |
|
1068 |
|
|
1069 |
effect[4].setMeshAssociation(10,-1); // meshes 1 & 3 |
|
1070 |
effect[5].setMeshAssociation(12,-1); // meshes 2 & 3 |
|
1071 |
effect[6].setMeshAssociation(12,-1); // meshes 2 & 3 |
|
1072 |
|
|
1073 |
return effect; |
|
1074 |
} |
|
1075 |
|
|
1076 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1077 |
|
|
1078 |
VertexEffect[] createVertexEffectsDino() |
|
1079 |
{ |
|
1080 |
float E = 0.5f*SQ2; |
|
1081 |
float F = 0.5f; |
|
1082 |
final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2))); |
|
1083 |
|
|
1084 |
Static1D angle1 = new Static1D(-ANGLE); |
|
1085 |
Static1D angle2 = new Static1D(+ANGLE); |
|
1086 |
Static3D axisX = new Static3D(1,0,0); |
|
1087 |
Static3D axisY = new Static3D(0,1,0); |
|
1088 |
Static3D axisZ = new Static3D(0,-1,1); |
|
1089 |
Static3D center0= new Static3D(0,0,0); |
|
1090 |
Static3D center1= new Static3D(0,-3*F,0); |
|
1091 |
|
|
1092 |
VertexEffect[] effect = new VertexEffect[10]; |
|
1093 |
|
|
1094 |
effect[0] = new VertexEffectScale ( new Static3D(3,3,3) ); |
|
1095 |
effect[1] = new VertexEffectMove ( new Static3D(0,-F,0) ); |
|
1096 |
effect[2] = new VertexEffectRotate( new Static1D(90), axisX, center0 ); |
|
1097 |
effect[3] = new VertexEffectScale ( new Static3D(1,-1,1) ); |
|
1098 |
effect[4] = new VertexEffectMove ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) ); |
|
1099 |
effect[5] = new VertexEffectRotate( new Static1D(+90), axisY, center1 ); |
|
1100 |
effect[6] = new VertexEffectScale ( new Static3D(-1,1,1) ); |
|
1101 |
effect[7] = new VertexEffectRotate( new Static1D( 45), axisX, center1 ); |
|
1102 |
effect[8] = new VertexEffectRotate( angle1 , axisZ, center1 ); |
|
1103 |
effect[9] = new VertexEffectRotate( angle2 , axisZ, center1 ); |
|
1104 |
|
|
1105 |
effect[0].setMeshAssociation(15,-1); // apply to meshes 0,1,2,3 |
|
1106 |
effect[1].setMeshAssociation( 3,-1); // apply to meshes 0,1 |
|
1107 |
effect[2].setMeshAssociation( 2,-1); // apply to mesh 1 |
|
1108 |
effect[3].setMeshAssociation( 2,-1); // apply to mesh 1 |
|
1109 |
effect[4].setMeshAssociation(12,-1); // apply to meshes 2,3 |
|
1110 |
effect[5].setMeshAssociation(12,-1); // apply to meshes 2,3 |
|
1111 |
effect[6].setMeshAssociation( 8,-1); // apply to mesh 3 |
|
1112 |
effect[7].setMeshAssociation(12,-1); // apply to meshes 2,3 |
|
1113 |
effect[8].setMeshAssociation( 4,-1); // apply to mesh 2 |
|
1114 |
effect[9].setMeshAssociation( 8,-1); // apply to mesh 3 |
|
1115 |
|
|
1116 |
return effect; |
|
1117 |
} |
|
1118 |
|
|
1119 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1120 |
|
|
1121 |
VertexEffect[] createVertexEffectsHelicopterCorner() |
|
1122 |
{ |
|
1123 |
float E = 0.5f; |
|
1124 |
|
|
1125 |
Static3D axisX = new Static3D(1,0,0); |
|
1126 |
Static3D axisY = new Static3D(0,1,0); |
|
1127 |
Static3D axis0 = new Static3D(-SQ2/2,0,SQ2/2); |
|
1128 |
Static3D axis1 = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3); |
|
1129 |
Static1D angle1 = new Static1D(+90); |
|
1130 |
Static1D angle2 = new Static1D(-90); |
|
1131 |
Static1D angle3 = new Static1D(-135); |
|
1132 |
Static1D angle4 = new Static1D(90); |
|
1133 |
Static1D angle5 = new Static1D(120); |
|
1134 |
Static1D angle6 = new Static1D(240); |
|
1135 |
Static3D center1= new Static3D(0,0,0); |
|
1136 |
Static3D center2= new Static3D(-0.25f,-0.25f,-0.25f); |
|
1137 |
Static3D move1 = new Static3D(-E/4,-E/4,0); |
|
1138 |
Static3D move2 = new Static3D(-0.25f,(-1.0f/6)-0.25f,-0.25f); |
|
1139 |
|
|
1140 |
VertexEffect[] effect = new VertexEffect[10]; |
|
1141 |
|
|
1142 |
effect[0] = new VertexEffectMove(move1); |
|
1143 |
effect[1] = new VertexEffectScale(new Static3D(1,1,-1)); |
|
1144 |
effect[2] = new VertexEffectRotate(angle1,axisX,center1); |
|
1145 |
effect[3] = new VertexEffectRotate(angle2,axisY,center1); |
|
1146 |
effect[4] = new VertexEffectMove(move2); |
|
1147 |
effect[5] = new VertexEffectRotate(angle1,axisX,center2); |
|
1148 |
effect[6] = new VertexEffectRotate(angle3,axisY,center2); |
|
1149 |
effect[7] = new VertexEffectRotate(angle4,axis0,center2); |
|
1150 |
effect[8] = new VertexEffectRotate(angle5,axis1,center2); |
|
1151 |
effect[9] = new VertexEffectRotate(angle6,axis1,center2); |
|
1152 |
|
|
1153 |
effect[0].setMeshAssociation( 7,-1); // meshes 0,1,2 |
|
1154 |
effect[1].setMeshAssociation( 6,-1); // meshes 1,2 |
|
1155 |
effect[2].setMeshAssociation( 2,-1); // mesh 1 |
|
1156 |
effect[3].setMeshAssociation( 4,-1); // mesh 2 |
|
1157 |
effect[4].setMeshAssociation(56,-1); // meshes 3,4,5 |
|
1158 |
effect[5].setMeshAssociation(56,-1); // meshes 3,4,5 |
|
1159 |
effect[6].setMeshAssociation(56,-1); // meshes 3,4,5 |
|
1160 |
effect[7].setMeshAssociation(56,-1); // meshes 3,4,5 |
|
1161 |
effect[8].setMeshAssociation(16,-1); // mesh 4 |
|
1162 |
effect[9].setMeshAssociation(32,-1); // mesh 5 |
|
1163 |
|
|
1164 |
return effect; |
|
1165 |
} |
|
1166 |
|
|
1167 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1168 |
|
|
1169 |
VertexEffect[] createVertexEffectsHelicopterFace() |
|
1170 |
{ |
|
1171 |
float E = 0.5f; |
|
1172 |
float F = SQ2/4; |
|
1173 |
|
|
1174 |
Static3D move0 = new Static3D(-E/4, -E/4, 0); |
|
1175 |
Static3D move1 = new Static3D(-(SQ2/24)-E/2, -(SQ2/24)-E/2, 0); |
|
1176 |
Static3D move2 = new Static3D(-E/2, F/3, 0); |
|
1177 |
Static3D move3 = new Static3D(+E/2, F/3, 0); |
|
1178 |
Static3D move4 = new Static3D(+E/3,+E/3, 0); |
|
1179 |
Static1D angle1 = new Static1D(135); |
|
1180 |
Static1D angle2 = new Static1D(90); |
|
1181 |
Static1D angle3 = new Static1D(-90); |
|
1182 |
Static1D angle4 = new Static1D(-135); |
|
1183 |
Static3D axisX = new Static3D(1,0,0); |
|
1184 |
Static3D axisY = new Static3D(0,1,0); |
|
1185 |
Static3D axisZ = new Static3D(0,0,1); |
|
1186 |
Static3D axis1 = new Static3D(1,-1,0); |
|
1187 |
Static3D center = new Static3D(0,0,0); |
|
1188 |
Static3D center1= new Static3D(-E/2,-E/2,0); |
|
1189 |
|
|
1190 |
VertexEffect[] effect = new VertexEffect[10]; |
|
1191 |
|
|
1192 |
effect[0] = new VertexEffectMove(move0); |
|
1193 |
effect[1] = new VertexEffectRotate(angle1, axisZ, center); |
|
1194 |
effect[2] = new VertexEffectMove(move1); |
|
1195 |
effect[3] = new VertexEffectRotate(angle2, axis1, center1); |
|
1196 |
effect[4] = new VertexEffectMove(move2); |
|
1197 |
effect[5] = new VertexEffectMove(move3); |
|
1198 |
effect[6] = new VertexEffectRotate(angle3, axisZ, center); |
|
1199 |
effect[7] = new VertexEffectRotate(angle4, axisX, center); |
|
1200 |
effect[8] = new VertexEffectRotate(angle1, axisY, center); |
|
1201 |
effect[9] = new VertexEffectMove(move4); |
|
1202 |
|
|
1203 |
effect[0].setMeshAssociation( 1,-1); // mesh 0 |
|
1204 |
effect[1].setMeshAssociation( 2,-1); // mesh 1 |
|
1205 |
effect[2].setMeshAssociation( 2,-1); // mesh 1 |
|
1206 |
effect[3].setMeshAssociation( 2,-1); // mesh 1 |
|
1207 |
effect[4].setMeshAssociation( 4,-1); // mesh 2 |
|
1208 |
effect[5].setMeshAssociation( 8,-1); // mesh 3 |
|
1209 |
effect[6].setMeshAssociation( 8,-1); // mesh 3 |
|
1210 |
effect[7].setMeshAssociation( 4,-1); // mesh 2 |
|
1211 |
effect[8].setMeshAssociation( 8,-1); // mesh 3 |
|
1212 |
effect[9].setMeshAssociation(15,-1); // meshes 0,1,2,3 |
|
1213 |
|
|
1214 |
return effect; |
|
1215 |
} |
|
1216 |
|
|
1217 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1218 |
|
|
1219 |
VertexEffect[] createVertexEffectsRediEdge() |
|
1220 |
{ |
|
1221 |
Static3D move0 = new Static3D(0.0f, -0.5f, 0.0f); |
|
1222 |
Static3D move1 = new Static3D(0.25f, -0.25f, 0.0f); |
|
1223 |
Static3D move2 = new Static3D(0.5f, 0.0f, 0.0f); |
|
1224 |
Static3D move3 = new Static3D(0.0f, (SQ3-6)/8, (SQ3-6)/8); |
|
1225 |
Static3D flipZ = new Static3D(1,1,-1); |
|
1226 |
Static3D flipX = new Static3D(-1,1,1); |
|
1227 |
Static3D scale = new Static3D(2,2,2); |
|
1228 |
Static3D cent0 = new Static3D(0,0, 0); |
|
1229 |
Static3D cent1 = new Static3D(0,0, -1.5f); |
|
1230 |
Static3D axisX = new Static3D(1,0, 0); |
|
1231 |
Static3D axisY = new Static3D(0,1, 0); |
|
1232 |
Static3D axis = new Static3D(0,SQ2/2,-SQ2/2); |
|
1233 |
Static1D angle1= new Static1D(90); |
|
1234 |
Static1D angle2= new Static1D(45); |
|
1235 |
Static1D angle3= new Static1D( (float)(180/Math.PI*Math.acos(SQ3/3)) ); |
|
1236 |
|
|
1237 |
VertexEffect[] effect = new VertexEffect[12]; |
|
1238 |
|
|
1239 |
effect[0] = new VertexEffectScale(scale); |
|
1240 |
effect[1] = new VertexEffectMove(move0); |
|
1241 |
effect[2] = new VertexEffectScale(flipZ); |
|
1242 |
effect[3] = new VertexEffectRotate(angle1,axisX,cent0); |
|
1243 |
effect[4] = new VertexEffectMove(move1); |
|
1244 |
effect[5] = new VertexEffectRotate(angle1,axisY,cent0); |
|
1245 |
effect[6] = new VertexEffectMove(move2); |
|
1246 |
effect[7] = new VertexEffectScale(flipX); |
|
1247 |
effect[8] = new VertexEffectRotate(angle2,axisX,cent0); |
|
1248 |
effect[9] = new VertexEffectMove(move3); |
|
1249 |
effect[10]= new VertexEffectRotate(angle3,axis ,cent1); |
|
1250 |
effect[11]= new VertexEffectScale(flipX); |
|
1251 |
|
|
1252 |
effect[0].setMeshAssociation(63,-1); // meshes 0,1,2,3,4,5 |
|
1253 |
effect[1].setMeshAssociation( 3,-1); // meshes 0,1 |
|
1254 |
effect[2].setMeshAssociation( 2,-1); // mesh 1 |
|
1255 |
effect[3].setMeshAssociation( 2,-1); // mesh 1 |
|
1256 |
effect[4].setMeshAssociation(12,-1); // meshes 2,3 |
|
1257 |
effect[5].setMeshAssociation(60,-1); // meshes 2,3,4,5 |
|
1258 |
effect[6].setMeshAssociation(12,-1); // meshes 2,3 |
|
1259 |
effect[7].setMeshAssociation( 8,-1); // mesh 3 |
|
1260 |
effect[8].setMeshAssociation(48,-1); // meshes 4,5 |
|
1261 |
effect[9].setMeshAssociation(48,-1); // meshes 4,5 |
|
1262 |
effect[10].setMeshAssociation(48,-1); // meshes 4,5 |
|
1263 |
effect[11].setMeshAssociation(32,-1); // mesh 5 |
|
1264 |
|
|
1265 |
return effect; |
|
1266 |
} |
|
1267 |
|
|
1268 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1269 |
|
|
1270 |
VertexEffect[] createVertexEffectsRediCorner() |
|
1271 |
{ |
|
1272 |
Static3D axisY = new Static3D(0,1,0); |
|
1273 |
Static3D axisX = new Static3D(1,0,0); |
|
1274 |
Static3D axisZ = new Static3D(0,0,1); |
|
1275 |
Static3D center = new Static3D(0,0,0); |
|
1276 |
Static1D angle90 = new Static1D(90); |
|
1277 |
Static1D angle270= new Static1D(270); |
|
1278 |
Static1D angle45 = new Static1D(-45); |
|
1279 |
Static3D scale = new Static3D(1.0f, SQ2, 1.0f); |
|
1280 |
|
|
1281 |
VertexEffect[] effect = new VertexEffect[7]; |
|
1282 |
|
|
1283 |
effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f)); |
|
1284 |
effect[1] = new VertexEffectRotate( angle270, axisX, center ); |
|
1285 |
effect[2] = new VertexEffectRotate( angle90 , axisY, center ); |
|
1286 |
effect[3] = new VertexEffectScale(scale); |
|
1287 |
effect[4] = new VertexEffectRotate( angle45 , axisX, center ); |
|
1288 |
effect[5] = new VertexEffectRotate( angle90 , axisY, center ); |
|
1289 |
effect[6] = new VertexEffectRotate( angle270, axisZ, center ); |
|
1290 |
|
|
1291 |
effect[0].setMeshAssociation( 7,-1); // 0,1,2 |
|
1292 |
effect[1].setMeshAssociation( 2,-1); // 1 |
|
1293 |
effect[2].setMeshAssociation( 4,-1); // 2 |
|
1294 |
effect[3].setMeshAssociation(56,-1); // 3,4,5 |
|
1295 |
effect[4].setMeshAssociation(56,-1); // 3,4,5 |
|
1296 |
effect[5].setMeshAssociation(16,-1); // 4 |
|
1297 |
effect[6].setMeshAssociation(32,-1); // 5 |
|
1298 |
|
|
1299 |
return effect; |
|
1300 |
} |
|
1301 |
|
|
1302 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1303 |
|
|
1304 |
VertexEffect[] createVertexEffectsIvyCorner() |
|
1305 |
{ |
|
1306 |
Static3D axisX = new Static3D(1,0,0); |
|
1307 |
Static3D axisY = new Static3D(0,1,0); |
|
1308 |
Static1D angle1 = new Static1D(+90); |
|
1309 |
Static1D angle2 = new Static1D(-90); |
|
1310 |
Static3D center = new Static3D(0,0,0); |
|
1311 |
Static3D move1 = new Static3D(IVY_M-0.5f,IVY_M-0.5f,0); |
|
1312 |
|
|
1313 |
VertexEffect[] effect = new VertexEffect[5]; |
|
1314 |
|
|
1315 |
effect[0] = new VertexEffectScale(1/IVY_C); |
|
1316 |
effect[1] = new VertexEffectMove(move1); |
|
1317 |
effect[2] = new VertexEffectScale(new Static3D(1,1,-1)); |
|
1318 |
effect[3] = new VertexEffectRotate(angle1,axisX,center); |
|
1319 |
effect[4] = new VertexEffectRotate(angle2,axisY,center); |
|
1320 |
|
|
1321 |
effect[2].setMeshAssociation(54,-1); // meshes 1,2,4,5 |
|
1322 |
effect[3].setMeshAssociation(18,-1); // meshes 1,4 |
|
1323 |
effect[4].setMeshAssociation(36,-1); // meshes 2,5 |
|
1324 |
|
|
1325 |
return effect; |
|
1326 |
} |
|
1327 |
|
|
1328 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1329 |
|
|
1330 |
VertexEffect[] createVertexEffectsRexEdge() |
|
1331 |
{ |
|
1332 |
float E = 0.5f - REX_D; |
|
1333 |
float F = 0.5f; |
|
1334 |
float G = (float)Math.sqrt(E*E+F*F); |
|
1335 |
float A = (float)((180/Math.PI)*Math.asin(E/G)); |
|
1336 |
|
|
1337 |
Static3D move1 = new Static3D( 0.0f, -E/3, 0.0f); |
|
1338 |
Static3D move2 = new Static3D(2*G/3 -F, +E/3, 0.0f); |
|
1339 |
|
|
1340 |
Static3D center0= new Static3D(0.0f, 0.0f, 0.0f); |
|
1341 |
Static3D center1= new Static3D( -F, 0.0f, 0.0f); |
|
1342 |
Static3D center2= new Static3D( +F, 0.0f, 0.0f); |
|
1343 |
Static3D axisX = new Static3D(1.0f, 0.0f, 0.0f); |
|
1344 |
Static3D axisY = new Static3D(0.0f, 1.0f, 0.0f); |
|
1345 |
Static3D axisZ = new Static3D(0.0f, 0.0f, 1.0f); |
|
1346 |
|
|
1347 |
Static1D angle180 = new Static1D(180); |
|
1348 |
Static1D angle90 = new Static1D( 90); |
|
1349 |
Static1D angle270 = new Static1D(270); |
|
1350 |
Static1D angle1 = new Static1D(+A); |
|
1351 |
Static1D angle2 = new Static1D(-A); |
|
1352 |
|
|
1353 |
VertexEffect[] effect = new VertexEffect[12]; |
|
1354 |
|
|
1355 |
effect[0] = new VertexEffectMove(move1); |
|
1356 |
effect[1] = new VertexEffectMove(move2); |
|
1357 |
effect[2] = new VertexEffectRotate( angle90, axisX, center0 ); |
|
1358 |
effect[3] = new VertexEffectRotate( angle270, axisX, center0 ); |
|
1359 |
effect[4] = new VertexEffectRotate( angle180, axisX, center0 ); |
|
1360 |
effect[5] = new VertexEffectRotate( angle180, axisY, center0 ); |
|
1361 |
effect[6] = new VertexEffectScale ( new Static3D(-1, 1, 1) ); |
|
1362 |
effect[7] = new VertexEffectScale ( new Static3D( 1,-1, 1) ); |
|
1363 |
effect[8] = new VertexEffectRotate( angle1, axisY, center1); |
|
1364 |
effect[9] = new VertexEffectRotate( angle2, axisY, center2); |
|
1365 |
effect[10]= new VertexEffectRotate( angle2, axisZ, center1); |
|
1366 |
effect[11]= new VertexEffectRotate( angle1, axisZ, center2); |
|
1367 |
|
|
1368 |
effect[0].setMeshAssociation( 3,-1); // meshes 0 & 1 |
|
1369 |
effect[1].setMeshAssociation(60,-1); // meshes 2,3,4,5 |
|
1370 |
effect[2].setMeshAssociation( 2,-1); // meshes 1 |
|
1371 |
effect[3].setMeshAssociation(12,-1); // meshes 2,3 |
|
1372 |
effect[4].setMeshAssociation(48,-1); // meshes 4,5 |
|
1373 |
effect[5].setMeshAssociation(32,-1); // mesh 5 |
|
1374 |
effect[6].setMeshAssociation( 8,-1); // apply to mesh 3 |
|
1375 |
effect[7].setMeshAssociation( 2,-1); // apply to mesh 1 |
|
1376 |
effect[8].setMeshAssociation(16,-1); // apply to mesh 4 |
|
1377 |
effect[9].setMeshAssociation(32,-1); // apply to mesh 5 |
|
1378 |
effect[10].setMeshAssociation(4,-1); // apply to mesh 2 |
|
1379 |
effect[11].setMeshAssociation(8,-1); // apply to mesh 3 |
|
1380 |
|
|
1381 |
return effect; |
|
1382 |
} |
|
1383 |
|
|
1384 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1385 |
|
|
1386 |
VertexEffect[] createVertexEffectsRexCorner() |
|
1387 |
{ |
|
1388 |
Static3D center= new Static3D(0.0f, 0.0f, 0.0f); |
|
1389 |
Static3D axisZ = new Static3D(0.0f, 0.0f, 1.0f); |
|
1390 |
Static1D angle = new Static1D(225); |
|
1391 |
|
|
1392 |
VertexEffect[] effect = new VertexEffect[1]; |
|
1393 |
effect[0] = new VertexEffectRotate(angle, axisZ, center); |
|
1394 |
|
|
1395 |
return effect; |
|
1396 |
} |
|
1397 |
|
|
1398 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1399 |
|
|
1400 |
VertexEffect[] createVertexEffectsKilominxCenter(float width) |
|
1401 |
{ |
|
1402 |
VertexEffect[] effect = new VertexEffect[11]; |
|
1403 |
|
|
1404 |
float H = 0.5f*(SIN54/COS54); |
|
1405 |
float Y1= 0.5f*SIN_HALFD; |
|
1406 |
float Y2= H/(2*COS_HALFD); |
|
1407 |
float cos18 = (float)(Math.sqrt(1- SIN18 * SIN18)); |
|
1408 |
float LEN = (float)Math.sqrt(H*H/(COS_HALFD*COS_HALFD) + 0.25f); |
|
1409 |
|
|
1410 |
Static3D axisZ = new Static3D(0.0f , 0.0f , 1.0f); |
|
1411 |
Static3D axisY = new Static3D(0.0f , 1.0f , 0.0f); |
|
1412 |
Static3D axisA = new Static3D(-SIN18, cos18, 0.0f); |
|
1413 |
Static3D axisC = new Static3D( H/LEN, -0.5f/LEN,-H* SIN_HALFD /(COS_HALFD*LEN)); |
|
1414 |
|
|
1415 |
Static3D move1 = new Static3D(0,-Y1,0); |
|
1416 |
Static3D move2 = new Static3D(0,-Y2,0); |
|
1417 |
Static3D move3 = new Static3D(0.5f*cos18,0.5f*SIN18,0); |
|
1418 |
Static3D center= new Static3D(0.0f, 0.0f, 0.0f); |
|
1419 |
|
|
1420 |
Static1D angle1 = new Static1D(54); |
|
1421 |
Static1D angle2 = new Static1D(DIHEDRAL1/2+18); |
|
1422 |
Static1D angle3 = new Static1D(90); |
|
1423 |
Static1D angle4 = new Static1D(120); |
|
1424 |
Static1D angle5 = new Static1D(240); |
|
1425 |
Static1D angle6 = new Static1D(90-DIHEDRAL1/2); |
|
1426 |
|
|
1427 |
effect[0] = new VertexEffectMove(move1); |
|
1428 |
effect[1] = new VertexEffectScale(1/MINX_SC); |
|
1429 |
effect[2] = new VertexEffectMove(move2); |
|
1430 |
effect[3] = new VertexEffectRotate(angle1, axisZ, center); |
|
1431 |
effect[4] = new VertexEffectRotate(angle2, axisZ, center); |
|
1432 |
effect[5] = new VertexEffectRotate(angle3, axisA, center); |
|
1433 |
effect[6] = new VertexEffectMove(move3); |
|
1434 |
effect[7] = new VertexEffectRotate(angle4, axisC, center); |
|
1435 |
effect[8] = new VertexEffectRotate(angle5, axisC, center); |
|
1436 |
effect[9] = new VertexEffectRotate(angle6, axisY, center); |
|
1437 |
effect[10]= new VertexEffectScale(width/0.5f); |
|
1438 |
|
|
1439 |
effect[0].setMeshAssociation( 7,-1); // meshes 0,1,2 |
|
1440 |
effect[1].setMeshAssociation(56,-1); // meshes 3,4,5 |
|
1441 |
effect[2].setMeshAssociation(56,-1); // meshes 3,4,5 |
|
1442 |
effect[3].setMeshAssociation( 7,-1); // meshes 0,1,2 |
|
1443 |
effect[4].setMeshAssociation(56,-1); // meshes 3,4,5 |
|
1444 |
effect[5].setMeshAssociation(56,-1); // meshes 3,4,5 |
|
1445 |
effect[6].setMeshAssociation(56,-1); // meshes 3,4,5 |
|
1446 |
effect[7].setMeshAssociation(18,-1); // meshes 1,4 |
|
1447 |
effect[8].setMeshAssociation(36,-1); // meshes 2,5 |
|
1448 |
|
|
1449 |
return effect; |
|
1450 |
} |
|
1451 |
|
|
1452 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
1453 |
|
|
1454 |
VertexEffect[] createVertexEffectsMinxCorner(float width) |
|
1455 |
{ |
|
1456 |
VertexEffect[] effect = new VertexEffect[9]; |
|
1457 |
|
|
1458 |
float Y = COS54/(2*SIN54); |
|
1459 |
|
|
1460 |
float sinA = (2*SIN54*SIN54-1)/COS54; |
|
1461 |
float cosA = (float)Math.sqrt(1-sinA*sinA); |
|
1462 |
float LEN = 0.5f/SIN54; |
|
1463 |
float scale= width/LEN; |
|
1464 |
|
|
1465 |
Static3D axisA = new Static3D( SIN54, COS54, 0.0f); |
|
1466 |
Static3D axisB = new Static3D(-SIN54, COS54, 0.0f); |
|
1467 |
Static3D axisX = new Static3D( 1.0f, 0.0f, 0.0f); |
|
1468 |
|
|
1469 |
Static3D centerU = new Static3D( 0.0f, Y, 0.0f); |
|
1470 |
Static3D centerD = new Static3D( 0.0f,-Y, 0.0f); |
|
1471 |
|
|
1472 |
Static3D move1= new Static3D(0.0f, -sinA*LEN, -cosA*LEN ); |
|
1473 |
Static3D move2= new Static3D(0.0f, Y , 0.0f ); |
|
1474 |
|
|
1475 |
Static1D angleD = new Static1D(DIHEDRAL1); |
|
1476 |
Static1D angleE = new Static1D(360-DIHEDRAL1); |
|
1477 |
Static1D angleF = new Static1D(DIHEDRAL2); |
|
1478 |
|
|
1479 |
effect[0] = new VertexEffectScale ( new Static3D( 1, 1,-1) ); |
|
1480 |
effect[1] = new VertexEffectRotate(angleE, axisA, centerU); |
|
1481 |
effect[2] = new VertexEffectRotate(angleD, axisB, centerU); |
|
1482 |
effect[3] = new VertexEffectMove(move1); |
|
1483 |
effect[4] = new VertexEffectRotate(angleE, axisA, centerD); |
|
1484 |
effect[5] = new VertexEffectRotate(angleD, axisB, centerD); |
|
1485 |
effect[6] = new VertexEffectRotate(angleF, axisX, centerD); |
|
1486 |
effect[7] = new VertexEffectMove(move2); |
|
1487 |
effect[8] = new VertexEffectScale(scale); |
|
1488 |
|
|
1489 |
effect[0].setMeshAssociation( 3,-1); // meshes 0,1 |
Also available in: Unified diff
Move Factories to the 'helpers' package.