|
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.objects;
|
|
21 |
|
|
22 |
import org.distorted.library.effect.VertexEffectDeform;
|
|
23 |
import org.distorted.library.effect.VertexEffectMove;
|
|
24 |
import org.distorted.library.effect.VertexEffectRotate;
|
|
25 |
import org.distorted.library.effect.VertexEffectScale;
|
|
26 |
import org.distorted.library.mesh.MeshBase;
|
|
27 |
import org.distorted.library.mesh.MeshJoined;
|
|
28 |
import org.distorted.library.mesh.MeshPolygon;
|
|
29 |
import org.distorted.library.mesh.MeshTriangle;
|
|
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 CubitFactory
|
|
37 |
{
|
|
38 |
private static final float SQ2 = (float)Math.sqrt(2);
|
|
39 |
private static final float SQ3 = (float)Math.sqrt(3);
|
|
40 |
|
|
41 |
private static CubitFactory mThis;
|
|
42 |
|
|
43 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
44 |
|
|
45 |
private CubitFactory()
|
|
46 |
{
|
|
47 |
|
|
48 |
}
|
|
49 |
|
|
50 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
51 |
|
|
52 |
public static CubitFactory getInstance()
|
|
53 |
{
|
|
54 |
if( mThis==null ) mThis = new CubitFactory();
|
|
55 |
|
|
56 |
return mThis;
|
|
57 |
}
|
|
58 |
|
|
59 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
60 |
// CUBE
|
|
61 |
|
|
62 |
MeshBase createCubeMesh(int index)
|
|
63 |
{
|
|
64 |
float[] bands;
|
|
65 |
float D = 0.027f;
|
|
66 |
float E = 0.5f-D;
|
|
67 |
float[] vertices = { -E,-E, +E,-E, +E,+E, -E,+E };
|
|
68 |
int extraI, extraV;
|
|
69 |
|
|
70 |
switch(index)
|
|
71 |
{
|
|
72 |
case 0 : bands = new float[] { 1.0f ,-D,
|
|
73 |
1.0f-D/2,-D*0.55f,
|
|
74 |
1.0f-D ,-D*0.25f,
|
|
75 |
1.0f-2*D, 0.0f,
|
|
76 |
0.50f, 0.040f,
|
|
77 |
0.0f, 0.048f };
|
|
78 |
extraI = 2;
|
|
79 |
extraV = 2;
|
|
80 |
break;
|
|
81 |
case 1 : bands = new float[] { 1.0f ,-D,
|
|
82 |
1.0f-D*1.2f,-D*0.55f,
|
|
83 |
1.0f-2*D, 0.0f,
|
|
84 |
0.50f, 0.040f,
|
|
85 |
0.0f, 0.048f };
|
|
86 |
extraI = 2;
|
|
87 |
extraV = 2;
|
|
88 |
break;
|
|
89 |
case 2 : bands = new float[] { 1.0f ,-D,
|
|
90 |
1.0f-D*1.2f,-D*0.55f,
|
|
91 |
1.0f-2*D, 0.0f,
|
|
92 |
0.50f, 0.040f,
|
|
93 |
0.0f, 0.048f };
|
|
94 |
extraI = 1;
|
|
95 |
extraV = 2;
|
|
96 |
break;
|
|
97 |
default: bands = new float[] { 1.0f ,-D,
|
|
98 |
1.0f-2*D, 0.0f,
|
|
99 |
0.50f, 0.025f,
|
|
100 |
0.0f, 0.030f };
|
|
101 |
extraI = 1;
|
|
102 |
extraV = 1;
|
|
103 |
break;
|
|
104 |
}
|
|
105 |
|
|
106 |
return createCubeMesh(vertices,bands,extraI,extraV);
|
|
107 |
}
|
|
108 |
|
|
109 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
110 |
|
|
111 |
private MeshBase createCubeMesh(float[] vertices, float[] bands, int extraI, int extraV)
|
|
112 |
{
|
|
113 |
final int MESHES=6;
|
|
114 |
int association = 1;
|
|
115 |
MeshBase[] meshes = new MeshPolygon[MESHES];
|
|
116 |
meshes[0] = new MeshPolygon(vertices,bands,extraI,extraV);
|
|
117 |
meshes[0].setEffectAssociation(0,association,0);
|
|
118 |
|
|
119 |
for(int i=1; i<MESHES; i++)
|
|
120 |
{
|
|
121 |
association <<=1;
|
|
122 |
meshes[i] = meshes[0].copy(true);
|
|
123 |
meshes[i].setEffectAssociation(0,association,0);
|
|
124 |
}
|
|
125 |
|
|
126 |
MeshBase mesh = new MeshJoined(meshes);
|
|
127 |
|
|
128 |
Static3D axisY = new Static3D(0,1,0);
|
|
129 |
Static3D axisX = new Static3D(1,0,0);
|
|
130 |
Static3D center = new Static3D(0,0,0);
|
|
131 |
Static1D angle90 = new Static1D(90);
|
|
132 |
Static1D angle180= new Static1D(180);
|
|
133 |
Static1D angle270= new Static1D(270);
|
|
134 |
|
|
135 |
float d1 = 1.0f;
|
|
136 |
float d2 =-0.05f;
|
|
137 |
float d3 = 0.12f;
|
|
138 |
|
|
139 |
Static3D dCen0 = new Static3D( d1*(+0.5f), d1*(+0.5f), d1*(+0.5f) );
|
|
140 |
Static3D dCen1 = new Static3D( d1*(+0.5f), d1*(+0.5f), d1*(-0.5f) );
|
|
141 |
Static3D dCen2 = new Static3D( d1*(+0.5f), d1*(-0.5f), d1*(+0.5f) );
|
|
142 |
Static3D dCen3 = new Static3D( d1*(+0.5f), d1*(-0.5f), d1*(-0.5f) );
|
|
143 |
Static3D dCen4 = new Static3D( d1*(-0.5f), d1*(+0.5f), d1*(+0.5f) );
|
|
144 |
Static3D dCen5 = new Static3D( d1*(-0.5f), d1*(+0.5f), d1*(-0.5f) );
|
|
145 |
Static3D dCen6 = new Static3D( d1*(-0.5f), d1*(-0.5f), d1*(+0.5f) );
|
|
146 |
Static3D dCen7 = new Static3D( d1*(-0.5f), d1*(-0.5f), d1*(-0.5f) );
|
|
147 |
|
|
148 |
Static3D dVec0 = new Static3D( d2*(+0.5f), d2*(+0.5f), d2*(+0.5f) );
|
|
149 |
Static3D dVec1 = new Static3D( d2*(+0.5f), d2*(+0.5f), d2*(-0.5f) );
|
|
150 |
Static3D dVec2 = new Static3D( d2*(+0.5f), d2*(-0.5f), d2*(+0.5f) );
|
|
151 |
Static3D dVec3 = new Static3D( d2*(+0.5f), d2*(-0.5f), d2*(-0.5f) );
|
|
152 |
Static3D dVec4 = new Static3D( d2*(-0.5f), d2*(+0.5f), d2*(+0.5f) );
|
|
153 |
Static3D dVec5 = new Static3D( d2*(-0.5f), d2*(+0.5f), d2*(-0.5f) );
|
|
154 |
Static3D dVec6 = new Static3D( d2*(-0.5f), d2*(-0.5f), d2*(+0.5f) );
|
|
155 |
Static3D dVec7 = new Static3D( d2*(-0.5f), d2*(-0.5f), d2*(-0.5f) );
|
|
156 |
|
|
157 |
Static4D dReg = new Static4D(0,0,0,d3);
|
|
158 |
Static1D dRad = new Static1D(1);
|
|
159 |
|
|
160 |
VertexEffectMove effect0 = new VertexEffectMove(new Static3D(0,0,+0.5f));
|
|
161 |
VertexEffectRotate effect1 = new VertexEffectRotate( angle180, axisX, center );
|
|
162 |
VertexEffectRotate effect2 = new VertexEffectRotate( angle90 , axisX, center );
|
|
163 |
VertexEffectRotate effect3 = new VertexEffectRotate( angle270, axisX, center );
|
|
164 |
VertexEffectRotate effect4 = new VertexEffectRotate( angle270, axisY, center );
|
|
165 |
VertexEffectRotate effect5 = new VertexEffectRotate( angle90 , axisY, center );
|
|
166 |
|
|
167 |
VertexEffectDeform effect6 = new VertexEffectDeform(dVec0, dRad, dCen0, dReg);
|
|
168 |
VertexEffectDeform effect7 = new VertexEffectDeform(dVec1, dRad, dCen1, dReg);
|
|
169 |
VertexEffectDeform effect8 = new VertexEffectDeform(dVec2, dRad, dCen2, dReg);
|
|
170 |
VertexEffectDeform effect9 = new VertexEffectDeform(dVec3, dRad, dCen3, dReg);
|
|
171 |
VertexEffectDeform effect10= new VertexEffectDeform(dVec4, dRad, dCen4, dReg);
|
|
172 |
VertexEffectDeform effect11= new VertexEffectDeform(dVec5, dRad, dCen5, dReg);
|
|
173 |
VertexEffectDeform effect12= new VertexEffectDeform(dVec6, dRad, dCen6, dReg);
|
|
174 |
VertexEffectDeform effect13= new VertexEffectDeform(dVec7, dRad, dCen7, dReg);
|
|
175 |
|
|
176 |
effect0.setMeshAssociation(63,-1); // all 6 sides
|
|
177 |
effect1.setMeshAssociation(32,-1); // back
|
|
178 |
effect2.setMeshAssociation( 8,-1); // bottom
|
|
179 |
effect3.setMeshAssociation( 4,-1); // top
|
|
180 |
effect4.setMeshAssociation( 2,-1); // left
|
|
181 |
effect5.setMeshAssociation( 1,-1); // right
|
|
182 |
|
|
183 |
mesh.apply(effect0);
|
|
184 |
mesh.apply(effect1);
|
|
185 |
mesh.apply(effect2);
|
|
186 |
mesh.apply(effect3);
|
|
187 |
mesh.apply(effect4);
|
|
188 |
mesh.apply(effect5);
|
|
189 |
mesh.apply(effect6);
|
|
190 |
mesh.apply(effect7);
|
|
191 |
mesh.apply(effect8);
|
|
192 |
mesh.apply(effect9);
|
|
193 |
mesh.apply(effect10);
|
|
194 |
mesh.apply(effect11);
|
|
195 |
mesh.apply(effect12);
|
|
196 |
mesh.apply(effect13);
|
|
197 |
|
|
198 |
mesh.mergeEffComponents();
|
|
199 |
|
|
200 |
return mesh;
|
|
201 |
}
|
|
202 |
|
|
203 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
204 |
// SKEWB
|
|
205 |
|
|
206 |
MeshBase createSkewbCornerMesh()
|
|
207 |
{
|
|
208 |
float D = 0.02f;
|
|
209 |
float E = 0.5f;
|
|
210 |
float F = SQ2/2;
|
|
211 |
|
|
212 |
float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
|
|
213 |
|
|
214 |
float[] bands0 = { 1.0f , 0,
|
|
215 |
1.0f-2*D, D*0.25f,
|
|
216 |
1.0f-4*D, D*0.35f,
|
|
217 |
1.0f-8*D, D*0.6f,
|
|
218 |
0.60f , D*1.0f,
|
|
219 |
0.30f , D*1.375f,
|
|
220 |
0.0f , D*1.4f };
|
|
221 |
|
|
222 |
MeshBase[] meshes = new MeshBase[6];
|
|
223 |
|
|
224 |
meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
|
|
225 |
meshes[0].setEffectAssociation(0,1,0);
|
|
226 |
meshes[1] = meshes[0].copy(true);
|
|
227 |
meshes[1].setEffectAssociation(0,2,0);
|
|
228 |
meshes[2] = meshes[0].copy(true);
|
|
229 |
meshes[2].setEffectAssociation(0,4,0);
|
|
230 |
|
|
231 |
float[] vertices1 = { 0,0, F,0, F/2,(SQ3/2)*F };
|
|
232 |
float[] bands1 = { 1.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f };
|
|
233 |
|
|
234 |
meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
|
|
235 |
meshes[3].setEffectAssociation(0,8,0);
|
|
236 |
meshes[4] = meshes[3].copy(true);
|
|
237 |
meshes[4].setEffectAssociation(0,16,0);
|
|
238 |
meshes[5] = meshes[3].copy(true);
|
|
239 |
meshes[5].setEffectAssociation(0,32,0);
|
|
240 |
|
|
241 |
MeshBase mesh = new MeshJoined(meshes);
|
|
242 |
|
|
243 |
Static3D axisX = new Static3D(1,0,0);
|
|
244 |
Static3D axisY = new Static3D(0,1,0);
|
|
245 |
Static3D axis0 = new Static3D(-SQ2/2,0,SQ2/2);
|
|
246 |
Static3D axis1 = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
|
|
247 |
Static1D angle1 = new Static1D(+90);
|
|
248 |
Static1D angle2 = new Static1D(-90);
|
|
249 |
Static1D angle3 = new Static1D(-15);
|
|
250 |
Static1D angle4 = new Static1D((float)((180.0f/Math.PI)*Math.acos(SQ3/3)));
|
|
251 |
Static1D angle5 = new Static1D(120);
|
|
252 |
Static1D angle6 = new Static1D(240);
|
|
253 |
Static3D center1= new Static3D(0,0,0);
|
|
254 |
Static3D center2= new Static3D(-0.5f,-0.5f,-0.5f);
|
|
255 |
Static3D move1 = new Static3D(-E/4,-E/4,0);
|
|
256 |
Static3D move2 = new Static3D(-0.5f,-0.5f,-0.5f);
|
|
257 |
|
|
258 |
float d0 =-0.04f;
|
|
259 |
float d1 = 0.04f;
|
|
260 |
float r0 = 0.15f;
|
|
261 |
float r1 = 0.10f;
|
|
262 |
|
|
263 |
Static3D vec0 = new Static3D(d0*(+SQ3/3),d0*(+SQ3/3),d0*(+SQ3/3));
|
|
264 |
Static3D vec1 = new Static3D(d1*(+SQ3/3),d1*(-SQ3/3),d1*(-SQ3/3));
|
|
265 |
Static3D vec2 = new Static3D(d1*(-SQ3/3),d1*(+SQ3/3),d1*(-SQ3/3));
|
|
266 |
Static3D vec3 = new Static3D(d1*(-SQ3/3),d1*(-SQ3/3),d1*(+SQ3/3));
|
|
267 |
|
|
268 |
Static1D radius = new Static1D(0.5f);
|
|
269 |
|
|
270 |
Static3D cent0 = new Static3D( 0.0f, 0.0f, 0.0f);
|
|
271 |
Static3D cent1 = new Static3D(-0.5f, 0.0f, 0.0f);
|
|
272 |
Static3D cent2 = new Static3D( 0.0f,-0.5f, 0.0f);
|
|
273 |
Static3D cent3 = new Static3D( 0.0f, 0.0f,-0.5f);
|
|
274 |
|
|
275 |
Static4D reg0 = new Static4D(0,0,0,r0);
|
|
276 |
Static4D reg1 = new Static4D(0,0,0,r1);
|
|
277 |
|
|
278 |
VertexEffectMove effect0 = new VertexEffectMove(move1);
|
|
279 |
VertexEffectScale effect1 = new VertexEffectScale(new Static3D(1,1,-1));
|
|
280 |
VertexEffectRotate effect2 = new VertexEffectRotate(angle1,axisX,center1);
|
|
281 |
VertexEffectRotate effect3 = new VertexEffectRotate(angle2,axisY,center1);
|
|
282 |
VertexEffectMove effect4 = new VertexEffectMove(move2);
|
|
283 |
VertexEffectRotate effect5 = new VertexEffectRotate(angle1,axisX,center2);
|
|
284 |
VertexEffectRotate effect6 = new VertexEffectRotate(angle3,axisY,center2);
|
|
285 |
VertexEffectRotate effect7 = new VertexEffectRotate(angle4,axis0,center2);
|
|
286 |
VertexEffectRotate effect8 = new VertexEffectRotate(angle5,axis1,center2);
|
|
287 |
VertexEffectRotate effect9 = new VertexEffectRotate(angle6,axis1,center2);
|
|
288 |
|
|
289 |
VertexEffectDeform effect10= new VertexEffectDeform(vec0,radius,cent0,reg0);
|
|
290 |
VertexEffectDeform effect11= new VertexEffectDeform(vec1,radius,cent1,reg1);
|
|
291 |
VertexEffectDeform effect12= new VertexEffectDeform(vec2,radius,cent2,reg1);
|
|
292 |
VertexEffectDeform effect13= new VertexEffectDeform(vec3,radius,cent3,reg1);
|
|
293 |
|
|
294 |
effect0.setMeshAssociation( 7,-1); // meshes 0,1,2
|
|
295 |
effect1.setMeshAssociation( 6,-1); // meshes 1,2
|
|
296 |
effect2.setMeshAssociation( 2,-1); // mesh 1
|
|
297 |
effect3.setMeshAssociation( 4,-1); // mesh 2
|
|
298 |
effect4.setMeshAssociation(56,-1); // meshes 3,4,5
|
|
299 |
effect5.setMeshAssociation(56,-1); // meshes 3,4,5
|
|
300 |
effect6.setMeshAssociation(56,-1); // meshes 3,4,5
|
|
301 |
effect7.setMeshAssociation(56,-1); // meshes 3,4,5
|
|
302 |
effect8.setMeshAssociation(16,-1); // mesh 4
|
|
303 |
effect9.setMeshAssociation(32,-1); // mesh 5
|
|
304 |
|
|
305 |
effect10.setMeshAssociation(63,-1); // all meshes
|
|
306 |
effect11.setMeshAssociation(63,-1); // all meshes
|
|
307 |
effect12.setMeshAssociation(63,-1); // all meshes
|
|
308 |
effect13.setMeshAssociation(63,-1); // all meshes
|
|
309 |
|
|
310 |
mesh.apply(effect0);
|
|
311 |
mesh.apply(effect1);
|
|
312 |
mesh.apply(effect2);
|
|
313 |
mesh.apply(effect3);
|
|
314 |
mesh.apply(effect4);
|
|
315 |
mesh.apply(effect5);
|
|
316 |
mesh.apply(effect6);
|
|
317 |
mesh.apply(effect7);
|
|
318 |
mesh.apply(effect8);
|
|
319 |
mesh.apply(effect9);
|
|
320 |
|
|
321 |
mesh.apply(effect10);
|
|
322 |
mesh.apply(effect11);
|
|
323 |
mesh.apply(effect12);
|
|
324 |
mesh.apply(effect13);
|
|
325 |
|
|
326 |
mesh.mergeEffComponents();
|
|
327 |
|
|
328 |
return mesh;
|
|
329 |
}
|
|
330 |
|
|
331 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
332 |
|
|
333 |
MeshBase createSkewbFaceMesh()
|
|
334 |
{
|
|
335 |
int association = 1;
|
|
336 |
|
|
337 |
float D = 0.03f;
|
|
338 |
float E = SQ2/4;
|
|
339 |
float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
|
|
340 |
|
|
341 |
float[] bands0 = { 1.0f , 0,
|
|
342 |
1.0f-D/2, D*0.30f,
|
|
343 |
1.0f- D , D*0.50f,
|
|
344 |
1.0f-2*D, D*0.80f,
|
|
345 |
0.60f , D*1.40f,
|
|
346 |
0.30f , D*1.60f,
|
|
347 |
0.0f , D*1.70f };
|
|
348 |
|
|
349 |
MeshBase[] meshes = new MeshBase[6];
|
|
350 |
meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
|
|
351 |
meshes[0].setEffectAssociation(0,association,0);
|
|
352 |
|
|
353 |
association <<= 1;
|
|
354 |
|
|
355 |
float[] vertices1 = { -E,-SQ3*E, +E,-SQ3*E, 0,0 };
|
|
356 |
float[] bands1 = { 1.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f };
|
|
357 |
|
|
358 |
meshes[1] = new MeshPolygon(vertices1,bands1,0,0);
|
|
359 |
meshes[1].setEffectAssociation(0,association,0);
|
|
360 |
|
|
361 |
for(int i=2; i<5; i++)
|
|
362 |
{
|
|
363 |
association <<= 1;
|
|
364 |
meshes[i] = meshes[1].copy(true);
|
|
365 |
meshes[i].setEffectAssociation(0,association,0);
|
|
366 |
}
|
|
367 |
|
|
368 |
association <<= 1;
|
|
369 |
meshes[5] = new MeshTriangle(1); // empty triangle so that
|
|
370 |
meshes[5].setEffectAssociation(0,association,0); // all cubits have 6 faces
|
|
371 |
|
|
372 |
MeshBase mesh = new MeshJoined(meshes);
|
|
373 |
|
|
374 |
Static3D center = new Static3D(0,0,0);
|
|
375 |
Static3D axis1 = new Static3D(1,0,0);
|
|
376 |
Static3D axis2 = new Static3D(0,0,1);
|
|
377 |
float angle = -(float)((180.0f/Math.PI)*Math.acos(SQ3/3));
|
|
378 |
|
|
379 |
float f = 0.05f;
|
|
380 |
float r = 0.10f;
|
|
381 |
float d = 0.5f;
|
|
382 |
float e = +D*0.6f;
|
|
383 |
Static3D vector0 = new Static3D(-f, 0, 0);
|
|
384 |
Static3D vector1 = new Static3D( 0,+f, 0);
|
|
385 |
Static3D vector2 = new Static3D(+f, 0, 0);
|
|
386 |
Static3D vector3 = new Static3D( 0,-f, 0);
|
|
387 |
Static1D radius = new Static1D(1.0f);
|
|
388 |
Static4D region = new Static4D(0,0,0,r);
|
|
389 |
Static3D center0 = new Static3D(+d, 0, e);
|
|
390 |
Static3D center1 = new Static3D( 0,-d, e);
|
|
391 |
Static3D center2 = new Static3D(-d, 0, e);
|
|
392 |
Static3D center3 = new Static3D( 0,+d, e);
|
|
393 |
|
|
394 |
VertexEffectRotate effect0 = new VertexEffectRotate( new Static1D(angle), axis1, center);
|
|
395 |
VertexEffectRotate effect1 = new VertexEffectRotate( new Static1D( 135), axis2, center);
|
|
396 |
VertexEffectRotate effect2 = new VertexEffectRotate( new Static1D( 45), axis2, center);
|
|
397 |
VertexEffectRotate effect3 = new VertexEffectRotate( new Static1D( -45), axis2, center);
|
|
398 |
VertexEffectRotate effect4 = new VertexEffectRotate( new Static1D( -135), axis2, center);
|
|
399 |
VertexEffectMove effect5 = new VertexEffectMove( new Static3D(0,0,-0.5f) );
|
|
400 |
VertexEffectDeform effect6 = new VertexEffectDeform(vector0,radius,center0,region);
|
|
401 |
VertexEffectDeform effect7 = new VertexEffectDeform(vector1,radius,center1,region);
|
|
402 |
VertexEffectDeform effect8 = new VertexEffectDeform(vector2,radius,center2,region);
|
|
403 |
VertexEffectDeform effect9 = new VertexEffectDeform(vector3,radius,center3,region);
|
|
404 |
VertexEffectScale effect10= new VertexEffectScale(0.01f);
|
|
405 |
|
|
406 |
effect0.setMeshAssociation(30,-1); // meshes 1,2,3,4
|
|
407 |
effect1.setMeshAssociation( 2,-1); // mesh 1
|
|
408 |
effect2.setMeshAssociation( 5,-1); // meshes 0,2
|
|
409 |
effect3.setMeshAssociation( 8,-1); // mesh 3
|
|
410 |
effect4.setMeshAssociation(16,-1); // mesh 4
|
|
411 |
effect5.setMeshAssociation(30,-1); // meshes 1,2,3,4
|
|
412 |
effect6.setMeshAssociation(31,-1); // meshes 0,1,2,3,4
|
|
413 |
effect7.setMeshAssociation(31,-1); // meshes 0,1,2,3,4
|
|
414 |
effect8.setMeshAssociation(31,-1); // meshes 0,1,2,3,4
|
|
415 |
effect9.setMeshAssociation(31,-1); // meshes 0,1,2,3,4
|
|
416 |
effect10.setMeshAssociation(32,-1); // mesh 5
|
|
417 |
|
|
418 |
mesh.apply(effect0);
|
|
419 |
mesh.apply(effect1);
|
|
420 |
mesh.apply(effect2);
|
|
421 |
mesh.apply(effect3);
|
|
422 |
mesh.apply(effect4);
|
|
423 |
mesh.apply(effect5);
|
|
424 |
mesh.apply(effect6);
|
|
425 |
mesh.apply(effect7);
|
|
426 |
mesh.apply(effect8);
|
|
427 |
mesh.apply(effect9);
|
|
428 |
mesh.apply(effect10);
|
|
429 |
|
|
430 |
mesh.mergeEffComponents();
|
|
431 |
|
|
432 |
return mesh;
|
|
433 |
}
|
|
434 |
|
|
435 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
436 |
// SKEWB DIAMOND / PYRAMINX
|
|
437 |
|
|
438 |
MeshBase createOctaMesh()
|
|
439 |
{
|
|
440 |
int association = 1;
|
|
441 |
|
|
442 |
float C = 0.06f;
|
|
443 |
float D = 0.02f;
|
|
444 |
float E = SQ3/2;
|
|
445 |
float F = 0.5f;
|
|
446 |
|
|
447 |
float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
|
|
448 |
|
|
449 |
float[] bands = new float[] { 1.0f , 0,
|
|
450 |
1.0f -C, D*0.55f,
|
|
451 |
1.0f-2*C, D*0.85f,
|
|
452 |
1.0f-4*C, D*1.20f,
|
|
453 |
0.5f , D*1.40f,
|
|
454 |
0.0f , D*1.50f };
|
|
455 |
|
|
456 |
MeshBase[] meshes = new MeshPolygon[8];
|
|
457 |
meshes[0] = new MeshPolygon(vertices, bands, 2,2);
|
|
458 |
meshes[0].setEffectAssociation(0,association,0);
|
|
459 |
|
|
460 |
for(int i=1; i<8; i++)
|
|
461 |
{
|
|
462 |
association <<= 1;
|
|
463 |
meshes[i] = meshes[0].copy(true);
|
|
464 |
meshes[i].setEffectAssociation(0,association,0);
|
|
465 |
}
|
|
466 |
|
|
467 |
MeshBase mesh = new MeshJoined(meshes);
|
|
468 |
|
|
469 |
float d1 = SQ2/2;
|
|
470 |
float d2 =-0.06f;
|
|
471 |
float d3 = 0.20f;
|
|
472 |
|
|
473 |
Static3D a0 = new Static3D( 0, 1, 0 );
|
|
474 |
Static3D a1 = new Static3D( SQ2/2, 0, SQ2/2 );
|
|
475 |
Static3D a2 = new Static3D(-SQ2/2, 0, SQ2/2 );
|
|
476 |
|
|
477 |
Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
|
|
478 |
Static1D angle1= new Static1D( 90);
|
|
479 |
Static1D angle2= new Static1D(180);
|
|
480 |
Static1D angle3= new Static1D(270);
|
|
481 |
|
|
482 |
Static3D move1 = new Static3D(0,SQ2/2-SQ3/3,0);
|
|
483 |
|
|
484 |
Static3D axisX = new Static3D(1,0,0);
|
|
485 |
Static3D axisY = new Static3D(0,1,0);
|
|
486 |
|
|
487 |
Static3D cent0 = new Static3D(0,0,0);
|
|
488 |
Static3D cent1 = new Static3D(0,SQ2/2,0);
|
|
489 |
|
|
490 |
Static3D flipY = new Static3D( 1,-1, 1);
|
|
491 |
|
|
492 |
Static3D dCen0 = new Static3D( d1*a0.get0(), d1*a0.get1(), d1*a0.get2() );
|
|
493 |
Static3D dCen1 = new Static3D( d1*a1.get0(), d1*a1.get1(), d1*a1.get2() );
|
|
494 |
Static3D dCen2 = new Static3D( d1*a2.get0(), d1*a2.get1(), d1*a2.get2() );
|
|
495 |
Static3D dCen3 = new Static3D(-d1*a0.get0(),-d1*a0.get1(),-d1*a0.get2() );
|
|
496 |
Static3D dCen4 = new Static3D(-d1*a1.get0(),-d1*a2.get1(),-d1*a2.get2() );
|
|
497 |
Static3D dCen5 = new Static3D(-d1*a2.get0(),-d1*a1.get1(),-d1*a1.get2() );
|
|
498 |
|
|
499 |
Static3D dVec0 = new Static3D( d2*a0.get0(), d2*a0.get1(), d2*a0.get2() );
|
|
500 |
Static3D dVec1 = new Static3D( d2*a1.get0(), d2*a1.get1(), d2*a1.get2() );
|
|
501 |
Static3D dVec2 = new Static3D( d2*a2.get0(), d2*a2.get1(), d2*a2.get2() );
|
|
502 |
Static3D dVec3 = new Static3D(-d2*a0.get0(),-d2*a0.get1(),-d2*a0.get2() );
|
|
503 |
Static3D dVec4 = new Static3D(-d2*a1.get0(),-d2*a1.get1(),-d2*a1.get2() );
|
|
504 |
Static3D dVec5 = new Static3D(-d2*a2.get0(),-d2*a2.get1(),-d2*a2.get2() );
|
|
505 |
|
|
506 |
Static4D dReg = new Static4D(0,0,0,d3);
|
|
507 |
Static1D dRad = new Static1D(1);
|
|
508 |
|
|
509 |
VertexEffectMove effect0 = new VertexEffectMove(move1);
|
|
510 |
VertexEffectRotate effect1 = new VertexEffectRotate(alpha , axisX, cent1);
|
|
511 |
VertexEffectRotate effect2 = new VertexEffectRotate(angle1, axisY, cent0);
|
|
512 |
VertexEffectRotate effect3 = new VertexEffectRotate(angle2, axisY, cent0);
|
|
513 |
VertexEffectRotate effect4 = new VertexEffectRotate(angle3, axisY, cent0);
|
|
514 |
VertexEffectScale effect5 = new VertexEffectScale(flipY);
|
|
515 |
|
|
516 |
VertexEffectDeform effect6 = new VertexEffectDeform(dVec0, dRad, dCen0, dReg);
|
|
517 |
VertexEffectDeform effect7 = new VertexEffectDeform(dVec1, dRad, dCen1, dReg);
|
|
518 |
VertexEffectDeform effect8 = new VertexEffectDeform(dVec2, dRad, dCen2, dReg);
|
|
519 |
VertexEffectDeform effect9 = new VertexEffectDeform(dVec3, dRad, dCen3, dReg);
|
|
520 |
VertexEffectDeform effect10= new VertexEffectDeform(dVec4, dRad, dCen4, dReg);
|
|
521 |
VertexEffectDeform effect11= new VertexEffectDeform(dVec5, dRad, dCen5, dReg);
|
|
522 |
|
|
523 |
effect0.setMeshAssociation (255,-1); // apply to all meshes
|
|
524 |
effect1.setMeshAssociation (255,-1); // apply to all meshes
|
|
525 |
effect2.setMeshAssociation ( 34,-1); // apply to meshes 1 & 5
|
|
526 |
effect3.setMeshAssociation ( 68,-1); // apply to meshes 2 & 6
|
|
527 |
effect4.setMeshAssociation (136,-1); // apply to meshes 3 & 7
|
|
528 |
effect5.setMeshAssociation (240,-1); // apply to meshes 4,5,6,7
|
|
529 |
effect6.setMeshAssociation (255,-1); // apply to all meshes
|
|
530 |
effect7.setMeshAssociation (255,-1); // apply to all meshes
|
|
531 |
effect8.setMeshAssociation (255,-1); // apply to all meshes
|
|
532 |
effect9.setMeshAssociation (255,-1); // apply to all meshes
|
|
533 |
effect10.setMeshAssociation(255,-1); // apply to all meshes
|
|
534 |
effect11.setMeshAssociation(255,-1); // apply to all meshes
|
|
535 |
|
|
536 |
mesh.apply(effect0);
|
|
537 |
mesh.apply(effect1);
|
|
538 |
mesh.apply(effect2);
|
|
539 |
mesh.apply(effect3);
|
|
540 |
mesh.apply(effect4);
|
|
541 |
mesh.apply(effect5);
|
|
542 |
mesh.apply(effect6);
|
|
543 |
mesh.apply(effect7);
|
|
544 |
mesh.apply(effect8);
|
|
545 |
mesh.apply(effect9);
|
|
546 |
mesh.apply(effect10);
|
|
547 |
mesh.apply(effect11);
|
|
548 |
|
|
549 |
mesh.mergeEffComponents();
|
|
550 |
|
|
551 |
return mesh;
|
|
552 |
}
|
|
553 |
|
|
554 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
555 |
|
|
556 |
MeshBase createTetraMesh()
|
|
557 |
{
|
|
558 |
int association = 1;
|
|
559 |
|
|
560 |
float C = 0.06f;
|
|
561 |
float D = 0.035f;
|
|
562 |
float E = SQ3/2;
|
|
563 |
float F = 0.5f;
|
|
564 |
|
|
565 |
float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
|
|
566 |
|
|
567 |
float[] bands = new float[] { 1.0f , 0,
|
|
568 |
1.0f -C, D*0.50f,
|
|
569 |
1.0f-2*C, D*0.80f,
|
|
570 |
1.0f-4*C, D*1.10f,
|
|
571 |
0.5f , D*1.30f,
|
|
572 |
0.0f , D*1.35f };
|
|
573 |
|
|
574 |
MeshBase[] meshes = new MeshBase[8];
|
|
575 |
meshes[0] = new MeshPolygon(vertices, bands, 2,2);
|
|
576 |
meshes[0].setEffectAssociation(0,association,0);
|
|
577 |
|
|
578 |
for(int i=1; i<4; i++)
|
|
579 |
{
|
|
580 |
association <<= 1;
|
|
581 |
meshes[i] = meshes[0].copy(true);
|
|
582 |
meshes[i].setEffectAssociation(0,association,0);
|
|
583 |
}
|
|
584 |
|
|
585 |
for(int i=4; i<8; i++)
|
|
586 |
{
|
|
587 |
association <<= 1;
|
|
588 |
meshes[i] = new MeshTriangle(1);
|
|
589 |
meshes[i].setEffectAssociation(0,association,0);
|
|
590 |
}
|
|
591 |
|
|
592 |
MeshBase mesh = new MeshJoined(meshes);
|
|
593 |
|
|
594 |
Static3D flipZ = new Static3D( 1, 1,-1);
|
|
595 |
|
|
596 |
Static1D alpha = new Static1D((float)(-(180/Math.PI)*Math.asin(SQ3/3)));
|
|
597 |
Static1D angle1= new Static1D( 90);
|
|
598 |
Static1D angle2= new Static1D(180);
|
|
599 |
Static3D move1 = new Static3D(0,SQ2/4-SQ3/6,0);
|
|
600 |
|
|
601 |
Static3D axisX = new Static3D(1,0,0);
|
|
602 |
Static3D axisY = new Static3D(0,1,0);
|
|
603 |
Static3D axisZ = new Static3D(0,0,1);
|
|
604 |
|
|
605 |
Static3D cent0 = new Static3D(0,0,0);
|
|
606 |
Static3D cent1 = new Static3D(0,SQ2/4,0);
|
|
607 |
|
|
608 |
float d1 =-1.00f;
|
|
609 |
float d2 = 0.10f;
|
|
610 |
float d3 = 0.15f;
|
|
611 |
|
|
612 |
float vx = 0.5f ;
|
|
613 |
float vy = (SQ2/4);
|
|
614 |
|
|
615 |
Static3D a0 = new Static3D(+vx,-vy, 0 );
|
|
616 |
Static3D a1 = new Static3D(-vx,-vy, 0 );
|
|
617 |
Static3D a2 = new Static3D( 0, vy,-vx);
|
|
618 |
Static3D a3 = new Static3D( 0, vy,+vx);
|
|
619 |
|
|
620 |
Static4D dReg = new Static4D(0,0,0,d3);
|
|
621 |
Static1D dRad = new Static1D(1);
|
|
622 |
|
|
623 |
Static3D dCen0 = new Static3D( d1*a0.get0(), d1*a0.get1(), d1*a0.get2() );
|
|
624 |
Static3D dCen1 = new Static3D( d1*a1.get0(), d1*a1.get1(), d1*a1.get2() );
|
|
625 |
Static3D dCen2 = new Static3D( d1*a2.get0(), d1*a2.get1(), d1*a2.get2() );
|
|
626 |
Static3D dCen3 = new Static3D( d1*a3.get0(), d1*a3.get1(), d1*a3.get2() );
|
|
627 |
|
|
628 |
Static3D dVec0 = new Static3D( d2*a0.get0(), d2*a0.get1(), d2*a0.get2() );
|
|
629 |
Static3D dVec1 = new Static3D( d2*a1.get0(), d2*a1.get1(), d2*a1.get2() );
|
|
630 |
Static3D dVec2 = new Static3D( d2*a2.get0(), d2*a2.get1(), d2*a2.get2() );
|
|
631 |
Static3D dVec3 = new Static3D( d2*a3.get0(), d2*a3.get1(), d2*a3.get2() );
|
|
632 |
|
|
633 |
VertexEffectRotate effect0 = new VertexEffectRotate(angle2, axisZ, cent0);
|
|
634 |
VertexEffectMove effect1 = new VertexEffectMove(move1);
|
|
635 |
VertexEffectRotate effect2 = new VertexEffectRotate(alpha , axisX, cent1);
|
|
636 |
VertexEffectScale effect3 = new VertexEffectScale(flipZ);
|
|
637 |
VertexEffectRotate effect4 = new VertexEffectRotate(angle1, axisY, cent0);
|
|
638 |
VertexEffectRotate effect5 = new VertexEffectRotate(angle2, axisZ, cent0);
|
|
639 |
|
|
640 |
VertexEffectDeform effect6 = new VertexEffectDeform(dVec0, dRad, dCen0, dReg);
|
|
641 |
VertexEffectDeform effect7 = new VertexEffectDeform(dVec1, dRad, dCen1, dReg);
|
|
642 |
VertexEffectDeform effect8 = new VertexEffectDeform(dVec2, dRad, dCen2, dReg);
|
|
643 |
VertexEffectDeform effect9 = new VertexEffectDeform(dVec3, dRad, dCen3, dReg);
|
|
644 |
|
|
645 |
VertexEffectScale effect10 = new VertexEffectScale(0.1f);
|
|
646 |
|
|
647 |
effect0.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
648 |
effect1.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
649 |
effect2.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
650 |
effect3.setMeshAssociation(10,-1); // meshes 1 & 3
|
|
651 |
effect4.setMeshAssociation(12,-1); // meshes 2 & 3
|
|
652 |
effect5.setMeshAssociation(12,-1); // meshes 2 & 3
|
|
653 |
effect6.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
654 |
effect7.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
655 |
effect8.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
656 |
effect9.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
657 |
effect10.setMeshAssociation(240,-1); // meshes 4,5,6,7
|
|
658 |
|
|
659 |
mesh.apply(effect0);
|
|
660 |
mesh.apply(effect1);
|
|
661 |
mesh.apply(effect2);
|
|
662 |
mesh.apply(effect3);
|
|
663 |
mesh.apply(effect4);
|
|
664 |
mesh.apply(effect5);
|
|
665 |
mesh.apply(effect6);
|
|
666 |
mesh.apply(effect7);
|
|
667 |
mesh.apply(effect8);
|
|
668 |
mesh.apply(effect9);
|
|
669 |
mesh.apply(effect10);
|
|
670 |
|
|
671 |
mesh.mergeEffComponents();
|
|
672 |
|
|
673 |
return mesh;
|
|
674 |
}
|
|
675 |
|
|
676 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
677 |
// DINO
|
|
678 |
|
|
679 |
MeshBase createDinoMesh()
|
|
680 |
{
|
|
681 |
final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
|
|
682 |
|
|
683 |
final int MESHES=4;
|
|
684 |
|
|
685 |
float D = 0.02f;
|
|
686 |
float E = 0.5f*SQ2;
|
|
687 |
float F = 0.5f;
|
|
688 |
|
|
689 |
float[] bands0 = { 1.0f , 0,
|
|
690 |
1.0f-2*D, D*0.25f,
|
|
691 |
1.0f-4*D, D*0.35f,
|
|
692 |
1.0f-8*D, D*0.6f,
|
|
693 |
0.60f , D*1.0f,
|
|
694 |
0.30f , D*1.375f,
|
|
695 |
0.0f , D*1.4f };
|
|
696 |
|
|
697 |
float[] vertices0 = { -F,F/3, 0,-2*F/3, +F,F/3 };
|
|
698 |
|
|
699 |
MeshBase[] meshes = new MeshPolygon[MESHES];
|
|
700 |
meshes[0] = new MeshPolygon(vertices0, bands0, 2, 5);
|
|
701 |
meshes[0].setEffectAssociation(0,1,0);
|
|
702 |
meshes[1] = meshes[0].copy(true);
|
|
703 |
meshes[1].setEffectAssociation(0,2,0);
|
|
704 |
|
|
705 |
float[] bands1 = { 1.0f , 0,
|
|
706 |
0.50f , 0.10f,
|
|
707 |
0.0f , 0.20f };
|
|
708 |
|
|
709 |
float[] vertices1 = { -E/2,-E*(SQ3/6), E/2,-E*(SQ3/6), 0,E*(SQ3/3) };
|
|
710 |
|
|
711 |
meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
|
|
712 |
meshes[2].setEffectAssociation(0,4,0);
|
|
713 |
meshes[3] = meshes[2].copy(true);
|
|
714 |
meshes[3].setEffectAssociation(0,8,0);
|
|
715 |
|
|
716 |
MeshBase mesh = new MeshJoined(meshes);
|
|
717 |
|
|
718 |
Static3D a0 = new Static3D( 0,-3*F, 0 );
|
|
719 |
Static3D a1 = new Static3D( 0, 0, -3*F );
|
|
720 |
Static3D a2 = new Static3D( -3*F, 0, 0 );
|
|
721 |
Static3D a3 = new Static3D( +3*F, 0, 0 );
|
|
722 |
|
|
723 |
Static3D v0 = new Static3D( 0,-3*F/2, 3*F/2 );
|
|
724 |
Static3D v1 = new Static3D( 0, 3*F/2,-3*F/2 );
|
|
725 |
Static3D v2 = new Static3D( -3*F, 3*F/2, 3*F/2 );
|
|
726 |
Static3D v3 = new Static3D( +3*F, 3*F/2, 3*F/2 );
|
|
727 |
|
|
728 |
float d1 = 1.0f;
|
|
729 |
float d2 =-0.10f;
|
|
730 |
float d3 =-0.10f;
|
|
731 |
float d4 = 0.40f;
|
|
732 |
|
|
733 |
Static3D dCen0 = new Static3D( d1*a0.get0(), d1*a0.get1(), d1*a0.get2() );
|
|
734 |
Static3D dCen1 = new Static3D( d1*a1.get0(), d1*a1.get1(), d1*a1.get2() );
|
|
735 |
Static3D dCen2 = new Static3D( d1*a2.get0(), d1*a2.get1(), d1*a2.get2() );
|
|
736 |
Static3D dCen3 = new Static3D( d1*a3.get0(), d1*a3.get1(), d1*a3.get2() );
|
|
737 |
|
|
738 |
Static3D dVec0 = new Static3D( d3*v0.get0(), d3*v0.get1(), d3*v0.get2() );
|
|
739 |
Static3D dVec1 = new Static3D( d3*v1.get0(), d3*v1.get1(), d3*v1.get2() );
|
|
740 |
Static3D dVec2 = new Static3D( d2*v2.get0(), d2*v2.get1(), d2*v2.get2() );
|
|
741 |
Static3D dVec3 = new Static3D( d2*v3.get0(), d2*v3.get1(), d2*v3.get2() );
|
|
742 |
|
|
743 |
Static4D dReg = new Static4D(0,0,0,d4);
|
|
744 |
Static1D dRad = new Static1D(1);
|
|
745 |
|
|
746 |
Static1D angle1 = new Static1D(+ANGLE);
|
|
747 |
Static1D angle2 = new Static1D(-ANGLE);
|
|
748 |
|
|
749 |
Static3D axisX = new Static3D(1,0,0);
|
|
750 |
Static3D axisY = new Static3D(0,1,0);
|
|
751 |
Static3D axisZ = new Static3D(0,-1,1);
|
|
752 |
|
|
753 |
Static3D center0= new Static3D(0,0,0);
|
|
754 |
Static3D center1= new Static3D(0,-3*F,0);
|
|
755 |
|
|
756 |
VertexEffectScale effect0 = new VertexEffectScale ( new Static3D(3,3,3) );
|
|
757 |
VertexEffectMove effect1 = new VertexEffectMove ( new Static3D(0,-F,0) );
|
|
758 |
VertexEffectRotate effect2 = new VertexEffectRotate( new Static1D(90), axisX, center0 );
|
|
759 |
VertexEffectScale effect3 = new VertexEffectScale ( new Static3D(1,-1,1) );
|
|
760 |
VertexEffectMove effect4 = new VertexEffectMove ( new Static3D(3*E/2,E*(SQ3/2)-3*F,0) );
|
|
761 |
VertexEffectRotate effect5 = new VertexEffectRotate( new Static1D(+90), axisY, center1 );
|
|
762 |
VertexEffectScale effect6 = new VertexEffectScale ( new Static3D(-1,1,1) );
|
|
763 |
VertexEffectRotate effect7 = new VertexEffectRotate( new Static1D( 45), axisX, center1 );
|
|
764 |
VertexEffectRotate effect8 = new VertexEffectRotate( angle1 , axisZ, center1 );
|
|
765 |
VertexEffectRotate effect9 = new VertexEffectRotate( angle2 , axisZ, center1 );
|
|
766 |
|
|
767 |
VertexEffectDeform effect10= new VertexEffectDeform(dVec0, dRad, dCen0, dReg);
|
|
768 |
VertexEffectDeform effect11= new VertexEffectDeform(dVec1, dRad, dCen1, dReg);
|
|
769 |
VertexEffectDeform effect12= new VertexEffectDeform(dVec2, dRad, dCen2, dReg);
|
|
770 |
VertexEffectDeform effect13= new VertexEffectDeform(dVec3, dRad, dCen3, dReg);
|
|
771 |
|
|
772 |
effect0.setMeshAssociation(15,-1); // apply to meshes 0,1,2,3
|
|
773 |
effect1.setMeshAssociation( 3,-1); // apply to meshes 0,1
|
|
774 |
effect2.setMeshAssociation( 2,-1); // apply to mesh 1
|
|
775 |
effect3.setMeshAssociation( 2,-1); // apply to mesh 0
|
|
776 |
effect4.setMeshAssociation(12,-1); // apply to meshes 2,3
|
|
777 |
effect5.setMeshAssociation(12,-1); // apply to meshes 2,3
|
|
778 |
effect6.setMeshAssociation( 8,-1); // apply to mesh 3
|
|
779 |
effect7.setMeshAssociation(12,-1); // apply to meshes 2,3
|
|
780 |
effect8.setMeshAssociation( 4,-1); // apply to mesh 2
|
|
781 |
effect9.setMeshAssociation( 8,-1); // apply to mesh 3
|
|
782 |
effect10.setMeshAssociation(15,-1); // apply to meshes 0,1,2,3
|
|
783 |
effect11.setMeshAssociation(15,-1); // apply to meshes 0,1,2,3
|
|
784 |
effect12.setMeshAssociation(15,-1); // apply to meshes 0,1,2,3
|
|
785 |
effect13.setMeshAssociation(15,-1); // apply to meshes 0,1,2,3
|
|
786 |
|
|
787 |
mesh.apply(effect0);
|
|
788 |
mesh.apply(effect1);
|
|
789 |
mesh.apply(effect2);
|
|
790 |
mesh.apply(effect3);
|
|
791 |
mesh.apply(effect4);
|
|
792 |
mesh.apply(effect5);
|
|
793 |
mesh.apply(effect6);
|
|
794 |
mesh.apply(effect7);
|
|
795 |
mesh.apply(effect8);
|
|
796 |
mesh.apply(effect9);
|
|
797 |
mesh.apply(effect10);
|
|
798 |
mesh.apply(effect11);
|
|
799 |
mesh.apply(effect12);
|
|
800 |
mesh.apply(effect13);
|
|
801 |
|
|
802 |
mesh.mergeEffComponents();
|
|
803 |
|
|
804 |
return mesh;
|
|
805 |
}
|
|
806 |
|
|
807 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
808 |
// Helicopter
|
|
809 |
|
|
810 |
MeshBase createHelicopterCornerMesh()
|
|
811 |
{
|
|
812 |
float D = 0.02f;
|
|
813 |
float E = 0.5f;
|
|
814 |
float F = SQ2/4;
|
|
815 |
|
|
816 |
float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
|
|
817 |
|
|
818 |
float[] bands0 = { 1.0f , 0,
|
|
819 |
1.0f-2*D, D*0.25f,
|
|
820 |
1.0f-4*D, D*0.35f,
|
|
821 |
1.0f-8*D, D*0.6f,
|
|
822 |
0.60f , D*1.0f,
|
|
823 |
0.30f , D*1.375f,
|
|
824 |
0.0f , D*1.4f };
|
|
825 |
|
|
826 |
MeshBase[] meshes = new MeshBase[6];
|
|
827 |
|
|
828 |
meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
|
|
829 |
meshes[0].setEffectAssociation(0,1,0);
|
|
830 |
meshes[1] = meshes[0].copy(true);
|
|
831 |
meshes[1].setEffectAssociation(0,2,0);
|
|
832 |
meshes[2] = meshes[0].copy(true);
|
|
833 |
meshes[2].setEffectAssociation(0,4,0);
|
|
834 |
|
|
835 |
float[] vertices1 = { -F,-1.0f/12, +F,-1.0f/12, 0,1.0f/6 };
|
|
836 |
float[] bands1 = { 1.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f };
|
|
837 |
|
|
838 |
meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
|
|
839 |
meshes[3].setEffectAssociation(0,8,0);
|
|
840 |
meshes[4] = meshes[3].copy(true);
|
|
841 |
meshes[4].setEffectAssociation(0,16,0);
|
|
842 |
meshes[5] = meshes[3].copy(true);
|
|
843 |
meshes[5].setEffectAssociation(0,32,0);
|
|
844 |
|
|
845 |
MeshBase mesh = new MeshJoined(meshes);
|
|
846 |
|
|
847 |
Static3D axisX = new Static3D(1,0,0);
|
|
848 |
Static3D axisY = new Static3D(0,1,0);
|
|
849 |
Static3D axis0 = new Static3D(-SQ2/2,0,SQ2/2);
|
|
850 |
Static3D axis1 = new Static3D(+SQ3/3,+SQ3/3,+SQ3/3);
|
|
851 |
Static1D angle1 = new Static1D(+90);
|
|
852 |
Static1D angle2 = new Static1D(-90);
|
|
853 |
Static1D angle3 = new Static1D(-135);
|
|
854 |
Static1D angle4 = new Static1D(90);
|
|
855 |
Static1D angle5 = new Static1D(120);
|
|
856 |
Static1D angle6 = new Static1D(240);
|
|
857 |
Static3D center1= new Static3D(0,0,0);
|
|
858 |
Static3D center2= new Static3D(-0.25f,-0.25f,-0.25f);
|
|
859 |
Static3D move1 = new Static3D(-E/4,-E/4,0);
|
|
860 |
Static3D move2 = new Static3D(-0.25f,(-1.0f/6)-0.25f,-0.25f);
|
|
861 |
|
|
862 |
float d0 =-0.04f;
|
|
863 |
float d1 = 0.04f;
|
|
864 |
float r0 = 0.15f;
|
|
865 |
float r1 = 0.10f;
|
|
866 |
|
|
867 |
Static3D vec0 = new Static3D(d0*(+SQ3/3),d0*(+SQ3/3),d0*(+SQ3/3));
|
|
868 |
Static3D vec1 = new Static3D(d1*(+SQ3/3),d1*(-SQ3/3),d1*(-SQ3/3));
|
|
869 |
Static3D vec2 = new Static3D(d1*(-SQ3/3),d1*(+SQ3/3),d1*(-SQ3/3));
|
|
870 |
Static3D vec3 = new Static3D(d1*(-SQ3/3),d1*(-SQ3/3),d1*(+SQ3/3));
|
|
871 |
|
|
872 |
Static1D radius = new Static1D(0.5f);
|
|
873 |
|
|
874 |
Static3D cent0 = new Static3D( 0.0f, 0.0f, 0.0f);
|
|
875 |
Static3D cent1 = new Static3D(-0.5f, 0.0f, 0.0f);
|
|
876 |
Static3D cent2 = new Static3D( 0.0f,-0.5f, 0.0f);
|
|
877 |
Static3D cent3 = new Static3D( 0.0f, 0.0f,-0.5f);
|
|
878 |
|
|
879 |
Static4D reg0 = new Static4D(0,0,0,r0);
|
|
880 |
Static4D reg1 = new Static4D(0,0,0,r1);
|
|
881 |
|
|
882 |
VertexEffectMove effect0 = new VertexEffectMove(move1);
|
|
883 |
VertexEffectScale effect1 = new VertexEffectScale(new Static3D(1,1,-1));
|
|
884 |
VertexEffectRotate effect2 = new VertexEffectRotate(angle1,axisX,center1);
|
|
885 |
VertexEffectRotate effect3 = new VertexEffectRotate(angle2,axisY,center1);
|
|
886 |
VertexEffectMove effect4 = new VertexEffectMove(move2);
|
|
887 |
VertexEffectRotate effect5 = new VertexEffectRotate(angle1,axisX,center2);
|
|
888 |
VertexEffectRotate effect6 = new VertexEffectRotate(angle3,axisY,center2);
|
|
889 |
VertexEffectRotate effect7 = new VertexEffectRotate(angle4,axis0,center2);
|
|
890 |
VertexEffectRotate effect8 = new VertexEffectRotate(angle5,axis1,center2);
|
|
891 |
VertexEffectRotate effect9 = new VertexEffectRotate(angle6,axis1,center2);
|
|
892 |
|
|
893 |
VertexEffectDeform effect10= new VertexEffectDeform(vec0,radius,cent0,reg0);
|
|
894 |
VertexEffectDeform effect11= new VertexEffectDeform(vec1,radius,cent1,reg1);
|
|
895 |
VertexEffectDeform effect12= new VertexEffectDeform(vec2,radius,cent2,reg1);
|
|
896 |
VertexEffectDeform effect13= new VertexEffectDeform(vec3,radius,cent3,reg1);
|
|
897 |
|
|
898 |
effect0.setMeshAssociation( 7,-1); // meshes 0,1,2
|
|
899 |
effect1.setMeshAssociation( 6,-1); // meshes 1,2
|
|
900 |
effect2.setMeshAssociation( 2,-1); // mesh 1
|
|
901 |
effect3.setMeshAssociation( 4,-1); // mesh 2
|
|
902 |
effect4.setMeshAssociation(56,-1); // meshes 3,4,5
|
|
903 |
effect5.setMeshAssociation(56,-1); // meshes 3,4,5
|
|
904 |
effect6.setMeshAssociation(56,-1); // meshes 3,4,5
|
|
905 |
effect7.setMeshAssociation(56,-1); // meshes 3,4,5
|
|
906 |
effect8.setMeshAssociation(16,-1); // mesh 4
|
|
907 |
effect9.setMeshAssociation(32,-1); // mesh 5
|
|
908 |
|
|
909 |
effect10.setMeshAssociation(63,-1); // all meshes
|
|
910 |
effect11.setMeshAssociation(63,-1); // all meshes
|
|
911 |
effect12.setMeshAssociation(63,-1); // all meshes
|
|
912 |
effect13.setMeshAssociation(63,-1); // all meshes
|
|
913 |
|
|
914 |
mesh.apply(effect0);
|
|
915 |
mesh.apply(effect1);
|
|
916 |
mesh.apply(effect2);
|
|
917 |
mesh.apply(effect3);
|
|
918 |
mesh.apply(effect4);
|
|
919 |
mesh.apply(effect5);
|
|
920 |
mesh.apply(effect6);
|
|
921 |
mesh.apply(effect7);
|
|
922 |
mesh.apply(effect8);
|
|
923 |
mesh.apply(effect9);
|
|
924 |
|
|
925 |
mesh.apply(effect10);
|
|
926 |
mesh.apply(effect11);
|
|
927 |
mesh.apply(effect12);
|
|
928 |
mesh.apply(effect13);
|
|
929 |
|
|
930 |
mesh.mergeEffComponents();
|
|
931 |
|
|
932 |
return mesh;
|
|
933 |
}
|
|
934 |
|
|
935 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
936 |
|
|
937 |
MeshBase createHelicopterFaceMesh()
|
|
938 |
{
|
|
939 |
MeshBase[] meshes = new MeshBase[6];
|
|
940 |
|
|
941 |
float D = 0.02f;
|
|
942 |
float E = 0.5f;
|
|
943 |
float F = SQ2/4;
|
|
944 |
float G = 1.0f/12;
|
|
945 |
|
|
946 |
float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
|
|
947 |
|
|
948 |
float[] bands0 = { 1.0f , 0,
|
|
949 |
1.0f-2*D, D*0.25f,
|
|
950 |
1.0f-4*D, D*0.35f,
|
|
951 |
1.0f-8*D, D*0.6f,
|
|
952 |
0.60f , D*1.0f,
|
|
953 |
0.30f , D*1.375f,
|
|
954 |
0.0f , D*1.4f };
|
|
955 |
|
|
956 |
meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
|
|
957 |
meshes[0].setEffectAssociation(0,1,0);
|
|
958 |
|
|
959 |
float[] vertices1 = { -F,-G, +F,-G, 0,2*G};
|
|
960 |
|
|
961 |
float[] bands1 = { 1.0f , 0.0f,
|
|
962 |
0.5f , 0.01f,
|
|
963 |
0.0f , 0.01f };
|
|
964 |
|
|
965 |
meshes[1] = new MeshPolygon(vertices1, bands1, 1, 3);
|
|
966 |
meshes[1].setEffectAssociation(0,2,0);
|
|
967 |
|
|
968 |
float[] vertices2 = { -E/2,-F/3, +E/2,-F/3, 0,2*F/3};
|
|
969 |
|
|
970 |
float[] bands2 = { 1.0f , 0.0f,
|
|
971 |
0.5f , 0.01f,
|
|
972 |
0.0f , 0.01f };
|
|
973 |
|
|
974 |
meshes[2] = new MeshPolygon(vertices2, bands2, 1, 3);
|
|
975 |
meshes[2].setEffectAssociation(0,4,0);
|
|
976 |
meshes[3] = meshes[2].copy(true);
|
|
977 |
meshes[3].setEffectAssociation(0,8,0);
|
|
978 |
meshes[4] = new MeshTriangle(1);
|
|
979 |
meshes[4].setEffectAssociation(0,16,0);
|
|
980 |
meshes[5] = new MeshTriangle(1);
|
|
981 |
meshes[5].setEffectAssociation(0,32,0);
|
|
982 |
|
|
983 |
MeshBase mesh = new MeshJoined(meshes);
|
|
984 |
|
|
985 |
Static3D move0 = new Static3D(-1.0f/8, -1.0f/8, 0);
|
|
986 |
Static3D move1 = new Static3D(-(SQ2/24)-1.0f/4, -(SQ2/24)-1.0f/4, 0);
|
|
987 |
Static3D move2 = new Static3D(-E/2, F/3, 0);
|
|
988 |
Static3D move3 = new Static3D(+E/2, F/3, 0);
|
|
989 |
Static3D move4 = new Static3D(+E/3,+E/3, 0);
|
|
990 |
Static1D angle1 = new Static1D(135);
|
|
991 |
Static1D angle2 = new Static1D(90);
|
|
992 |
Static1D angle3 = new Static1D(-90);
|
|
993 |
Static1D angle4 = new Static1D(-135);
|
|
994 |
Static3D axisX = new Static3D(1,0,0);
|
|
995 |
Static3D axisY = new Static3D(0,1,0);
|
|
996 |
Static3D axisZ = new Static3D(0,0,1);
|
|
997 |
Static3D axis1 = new Static3D(1,-1,0);
|
|
998 |
Static3D center = new Static3D(0,0,0);
|
|
999 |
Static3D center1= new Static3D(-0.25f,-0.25f,0);
|
|
1000 |
|
|
1001 |
float d0 =-0.03f;
|
|
1002 |
float d1 =-0.04f;
|
|
1003 |
float r0 = 0.15f;
|
|
1004 |
float r1 = 0.10f;
|
|
1005 |
|
|
1006 |
Static3D vec0 = new Static3D(d0*(+SQ3/3),d0*(+SQ3/3),d0*(+SQ3/3));
|
|
1007 |
Static3D vec1 = new Static3D(d1*(-SQ3/3),d1*(+SQ3/3),d1*(+SQ3/3));
|
|
1008 |
Static3D vec2 = new Static3D(d1*(+SQ3/3),d1*(-SQ3/3),d1*(+SQ3/3));
|
|
1009 |
|
|
1010 |
Static1D radius = new Static1D(0.5f);
|
|
1011 |
|
|
1012 |
Static3D cent0 = new Static3D( 0.0f, 0.0f, 0.0f);
|
|
1013 |
Static3D cent1 = new Static3D(-0.5f, 0.0f, 0.0f);
|
|
1014 |
Static3D cent2 = new Static3D( 0.0f,-0.5f, 0.0f);
|
|
1015 |
|
|
1016 |
Static4D reg0 = new Static4D(0,0,0,r0);
|
|
1017 |
Static4D reg1 = new Static4D(0,0,0,r1);
|
|
1018 |
|
|
1019 |
VertexEffectMove effect0 = new VertexEffectMove(move0);
|
|
1020 |
VertexEffectRotate effect1 = new VertexEffectRotate(angle1, axisZ, center);
|
|
1021 |
VertexEffectMove effect2 = new VertexEffectMove(move1);
|
|
1022 |
VertexEffectRotate effect3 = new VertexEffectRotate(angle2, axis1, center1);
|
|
1023 |
VertexEffectMove effect4 = new VertexEffectMove(move2);
|
|
1024 |
VertexEffectMove effect5 = new VertexEffectMove(move3);
|
|
1025 |
VertexEffectRotate effect6 = new VertexEffectRotate(angle3, axisZ, center);
|
|
1026 |
VertexEffectRotate effect7 = new VertexEffectRotate(angle4, axisX, center);
|
|
1027 |
VertexEffectRotate effect8 = new VertexEffectRotate(angle1, axisY, center);
|
|
1028 |
VertexEffectScale effect9 = new VertexEffectScale(0);
|
|
1029 |
VertexEffectDeform effect10= new VertexEffectDeform(vec0,radius,cent0,reg0);
|
|
1030 |
VertexEffectDeform effect11= new VertexEffectDeform(vec1,radius,cent1,reg1);
|
|
1031 |
VertexEffectDeform effect12= new VertexEffectDeform(vec2,radius,cent2,reg1);
|
|
1032 |
VertexEffectMove effect13= new VertexEffectMove(move4);
|
|
1033 |
|
|
1034 |
effect0.setMeshAssociation( 1,-1); // mesh 0
|
|
1035 |
effect1.setMeshAssociation( 2,-1); // mesh 1
|
|
1036 |
effect2.setMeshAssociation( 2,-1); // mesh 1
|
|
1037 |
effect3.setMeshAssociation( 2,-1); // mesh 1
|
|
1038 |
effect4.setMeshAssociation( 4,-1); // mesh 2
|
|
1039 |
effect5.setMeshAssociation( 8,-1); // mesh 3
|
|
1040 |
effect6.setMeshAssociation( 8,-1); // mesh 3
|
|
1041 |
effect7.setMeshAssociation( 4,-1); // mesh 2
|
|
1042 |
effect8.setMeshAssociation( 8,-1); // mesh 3
|
|
1043 |
effect9.setMeshAssociation(48,-1); // meshes 4,5
|
|
1044 |
effect10.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
1045 |
effect11.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
1046 |
effect12.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
1047 |
effect13.setMeshAssociation(15,-1); // meshes 0,1,2,3
|
|
1048 |
|
|
1049 |
mesh.apply(effect0);
|
|
1050 |
mesh.apply(effect1);
|
|
1051 |
mesh.apply(effect2);
|
|
1052 |
mesh.apply(effect3);
|
|
1053 |
mesh.apply(effect4);
|
|
1054 |
mesh.apply(effect5);
|
|
1055 |
mesh.apply(effect6);
|
|
1056 |
mesh.apply(effect7);
|
|
1057 |
mesh.apply(effect8);
|
|
1058 |
mesh.apply(effect9);
|
|
1059 |
mesh.apply(effect10);
|
|
1060 |
mesh.apply(effect11);
|
|
1061 |
mesh.apply(effect12);
|
|
1062 |
mesh.apply(effect13);
|
|
1063 |
|
|
1064 |
mesh.mergeEffComponents();
|
|
1065 |
|
|
1066 |
return mesh;
|
|
1067 |
}
|
|
1068 |
}
|
Add a CubitFactory and convert all objects to use it. Biggest change is thr Pyramiinx which now uses a lattice of Octahedrons and Tetrahedrons, just like the Diamond.