1 |
ac940e24
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
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 |
749ef882
|
Leszek Koltunski
|
package org.distorted.helpers;
|
21 |
ac940e24
|
Leszek Koltunski
|
|
22 |
b1f2ccf5
|
Leszek Koltunski
|
import org.distorted.library.effect.MatrixEffectMove;
|
23 |
|
|
import org.distorted.library.effect.MatrixEffectQuaternion;
|
24 |
|
|
import org.distorted.library.effect.MatrixEffectScale;
|
25 |
68f6046c
|
Leszek Koltunski
|
import org.distorted.library.effect.VertexEffect;
|
26 |
ac940e24
|
Leszek Koltunski
|
import org.distorted.library.effect.VertexEffectDeform;
|
27 |
|
|
import org.distorted.library.effect.VertexEffectMove;
|
28 |
|
|
import org.distorted.library.effect.VertexEffectRotate;
|
29 |
|
|
import org.distorted.library.effect.VertexEffectScale;
|
30 |
|
|
import org.distorted.library.mesh.MeshBase;
|
31 |
|
|
import org.distorted.library.mesh.MeshJoined;
|
32 |
|
|
import org.distorted.library.mesh.MeshPolygon;
|
33 |
|
|
import org.distorted.library.type.Static1D;
|
34 |
|
|
import org.distorted.library.type.Static3D;
|
35 |
|
|
import org.distorted.library.type.Static4D;
|
36 |
|
|
|
37 |
b1f2ccf5
|
Leszek Koltunski
|
import java.util.ArrayList;
|
38 |
|
|
|
39 |
ac940e24
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
40 |
|
|
|
41 |
749ef882
|
Leszek Koltunski
|
public class FactoryCubit
|
42 |
ac940e24
|
Leszek Koltunski
|
{
|
43 |
|
|
private static final float SQ2 = (float)Math.sqrt(2);
|
44 |
|
|
private static final float SQ3 = (float)Math.sqrt(3);
|
45 |
4e627d8b
|
Leszek Koltunski
|
private static final float SQ5 = (float)Math.sqrt(5);
|
46 |
68f6046c
|
Leszek Koltunski
|
private static final float SQ6 = (float)Math.sqrt(6);
|
47 |
ac940e24
|
Leszek Koltunski
|
|
48 |
b5347187
|
Leszek Koltunski
|
private static final Static1D RADIUS = new Static1D(1);
|
49 |
|
|
private static FactoryCubit mThis;
|
50 |
|
|
|
51 |
|
|
// IVY
|
52 |
|
|
static final float IVY_D = 0.003f;
|
53 |
|
|
static final float IVY_C = 0.59f;
|
54 |
|
|
static final float IVY_M = 0.35f;
|
55 |
|
|
private static final int IVY_N = 8;
|
56 |
|
|
|
57 |
|
|
// REX
|
58 |
749ef882
|
Leszek Koltunski
|
public static final float REX_D = 0.2f;
|
59 |
b5347187
|
Leszek Koltunski
|
|
60 |
|
|
// KILO / MEGAMINX
|
61 |
749ef882
|
Leszek Koltunski
|
public static final float SIN54 = (SQ5+1)/4;
|
62 |
|
|
public static final float COS54 = (float)(Math.sqrt(10-2*SQ5)/4);
|
63 |
|
|
public static final float SIN18 = (SQ5-1)/4;
|
64 |
|
|
public static final float COS18 = (float)(0.25f*Math.sqrt(10.0f+2.0f*SQ5));
|
65 |
|
|
public static final float COS_HALFD= (float)(Math.sqrt(0.5f-0.1f*SQ5)); // cos(half the dihedral angle)
|
66 |
|
|
public static final float SIN_HALFD= (float)(Math.sqrt(0.5f+0.1f*SQ5)); // sin(half the dihedral angle)
|
67 |
|
|
public static final float DIHEDRAL1= (float)(Math.acos(-SQ5/5)*180/Math.PI);
|
68 |
|
|
public static final float DIHEDRAL2= (float)((180/Math.PI)*Math.asin((2*SIN54*SIN54-1)/COS54) - 90);
|
69 |
|
|
public static final float MINX_SC = 0.5f;
|
70 |
4e627d8b
|
Leszek Koltunski
|
|
71 |
b1f2ccf5
|
Leszek Koltunski
|
|
72 |
|
|
private static final double[] mBuffer = new double[3];
|
73 |
|
|
private static final double[] mQuat1 = new double[4];
|
74 |
|
|
private static final double[] mQuat2 = new double[4];
|
75 |
|
|
private static final double[] mQuat3 = new double[4];
|
76 |
|
|
private static final double[] mQuat4 = new double[4];
|
77 |
|
|
|
78 |
|
|
private static class StickerCoords
|
79 |
|
|
{
|
80 |
|
|
double[] vertices;
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
private static class FaceTransform
|
84 |
|
|
{
|
85 |
|
|
int sticker;
|
86 |
|
|
double vx,vy,vz;
|
87 |
|
|
double scale;
|
88 |
|
|
double qx,qy,qz,qw;
|
89 |
|
|
boolean flip;
|
90 |
|
|
}
|
91 |
|
|
|
92 |
31cd7256
|
Leszek Koltunski
|
private static final ArrayList<FaceTransform> mNewFaceTransf = new ArrayList<>();
|
93 |
|
|
private static final ArrayList<FaceTransform> mOldFaceTransf = new ArrayList<>();
|
94 |
b1f2ccf5
|
Leszek Koltunski
|
private static final ArrayList<StickerCoords> mStickerCoords = new ArrayList<>();
|
95 |
|
|
|
96 |
ac940e24
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
97 |
|
|
|
98 |
b89898c5
|
Leszek Koltunski
|
private FactoryCubit()
|
99 |
ac940e24
|
Leszek Koltunski
|
{
|
100 |
|
|
|
101 |
|
|
}
|
102 |
|
|
|
103 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
104 |
|
|
|
105 |
b89898c5
|
Leszek Koltunski
|
public static FactoryCubit getInstance()
|
106 |
ac940e24
|
Leszek Koltunski
|
{
|
107 |
b89898c5
|
Leszek Koltunski
|
if( mThis==null ) mThis = new FactoryCubit();
|
108 |
ac940e24
|
Leszek Koltunski
|
|
109 |
|
|
return mThis;
|
110 |
|
|
}
|
111 |
|
|
|
112 |
2fcfce81
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
113 |
|
|
// H - height of the band in the middle
|
114 |
|
|
// alpha - angle of the edge [0,90]
|
115 |
|
|
// dist - often in a polygon the distance from edge to center is not 1, but something else.
|
116 |
|
|
// This is the distance.
|
117 |
|
|
// K - where to begin the second, much more flat part of the band. [0,1]
|
118 |
|
|
// N - number of bands. N>=3
|
119 |
|
|
//
|
120 |
|
|
// theory: two distinct parts to the band:
|
121 |
|
|
// 1) (0,B) - steep
|
122 |
|
|
// 2) (B,1) - flat
|
123 |
|
|
//
|
124 |
|
|
// In first part, we have y = g(x) ; in second - y = g(f(x)) where
|
125 |
|
|
//
|
126 |
|
|
// g(x) = sqrt( R^2 - (x-D)^2 ) - R*cos(alpha)
|
127 |
|
|
// f(x) = ((D-B)/(1-B)*x + B*(1-D)/(1-B)
|
128 |
|
|
// h(x) = R*(sin(alpha) - sin(x))
|
129 |
|
|
// R = H/(1-cos(alpha))
|
130 |
|
|
// D = H*sin(alpha)
|
131 |
|
|
// B = h(K*alpha)
|
132 |
|
|
//
|
133 |
|
|
// The N points are taken at:
|
134 |
|
|
//
|
135 |
|
|
// 1) in the second part, there are K2 = (N-3)/3 such points
|
136 |
|
|
// 2) in the first - K1 = (N-3) - K2
|
137 |
|
|
// 3) also, the 3 points 0,B,1
|
138 |
|
|
//
|
139 |
|
|
// so we have the sequence A[i] of N points
|
140 |
|
|
//
|
141 |
|
|
// 0
|
142 |
|
|
// h((i+1)*(1-K)*alpha/(K1+1)) (i=0,1,...,K1-1)
|
143 |
|
|
// B
|
144 |
|
|
// (1-B)*(i+1)/(K2+1) + B (i=0,i,...,K2-1)
|
145 |
|
|
// 1
|
146 |
|
|
|
147 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
148 |
|
|
|
149 |
|
|
private float f(float D, float B, float x)
|
150 |
|
|
{
|
151 |
|
|
return ((D-B)*x + B*(1-D))/(1-B);
|
152 |
|
|
}
|
153 |
|
|
|
154 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
155 |
|
|
|
156 |
|
|
private float g(float R, float D, float x, float cosAlpha)
|
157 |
|
|
{
|
158 |
|
|
float d = x-D;
|
159 |
|
|
return (float)(Math.sqrt(R*R-d*d)-R*cosAlpha);
|
160 |
|
|
}
|
161 |
|
|
|
162 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
163 |
|
|
|
164 |
|
|
private float h(float R, float sinAlpha, float x)
|
165 |
|
|
{
|
166 |
|
|
return R*(sinAlpha-(float)Math.sin(x));
|
167 |
|
|
}
|
168 |
|
|
|
169 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
170 |
|
|
|
171 |
|
|
private float[] computeBands(float H, int alpha, float dist, float K, int N)
|
172 |
|
|
{
|
173 |
|
|
float[] bands = new float[2*N];
|
174 |
|
|
|
175 |
|
|
bands[0] = 1.0f;
|
176 |
|
|
bands[1] = 0.0f;
|
177 |
|
|
|
178 |
|
|
float beta = (float)Math.atan(dist*Math.tan(Math.PI*alpha/180));
|
179 |
|
|
float sinBeta = (float)Math.sin(beta);
|
180 |
|
|
float cosBeta = (float)Math.cos(beta);
|
181 |
|
|
float R = cosBeta<1.0f ? H/(1.0f-cosBeta) : 0.0f;
|
182 |
|
|
float D = R*sinBeta;
|
183 |
|
|
float B = h(R,sinBeta,K*beta);
|
184 |
|
|
|
185 |
|
|
if( D>1.0f )
|
186 |
|
|
{
|
187 |
|
|
for(int i=1; i<N; i++)
|
188 |
|
|
{
|
189 |
|
|
bands[2*i ] = (float)(N-1-i)/(N-1);
|
190 |
|
|
bands[2*i+1] = H*(1-bands[2*i]);
|
191 |
|
|
}
|
192 |
|
|
}
|
193 |
|
|
else
|
194 |
|
|
{
|
195 |
|
|
int K2 = (int)((N-3)*K);
|
196 |
|
|
int K1 = (N-3)-K2;
|
197 |
|
|
|
198 |
|
|
for(int i=0; i<=K1; i++)
|
199 |
|
|
{
|
200 |
|
|
float angle = K*beta + (1-K)*beta*(K1-i)/(K1+1);
|
201 |
|
|
float x = h(R,sinBeta,angle);
|
202 |
|
|
bands[2*i+2] = 1.0f - x;
|
203 |
|
|
bands[2*i+3] = g(R,D,x,cosBeta);
|
204 |
|
|
}
|
205 |
|
|
|
206 |
|
|
for(int i=0; i<=K2; i++)
|
207 |
|
|
{
|
208 |
|
|
float x = (1-B)*(i+1)/(K2+1) + B;
|
209 |
|
|
bands[2*K1+2 + 2*i+2] = 1.0f - x;
|
210 |
|
|
bands[2*K1+2 + 2*i+3] = g(R,D,f(D,B,x),cosBeta);
|
211 |
|
|
}
|
212 |
|
|
}
|
213 |
|
|
|
214 |
|
|
bands[2*N-2] = 0.0f;
|
215 |
|
|
bands[2*N-1] = H;
|
216 |
|
|
|
217 |
|
|
return bands;
|
218 |
|
|
}
|
219 |
|
|
|
220 |
05cc8075
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
221 |
|
|
|
222 |
|
|
private void roundCorners(MeshBase mesh, Static3D center, Static3D[] vertices, float strength, float regionRadius)
|
223 |
|
|
{
|
224 |
|
|
Static4D reg= new Static4D(0,0,0,regionRadius);
|
225 |
|
|
|
226 |
|
|
float centX = center.get0();
|
227 |
|
|
float centY = center.get1();
|
228 |
|
|
float centZ = center.get2();
|
229 |
|
|
|
230 |
|
|
for (Static3D vertex : vertices)
|
231 |
|
|
{
|
232 |
|
|
float x = strength*(centX - vertex.get0());
|
233 |
|
|
float y = strength*(centY - vertex.get1());
|
234 |
|
|
float z = strength*(centZ - vertex.get2());
|
235 |
|
|
|
236 |
|
|
VertexEffect effect = new VertexEffectDeform(new Static3D(x,y,z), RADIUS, vertex, reg);
|
237 |
|
|
mesh.apply(effect);
|
238 |
|
|
}
|
239 |
|
|
}
|
240 |
|
|
|
241 |
ac940e24
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
242 |
|
|
|
243 |
55fb45c2
|
Leszek Koltunski
|
MeshBase createFacesHelicopterFace()
|
244 |
ac940e24
|
Leszek Koltunski
|
{
|
245 |
8d3cfe99
|
Leszek Koltunski
|
MeshBase[] meshes = new MeshBase[4];
|
246 |
ac940e24
|
Leszek Koltunski
|
|
247 |
|
|
float E = 0.5f;
|
248 |
|
|
float F = SQ2/4;
|
249 |
|
|
float G = 1.0f/12;
|
250 |
|
|
float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
|
251 |
2fcfce81
|
Leszek Koltunski
|
float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
|
252 |
ac940e24
|
Leszek Koltunski
|
|
253 |
|
|
meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
|
254 |
|
|
meshes[0].setEffectAssociation(0,1,0);
|
255 |
|
|
|
256 |
|
|
float[] vertices1 = { -F,-G, +F,-G, 0,2*G};
|
257 |
2fcfce81
|
Leszek Koltunski
|
float[] bands1 = computeBands(0.01f,45,F,0.0f,3);
|
258 |
ac940e24
|
Leszek Koltunski
|
|
259 |
|
|
meshes[1] = new MeshPolygon(vertices1, bands1, 1, 3);
|
260 |
|
|
meshes[1].setEffectAssociation(0,2,0);
|
261 |
|
|
|
262 |
|
|
float[] vertices2 = { -E/2,-F/3, +E/2,-F/3, 0,2*F/3};
|
263 |
|
|
|
264 |
2fcfce81
|
Leszek Koltunski
|
meshes[2] = new MeshPolygon(vertices2, bands1, 1, 3);
|
265 |
ac940e24
|
Leszek Koltunski
|
meshes[2].setEffectAssociation(0,4,0);
|
266 |
|
|
meshes[3] = meshes[2].copy(true);
|
267 |
|
|
meshes[3].setEffectAssociation(0,8,0);
|
268 |
|
|
|
269 |
55fb45c2
|
Leszek Koltunski
|
return new MeshJoined(meshes);
|
270 |
68f6046c
|
Leszek Koltunski
|
}
|
271 |
|
|
|
272 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
273 |
|
|
|
274 |
55fb45c2
|
Leszek Koltunski
|
MeshBase createFacesRediEdge()
|
275 |
68f6046c
|
Leszek Koltunski
|
{
|
276 |
2fcfce81
|
Leszek Koltunski
|
MeshBase[] meshes = new MeshPolygon[6];
|
277 |
68f6046c
|
Leszek Koltunski
|
|
278 |
|
|
float F = 0.25f;
|
279 |
|
|
float[] vertices0 = { -F,+F, -F,-F, 0, -2*F, +F,-F, +F,+F };
|
280 |
2fcfce81
|
Leszek Koltunski
|
float[] bands0 = computeBands(0.038f,35,F,0.7f,7);
|
281 |
68f6046c
|
Leszek Koltunski
|
|
282 |
|
|
meshes[0] = new MeshPolygon(vertices0, bands0, 2, 2);
|
283 |
|
|
meshes[0].setEffectAssociation(0,1,0);
|
284 |
|
|
meshes[1] = meshes[0].copy(true);
|
285 |
|
|
meshes[1].setEffectAssociation(0,2,0);
|
286 |
|
|
|
287 |
2fcfce81
|
Leszek Koltunski
|
float[] bands1 = computeBands(0.02f,35,F/2,0.2f,3);
|
288 |
68f6046c
|
Leszek Koltunski
|
float[] vertices1 = { -F/2, +F/2, -F/2, -1.5f*F, 1.5f*F, +F/2 };
|
289 |
|
|
|
290 |
|
|
meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
|
291 |
|
|
meshes[2].setEffectAssociation(0,4,0);
|
292 |
|
|
meshes[3] = meshes[2].copy(true);
|
293 |
|
|
meshes[3].setEffectAssociation(0,8,0);
|
294 |
|
|
|
295 |
962437b5
|
Leszek Koltunski
|
float X = 0.25f*SQ2;
|
296 |
|
|
float Y = SQ6/16;
|
297 |
|
|
float[] vertices2 = { -X, Y, -1.5f*X, -Y, +1.5f*X, -Y, +X, Y };
|
298 |
68f6046c
|
Leszek Koltunski
|
|
299 |
2fcfce81
|
Leszek Koltunski
|
meshes[4] = new MeshPolygon(vertices2, bands1, 1, 1);
|
300 |
68f6046c
|
Leszek Koltunski
|
meshes[4].setEffectAssociation(0,16,0);
|
301 |
|
|
meshes[5] = meshes[4].copy(true);
|
302 |
|
|
meshes[5].setEffectAssociation(0,32,0);
|
303 |
|
|
|
304 |
55fb45c2
|
Leszek Koltunski
|
return new MeshJoined(meshes);
|
305 |
962437b5
|
Leszek Koltunski
|
}
|
306 |
|
|
|
307 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
308 |
|
|
|
309 |
55fb45c2
|
Leszek Koltunski
|
MeshBase createFacesRediCorner()
|
310 |
962437b5
|
Leszek Koltunski
|
{
|
311 |
2fcfce81
|
Leszek Koltunski
|
MeshBase[] meshes = new MeshBase[6];
|
312 |
962437b5
|
Leszek Koltunski
|
|
313 |
|
|
float E = 0.5f;
|
314 |
2fcfce81
|
Leszek Koltunski
|
float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
|
315 |
|
|
float[] bands0 = computeBands(0.06f,35,E,0.7f,6);
|
316 |
962437b5
|
Leszek Koltunski
|
|
317 |
2fcfce81
|
Leszek Koltunski
|
meshes[0] = new MeshPolygon(vertices0,bands0,2,2);
|
318 |
962437b5
|
Leszek Koltunski
|
meshes[0].setEffectAssociation(0,1,0);
|
319 |
|
|
meshes[1] = meshes[0].copy(true);
|
320 |
|
|
meshes[1].setEffectAssociation(0,2,0);
|
321 |
|
|
meshes[2] = meshes[0].copy(true);
|
322 |
|
|
meshes[2].setEffectAssociation(0,4,0);
|
323 |
|
|
|
324 |
ae755eda
|
Leszek Koltunski
|
float F = 0.5f;
|
325 |
962437b5
|
Leszek Koltunski
|
float X = 0.5f;
|
326 |
2fcfce81
|
Leszek Koltunski
|
float G = 0.72f;
|
327 |
|
|
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 };
|
328 |
|
|
float[] bands1 = computeBands(0.0f,0,1.0f,0.0f,2);
|
329 |
962437b5
|
Leszek Koltunski
|
|
330 |
2fcfce81
|
Leszek Koltunski
|
meshes[3] = new MeshPolygon(vertices1,bands1,0,0);
|
331 |
962437b5
|
Leszek Koltunski
|
meshes[3].setEffectAssociation(0,8,0);
|
332 |
|
|
meshes[4] = meshes[3].copy(true);
|
333 |
|
|
meshes[4].setEffectAssociation(0,16,0);
|
334 |
|
|
meshes[5] = meshes[3].copy(true);
|
335 |
|
|
meshes[5].setEffectAssociation(0,32,0);
|
336 |
|
|
|
337 |
55fb45c2
|
Leszek Koltunski
|
return new MeshJoined(meshes);
|
338 |
|
|
}
|
339 |
962437b5
|
Leszek Koltunski
|
|
340 |
49cd8581
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
341 |
|
|
|
342 |
|
|
MeshBase createFacesIvyCorner()
|
343 |
|
|
{
|
344 |
db3b12e6
|
Leszek Koltunski
|
MeshBase[] meshes = new MeshBase[6];
|
345 |
|
|
|
346 |
|
|
final float angle = (float)Math.PI/(2*IVY_N);
|
347 |
6a224bdc
|
Leszek Koltunski
|
final float CORR = 1.0f - 2*IVY_D;
|
348 |
886d1ebb
|
Leszek Koltunski
|
final float DIST = -0.5f*CORR + IVY_D;
|
349 |
|
|
float[] vertices = new float[2*(IVY_N+1)+6];
|
350 |
|
|
|
351 |
|
|
vertices[0] = (0.5f-IVY_M) * IVY_C;
|
352 |
|
|
vertices[1] = (DIST-IVY_M) * IVY_C;
|
353 |
|
|
vertices[2] = (0.5f-IVY_M) * IVY_C;
|
354 |
|
|
vertices[3] = (0.5f-IVY_M) * IVY_C;
|
355 |
|
|
vertices[4] = (DIST-IVY_M) * IVY_C;
|
356 |
|
|
vertices[5] = (0.5f-IVY_M) * IVY_C;
|
357 |
db3b12e6
|
Leszek Koltunski
|
|
358 |
|
|
for(int i=0; i<=IVY_N; i++)
|
359 |
|
|
{
|
360 |
|
|
float ang = (IVY_N-i)*angle;
|
361 |
|
|
float sin = (float)Math.sin(ang);
|
362 |
|
|
float cos = (float)Math.cos(ang);
|
363 |
|
|
|
364 |
886d1ebb
|
Leszek Koltunski
|
vertices[2*i+6] = (CORR*(cos-0.5f)-IVY_M)*IVY_C;
|
365 |
|
|
vertices[2*i+7] = (CORR*(sin-0.5f)-IVY_M)*IVY_C;
|
366 |
db3b12e6
|
Leszek Koltunski
|
}
|
367 |
|
|
|
368 |
f9464035
|
Leszek Koltunski
|
float[] bands0 = computeBands(+0.012f,20,0.2f,0.5f,7);
|
369 |
|
|
float[] bands1 = computeBands(-0.100f,20,0.2f,0.0f,2);
|
370 |
db3b12e6
|
Leszek Koltunski
|
|
371 |
2113cf12
|
Leszek Koltunski
|
meshes[0] = new MeshPolygon(vertices,bands0,1,2);
|
372 |
db3b12e6
|
Leszek Koltunski
|
meshes[0].setEffectAssociation(0,1,0);
|
373 |
|
|
meshes[1] = meshes[0].copy(true);
|
374 |
|
|
meshes[1].setEffectAssociation(0,2,0);
|
375 |
|
|
meshes[2] = meshes[0].copy(true);
|
376 |
|
|
meshes[2].setEffectAssociation(0,4,0);
|
377 |
2113cf12
|
Leszek Koltunski
|
meshes[3] = new MeshPolygon(vertices,bands1,1,2);
|
378 |
db3b12e6
|
Leszek Koltunski
|
meshes[3].setEffectAssociation(0,8,0);
|
379 |
|
|
meshes[4] = meshes[3].copy(true);
|
380 |
|
|
meshes[4].setEffectAssociation(0,16,0);
|
381 |
|
|
meshes[5] = meshes[3].copy(true);
|
382 |
|
|
meshes[5].setEffectAssociation(0,32,0);
|
383 |
|
|
|
384 |
|
|
return new MeshJoined(meshes);
|
385 |
49cd8581
|
Leszek Koltunski
|
}
|
386 |
|
|
|
387 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
388 |
|
|
|
389 |
|
|
MeshBase createFacesIvyFace()
|
390 |
|
|
{
|
391 |
|
|
MeshBase[] meshes = new MeshBase[2];
|
392 |
|
|
|
393 |
|
|
final float angle = (float)Math.PI/(2*IVY_N);
|
394 |
9e5b990e
|
Leszek Koltunski
|
final float CORR = 1.0f - 2*IVY_D;
|
395 |
49cd8581
|
Leszek Koltunski
|
float[] vertices = new float[4*IVY_N];
|
396 |
|
|
|
397 |
|
|
for(int i=0; i<IVY_N; i++)
|
398 |
|
|
{
|
399 |
|
|
float sin = (float)Math.sin(i*angle);
|
400 |
|
|
float cos = (float)Math.cos(i*angle);
|
401 |
|
|
|
402 |
18a5f95f
|
Leszek Koltunski
|
vertices[2*i ] = CORR*(0.5f-cos);
|
403 |
|
|
vertices[2*i+1 ] = CORR*(0.5f-sin);
|
404 |
|
|
vertices[2*i +2*IVY_N] = CORR*(cos-0.5f);
|
405 |
|
|
vertices[2*i+1+2*IVY_N] = CORR*(sin-0.5f);
|
406 |
49cd8581
|
Leszek Koltunski
|
}
|
407 |
|
|
|
408 |
886d1ebb
|
Leszek Koltunski
|
float[] bands0 = computeBands(+0.03f,35,0.5f,0.5f,5);
|
409 |
9e5b990e
|
Leszek Koltunski
|
float[] bands1 = computeBands(-0.10f,45,0.5f,0.0f,2);
|
410 |
49cd8581
|
Leszek Koltunski
|
|
411 |
18a5f95f
|
Leszek Koltunski
|
meshes[0] = new MeshPolygon(vertices,bands0,0,0);
|
412 |
49cd8581
|
Leszek Koltunski
|
meshes[0].setEffectAssociation(0,1,0);
|
413 |
|
|
meshes[1] = new MeshPolygon(vertices,bands1,0,0);
|
414 |
|
|
meshes[1].setEffectAssociation(0,2,0);
|
415 |
|
|
|
416 |
|
|
return new MeshJoined(meshes);
|
417 |
|
|
}
|
418 |
|
|
|
419 |
59b87d56
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
420 |
|
|
|
421 |
|
|
MeshBase createFacesRexCorner()
|
422 |
|
|
{
|
423 |
|
|
MeshBase[] meshes = new MeshBase[2];
|
424 |
|
|
|
425 |
da36b97e
|
Leszek Koltunski
|
float F = REX_D*SQ2;
|
426 |
|
|
float G = (1-REX_D)*SQ2/2;
|
427 |
|
|
float H = 0.1f;
|
428 |
|
|
float J = +2*G/3 - H*G;
|
429 |
|
|
|
430 |
|
|
float[] vertices = { -F/2, -G/3, +F/2, -G/3, H*F/2, J, -H*F/2, J};
|
431 |
59b87d56
|
Leszek Koltunski
|
|
432 |
da36b97e
|
Leszek Koltunski
|
float[] bands0 = computeBands(+0.016f,10,G/3,0.5f,5);
|
433 |
|
|
float[] bands1 = computeBands(-0.230f,45,G/3,0.0f,2);
|
434 |
59b87d56
|
Leszek Koltunski
|
|
435 |
|
|
meshes[0] = new MeshPolygon(vertices,bands0,1,1);
|
436 |
|
|
meshes[0].setEffectAssociation(0,1,0);
|
437 |
|
|
meshes[1] = new MeshPolygon(vertices,bands1,0,0);
|
438 |
|
|
meshes[1].setEffectAssociation(0,2,0);
|
439 |
|
|
|
440 |
|
|
return new MeshJoined(meshes);
|
441 |
|
|
}
|
442 |
|
|
|
443 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
444 |
|
|
|
445 |
|
|
MeshBase createFacesRexFace()
|
446 |
|
|
{
|
447 |
|
|
MeshBase[] meshes = new MeshBase[2];
|
448 |
|
|
|
449 |
da36b97e
|
Leszek Koltunski
|
float[] vertices = { -REX_D,0.0f, 0.0f, -REX_D, +REX_D, 0.0f, 0.0f, +REX_D};
|
450 |
59b87d56
|
Leszek Koltunski
|
|
451 |
da36b97e
|
Leszek Koltunski
|
float[] bands0 = computeBands(0.016f,10,REX_D/2,0.5f,5);
|
452 |
|
|
float[] bands1 = computeBands(0.000f,45,REX_D/2,0.0f,2);
|
453 |
59b87d56
|
Leszek Koltunski
|
|
454 |
|
|
meshes[0] = new MeshPolygon(vertices,bands0,0,0);
|
455 |
|
|
meshes[0].setEffectAssociation(0,1,0);
|
456 |
|
|
meshes[1] = new MeshPolygon(vertices,bands1,0,0);
|
457 |
|
|
meshes[1].setEffectAssociation(0,2,0);
|
458 |
|
|
|
459 |
|
|
return new MeshJoined(meshes);
|
460 |
|
|
}
|
461 |
|
|
|
462 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
463 |
|
|
|
464 |
|
|
MeshBase createFacesRexEdge()
|
465 |
|
|
{
|
466 |
da36b97e
|
Leszek Koltunski
|
MeshBase[] meshes = new MeshPolygon[6];
|
467 |
59b87d56
|
Leszek Koltunski
|
|
468 |
da36b97e
|
Leszek Koltunski
|
float E = 0.5f - REX_D;
|
469 |
|
|
float F = 0.5f;
|
470 |
|
|
float[] vertices0 = { -F,E/3, 0,-2*E/3, +F,E/3 };
|
471 |
|
|
float[] bands0 = computeBands(0.03f,27,F/3,0.8f,5);
|
472 |
59b87d56
|
Leszek Koltunski
|
|
473 |
da36b97e
|
Leszek Koltunski
|
meshes[0] = new MeshPolygon(vertices0, bands0, 2, 3);
|
474 |
59b87d56
|
Leszek Koltunski
|
meshes[0].setEffectAssociation(0,1,0);
|
475 |
|
|
meshes[1] = meshes[0].copy(true);
|
476 |
|
|
meshes[1].setEffectAssociation(0,2,0);
|
477 |
da36b97e
|
Leszek Koltunski
|
|
478 |
|
|
float G = (float)Math.sqrt(E*E+F*F);
|
479 |
|
|
float[] vertices1 = { -2*G/3, -E/3, G/3, -E/3, G/3, 2*E/3 };
|
480 |
|
|
float[] bands1 = computeBands(0.00f,45,G/3,0.2f,3);
|
481 |
|
|
|
482 |
|
|
meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
|
483 |
59b87d56
|
Leszek Koltunski
|
meshes[2].setEffectAssociation(0,4,0);
|
484 |
|
|
meshes[3] = meshes[2].copy(true);
|
485 |
|
|
meshes[3].setEffectAssociation(0,8,0);
|
486 |
da36b97e
|
Leszek Koltunski
|
meshes[4] = meshes[2].copy(true);
|
487 |
|
|
meshes[4].setEffectAssociation(0,16,0);
|
488 |
|
|
meshes[5] = meshes[2].copy(true);
|
489 |
|
|
meshes[5].setEffectAssociation(0,32,0);
|
490 |
59b87d56
|
Leszek Koltunski
|
|
491 |
|
|
return new MeshJoined(meshes);
|
492 |
|
|
}
|
493 |
|
|
|
494 |
bbc6da6c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
495 |
|
|
|
496 |
7764a67a
|
Leszek Koltunski
|
MeshBase createFacesKilominxCenter()
|
497 |
bbc6da6c
|
Leszek Koltunski
|
{
|
498 |
|
|
MeshBase[] meshes = new MeshPolygon[6];
|
499 |
|
|
|
500 |
7764a67a
|
Leszek Koltunski
|
float X1= 0.5f*SIN54;
|
501 |
|
|
float Y1= 0.5f*SIN_HALFD;
|
502 |
|
|
float Y2= Y1 - 0.5f*COS54;
|
503 |
12313693
|
Leszek Koltunski
|
float H = 0.5f* SIN54 /COS54 ;
|
504 |
a64e07d0
|
Leszek Koltunski
|
float X2= MINX_SC*H* SIN_HALFD;
|
505 |
|
|
float Y3= MINX_SC*H/(2*COS_HALFD);
|
506 |
|
|
float Y4= MINX_SC*H*(1/(2*COS_HALFD) - COS_HALFD);
|
507 |
4e627d8b
|
Leszek Koltunski
|
|
508 |
|
|
float[] vertices0 = { -X1, Y2, 0, -Y1, X1, Y2, 0, Y1 };
|
509 |
4b4c217e
|
Leszek Koltunski
|
float[] bands0 = computeBands(0.04f,17,0.3f,0.2f,5);
|
510 |
4e627d8b
|
Leszek Koltunski
|
float[] vertices1 = { -X2, Y4, 0, -Y3, X2, Y4, 0, Y3 };
|
511 |
32f4e2a7
|
Leszek Koltunski
|
float[] bands1 = computeBands(0.00f, 0,0.25f,0.5f,2);
|
512 |
bbc6da6c
|
Leszek Koltunski
|
|
513 |
|
|
meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
|
514 |
|
|
meshes[0].setEffectAssociation(0, 1,0);
|
515 |
|
|
meshes[1] = meshes[0].copy(true);
|
516 |
|
|
meshes[1].setEffectAssociation(0, 2,0);
|
517 |
|
|
meshes[2] = meshes[0].copy(true);
|
518 |
|
|
meshes[2].setEffectAssociation(0, 4,0);
|
519 |
32f4e2a7
|
Leszek Koltunski
|
meshes[3] = new MeshPolygon(vertices1, bands1, 0, 0);
|
520 |
bbc6da6c
|
Leszek Koltunski
|
meshes[3].setEffectAssociation(0, 8,0);
|
521 |
|
|
meshes[4] = meshes[3].copy(true);
|
522 |
|
|
meshes[4].setEffectAssociation(0,16,0);
|
523 |
|
|
meshes[5] = meshes[3].copy(true);
|
524 |
|
|
meshes[5].setEffectAssociation(0,32,0);
|
525 |
|
|
|
526 |
|
|
return new MeshJoined(meshes);
|
527 |
|
|
}
|
528 |
|
|
|
529 |
a64e07d0
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
530 |
|
|
|
531 |
16f34a98
|
Leszek Koltunski
|
MeshBase createFacesMinxCorner(int numLayers)
|
532 |
a64e07d0
|
Leszek Koltunski
|
{
|
533 |
|
|
MeshBase[] meshes = new MeshPolygon[6];
|
534 |
|
|
|
535 |
|
|
float Y = COS54/(2*SIN54);
|
536 |
|
|
|
537 |
|
|
float[] vertices0 = { -0.5f, 0.0f, 0.0f, -Y, 0.5f, 0.0f, 0.0f, Y };
|
538 |
61b217a5
|
Leszek Koltunski
|
|
539 |
|
|
int numBands0 = numLayers==3 ? 5 : 3;
|
540 |
|
|
int numBands1 = numLayers==3 ? 2 : 2;
|
541 |
|
|
float h = numLayers==3 ? 0.04f : 0.03f;
|
542 |
|
|
int e = numLayers==3 ? 4 : 1;
|
543 |
|
|
|
544 |
|
|
float[] bands0 = computeBands(h ,34,0.3f,0.2f, numBands0);
|
545 |
|
|
float[] bands1 = computeBands(0.00f,34,0.3f,0.2f, numBands1);
|
546 |
a64e07d0
|
Leszek Koltunski
|
|
547 |
|
|
meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
|
548 |
|
|
meshes[0].setEffectAssociation(0, 1,0);
|
549 |
|
|
meshes[1] = meshes[0].copy(true);
|
550 |
|
|
meshes[1].setEffectAssociation(0, 2,0);
|
551 |
|
|
meshes[2] = meshes[0].copy(true);
|
552 |
|
|
meshes[2].setEffectAssociation(0, 4,0);
|
553 |
61b217a5
|
Leszek Koltunski
|
meshes[3] = new MeshPolygon(vertices0, bands1, 1, e);
|
554 |
a64e07d0
|
Leszek Koltunski
|
meshes[3].setEffectAssociation(0, 8,0);
|
555 |
|
|
meshes[4] = meshes[3].copy(true);
|
556 |
|
|
meshes[4].setEffectAssociation(0,16,0);
|
557 |
|
|
meshes[5] = meshes[3].copy(true);
|
558 |
|
|
meshes[5].setEffectAssociation(0,32,0);
|
559 |
|
|
|
560 |
|
|
return new MeshJoined(meshes);
|
561 |
|
|
}
|
562 |
|
|
|
563 |
16f34a98
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
564 |
|
|
|
565 |
|
|
MeshBase createFacesKilominxEdge(int numLayers, float width, float height)
|
566 |
|
|
{
|
567 |
|
|
MeshBase[] meshes = new MeshPolygon[6];
|
568 |
|
|
|
569 |
|
|
float D = height/COS18;
|
570 |
|
|
float W = D*SIN18;
|
571 |
|
|
float X1 = height/2;
|
572 |
|
|
float Y1 = width/2;
|
573 |
|
|
float Y2 = (width+W)/2;
|
574 |
|
|
float X3 = D*SIN54;
|
575 |
|
|
float Y3 = D*COS54;
|
576 |
|
|
float X4 = height*SIN_HALFD;
|
577 |
|
|
float Y4 = height*COS_HALFD;
|
578 |
|
|
|
579 |
|
|
float[] vertices0 = { -X1,-Y1, X1, -Y1, X1, Y1+W,-X1, Y1 };
|
580 |
|
|
float[] vertices1 = { -X1,-Y2, X1, -Y2, X1, Y2+W,-X1, Y2 };
|
581 |
|
|
float[] vertices2 = { -X3, 0.0f, 0.0f, -Y3, X3, 0.0f, 0.0f, Y3 };
|
582 |
|
|
float[] vertices3 = { -X4, 0.0f, 0.0f, -Y4, X4, 0.0f, 0.0f, Y4 };
|
583 |
|
|
|
584 |
|
|
int numBands0 = numLayers<=5 ? 5 : 3;
|
585 |
|
|
int numBands1 = numLayers<=5 ? 3 : 2;
|
586 |
|
|
float h = numLayers<=5 ? 0.03f : 0.03f;
|
587 |
|
|
|
588 |
|
|
float[] bands0 = computeBands(h ,34,0.2f,0.2f,numBands0);
|
589 |
|
|
float[] bands1 = computeBands(0.01f,34,0.3f,0.2f,numBands1);
|
590 |
|
|
|
591 |
|
|
meshes[0] = new MeshPolygon(vertices0, bands0, 1, 1);
|
592 |
|
|
meshes[0].setEffectAssociation(0, 1,0);
|
593 |
|
|
meshes[1] = meshes[0].copy(true);
|
594 |
|
|
meshes[1].setEffectAssociation(0, 2,0);
|
595 |
|
|
meshes[2] = new MeshPolygon(vertices1, bands1, 0, 0);
|
596 |
|
|
meshes[2].setEffectAssociation(0, 4,0);
|
597 |
|
|
meshes[3] = meshes[2].copy(true);
|
598 |
|
|
meshes[3].setEffectAssociation(0, 8,0);
|
599 |
32f4e2a7
|
Leszek Koltunski
|
meshes[4] = new MeshPolygon(vertices2, bands1, 0, 0);
|
600 |
16f34a98
|
Leszek Koltunski
|
meshes[4].setEffectAssociation(0,16,0);
|
601 |
32f4e2a7
|
Leszek Koltunski
|
meshes[5] = new MeshPolygon(vertices3, bands1, 0, 0);
|
602 |
16f34a98
|
Leszek Koltunski
|
meshes[5].setEffectAssociation(0,32,0);
|
603 |
|
|
|
604 |
|
|
return new MeshJoined(meshes);
|
605 |
|
|
}
|
606 |
|
|
|
607 |
db608887
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
608 |
|
|
|
609 |
61b217a5
|
Leszek Koltunski
|
MeshBase createFacesMegaminxEdge(int numLayers, float width, float height)
|
610 |
db608887
|
Leszek Koltunski
|
{
|
611 |
|
|
MeshBase[] meshes = new MeshPolygon[6];
|
612 |
|
|
|
613 |
|
|
float D = height/COS18;
|
614 |
|
|
float W = D*SIN18;
|
615 |
|
|
|
616 |
|
|
float Y1 = 0.5f*width;
|
617 |
|
|
float Y2 = 0.5f*width + W;
|
618 |
|
|
float Y3 = 0.5f*width + 2*W;
|
619 |
|
|
float X2 = D*SIN54;
|
620 |
|
|
float X1 = 0.5f*height;
|
621 |
|
|
float Y4 = D*COS54;
|
622 |
|
|
|
623 |
|
|
float[] vertices0 = { -X1, Y1, -X1, -Y1, X1, -Y2, X1, Y2 };
|
624 |
|
|
float[] vertices1 = { -X1, Y3, -X1, -Y3, X1, -Y2, X1, Y2 };
|
625 |
|
|
float[] vertices2 = { -X2, 0.0f, 0.0f, -Y4, X2, 0.0f, 0.0f, Y4 };
|
626 |
|
|
|
627 |
61b217a5
|
Leszek Koltunski
|
int numBands0 = numLayers==3 ? 5 : 3;
|
628 |
|
|
int numBands1 = numLayers==3 ? 2 : 2;
|
629 |
|
|
float h = numLayers==3 ? 0.03f : 0.03f;
|
630 |
|
|
|
631 |
|
|
float[] bands0 = computeBands(h ,34,0.2f,0.2f,numBands0);
|
632 |
|
|
float[] bands1 = computeBands(0.00f,34,0.3f,0.2f,numBands1);
|
633 |
db608887
|
Leszek Koltunski
|
|
634 |
e4bf4d02
|
Leszek Koltunski
|
meshes[0] = new MeshPolygon(vertices0, bands0, 0, 0);
|
635 |
db608887
|
Leszek Koltunski
|
meshes[0].setEffectAssociation(0, 1,0);
|
636 |
|
|
meshes[1] = meshes[0].copy(true);
|
637 |
|
|
meshes[1].setEffectAssociation(0, 2,0);
|
638 |
e4bf4d02
|
Leszek Koltunski
|
meshes[2] = new MeshPolygon(vertices1, bands1, 0, 0);
|
639 |
db608887
|
Leszek Koltunski
|
meshes[2].setEffectAssociation(0, 4,0);
|
640 |
|
|
meshes[3] = meshes[2].copy(true);
|
641 |
|
|
meshes[3].setEffectAssociation(0, 8,0);
|
642 |
e4bf4d02
|
Leszek Koltunski
|
meshes[4] = new MeshPolygon(vertices2, bands1, 0, 0);
|
643 |
db608887
|
Leszek Koltunski
|
meshes[4].setEffectAssociation(0,16,0);
|
644 |
|
|
meshes[5] = meshes[4].copy(true);
|
645 |
|
|
meshes[5].setEffectAssociation(0,32,0);
|
646 |
|
|
|
647 |
|
|
return new MeshJoined(meshes);
|
648 |
|
|
}
|
649 |
|
|
|
650 |
e4bf4d02
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
651 |
|
|
|
652 |
61b217a5
|
Leszek Koltunski
|
MeshBase createFacesMegaminxCenter(int numLayers)
|
653 |
e4bf4d02
|
Leszek Koltunski
|
{
|
654 |
|
|
MeshBase[] meshes = new MeshPolygon[2];
|
655 |
|
|
|
656 |
ed01e351
|
Leszek Koltunski
|
float R = 0.5f;
|
657 |
|
|
float X1 = R*COS54;
|
658 |
e4bf4d02
|
Leszek Koltunski
|
float Y1 = R*SIN54;
|
659 |
|
|
float X2 = R*COS18;
|
660 |
|
|
float Y2 = R*SIN18;
|
661 |
|
|
|
662 |
|
|
float[] vertices0 = { -X1,+Y1, -X2,-Y2, 0.0f,-R, +X2,-Y2, +X1,+Y1 };
|
663 |
61b217a5
|
Leszek Koltunski
|
|
664 |
|
|
int numBands0 = numLayers==3 ? 4 : 3;
|
665 |
|
|
int numBands1 = numLayers==3 ? 2 : 2;
|
666 |
|
|
float h = numLayers==3 ? 0.04f : 0.04f;
|
667 |
|
|
|
668 |
|
|
float[] bands0 = computeBands( h ,45, R/3,0.2f, numBands0);
|
669 |
|
|
float[] bands1 = computeBands( 0.00f,34, R/3,0.2f, numBands1);
|
670 |
e4bf4d02
|
Leszek Koltunski
|
|
671 |
|
|
meshes[0] = new MeshPolygon(vertices0, bands0, 0, 0);
|
672 |
|
|
meshes[0].setEffectAssociation(0,1,0);
|
673 |
|
|
meshes[1] = new MeshPolygon(vertices0, bands1, 0, 0);
|
674 |
|
|
meshes[1].setEffectAssociation(0,2,0);
|
675 |
|
|
|
676 |
|
|
return new MeshJoined(meshes);
|
677 |
|
|
}
|
678 |
|
|
|
679 |
4c0a6d97
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
680 |
|
|
|
681 |
|
|
private float[] createVertices(int A, int B)
|
682 |
|
|
{
|
683 |
|
|
float E = 0.5f / Math.max(A,B);
|
684 |
|
|
return new float[] { -A*E,-B*E, +A*E,-B*E, +A*E,+B*E, -A*E,+B*E };
|
685 |
|
|
}
|
686 |
|
|
|
687 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
688 |
|
|
|
689 |
|
|
MeshBase createCuboid(int[] dimensions)
|
690 |
|
|
{
|
691 |
|
|
int X = dimensions[0];
|
692 |
|
|
int Y = dimensions[1];
|
693 |
|
|
int Z = dimensions[2];
|
694 |
|
|
|
695 |
|
|
float[] verticesXY = createVertices(X,Y);
|
696 |
|
|
float[] verticesXZ = createVertices(X,Z);
|
697 |
|
|
float[] verticesYZ = createVertices(Z,Y);
|
698 |
|
|
|
699 |
|
|
float defHeight = 0.048f;
|
700 |
|
|
|
701 |
|
|
float[] bandsX = computeBands( defHeight/X,65,0.25f,0.5f,5);
|
702 |
|
|
float[] bandsY = computeBands( defHeight/Y,65,0.25f,0.5f,5);
|
703 |
|
|
float[] bandsZ = computeBands( defHeight/Z,65,0.25f,0.5f,5);
|
704 |
|
|
|
705 |
|
|
MeshBase[] meshes = new MeshPolygon[6];
|
706 |
|
|
|
707 |
|
|
meshes[0] = new MeshPolygon(verticesYZ,bandsX,1,2);
|
708 |
|
|
meshes[0].setEffectAssociation(0,1,0);
|
709 |
|
|
meshes[1] = meshes[0].copy(true);
|
710 |
|
|
meshes[1].setEffectAssociation(0,2,0);
|
711 |
|
|
meshes[2] = new MeshPolygon(verticesXZ,bandsY,1,2);
|
712 |
|
|
meshes[2].setEffectAssociation(0,4,0);
|
713 |
|
|
meshes[3] = meshes[2].copy(true);
|
714 |
|
|
meshes[3].setEffectAssociation(0,8,0);
|
715 |
|
|
meshes[4] = new MeshPolygon(verticesXY,bandsZ,1,2);
|
716 |
|
|
meshes[4].setEffectAssociation(0,16,0);
|
717 |
|
|
meshes[5] = meshes[4].copy(true);
|
718 |
|
|
meshes[5].setEffectAssociation(0,32,0);
|
719 |
|
|
|
720 |
|
|
return new MeshJoined(meshes);
|
721 |
|
|
}
|
722 |
|
|
|
723 |
2fcfce81
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
724 |
|
|
// EFFECTS
|
725 |
55fb45c2
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
726 |
|
|
|
727 |
|
|
VertexEffect[] createVertexEffectsRediEdge()
|
728 |
|
|
{
|
729 |
|
|
Static3D move0 = new Static3D(0.0f, -0.5f, 0.0f);
|
730 |
|
|
Static3D move1 = new Static3D(0.25f, -0.25f, 0.0f);
|
731 |
|
|
Static3D move2 = new Static3D(0.5f, 0.0f, 0.0f);
|
732 |
|
|
Static3D move3 = new Static3D(0.0f, (SQ3-6)/8, (SQ3-6)/8);
|
733 |
|
|
Static3D flipZ = new Static3D(1,1,-1);
|
734 |
|
|
Static3D flipX = new Static3D(-1,1,1);
|
735 |
|
|
Static3D scale = new Static3D(2,2,2);
|
736 |
|
|
Static3D cent0 = new Static3D(0,0, 0);
|
737 |
|
|
Static3D cent1 = new Static3D(0,0, -1.5f);
|
738 |
|
|
Static3D axisX = new Static3D(1,0, 0);
|
739 |
|
|
Static3D axisY = new Static3D(0,1, 0);
|
740 |
|
|
Static3D axis = new Static3D(0,SQ2/2,-SQ2/2);
|
741 |
|
|
Static1D angle1= new Static1D(90);
|
742 |
|
|
Static1D angle2= new Static1D(45);
|
743 |
|
|
Static1D angle3= new Static1D( (float)(180/Math.PI*Math.acos(SQ3/3)) );
|
744 |
|
|
|
745 |
|
|
VertexEffect[] effect = new VertexEffect[12];
|
746 |
|
|
|
747 |
|
|
effect[0] = new VertexEffectScale(scale);
|
748 |
|
|
effect[1] = new VertexEffectMove(move0);
|
749 |
|
|
effect[2] = new VertexEffectScale(flipZ);
|
750 |
|
|
effect[3] = new VertexEffectRotate(angle1,axisX,cent0);
|
751 |
|
|
effect[4] = new VertexEffectMove(move1);
|
752 |
|
|
effect[5] = new VertexEffectRotate(angle1,axisY,cent0);
|
753 |
|
|
effect[6] = new VertexEffectMove(move2);
|
754 |
|
|
effect[7] = new VertexEffectScale(flipX);
|
755 |
|
|
effect[8] = new VertexEffectRotate(angle2,axisX,cent0);
|
756 |
|
|
effect[9] = new VertexEffectMove(move3);
|
757 |
|
|
effect[10]= new VertexEffectRotate(angle3,axis ,cent1);
|
758 |
|
|
effect[11]= new VertexEffectScale(flipX);
|
759 |
|
|
|
760 |
|
|
effect[0].setMeshAssociation(63,-1); // meshes 0,1,2,3,4,5
|
761 |
|
|
effect[1].setMeshAssociation( 3,-1); // meshes 0,1
|
762 |
|
|
effect[2].setMeshAssociation( 2,-1); // mesh 1
|
763 |
|
|
effect[3].setMeshAssociation( 2,-1); // mesh 1
|
764 |
|
|
effect[4].setMeshAssociation(12,-1); // meshes 2,3
|
765 |
|
|
effect[5].setMeshAssociation(60,-1); // meshes 2,3,4,5
|
766 |
|
|
effect[6].setMeshAssociation(12,-1); // meshes 2,3
|
767 |
|
|
effect[7].setMeshAssociation( 8,-1); // mesh 3
|
768 |
|
|
effect[8].setMeshAssociation(48,-1); // meshes 4,5
|
769 |
|
|
effect[9].setMeshAssociation(48,-1); // meshes 4,5
|
770 |
|
|
effect[10].setMeshAssociation(48,-1); // meshes 4,5
|
771 |
|
|
effect[11].setMeshAssociation(32,-1); // mesh 5
|
772 |
|
|
|
773 |
|
|
return effect;
|
774 |
|
|
}
|
775 |
|
|
|
776 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
777 |
|
|
|
778 |
|
|
VertexEffect[] createVertexEffectsRediCorner()
|
779 |
|
|
{
|
780 |
|
|
Static3D axisY = new Static3D(0,1,0);
|
781 |
|
|
Static3D axisX = new Static3D(1,0,0);
|
782 |
962437b5
|
Leszek Koltunski
|
Static3D axisZ = new Static3D(0,0,1);
|
783 |
|
|
Static3D center = new Static3D(0,0,0);
|
784 |
|
|
Static1D angle90 = new Static1D(90);
|
785 |
|
|
Static1D angle270= new Static1D(270);
|
786 |
|
|
Static1D angle45 = new Static1D(-45);
|
787 |
ae755eda
|
Leszek Koltunski
|
Static3D scale = new Static3D(1.0f, SQ2, 1.0f);
|
788 |
962437b5
|
Leszek Koltunski
|
|
789 |
ae755eda
|
Leszek Koltunski
|
VertexEffect[] effect = new VertexEffect[7];
|
790 |
55fb45c2
|
Leszek Koltunski
|
|
791 |
|
|
effect[0] = new VertexEffectMove(new Static3D(0,0,+0.5f));
|
792 |
|
|
effect[1] = new VertexEffectRotate( angle270, axisX, center );
|
793 |
|
|
effect[2] = new VertexEffectRotate( angle90 , axisY, center );
|
794 |
ae755eda
|
Leszek Koltunski
|
effect[3] = new VertexEffectScale(scale);
|
795 |
|
|
effect[4] = new VertexEffectRotate( angle45 , axisX, center );
|
796 |
|
|
effect[5] = new VertexEffectRotate( angle90 , axisY, center );
|
797 |
|
|
effect[6] = new VertexEffectRotate( angle270, axisZ, center );
|
798 |
55fb45c2
|
Leszek Koltunski
|
|
799 |
|
|
effect[0].setMeshAssociation( 7,-1); // 0,1,2
|
800 |
|
|
effect[1].setMeshAssociation( 2,-1); // 1
|
801 |
|
|
effect[2].setMeshAssociation( 4,-1); // 2
|
802 |
ae755eda
|
Leszek Koltunski
|
effect[3].setMeshAssociation(56,-1); // 3,4,5
|
803 |
|
|
effect[4].setMeshAssociation(56,-1); // 3,4,5
|
804 |
|
|
effect[5].setMeshAssociation(16,-1); // 4
|
805 |
|
|
effect[6].setMeshAssociation(32,-1); // 5
|
806 |
55fb45c2
|
Leszek Koltunski
|
|
807 |
|
|
return effect;
|
808 |
|
|
}
|
809 |
|
|
|
810 |
49cd8581
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
811 |
|
|
|
812 |
|
|
VertexEffect[] createVertexEffectsIvyCorner()
|
813 |
|
|
{
|
814 |
db3b12e6
|
Leszek Koltunski
|
Static3D axisX = new Static3D(1,0,0);
|
815 |
|
|
Static3D axisY = new Static3D(0,1,0);
|
816 |
|
|
Static1D angle1 = new Static1D(+90);
|
817 |
|
|
Static1D angle2 = new Static1D(-90);
|
818 |
|
|
Static3D center = new Static3D(0,0,0);
|
819 |
886d1ebb
|
Leszek Koltunski
|
Static3D move1 = new Static3D(IVY_M-0.5f,IVY_M-0.5f,0);
|
820 |
db3b12e6
|
Leszek Koltunski
|
|
821 |
|
|
VertexEffect[] effect = new VertexEffect[5];
|
822 |
|
|
|
823 |
886d1ebb
|
Leszek Koltunski
|
effect[0] = new VertexEffectScale(1/IVY_C);
|
824 |
db3b12e6
|
Leszek Koltunski
|
effect[1] = new VertexEffectMove(move1);
|
825 |
|
|
effect[2] = new VertexEffectScale(new Static3D(1,1,-1));
|
826 |
|
|
effect[3] = new VertexEffectRotate(angle1,axisX,center);
|
827 |
|
|
effect[4] = new VertexEffectRotate(angle2,axisY,center);
|
828 |
|
|
|
829 |
|
|
effect[2].setMeshAssociation(54,-1); // meshes 1,2,4,5
|
830 |
|
|
effect[3].setMeshAssociation(18,-1); // meshes 1,4
|
831 |
|
|
effect[4].setMeshAssociation(36,-1); // meshes 2,5
|
832 |
|
|
|
833 |
|
|
return effect;
|
834 |
49cd8581
|
Leszek Koltunski
|
}
|
835 |
|
|
|
836 |
59b87d56
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
837 |
|
|
|
838 |
|
|
VertexEffect[] createVertexEffectsRexEdge()
|
839 |
|
|
{
|
840 |
da36b97e
|
Leszek Koltunski
|
float E = 0.5f - REX_D;
|
841 |
|
|
float F = 0.5f;
|
842 |
|
|
float G = (float)Math.sqrt(E*E+F*F);
|
843 |
|
|
float A = (float)((180/Math.PI)*Math.asin(E/G));
|
844 |
59b87d56
|
Leszek Koltunski
|
|
845 |
da36b97e
|
Leszek Koltunski
|
Static3D move1 = new Static3D( 0.0f, -E/3, 0.0f);
|
846 |
|
|
Static3D move2 = new Static3D(2*G/3 -F, +E/3, 0.0f);
|
847 |
|
|
|
848 |
|
|
Static3D center0= new Static3D(0.0f, 0.0f, 0.0f);
|
849 |
|
|
Static3D center1= new Static3D( -F, 0.0f, 0.0f);
|
850 |
|
|
Static3D center2= new Static3D( +F, 0.0f, 0.0f);
|
851 |
|
|
Static3D axisX = new Static3D(1.0f, 0.0f, 0.0f);
|
852 |
|
|
Static3D axisY = new Static3D(0.0f, 1.0f, 0.0f);
|
853 |
|
|
Static3D axisZ = new Static3D(0.0f, 0.0f, 1.0f);
|
854 |
59b87d56
|
Leszek Koltunski
|
|
855 |
|
|
Static1D angle180 = new Static1D(180);
|
856 |
|
|
Static1D angle90 = new Static1D( 90);
|
857 |
da36b97e
|
Leszek Koltunski
|
Static1D angle270 = new Static1D(270);
|
858 |
|
|
Static1D angle1 = new Static1D(+A);
|
859 |
|
|
Static1D angle2 = new Static1D(-A);
|
860 |
59b87d56
|
Leszek Koltunski
|
|
861 |
da36b97e
|
Leszek Koltunski
|
VertexEffect[] effect = new VertexEffect[12];
|
862 |
59b87d56
|
Leszek Koltunski
|
|
863 |
da36b97e
|
Leszek Koltunski
|
effect[0] = new VertexEffectMove(move1);
|
864 |
|
|
effect[1] = new VertexEffectMove(move2);
|
865 |
|
|
effect[2] = new VertexEffectRotate( angle90, axisX, center0 );
|
866 |
|
|
effect[3] = new VertexEffectRotate( angle270, axisX, center0 );
|
867 |
|
|
effect[4] = new VertexEffectRotate( angle180, axisX, center0 );
|
868 |
|
|
effect[5] = new VertexEffectRotate( angle180, axisY, center0 );
|
869 |
|
|
effect[6] = new VertexEffectScale ( new Static3D(-1, 1, 1) );
|
870 |
|
|
effect[7] = new VertexEffectScale ( new Static3D( 1,-1, 1) );
|
871 |
|
|
effect[8] = new VertexEffectRotate( angle1, axisY, center1);
|
872 |
|
|
effect[9] = new VertexEffectRotate( angle2, axisY, center2);
|
873 |
|
|
effect[10]= new VertexEffectRotate( angle2, axisZ, center1);
|
874 |
|
|
effect[11]= new VertexEffectRotate( angle1, axisZ, center2);
|
875 |
|
|
|
876 |
|
|
effect[0].setMeshAssociation( 3,-1); // meshes 0 & 1
|
877 |
|
|
effect[1].setMeshAssociation(60,-1); // meshes 2,3,4,5
|
878 |
|
|
effect[2].setMeshAssociation( 2,-1); // meshes 1
|
879 |
|
|
effect[3].setMeshAssociation(12,-1); // meshes 2,3
|
880 |
|
|
effect[4].setMeshAssociation(48,-1); // meshes 4,5
|
881 |
|
|
effect[5].setMeshAssociation(32,-1); // mesh 5
|
882 |
|
|
effect[6].setMeshAssociation( 8,-1); // apply to mesh 3
|
883 |
|
|
effect[7].setMeshAssociation( 2,-1); // apply to mesh 1
|
884 |
|
|
effect[8].setMeshAssociation(16,-1); // apply to mesh 4
|
885 |
|
|
effect[9].setMeshAssociation(32,-1); // apply to mesh 5
|
886 |
|
|
effect[10].setMeshAssociation(4,-1); // apply to mesh 2
|
887 |
|
|
effect[11].setMeshAssociation(8,-1); // apply to mesh 3
|
888 |
59b87d56
|
Leszek Koltunski
|
|
889 |
|
|
return effect;
|
890 |
|
|
}
|
891 |
|
|
|
892 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
893 |
|
|
|
894 |
|
|
VertexEffect[] createVertexEffectsRexCorner()
|
895 |
|
|
{
|
896 |
|
|
Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
|
897 |
|
|
Static3D axisZ = new Static3D(0.0f, 0.0f, 1.0f);
|
898 |
80ec6abf
|
Leszek Koltunski
|
Static1D angle = new Static1D(225);
|
899 |
59b87d56
|
Leszek Koltunski
|
|
900 |
f5c134c3
|
Leszek Koltunski
|
VertexEffect[] effect = new VertexEffect[1];
|
901 |
59b87d56
|
Leszek Koltunski
|
effect[0] = new VertexEffectRotate(angle, axisZ, center);
|
902 |
|
|
|
903 |
|
|
return effect;
|
904 |
|
|
}
|
905 |
|
|
|
906 |
bbc6da6c
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
907 |
|
|
|
908 |
7764a67a
|
Leszek Koltunski
|
VertexEffect[] createVertexEffectsKilominxCenter(float width)
|
909 |
bbc6da6c
|
Leszek Koltunski
|
{
|
910 |
b5347187
|
Leszek Koltunski
|
VertexEffect[] effect = new VertexEffect[11];
|
911 |
4e627d8b
|
Leszek Koltunski
|
|
912 |
7764a67a
|
Leszek Koltunski
|
float H = 0.5f*(SIN54/COS54);
|
913 |
|
|
float Y1= 0.5f*SIN_HALFD;
|
914 |
a64e07d0
|
Leszek Koltunski
|
float Y2= H/(2*COS_HALFD);
|
915 |
db608887
|
Leszek Koltunski
|
float cos18 = (float)(Math.sqrt(1- SIN18 * SIN18));
|
916 |
a64e07d0
|
Leszek Koltunski
|
float LEN = (float)Math.sqrt(H*H/(COS_HALFD*COS_HALFD) + 0.25f);
|
917 |
4e627d8b
|
Leszek Koltunski
|
|
918 |
|
|
Static3D axisZ = new Static3D(0.0f , 0.0f , 1.0f);
|
919 |
|
|
Static3D axisY = new Static3D(0.0f , 1.0f , 0.0f);
|
920 |
7764a67a
|
Leszek Koltunski
|
Static3D axisA = new Static3D(-SIN18, cos18, 0.0f);
|
921 |
a64e07d0
|
Leszek Koltunski
|
Static3D axisC = new Static3D( H/LEN, -0.5f/LEN,-H* SIN_HALFD /(COS_HALFD*LEN));
|
922 |
4e627d8b
|
Leszek Koltunski
|
|
923 |
|
|
Static3D move1 = new Static3D(0,-Y1,0);
|
924 |
|
|
Static3D move2 = new Static3D(0,-Y2,0);
|
925 |
7764a67a
|
Leszek Koltunski
|
Static3D move3 = new Static3D(0.5f*cos18,0.5f*SIN18,0);
|
926 |
4e627d8b
|
Leszek Koltunski
|
Static3D center= new Static3D(0.0f, 0.0f, 0.0f);
|
927 |
|
|
|
928 |
|
|
Static1D angle1 = new Static1D(54);
|
929 |
7764a67a
|
Leszek Koltunski
|
Static1D angle2 = new Static1D(DIHEDRAL1/2+18);
|
930 |
4e627d8b
|
Leszek Koltunski
|
Static1D angle3 = new Static1D(90);
|
931 |
|
|
Static1D angle4 = new Static1D(120);
|
932 |
|
|
Static1D angle5 = new Static1D(240);
|
933 |
7764a67a
|
Leszek Koltunski
|
Static1D angle6 = new Static1D(90-DIHEDRAL1/2);
|
934 |
4e627d8b
|
Leszek Koltunski
|
|
935 |
|
|
effect[0] = new VertexEffectMove(move1);
|
936 |
b1dea8dd
|
Leszek Koltunski
|
effect[1] = new VertexEffectScale(1/MINX_SC);
|
937 |
|
|
effect[2] = new VertexEffectMove(move2);
|
938 |
|
|
effect[3] = new VertexEffectRotate(angle1, axisZ, center);
|
939 |
|
|
effect[4] = new VertexEffectRotate(angle2, axisZ, center);
|
940 |
|
|
effect[5] = new VertexEffectRotate(angle3, axisA, center);
|
941 |
|
|
effect[6] = new VertexEffectMove(move3);
|
942 |
|
|
effect[7] = new VertexEffectRotate(angle4, axisC, center);
|
943 |
|
|
effect[8] = new VertexEffectRotate(angle5, axisC, center);
|
944 |
|
|
effect[9] = new VertexEffectRotate(angle6, axisY, center);
|
945 |
b5347187
|
Leszek Koltunski
|
effect[10]= new VertexEffectScale(width/0.5f);
|
946 |
bbc6da6c
|
Leszek Koltunski
|
|
947 |
4e627d8b
|
Leszek Koltunski
|
effect[0].setMeshAssociation( 7,-1); // meshes 0,1,2
|
948 |
|
|
effect[1].setMeshAssociation(56,-1); // meshes 3,4,5
|
949 |
b1dea8dd
|
Leszek Koltunski
|
effect[2].setMeshAssociation(56,-1); // meshes 3,4,5
|
950 |
|
|
effect[3].setMeshAssociation( 7,-1); // meshes 0,1,2
|
951 |
4e627d8b
|
Leszek Koltunski
|
effect[4].setMeshAssociation(56,-1); // meshes 3,4,5
|
952 |
|
|
effect[5].setMeshAssociation(56,-1); // meshes 3,4,5
|
953 |
b1dea8dd
|
Leszek Koltunski
|
effect[6].setMeshAssociation(56,-1); // meshes 3,4,5
|
954 |
|
|
effect[7].setMeshAssociation(18,-1); // meshes 1,4
|
955 |
|
|
effect[8].setMeshAssociation(36,-1); // meshes 2,5
|
956 |
4e627d8b
|
Leszek Koltunski
|
|
957 |
|
|
return effect;
|
958 |
bbc6da6c
|
Leszek Koltunski
|
}
|
959 |
|
|
|
960 |
a64e07d0
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
961 |
|
|
|
962 |
16f34a98
|
Leszek Koltunski
|
VertexEffect[] createVertexEffectsMinxCorner(float width)
|
963 |
a64e07d0
|
Leszek Koltunski
|
{
|
964 |
|
|
VertexEffect[] effect = new VertexEffect[9];
|
965 |
|
|
|
966 |
|
|
float Y = COS54/(2*SIN54);
|
967 |
|
|
|
968 |
|
|
float sinA = (2*SIN54*SIN54-1)/COS54;
|
969 |
|
|
float cosA = (float)Math.sqrt(1-sinA*sinA);
|
970 |
|
|
float LEN = 0.5f/SIN54;
|
971 |
16f34a98
|
Leszek Koltunski
|
float scale= width/LEN;
|
972 |
a64e07d0
|
Leszek Koltunski
|
|
973 |
|
|
Static3D axisA = new Static3D( SIN54, COS54, 0.0f);
|
974 |
|
|
Static3D axisB = new Static3D(-SIN54, COS54, 0.0f);
|
975 |
|
|
Static3D axisX = new Static3D( 1.0f, 0.0f, 0.0f);
|
976 |
|
|
|
977 |
|
|
Static3D centerU = new Static3D( 0.0f, Y, 0.0f);
|
978 |
|
|
Static3D centerD = new Static3D( 0.0f,-Y, 0.0f);
|
979 |
|
|
|
980 |
|
|
Static3D move1= new Static3D(0.0f, -sinA*LEN, -cosA*LEN );
|
981 |
|
|
Static3D move2= new Static3D(0.0f, Y , 0.0f );
|
982 |
|
|
|
983 |
db608887
|
Leszek Koltunski
|
Static1D angleD = new Static1D(DIHEDRAL1);
|
984 |
|
|
Static1D angleE = new Static1D(360-DIHEDRAL1);
|
985 |
|
|
Static1D angleF = new Static1D(DIHEDRAL2);
|
986 |
a64e07d0
|
Leszek Koltunski
|
|
987 |
|
|
effect[0] = new VertexEffectScale ( new Static3D( 1, 1,-1) );
|
988 |
|
|
effect[1] = new VertexEffectRotate(angleE, axisA, centerU);
|
989 |
|
|
effect[2] = new VertexEffectRotate(angleD, axisB, centerU);
|
990 |
|
|
effect[3] = new VertexEffectMove(move1);
|
991 |
|
|
effect[4] = new VertexEffectRotate(angleE, axisA, centerD);
|
992 |
|
|
effect[5] = new VertexEffectRotate(angleD, axisB, centerD);
|
993 |
|
|
effect[6] = new VertexEffectRotate(angleF, axisX, centerD);
|
994 |
|
|
effect[7] = new VertexEffectMove(move2);
|
995 |
|
|
effect[8] = new VertexEffectScale(scale);
|
996 |
|
|
|
997 |
|
|
effect[0].setMeshAssociation( 3,-1); // meshes 0,1
|
998 |
|
|
effect[1].setMeshAssociation( 16,-1); // mesh 4
|
999 |
|
|
effect[2].setMeshAssociation( 32,-1); // mesh 5
|
1000 |
|
|
effect[3].setMeshAssociation( 56,-1); // meshes 3,4,5
|
1001 |
|
|
effect[4].setMeshAssociation( 1,-1); // mesh 0
|
1002 |
|
|
effect[5].setMeshAssociation( 2,-1); // mesh 1
|
1003 |
|
|
|
1004 |
|
|
return effect;
|
1005 |
|
|
}
|
1006 |
|
|
|
1007 |
16f34a98
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1008 |
|
|
|
1009 |
|
|
VertexEffect[] createVertexEffectsKilominxEdge(float width, float height, boolean left)
|
1010 |
|
|
{
|
1011 |
|
|
VertexEffect[] effect = new VertexEffect[11 + (left ? 0:1)];
|
1012 |
|
|
|
1013 |
|
|
float D = height/COS18;
|
1014 |
|
|
float W = D*SIN18;
|
1015 |
|
|
float X1 = height/2;
|
1016 |
|
|
float Y1 = width/2;
|
1017 |
|
|
float Y2 = (width+W)/2;
|
1018 |
|
|
float Y3 = D*COS54;
|
1019 |
|
|
float Y4 = height*COS_HALFD;
|
1020 |
|
|
float Z = 2*height*COS_HALFD;
|
1021 |
|
|
float alpha = 90-DIHEDRAL1/2;
|
1022 |
|
|
|
1023 |
|
|
Static1D angle1 = new Static1D(alpha);
|
1024 |
|
|
Static1D angle2 = new Static1D(180-alpha);
|
1025 |
|
|
Static1D angle3 = new Static1D(DIHEDRAL2);
|
1026 |
|
|
Static1D angle4 = new Static1D(90);
|
1027 |
|
|
|
1028 |
|
|
Static3D move1 = new Static3D(+X1,-Y1,0);
|
1029 |
|
|
Static3D move2 = new Static3D(-X1,-Y2+W,-Z);
|
1030 |
|
|
Static3D move3 = new Static3D(0,+Y3,0);
|
1031 |
|
|
Static3D move4 = new Static3D(0,-Y4-width,0);
|
1032 |
|
|
Static3D scale = new Static3D(+1,+1,-1);
|
1033 |
|
|
|
1034 |
|
|
Static3D axisXplus = new Static3D(+1, 0, 0);
|
1035 |
|
|
Static3D axisYplus = new Static3D( 0,+1, 0);
|
1036 |
|
|
|
1037 |
|
|
Static3D center1= new Static3D( 0, 0, 0);
|
1038 |
|
|
Static3D center2= new Static3D( 0, 0,-Z);
|
1039 |
|
|
Static3D center3= new Static3D( 0,-width, 0);
|
1040 |
|
|
|
1041 |
|
|
effect[ 0] = new VertexEffectMove(move1);
|
1042 |
|
|
effect[ 1] = new VertexEffectMove(move2);
|
1043 |
|
|
effect[ 2] = new VertexEffectMove(move3);
|
1044 |
|
|
effect[ 3] = new VertexEffectMove(move4);
|
1045 |
|
|
effect[ 4] = new VertexEffectScale(scale);
|
1046 |
|
|
effect[ 5] = new VertexEffectRotate(angle1, axisYplus , center1);
|
1047 |
|
|
effect[ 6] = new VertexEffectRotate(angle2, axisYplus , center1);
|
1048 |
|
|
effect[ 7] = new VertexEffectRotate(angle1, axisYplus , center2);
|
1049 |
|
|
effect[ 8] = new VertexEffectRotate(angle2, axisYplus , center2);
|
1050 |
|
|
effect[ 9] = new VertexEffectRotate(angle3, axisXplus , center1);
|
1051 |
|
|
effect[10] = new VertexEffectRotate(angle4, axisXplus , center3);
|
1052 |
|
|
|
1053 |
|
|
if( !left )
|
1054 |
|
|
{
|
1055 |
|
|
Static3D scale1 = new Static3D(+1,-1,+1);
|
1056 |
|
|
effect[11] = new VertexEffectScale(scale1);
|
1057 |
|
|
}
|
1058 |
|
|
|
1059 |
|
|
effect[ 0].setMeshAssociation( 3,-1); // meshes 0,1
|
1060 |
|
|
effect[ 1].setMeshAssociation(12,-1); // meshes 2,3
|
1061 |
|
|
effect[ 2].setMeshAssociation(16,-1); // mesh 4
|
1062 |
|
|
effect[ 3].setMeshAssociation(32,-1); // mesh 5
|
1063 |
|
|
effect[ 4].setMeshAssociation( 2,-1); // mesh 1
|
1064 |
|
|
effect[ 5].setMeshAssociation( 1,-1); // mesh 0
|
1065 |
|
|
effect[ 6].setMeshAssociation( 2,-1); // mesh 1
|
1066 |
|
|
effect[ 7].setMeshAssociation( 4,-1); // mesh 2
|
1067 |
|
|
effect[ 8].setMeshAssociation( 8,-1); // mesh 3
|
1068 |
|
|
effect[ 9].setMeshAssociation(16,-1); // mesh 4
|
1069 |
|
|
effect[10].setMeshAssociation(32,-1); // mesh 5
|
1070 |
|
|
|
1071 |
|
|
return effect;
|
1072 |
|
|
}
|
1073 |
|
|
|
1074 |
db608887
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1075 |
|
|
|
1076 |
|
|
VertexEffect[] createVertexEffectsMegaminxEdge(float width, float height)
|
1077 |
|
|
{
|
1078 |
|
|
VertexEffect[] effect = new VertexEffect[11];
|
1079 |
|
|
|
1080 |
|
|
float X = 0.5f*height;
|
1081 |
|
|
float Y = height*(COS54/COS18) + width*0.5f;
|
1082 |
|
|
float Z = 2*height*COS_HALFD;
|
1083 |
|
|
|
1084 |
|
|
float alpha = 90-DIHEDRAL1/2;
|
1085 |
|
|
float beta = DIHEDRAL2;
|
1086 |
|
|
|
1087 |
|
|
Static1D angle1 = new Static1D(alpha);
|
1088 |
|
|
Static1D angle2 = new Static1D(180-alpha);
|
1089 |
|
|
Static1D angle3 = new Static1D(beta);
|
1090 |
|
|
|
1091 |
|
|
Static3D move1 = new Static3D(X,0,0);
|
1092 |
|
|
Static3D move2 = new Static3D(X,0,-Z);
|
1093 |
|
|
Static3D move3 = new Static3D(0,+Y,0);
|
1094 |
|
|
Static3D move4 = new Static3D(0,-Y,0);
|
1095 |
|
|
Static3D scale = new Static3D(+1,+1,-1);
|
1096 |
|
|
|
1097 |
|
|
Static3D axisXplus = new Static3D(+1, 0, 0);
|
1098 |
|
|
Static3D axisXminus= new Static3D(-1, 0, 0);
|
1099 |
|
|
Static3D axisYplus = new Static3D( 0,+1, 0);
|
1100 |
|
|
Static3D axisYminus= new Static3D( 0,-1, 0);
|
1101 |
|
|
|
1102 |
|
|
Static3D center1= new Static3D( 0, 0, 0);
|
1103 |
|
|
Static3D center2= new Static3D( 0, 0,-Z);
|
1104 |
|
|
Static3D center3= new Static3D( 0,+width*0.5f, 0);
|
1105 |
|
|
Static3D center4= new Static3D( 0,-width*0.5f, 0);
|
1106 |
|
|
|
1107 |
|
|
effect[ 0] = new VertexEffectMove(move1);
|
1108 |
|
|
effect[ 1] = new VertexEffectMove(move2);
|
1109 |
|
|
effect[ 2] = new VertexEffectMove(move3);
|
1110 |
|
|
effect[ 3] = new VertexEffectMove(move4);
|
1111 |
|
|
effect[ 4] = new VertexEffectScale(scale);
|
1112 |
|
|
effect[ 5] = new VertexEffectRotate(angle1, axisYplus , center1);
|
1113 |
|
|
effect[ 6] = new VertexEffectRotate(angle2, axisYplus , center1);
|
1114 |
|
|
effect[ 7] = new VertexEffectRotate(angle1, axisYminus, center2);
|
1115 |
|
|
effect[ 8] = new VertexEffectRotate(angle2, axisYminus, center2);
|
1116 |
|
|
effect[ 9] = new VertexEffectRotate(angle3, axisXplus , center3);
|
1117 |
|
|
effect[10] = new VertexEffectRotate(angle3, axisXminus, center4);
|
1118 |
|
|
|
1119 |
|
|
effect[ 0].setMeshAssociation( 3,-1); // meshes 0,1
|
1120 |
|
|
effect[ 1].setMeshAssociation(12,-1); // meshes 2,3
|
1121 |
|
|
effect[ 2].setMeshAssociation(16,-1); // mesh 4
|
1122 |
|
|
effect[ 3].setMeshAssociation(32,-1); // mesh 5
|
1123 |
|
|
effect[ 4].setMeshAssociation( 2,-1); // mesh 1
|
1124 |
|
|
effect[ 5].setMeshAssociation( 1,-1); // mesh 0
|
1125 |
|
|
effect[ 6].setMeshAssociation( 2,-1); // mesh 1
|
1126 |
|
|
effect[ 7].setMeshAssociation( 4,-1); // mesh 2
|
1127 |
|
|
effect[ 8].setMeshAssociation( 8,-1); // mesh 3
|
1128 |
|
|
effect[ 9].setMeshAssociation(16,-1); // mesh 4
|
1129 |
|
|
effect[10].setMeshAssociation(32,-1); // mesh 5
|
1130 |
|
|
|
1131 |
|
|
return effect;
|
1132 |
|
|
}
|
1133 |
|
|
|
1134 |
e4bf4d02
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1135 |
|
|
|
1136 |
ed01e351
|
Leszek Koltunski
|
VertexEffect[] createVertexEffectsMegaminxCenter(float width)
|
1137 |
e4bf4d02
|
Leszek Koltunski
|
{
|
1138 |
ed01e351
|
Leszek Koltunski
|
VertexEffect[] effect = new VertexEffect[2];
|
1139 |
e4bf4d02
|
Leszek Koltunski
|
|
1140 |
|
|
Static1D angle = new Static1D(DIHEDRAL2);
|
1141 |
|
|
Static3D axisX = new Static3D( 1.0f, 0.0f, 0.0f);
|
1142 |
|
|
Static3D center= new Static3D( 0, 0, 0);
|
1143 |
|
|
|
1144 |
ed01e351
|
Leszek Koltunski
|
effect[0] = new VertexEffectScale(width/COS54);
|
1145 |
|
|
effect[1] = new VertexEffectRotate(angle, axisX, center);
|
1146 |
e4bf4d02
|
Leszek Koltunski
|
|
1147 |
|
|
return effect;
|
1148 |
|
|
}
|
1149 |
|
|
|
1150 |
4c0a6d97
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1151 |
|
|
|
1152 |
|
|
VertexEffect[] createCuboidEffects(int[] dimensions)
|
1153 |
|
|
{
|
1154 |
|
|
float X = dimensions[0];
|
1155 |
|
|
float Y = dimensions[1];
|
1156 |
|
|
float Z = dimensions[2];
|
1157 |
|
|
|
1158 |
|
|
float MAX_XY = Math.max(X,Y);
|
1159 |
|
|
float MAX_XZ = Math.max(X,Z);
|
1160 |
|
|
float MAX_YZ = Math.max(Z,Y);
|
1161 |
|
|
|
1162 |
|
|
Static1D angle = new Static1D(90);
|
1163 |
|
|
Static3D move = new Static3D( 0.0f, 0.0f, 0.5f);
|
1164 |
|
|
Static3D axisX = new Static3D( 1.0f, 0.0f, 0.0f);
|
1165 |
|
|
Static3D axisY = new Static3D( 0.0f, 1.0f, 0.0f);
|
1166 |
|
|
Static3D center= new Static3D( 0.0f, 0.0f, 0.0f);
|
1167 |
|
|
|
1168 |
|
|
Static3D scale3 = new Static3D(MAX_XY,MAX_XY,+Z);
|
1169 |
|
|
Static3D scale4 = new Static3D(MAX_XY,MAX_XY,-Z);
|
1170 |
|
|
Static3D scale5 = new Static3D(MAX_XZ,+Y,MAX_XZ);
|
1171 |
|
|
Static3D scale6 = new Static3D(MAX_XZ,-Y,MAX_XZ);
|
1172 |
|
|
Static3D scale7 = new Static3D(+X,MAX_YZ,MAX_YZ);
|
1173 |
|
|
Static3D scale8 = new Static3D(-X,MAX_YZ,MAX_YZ);
|
1174 |
|
|
|
1175 |
|
|
VertexEffect[] effect = new VertexEffect[9];
|
1176 |
|
|
|
1177 |
|
|
effect[0] = new VertexEffectMove(move);
|
1178 |
|
|
effect[1] = new VertexEffectRotate(angle, axisX, center);
|
1179 |
|
|
effect[2] = new VertexEffectRotate(angle, axisY, center);
|
1180 |
|
|
effect[3] = new VertexEffectScale(scale3);
|
1181 |
|
|
effect[4] = new VertexEffectScale(scale4);
|
1182 |
|
|
effect[5] = new VertexEffectScale(scale5);
|
1183 |
|
|
effect[6] = new VertexEffectScale(scale6);
|
1184 |
|
|
effect[7] = new VertexEffectScale(scale7);
|
1185 |
|
|
effect[8] = new VertexEffectScale(scale8);
|
1186 |
|
|
|
1187 |
|
|
effect[1].setMeshAssociation(12,-1); // meshes 2,3
|
1188 |
|
|
effect[2].setMeshAssociation( 3,-1); // meshes 0,1
|
1189 |
|
|
effect[3].setMeshAssociation(16,-1); // mesh 4
|
1190 |
|
|
effect[4].setMeshAssociation(32,-1); // mesh 5
|
1191 |
|
|
effect[5].setMeshAssociation( 8,-1); // mesh 3
|
1192 |
|
|
effect[6].setMeshAssociation( 4,-1); // mesh 2
|
1193 |
|
|
effect[7].setMeshAssociation( 1,-1); // mesh 0
|
1194 |
|
|
effect[8].setMeshAssociation( 2,-1); // mesh 1
|
1195 |
|
|
|
1196 |
|
|
return effect;
|
1197 |
|
|
}
|
1198 |
|
|
|
1199 |
55fb45c2
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1200 |
|
|
// OBJECTS
|
1201 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1202 |
|
|
|
1203 |
749ef882
|
Leszek Koltunski
|
public MeshBase createRediEdgeMesh()
|
1204 |
55fb45c2
|
Leszek Koltunski
|
{
|
1205 |
|
|
MeshBase mesh = createFacesRediEdge();
|
1206 |
|
|
VertexEffect[] effects = createVertexEffectsRediEdge();
|
1207 |
|
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1208 |
|
|
|
1209 |
|
|
Static3D center = new Static3D(0.0f,-0.75f,-0.75f);
|
1210 |
2fcfce81
|
Leszek Koltunski
|
Static3D[] vertices = new Static3D[2];
|
1211 |
55fb45c2
|
Leszek Koltunski
|
vertices[0] = new Static3D( 0.5f, 0.0f, 0.0f);
|
1212 |
|
|
vertices[1] = new Static3D(-0.5f, 0.0f, 0.0f);
|
1213 |
|
|
roundCorners(mesh,center,vertices,0.06f,0.20f);
|
1214 |
|
|
|
1215 |
|
|
mesh.mergeEffComponents();
|
1216 |
|
|
|
1217 |
|
|
return mesh;
|
1218 |
|
|
}
|
1219 |
|
|
|
1220 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1221 |
|
|
|
1222 |
749ef882
|
Leszek Koltunski
|
public MeshBase createRediCornerMesh()
|
1223 |
55fb45c2
|
Leszek Koltunski
|
{
|
1224 |
|
|
MeshBase mesh = createFacesRediCorner();
|
1225 |
|
|
VertexEffect[] effects = createVertexEffectsRediCorner();
|
1226 |
|
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1227 |
|
|
|
1228 |
|
|
Static3D center = new Static3D(0,0,0);
|
1229 |
05cc8075
|
Leszek Koltunski
|
Static3D[] vertices = new Static3D[8];
|
1230 |
|
|
vertices[0] = new Static3D(+0.5f,+0.5f,+0.5f);
|
1231 |
|
|
vertices[1] = new Static3D(+0.5f,+0.5f,-0.5f);
|
1232 |
|
|
vertices[2] = new Static3D(+0.5f,-0.5f,+0.5f);
|
1233 |
|
|
vertices[3] = new Static3D(+0.5f,-0.5f,-0.5f);
|
1234 |
|
|
vertices[4] = new Static3D(-0.5f,+0.5f,+0.5f);
|
1235 |
|
|
vertices[5] = new Static3D(-0.5f,+0.5f,-0.5f);
|
1236 |
|
|
vertices[6] = new Static3D(-0.5f,-0.5f,+0.5f);
|
1237 |
|
|
vertices[7] = new Static3D(-0.5f,-0.5f,-0.5f);
|
1238 |
|
|
|
1239 |
|
|
roundCorners(mesh,center,vertices,0.06f,0.12f);
|
1240 |
962437b5
|
Leszek Koltunski
|
|
1241 |
|
|
mesh.mergeEffComponents();
|
1242 |
|
|
|
1243 |
49cd8581
|
Leszek Koltunski
|
return mesh;
|
1244 |
|
|
}
|
1245 |
|
|
|
1246 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1247 |
|
|
|
1248 |
749ef882
|
Leszek Koltunski
|
public MeshBase createIvyCornerMesh()
|
1249 |
49cd8581
|
Leszek Koltunski
|
{
|
1250 |
|
|
MeshBase mesh = createFacesIvyCorner();
|
1251 |
|
|
VertexEffect[] effects = createVertexEffectsIvyCorner();
|
1252 |
|
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1253 |
|
|
|
1254 |
|
|
Static3D center = new Static3D(-0.5f,-0.5f,-0.5f);
|
1255 |
f9464035
|
Leszek Koltunski
|
Static3D[] vertices = new Static3D[4];
|
1256 |
6a224bdc
|
Leszek Koltunski
|
vertices[0] = new Static3D(+0.0f,+0.0f,+0.0f);
|
1257 |
f9464035
|
Leszek Koltunski
|
vertices[1] = new Static3D(-1.0f,+0.0f,+0.0f);
|
1258 |
|
|
vertices[2] = new Static3D(+0.0f,-1.0f,+0.0f);
|
1259 |
|
|
vertices[3] = new Static3D(+0.0f,+0.0f,-1.0f);
|
1260 |
|
|
|
1261 |
|
|
roundCorners(mesh,center,vertices,0.03f,0.10f);
|
1262 |
49cd8581
|
Leszek Koltunski
|
|
1263 |
|
|
mesh.mergeEffComponents();
|
1264 |
|
|
|
1265 |
|
|
return mesh;
|
1266 |
|
|
}
|
1267 |
|
|
|
1268 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1269 |
|
|
|
1270 |
749ef882
|
Leszek Koltunski
|
public MeshBase createIvyFaceMesh()
|
1271 |
49cd8581
|
Leszek Koltunski
|
{
|
1272 |
|
|
MeshBase mesh = createFacesIvyFace();
|
1273 |
|
|
|
1274 |
f9464035
|
Leszek Koltunski
|
Static3D center = new Static3D(-0.0f,-0.0f,-0.5f);
|
1275 |
|
|
Static3D[] vertices = new Static3D[2];
|
1276 |
|
|
vertices[0] = new Static3D(-0.5f,+0.5f,+0.0f);
|
1277 |
|
|
vertices[1] = new Static3D(+0.5f,-0.5f,+0.0f);
|
1278 |
|
|
|
1279 |
|
|
roundCorners(mesh,center,vertices,0.03f,0.10f);
|
1280 |
|
|
|
1281 |
49cd8581
|
Leszek Koltunski
|
mesh.mergeEffComponents();
|
1282 |
|
|
mesh.addEmptyTexComponent();
|
1283 |
|
|
mesh.addEmptyTexComponent();
|
1284 |
|
|
mesh.addEmptyTexComponent();
|
1285 |
|
|
mesh.addEmptyTexComponent();
|
1286 |
|
|
|
1287 |
59b87d56
|
Leszek Koltunski
|
return mesh;
|
1288 |
|
|
}
|
1289 |
|
|
|
1290 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1291 |
|
|
|
1292 |
749ef882
|
Leszek Koltunski
|
public MeshBase createRexCornerMesh()
|
1293 |
59b87d56
|
Leszek Koltunski
|
{
|
1294 |
|
|
MeshBase mesh = createFacesRexCorner();
|
1295 |
|
|
VertexEffect[] effects = createVertexEffectsRexCorner();
|
1296 |
|
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1297 |
|
|
|
1298 |
da36b97e
|
Leszek Koltunski
|
final float G = (1-REX_D)/3;
|
1299 |
|
|
Static3D center = new Static3D(0.0f,0.0f,-G*SQ2/2);
|
1300 |
59b87d56
|
Leszek Koltunski
|
Static3D[] vertices = new Static3D[1];
|
1301 |
72b93c08
|
Leszek Koltunski
|
vertices[0] = new Static3D(+G,-G,+0.0f);
|
1302 |
da36b97e
|
Leszek Koltunski
|
roundCorners(mesh,center,vertices,0.10f,0.10f);
|
1303 |
59b87d56
|
Leszek Koltunski
|
|
1304 |
|
|
mesh.mergeEffComponents();
|
1305 |
|
|
mesh.addEmptyTexComponent();
|
1306 |
|
|
mesh.addEmptyTexComponent();
|
1307 |
da36b97e
|
Leszek Koltunski
|
mesh.addEmptyTexComponent();
|
1308 |
|
|
mesh.addEmptyTexComponent();
|
1309 |
59b87d56
|
Leszek Koltunski
|
|
1310 |
|
|
return mesh;
|
1311 |
|
|
}
|
1312 |
|
|
|
1313 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1314 |
|
|
|
1315 |
749ef882
|
Leszek Koltunski
|
public MeshBase createRexFaceMesh()
|
1316 |
59b87d56
|
Leszek Koltunski
|
{
|
1317 |
|
|
MeshBase mesh = createFacesRexFace();
|
1318 |
|
|
|
1319 |
|
|
mesh.mergeEffComponents();
|
1320 |
|
|
mesh.addEmptyTexComponent();
|
1321 |
|
|
mesh.addEmptyTexComponent();
|
1322 |
da36b97e
|
Leszek Koltunski
|
mesh.addEmptyTexComponent();
|
1323 |
|
|
mesh.addEmptyTexComponent();
|
1324 |
59b87d56
|
Leszek Koltunski
|
|
1325 |
|
|
return mesh;
|
1326 |
|
|
}
|
1327 |
|
|
|
1328 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1329 |
|
|
|
1330 |
749ef882
|
Leszek Koltunski
|
public MeshBase createRexEdgeMesh()
|
1331 |
59b87d56
|
Leszek Koltunski
|
{
|
1332 |
|
|
MeshBase mesh = createFacesRexEdge();
|
1333 |
|
|
VertexEffect[] effects = createVertexEffectsRexEdge();
|
1334 |
|
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1335 |
|
|
|
1336 |
|
|
Static3D center = new Static3D(0.0f,-0.5f,-0.5f);
|
1337 |
|
|
Static3D[] vertices = new Static3D[2];
|
1338 |
|
|
vertices[0] = new Static3D(+0.5f,+0.0f,+0.0f);
|
1339 |
|
|
vertices[1] = new Static3D(-0.5f,+0.0f,+0.0f);
|
1340 |
0b8ffe1a
|
Leszek Koltunski
|
roundCorners(mesh,center,vertices,0.06f,0.10f);
|
1341 |
59b87d56
|
Leszek Koltunski
|
|
1342 |
|
|
mesh.mergeEffComponents();
|
1343 |
|
|
|
1344 |
bbc6da6c
|
Leszek Koltunski
|
return mesh;
|
1345 |
|
|
}
|
1346 |
|
|
|
1347 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1348 |
|
|
|
1349 |
749ef882
|
Leszek Koltunski
|
public MeshBase createKilominxCenterMesh(float width)
|
1350 |
bbc6da6c
|
Leszek Koltunski
|
{
|
1351 |
7764a67a
|
Leszek Koltunski
|
MeshBase mesh = createFacesKilominxCenter();
|
1352 |
|
|
VertexEffect[] effects = createVertexEffectsKilominxCenter(width);
|
1353 |
bbc6da6c
|
Leszek Koltunski
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1354 |
a2398d6b
|
Leszek Koltunski
|
|
1355 |
12313693
|
Leszek Koltunski
|
float A = (2*SQ3/3)* SIN54;
|
1356 |
a2398d6b
|
Leszek Koltunski
|
float B = 0.4f;
|
1357 |
a64e07d0
|
Leszek Koltunski
|
float X = SIN_HALFD * SIN54 *COS54 ;
|
1358 |
12313693
|
Leszek Koltunski
|
float Y = SIN54 * SIN54 - 0.5f;
|
1359 |
a64e07d0
|
Leszek Koltunski
|
float Z = COS_HALFD* SIN54 *COS54 ;
|
1360 |
a2398d6b
|
Leszek Koltunski
|
|
1361 |
|
|
Static3D center = new Static3D(0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B);
|
1362 |
|
|
|
1363 |
|
|
Static3D[] vertices = new Static3D[4];
|
1364 |
|
|
vertices[0] = new Static3D( 0.0f, 0.0f, 0.0f);
|
1365 |
|
|
vertices[1] = new Static3D( 0.0f,-0.5f, 0.0f);
|
1366 |
|
|
vertices[2] = new Static3D(-X , Y ,-Z );
|
1367 |
|
|
vertices[3] = new Static3D(+X , Y ,-Z );
|
1368 |
|
|
|
1369 |
|
|
roundCorners(mesh,center,vertices,0.03f,0.10f);
|
1370 |
|
|
|
1371 |
bbc6da6c
|
Leszek Koltunski
|
mesh.mergeEffComponents();
|
1372 |
|
|
|
1373 |
a64e07d0
|
Leszek Koltunski
|
return mesh;
|
1374 |
|
|
}
|
1375 |
|
|
|
1376 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1377 |
7764a67a
|
Leszek Koltunski
|
// numLayers==3 --> index=0; numLayers=5 --> index=1 ...
|
1378 |
|
|
// type: 0,1,... 0 --> edge, 1 --> 1 layer deeper, etc
|
1379 |
a64e07d0
|
Leszek Koltunski
|
|
1380 |
749ef882
|
Leszek Koltunski
|
public MeshBase createKilominxEdgeMesh(int numLayers, float width, float height, boolean left)
|
1381 |
7764a67a
|
Leszek Koltunski
|
{
|
1382 |
16f34a98
|
Leszek Koltunski
|
MeshBase mesh = createFacesKilominxEdge(numLayers,width,height);
|
1383 |
|
|
VertexEffect[] effects = createVertexEffectsKilominxEdge(width,height,left);
|
1384 |
7764a67a
|
Leszek Koltunski
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1385 |
|
|
|
1386 |
16f34a98
|
Leszek Koltunski
|
// round...
|
1387 |
|
|
|
1388 |
7764a67a
|
Leszek Koltunski
|
mesh.mergeEffComponents();
|
1389 |
|
|
|
1390 |
|
|
return mesh;
|
1391 |
|
|
}
|
1392 |
|
|
|
1393 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1394 |
|
|
|
1395 |
749ef882
|
Leszek Koltunski
|
public MeshBase createMinxCornerMesh(int numLayers, float width)
|
1396 |
a64e07d0
|
Leszek Koltunski
|
{
|
1397 |
16f34a98
|
Leszek Koltunski
|
MeshBase mesh = createFacesMinxCorner(numLayers);
|
1398 |
|
|
VertexEffect[] effects = createVertexEffectsMinxCorner(width);
|
1399 |
a64e07d0
|
Leszek Koltunski
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1400 |
|
|
|
1401 |
|
|
float A = (2*SQ3/3)* SIN54;
|
1402 |
|
|
float B = 0.4f;
|
1403 |
16f34a98
|
Leszek Koltunski
|
/*
|
1404 |
a64e07d0
|
Leszek Koltunski
|
float X = SIN_HALFD* SIN54 * COS54;
|
1405 |
|
|
float Y = SIN54 * SIN54 - 0.5f;
|
1406 |
|
|
float Z = COS_HALFD* SIN54 * COS54;
|
1407 |
16f34a98
|
Leszek Koltunski
|
float S = 2*width;
|
1408 |
|
|
*/
|
1409 |
a64e07d0
|
Leszek Koltunski
|
Static3D center = new Static3D(0.0f, -(float)Math.sqrt(1-A*A)*B,-A*B);
|
1410 |
16f34a98
|
Leszek Koltunski
|
Static3D[] vertices = new Static3D[1];
|
1411 |
a64e07d0
|
Leszek Koltunski
|
vertices[0] = new Static3D( 0.0f, 0.0f , 0.0f);
|
1412 |
16f34a98
|
Leszek Koltunski
|
/*
|
1413 |
a64e07d0
|
Leszek Koltunski
|
vertices[1] = new Static3D( 0.0f,-0.5f*S, 0.0f);
|
1414 |
|
|
vertices[2] = new Static3D(-X*S , Y*S ,-Z*S );
|
1415 |
|
|
vertices[3] = new Static3D(+X*S , Y*S ,-Z*S );
|
1416 |
16f34a98
|
Leszek Koltunski
|
*/
|
1417 |
a64e07d0
|
Leszek Koltunski
|
roundCorners(mesh,center,vertices,0.04f,0.10f);
|
1418 |
|
|
|
1419 |
|
|
mesh.mergeEffComponents();
|
1420 |
|
|
|
1421 |
ac940e24
|
Leszek Koltunski
|
return mesh;
|
1422 |
|
|
}
|
1423 |
d38f1397
|
Leszek Koltunski
|
|
1424 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1425 |
|
|
// numLayers==3 --> index=0; numLayers=5 --> index=1 ...
|
1426 |
|
|
// type: 0,1,... 0 --> edge, 1 --> 1 layer deeper, etc
|
1427 |
|
|
|
1428 |
749ef882
|
Leszek Koltunski
|
public MeshBase createMegaminxEdgeMesh(int numLayers, float width, float height)
|
1429 |
d38f1397
|
Leszek Koltunski
|
{
|
1430 |
61b217a5
|
Leszek Koltunski
|
MeshBase mesh = createFacesMegaminxEdge(numLayers,width,height);
|
1431 |
db608887
|
Leszek Koltunski
|
VertexEffect[] effects = createVertexEffectsMegaminxEdge(width,height);
|
1432 |
|
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1433 |
|
|
|
1434 |
|
|
mesh.mergeEffComponents();
|
1435 |
d38f1397
|
Leszek Koltunski
|
|
1436 |
e4bf4d02
|
Leszek Koltunski
|
return mesh;
|
1437 |
|
|
}
|
1438 |
|
|
|
1439 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1440 |
|
|
|
1441 |
749ef882
|
Leszek Koltunski
|
public MeshBase createMegaminxCenterMesh(int numLayers, float width)
|
1442 |
e4bf4d02
|
Leszek Koltunski
|
{
|
1443 |
61b217a5
|
Leszek Koltunski
|
MeshBase mesh = createFacesMegaminxCenter(numLayers);
|
1444 |
ed01e351
|
Leszek Koltunski
|
VertexEffect[] effects = createVertexEffectsMegaminxCenter(width);
|
1445 |
e4bf4d02
|
Leszek Koltunski
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1446 |
|
|
|
1447 |
|
|
mesh.mergeEffComponents();
|
1448 |
|
|
mesh.addEmptyTexComponent();
|
1449 |
|
|
mesh.addEmptyTexComponent();
|
1450 |
|
|
mesh.addEmptyTexComponent();
|
1451 |
|
|
mesh.addEmptyTexComponent();
|
1452 |
|
|
|
1453 |
4c0a6d97
|
Leszek Koltunski
|
return mesh;
|
1454 |
|
|
}
|
1455 |
|
|
|
1456 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1457 |
|
|
|
1458 |
749ef882
|
Leszek Koltunski
|
public MeshBase createCuboidMesh(int[] dimensions)
|
1459 |
4c0a6d97
|
Leszek Koltunski
|
{
|
1460 |
af940c29
|
Leszek Koltunski
|
MeshBase mesh = createCuboid(dimensions);
|
1461 |
4c0a6d97
|
Leszek Koltunski
|
VertexEffect[] effects = createCuboidEffects(dimensions);
|
1462 |
|
|
for( VertexEffect effect : effects ) mesh.apply(effect);
|
1463 |
|
|
|
1464 |
af940c29
|
Leszek Koltunski
|
int X = dimensions[0];
|
1465 |
|
|
int Y = dimensions[1];
|
1466 |
|
|
int Z = dimensions[2];
|
1467 |
|
|
|
1468 |
|
|
float strength = 0.04f;
|
1469 |
|
|
float radius = 0.15f;
|
1470 |
|
|
|
1471 |
|
|
Static3D[] vertices = new Static3D[1];
|
1472 |
|
|
Static3D center;
|
1473 |
|
|
|
1474 |
|
|
vertices[0] = new Static3D(+0.5f*X,+0.5f*Y,+0.5f*Z);
|
1475 |
|
|
center = new Static3D(+0.5f*(X-1),+0.5f*(Y-1),+0.5f*(Z-1));
|
1476 |
|
|
roundCorners(mesh, center, vertices, strength, radius);
|
1477 |
|
|
|
1478 |
|
|
vertices[0] = new Static3D(+0.5f*X,+0.5f*Y,-0.5f*Z);
|
1479 |
|
|
center = new Static3D(+0.5f*(X-1),+0.5f*(Y-1),-0.5f*(Z-1));
|
1480 |
|
|
roundCorners(mesh, center, vertices, strength, radius);
|
1481 |
|
|
|
1482 |
|
|
vertices[0] = new Static3D(+0.5f*X,-0.5f*Y,+0.5f*Z);
|
1483 |
|
|
center = new Static3D(+0.5f*(X-1),-0.5f*(Y-1),+0.5f*(Z-1));
|
1484 |
|
|
roundCorners(mesh, center, vertices, strength, radius);
|
1485 |
|
|
|
1486 |
|
|
vertices[0] = new Static3D(+0.5f*X,-0.5f*Y,-0.5f*Z);
|
1487 |
|
|
center = new Static3D(+0.5f*(X-1),-0.5f*(Y-1),-0.5f*(Z-1));
|
1488 |
|
|
roundCorners(mesh, center, vertices, strength, radius);
|
1489 |
|
|
|
1490 |
|
|
vertices[0] = new Static3D(-0.5f*X,+0.5f*Y,+0.5f*Z);
|
1491 |
|
|
center = new Static3D(-0.5f*(X-1),+0.5f*(Y-1),+0.5f*(Z-1));
|
1492 |
|
|
roundCorners(mesh, center, vertices, strength, radius);
|
1493 |
|
|
|
1494 |
|
|
vertices[0] = new Static3D(-0.5f*X,+0.5f*Y,-0.5f*Z);
|
1495 |
|
|
center = new Static3D(-0.5f*(X-1),+0.5f*(Y-1),-0.5f*(Z-1));
|
1496 |
|
|
roundCorners(mesh, center, vertices, strength, radius);
|
1497 |
|
|
|
1498 |
|
|
vertices[0] = new Static3D(-0.5f*X,-0.5f*Y,+0.5f*Z);
|
1499 |
|
|
center = new Static3D(-0.5f*(X-1),-0.5f*(Y-1),+0.5f*(Z-1));
|
1500 |
|
|
roundCorners(mesh, center, vertices, strength, radius);
|
1501 |
|
|
|
1502 |
|
|
vertices[0] = new Static3D(-0.5f*X,-0.5f*Y,-0.5f*Z);
|
1503 |
|
|
center = new Static3D(-0.5f*(X-1),-0.5f*(Y-1),-0.5f*(Z-1));
|
1504 |
|
|
roundCorners(mesh, center, vertices, strength, radius);
|
1505 |
|
|
|
1506 |
4c0a6d97
|
Leszek Koltunski
|
mesh.mergeEffComponents();
|
1507 |
|
|
|
1508 |
db608887
|
Leszek Koltunski
|
return mesh;
|
1509 |
d38f1397
|
Leszek Koltunski
|
}
|
1510 |
b1f2ccf5
|
Leszek Koltunski
|
|
1511 |
|
|
|
1512 |
|
|
|
1513 |
|
|
|
1514 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1515 |
|
|
|
1516 |
|
|
private boolean areColinear(double[][] vertices, int index1, int index2, int index3)
|
1517 |
|
|
{
|
1518 |
|
|
double x1 = vertices[index1][0];
|
1519 |
|
|
double y1 = vertices[index1][1];
|
1520 |
|
|
double z1 = vertices[index1][2];
|
1521 |
|
|
double x2 = vertices[index2][0];
|
1522 |
|
|
double y2 = vertices[index2][1];
|
1523 |
|
|
double z2 = vertices[index2][2];
|
1524 |
|
|
double x3 = vertices[index3][0];
|
1525 |
|
|
double y3 = vertices[index3][1];
|
1526 |
|
|
double z3 = vertices[index3][2];
|
1527 |
|
|
|
1528 |
|
|
double v1x = x2-x1;
|
1529 |
|
|
double v1y = y2-y1;
|
1530 |
|
|
double v1z = z2-z1;
|
1531 |
|
|
double v2x = x3-x1;
|
1532 |
|
|
double v2y = y3-y1;
|
1533 |
|
|
double v2z = z3-z1;
|
1534 |
|
|
|
1535 |
|
|
double A = Math.sqrt( (v1x*v1x+v1y*v1y+v1z*v1z) / (v2x*v2x+v2y*v2y+v2z*v2z) );
|
1536 |
|
|
|
1537 |
|
|
return (v1x==A*v2x && v1y==A*v2y && v1z==A*v2z);
|
1538 |
|
|
}
|
1539 |
|
|
|
1540 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1541 |
|
|
|
1542 |
|
|
private void computeNormalVector(double[][] vertices, int index1, int index2, int index3)
|
1543 |
|
|
{
|
1544 |
|
|
double x1 = vertices[index1][0];
|
1545 |
|
|
double y1 = vertices[index1][1];
|
1546 |
|
|
double z1 = vertices[index1][2];
|
1547 |
|
|
double x2 = vertices[index2][0];
|
1548 |
|
|
double y2 = vertices[index2][1];
|
1549 |
|
|
double z2 = vertices[index2][2];
|
1550 |
|
|
double x3 = vertices[index3][0];
|
1551 |
|
|
double y3 = vertices[index3][1];
|
1552 |
|
|
double z3 = vertices[index3][2];
|
1553 |
|
|
|
1554 |
|
|
double v1x = x2-x1;
|
1555 |
|
|
double v1y = y2-y1;
|
1556 |
|
|
double v1z = z2-z1;
|
1557 |
|
|
double v2x = x3-x1;
|
1558 |
|
|
double v2y = y3-y1;
|
1559 |
|
|
double v2z = z3-z1;
|
1560 |
|
|
|
1561 |
|
|
mBuffer[0] = v1y*v2z - v2y*v1z;
|
1562 |
|
|
mBuffer[1] = v1z*v2x - v2z*v1x;
|
1563 |
|
|
mBuffer[2] = v1x*v2y - v2x*v1y;
|
1564 |
|
|
|
1565 |
|
|
double len = mBuffer[0]*mBuffer[0] + mBuffer[1]*mBuffer[1] + mBuffer[2]*mBuffer[2];
|
1566 |
|
|
len = Math.sqrt(len);
|
1567 |
|
|
mBuffer[0] /= len;
|
1568 |
|
|
mBuffer[1] /= len;
|
1569 |
|
|
mBuffer[2] /= len;
|
1570 |
|
|
}
|
1571 |
|
|
|
1572 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1573 |
|
|
// return quat1*quat2
|
1574 |
|
|
|
1575 |
|
|
private static void quatMultiply( double[] quat1, double[] quat2, double[] result )
|
1576 |
|
|
{
|
1577 |
|
|
double qx = quat1[0];
|
1578 |
|
|
double qy = quat1[1];
|
1579 |
|
|
double qz = quat1[2];
|
1580 |
|
|
double qw = quat1[3];
|
1581 |
|
|
|
1582 |
|
|
double rx = quat2[0];
|
1583 |
|
|
double ry = quat2[1];
|
1584 |
|
|
double rz = quat2[2];
|
1585 |
|
|
double rw = quat2[3];
|
1586 |
|
|
|
1587 |
|
|
result[0] = rw*qx - rz*qy + ry*qz + rx*qw;
|
1588 |
|
|
result[1] = rw*qy + rz*qx + ry*qw - rx*qz;
|
1589 |
|
|
result[2] = rw*qz + rz*qw - ry*qx + rx*qy;
|
1590 |
|
|
result[3] = rw*qw - rz*qz - ry*qy - rx*qx;
|
1591 |
|
|
}
|
1592 |
|
|
|
1593 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1594 |
|
|
|
1595 |
|
|
private void fitInSquare(FaceTransform info, double[][] vert3D)
|
1596 |
|
|
{
|
1597 |
|
|
double minX = Double.MAX_VALUE;
|
1598 |
|
|
double maxX =-Double.MAX_VALUE;
|
1599 |
|
|
double minY = Double.MAX_VALUE;
|
1600 |
|
|
double maxY =-Double.MAX_VALUE;
|
1601 |
|
|
|
1602 |
|
|
for (double[] vert : vert3D)
|
1603 |
|
|
{
|
1604 |
|
|
double x = vert[0];
|
1605 |
|
|
double y = vert[1];
|
1606 |
|
|
|
1607 |
|
|
if (x > maxX) maxX = x;
|
1608 |
|
|
if (x < minX) minX = x;
|
1609 |
|
|
if (y > maxY) maxY = y;
|
1610 |
|
|
if (y < minY) minY = y;
|
1611 |
|
|
}
|
1612 |
|
|
|
1613 |
|
|
minX = minX<0 ? -minX:minX;
|
1614 |
|
|
maxX = maxX<0 ? -maxX:maxX;
|
1615 |
|
|
minY = minY<0 ? -minY:minY;
|
1616 |
|
|
maxY = maxY<0 ? -maxY:maxY;
|
1617 |
|
|
|
1618 |
|
|
double max1 = Math.max(minX,minY);
|
1619 |
|
|
double max2 = Math.max(maxX,maxY);
|
1620 |
|
|
double max3 = Math.max(max1,max2);
|
1621 |
|
|
|
1622 |
|
|
info.scale = max3/0.5;
|
1623 |
|
|
|
1624 |
|
|
int len = vert3D.length;
|
1625 |
|
|
StickerCoords sInfo = new StickerCoords();
|
1626 |
|
|
sInfo.vertices = new double[2*len];
|
1627 |
|
|
|
1628 |
|
|
for( int vertex=0; vertex<len; vertex++ )
|
1629 |
|
|
{
|
1630 |
|
|
sInfo.vertices[2*vertex ] = vert3D[vertex][0] / info.scale;
|
1631 |
|
|
sInfo.vertices[2*vertex+1] = vert3D[vertex][1] / info.scale;
|
1632 |
|
|
}
|
1633 |
|
|
|
1634 |
|
|
mStickerCoords.add(sInfo);
|
1635 |
|
|
|
1636 |
|
|
info.sticker = mStickerCoords.size() -1;
|
1637 |
|
|
info.flip = false;
|
1638 |
|
|
}
|
1639 |
|
|
|
1640 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1641 |
|
|
|
1642 |
31cd7256
|
Leszek Koltunski
|
private FaceTransform constructNewTransform(final double[][] vert3D)
|
1643 |
b1f2ccf5
|
Leszek Koltunski
|
{
|
1644 |
31cd7256
|
Leszek Koltunski
|
FaceTransform ft = new FaceTransform();
|
1645 |
|
|
|
1646 |
b1f2ccf5
|
Leszek Koltunski
|
// compute center of gravity
|
1647 |
31cd7256
|
Leszek Koltunski
|
ft.vx = 0.0f;
|
1648 |
|
|
ft.vy = 0.0f;
|
1649 |
|
|
ft.vz = 0.0f;
|
1650 |
b1f2ccf5
|
Leszek Koltunski
|
int len = vert3D.length;
|
1651 |
|
|
|
1652 |
|
|
for (double[] vert : vert3D)
|
1653 |
|
|
{
|
1654 |
31cd7256
|
Leszek Koltunski
|
ft.vx += vert[0];
|
1655 |
|
|
ft.vy += vert[1];
|
1656 |
|
|
ft.vz += vert[2];
|
1657 |
b1f2ccf5
|
Leszek Koltunski
|
}
|
1658 |
|
|
|
1659 |
31cd7256
|
Leszek Koltunski
|
ft.vx /= len;
|
1660 |
|
|
ft.vy /= len;
|
1661 |
|
|
ft.vz /= len;
|
1662 |
b1f2ccf5
|
Leszek Koltunski
|
|
1663 |
|
|
// move all vertices so that their center of gravity is at (0,0,0)
|
1664 |
|
|
for (int i=0; i<len; i++)
|
1665 |
|
|
{
|
1666 |
31cd7256
|
Leszek Koltunski
|
vert3D[i][0] -= ft.vx;
|
1667 |
|
|
vert3D[i][1] -= ft.vy;
|
1668 |
|
|
vert3D[i][2] -= ft.vz;
|
1669 |
b1f2ccf5
|
Leszek Koltunski
|
}
|
1670 |
|
|
|
1671 |
|
|
// find 3 non-colinear vertices
|
1672 |
|
|
int foundIndex = -1;
|
1673 |
|
|
|
1674 |
|
|
for(int vertex=2; vertex<len; vertex++)
|
1675 |
|
|
{
|
1676 |
|
|
if( !areColinear(vert3D,0,1,vertex) )
|
1677 |
|
|
{
|
1678 |
|
|
foundIndex = vertex;
|
1679 |
|
|
break;
|
1680 |
|
|
}
|
1681 |
|
|
}
|
1682 |
|
|
|
1683 |
|
|
// compute the normal vector
|
1684 |
|
|
if( foundIndex==-1 )
|
1685 |
|
|
{
|
1686 |
|
|
throw new RuntimeException("all vertices colinear");
|
1687 |
|
|
}
|
1688 |
|
|
|
1689 |
|
|
computeNormalVector(vert3D,0,1,foundIndex);
|
1690 |
|
|
|
1691 |
|
|
// rotate so that the normal vector becomes (0,0,1)
|
1692 |
|
|
double axisX, axisY, axisZ;
|
1693 |
|
|
|
1694 |
|
|
if( mBuffer[0]!=0.0f || mBuffer[1]!=0.0f )
|
1695 |
|
|
{
|
1696 |
|
|
axisX = -mBuffer[1];
|
1697 |
|
|
axisY = mBuffer[0];
|
1698 |
|
|
axisZ = 0.0f;
|
1699 |
|
|
|
1700 |
|
|
double axiLen = axisX*axisX + axisY*axisY;
|
1701 |
|
|
axiLen = Math.sqrt(axiLen);
|
1702 |
|
|
axisX /= axiLen;
|
1703 |
|
|
axisY /= axiLen;
|
1704 |
|
|
axisZ /= axiLen;
|
1705 |
|
|
}
|
1706 |
|
|
else
|
1707 |
|
|
{
|
1708 |
|
|
axisX = 0.0f;
|
1709 |
|
|
axisY = 1.0f;
|
1710 |
|
|
axisZ = 0.0f;
|
1711 |
|
|
}
|
1712 |
|
|
|
1713 |
|
|
double cosTheta = mBuffer[2];
|
1714 |
|
|
double sinTheta = Math.sqrt(1-cosTheta*cosTheta);
|
1715 |
|
|
double sinHalfTheta = computeSinHalf(cosTheta);
|
1716 |
|
|
double cosHalfTheta = computeCosHalf(sinTheta,cosTheta);
|
1717 |
|
|
|
1718 |
|
|
mQuat1[0] = axisX*sinHalfTheta;
|
1719 |
|
|
mQuat1[1] = axisY*sinHalfTheta;
|
1720 |
|
|
mQuat1[2] = axisZ*sinHalfTheta;
|
1721 |
|
|
mQuat1[3] = cosHalfTheta;
|
1722 |
|
|
mQuat2[0] =-axisX*sinHalfTheta;
|
1723 |
|
|
mQuat2[1] =-axisY*sinHalfTheta;
|
1724 |
|
|
mQuat2[2] =-axisZ*sinHalfTheta;
|
1725 |
|
|
mQuat2[3] = cosHalfTheta;
|
1726 |
|
|
|
1727 |
|
|
for (double[] vert : vert3D)
|
1728 |
|
|
{
|
1729 |
|
|
quatMultiply(mQuat1, vert , mQuat3);
|
1730 |
|
|
quatMultiply(mQuat3, mQuat2, vert );
|
1731 |
|
|
}
|
1732 |
|
|
|
1733 |
|
|
// fit the whole thing in a square and remember the scale & 2D vertices
|
1734 |
31cd7256
|
Leszek Koltunski
|
fitInSquare(ft, vert3D);
|
1735 |
b1f2ccf5
|
Leszek Koltunski
|
|
1736 |
|
|
// remember the rotation
|
1737 |
31cd7256
|
Leszek Koltunski
|
ft.qx =-mQuat1[0];
|
1738 |
|
|
ft.qy =-mQuat1[1];
|
1739 |
|
|
ft.qz =-mQuat1[2];
|
1740 |
|
|
ft.qw = mQuat1[3];
|
1741 |
|
|
|
1742 |
|
|
return ft;
|
1743 |
b1f2ccf5
|
Leszek Koltunski
|
}
|
1744 |
|
|
|
1745 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1746 |
|
|
|
1747 |
|
|
private double computeCos(double oldX, double oldY, double newX, double newY, double len1, double len2)
|
1748 |
|
|
{
|
1749 |
|
|
double ret= (oldX*newX+oldY*newY) / (len1*len2);
|
1750 |
|
|
if( ret<-1.0 ) return -1.0;
|
1751 |
|
|
if( ret> 1.0 ) return 1.0;
|
1752 |
|
|
|
1753 |
|
|
return ret;
|
1754 |
|
|
}
|
1755 |
|
|
|
1756 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1757 |
|
|
// sin of (signed!) angle between vectors 'old' and 'new', counterclockwise!
|
1758 |
|
|
|
1759 |
|
|
private double computeSin(double oldX, double oldY, double newX, double newY, double len1, double len2)
|
1760 |
|
|
{
|
1761 |
|
|
double ret= (newX*oldY-oldX*newY) / (len1*len2);
|
1762 |
|
|
if( ret<-1.0 ) return -1.0;
|
1763 |
|
|
if( ret> 1.0 ) return 1.0;
|
1764 |
|
|
|
1765 |
|
|
return ret;
|
1766 |
|
|
}
|
1767 |
|
|
|
1768 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1769 |
|
|
|
1770 |
|
|
private void rotateAllVertices(double[] result, int len, double[] vertices, double sin, double cos)
|
1771 |
|
|
{
|
1772 |
|
|
for(int i=0; i<len; i++)
|
1773 |
|
|
{
|
1774 |
|
|
result[2*i ] = vertices[2*i ]*cos - vertices[2*i+1]*sin;
|
1775 |
|
|
result[2*i+1] = vertices[2*i ]*sin + vertices[2*i+1]*cos;
|
1776 |
|
|
}
|
1777 |
|
|
}
|
1778 |
|
|
|
1779 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1780 |
|
|
|
1781 |
0919eba7
|
Leszek Koltunski
|
private double computeScale(double[] v1, double[] v2, int v1i, int v2i)
|
1782 |
b1f2ccf5
|
Leszek Koltunski
|
{
|
1783 |
0919eba7
|
Leszek Koltunski
|
double v1x = v1[2*v1i];
|
1784 |
|
|
double v1y = v1[2*v1i+1];
|
1785 |
|
|
double v2x = v2[2*v2i];
|
1786 |
|
|
double v2y = v2[2*v2i+1];
|
1787 |
|
|
|
1788 |
|
|
double lenSq1 = v1x*v1x + v1y*v1y;
|
1789 |
|
|
double lenSq2 = v2x*v2x + v2y*v2y;
|
1790 |
b1f2ccf5
|
Leszek Koltunski
|
|
1791 |
|
|
return Math.sqrt(lenSq2/lenSq1);
|
1792 |
|
|
}
|
1793 |
|
|
|
1794 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1795 |
31cd7256
|
Leszek Koltunski
|
// valid for 0<angle<2*PI
|
1796 |
b1f2ccf5
|
Leszek Koltunski
|
|
1797 |
|
|
private double computeSinHalf(double cos)
|
1798 |
|
|
{
|
1799 |
|
|
return Math.sqrt((1-cos)/2);
|
1800 |
|
|
}
|
1801 |
|
|
|
1802 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1803 |
31cd7256
|
Leszek Koltunski
|
// valid for 0<angle<2*PI
|
1804 |
b1f2ccf5
|
Leszek Koltunski
|
|
1805 |
|
|
private double computeCosHalf(double sin, double cos)
|
1806 |
|
|
{
|
1807 |
|
|
double cosHalf = Math.sqrt((1+cos)/2);
|
1808 |
|
|
return sin<0 ? -cosHalf : cosHalf;
|
1809 |
|
|
}
|
1810 |
|
|
|
1811 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1812 |
|
|
|
1813 |
|
|
private int computeRotatedIndex(int oldVertex, int len, int rotatedVertex, boolean inverted)
|
1814 |
|
|
{
|
1815 |
|
|
int v = (rotatedVertex + (inverted? -oldVertex : oldVertex));
|
1816 |
|
|
if( v>=len ) v-=len;
|
1817 |
|
|
if( v< 0 ) v+=len;
|
1818 |
|
|
|
1819 |
|
|
return v;
|
1820 |
|
|
}
|
1821 |
|
|
|
1822 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1823 |
|
|
|
1824 |
|
|
private boolean isScaledVersionOf(double[] newVert, double[] oldVert, int len, int vertex, boolean inverted)
|
1825 |
|
|
{
|
1826 |
0919eba7
|
Leszek Koltunski
|
int newZeroIndex = computeRotatedIndex(0,len,vertex,inverted);
|
1827 |
b1f2ccf5
|
Leszek Koltunski
|
double EPSILON = 0.001;
|
1828 |
0919eba7
|
Leszek Koltunski
|
double scale = computeScale(newVert,oldVert,newZeroIndex,0);
|
1829 |
b1f2ccf5
|
Leszek Koltunski
|
|
1830 |
|
|
for(int i=1; i<len; i++)
|
1831 |
|
|
{
|
1832 |
|
|
int index = computeRotatedIndex(i,len,vertex,inverted);
|
1833 |
|
|
|
1834 |
|
|
double horz = oldVert[2*i ] - scale*newVert[2*index ];
|
1835 |
|
|
double vert = oldVert[2*i+1] - scale*newVert[2*index+1];
|
1836 |
|
|
|
1837 |
|
|
if( horz>EPSILON || horz<-EPSILON || vert>EPSILON || vert<-EPSILON ) return false;
|
1838 |
|
|
}
|
1839 |
|
|
|
1840 |
|
|
return true;
|
1841 |
|
|
}
|
1842 |
|
|
|
1843 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1844 |
|
|
|
1845 |
|
|
private void mirrorAllVertices(double[] output, int len, double[] input)
|
1846 |
|
|
{
|
1847 |
|
|
for(int vertex=0; vertex<len; vertex++)
|
1848 |
|
|
{
|
1849 |
|
|
output[2*vertex ] = input[2*vertex ];
|
1850 |
|
|
output[2*vertex+1] =-input[2*vertex+1];
|
1851 |
|
|
}
|
1852 |
|
|
}
|
1853 |
|
|
|
1854 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1855 |
|
|
|
1856 |
|
|
private void correctInfo(FaceTransform info, double scale, double sin, double cos, int oldSticker, boolean flip)
|
1857 |
|
|
{
|
1858 |
|
|
mStickerCoords.remove(info.sticker);
|
1859 |
|
|
|
1860 |
|
|
info.flip = flip;
|
1861 |
|
|
info.sticker = oldSticker;
|
1862 |
|
|
info.scale *= scale;
|
1863 |
|
|
|
1864 |
|
|
mQuat1[0] = info.qx;
|
1865 |
|
|
mQuat1[1] = info.qy;
|
1866 |
|
|
mQuat1[2] = info.qz;
|
1867 |
|
|
mQuat1[3] = info.qw;
|
1868 |
|
|
|
1869 |
|
|
double sinHalf = computeSinHalf(cos);
|
1870 |
|
|
double cosHalf = computeCosHalf(sin,cos);
|
1871 |
|
|
|
1872 |
|
|
if( flip )
|
1873 |
|
|
{
|
1874 |
|
|
mQuat3[0] = 0.0f;
|
1875 |
|
|
mQuat3[1] = 0.0f;
|
1876 |
|
|
mQuat3[2] = sinHalf;
|
1877 |
|
|
mQuat3[3] = cosHalf;
|
1878 |
|
|
|
1879 |
|
|
mQuat4[0] = 1.0;
|
1880 |
|
|
mQuat4[1] = 0.0;
|
1881 |
|
|
mQuat4[2] = 0.0;
|
1882 |
|
|
mQuat4[3] = 0.0;
|
1883 |
|
|
|
1884 |
|
|
quatMultiply( mQuat3, mQuat4, mQuat2 );
|
1885 |
|
|
}
|
1886 |
|
|
else
|
1887 |
|
|
{
|
1888 |
|
|
mQuat2[0] = 0.0f;
|
1889 |
|
|
mQuat2[1] = 0.0f;
|
1890 |
|
|
mQuat2[2] = sinHalf;
|
1891 |
|
|
mQuat2[3] = cosHalf;
|
1892 |
|
|
}
|
1893 |
|
|
|
1894 |
|
|
quatMultiply( mQuat1, mQuat2, mQuat3 );
|
1895 |
|
|
|
1896 |
|
|
info.qx = mQuat3[0];
|
1897 |
|
|
info.qy = mQuat3[1];
|
1898 |
|
|
info.qz = mQuat3[2];
|
1899 |
|
|
info.qw = mQuat3[3];
|
1900 |
|
|
}
|
1901 |
|
|
|
1902 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1903 |
|
|
|
1904 |
|
|
private void printVert(double[] buffer)
|
1905 |
|
|
{
|
1906 |
|
|
int len = buffer.length/2;
|
1907 |
|
|
String str = "";
|
1908 |
|
|
|
1909 |
|
|
for(int i=0; i<len; i++)
|
1910 |
|
|
{
|
1911 |
|
|
str += (" ("+buffer[2*i]+" , "+buffer[2*i+1]+" ) ");
|
1912 |
|
|
}
|
1913 |
|
|
|
1914 |
|
|
android.util.Log.d("D", str);
|
1915 |
|
|
}
|
1916 |
|
|
|
1917 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1918 |
|
|
|
1919 |
|
|
private boolean foundVertex(FaceTransform info, double[] buffer, int len, double[] newVert,
|
1920 |
|
|
double[] oldVert, double lenFirstOld, int oldSticker, boolean inverted)
|
1921 |
|
|
{
|
1922 |
|
|
for(int vertex=0; vertex<len; vertex++)
|
1923 |
|
|
{
|
1924 |
|
|
double newX = newVert[2*vertex ];
|
1925 |
|
|
double newY = newVert[2*vertex+1];
|
1926 |
|
|
double lenIthNew = Math.sqrt(newX*newX + newY*newY);
|
1927 |
|
|
double cos = computeCos( oldVert[0], oldVert[1], newX, newY, lenIthNew, lenFirstOld);
|
1928 |
|
|
double sin = computeSin( oldVert[0], oldVert[1], newX, newY, lenIthNew, lenFirstOld);
|
1929 |
|
|
|
1930 |
|
|
rotateAllVertices(buffer,len,newVert,sin,cos);
|
1931 |
|
|
|
1932 |
|
|
if( isScaledVersionOf(buffer,oldVert,len,vertex,inverted) )
|
1933 |
|
|
{
|
1934 |
0919eba7
|
Leszek Koltunski
|
int newZeroIndex = computeRotatedIndex(0,len,vertex,inverted);
|
1935 |
|
|
double scale = computeScale(oldVert,newVert,0,newZeroIndex);
|
1936 |
b1f2ccf5
|
Leszek Koltunski
|
correctInfo(info,scale,sin,cos,oldSticker,inverted);
|
1937 |
|
|
return true;
|
1938 |
|
|
}
|
1939 |
|
|
}
|
1940 |
|
|
|
1941 |
|
|
return false;
|
1942 |
|
|
}
|
1943 |
|
|
|
1944 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1945 |
|
|
|
1946 |
|
|
private boolean successfullyCollapsedStickers(final FaceTransform newInfo, final FaceTransform oldInfo)
|
1947 |
|
|
{
|
1948 |
|
|
StickerCoords sNewInfo = mStickerCoords.get(newInfo.sticker);
|
1949 |
|
|
StickerCoords sOldInfo = mStickerCoords.get(oldInfo.sticker);
|
1950 |
|
|
double[] newVert = sNewInfo.vertices;
|
1951 |
|
|
double[] oldVert = sOldInfo.vertices;
|
1952 |
|
|
int oldLen = oldVert.length;
|
1953 |
|
|
int newLen = newVert.length;
|
1954 |
|
|
|
1955 |
|
|
if( oldLen == newLen )
|
1956 |
|
|
{
|
1957 |
|
|
int oldSticker = oldInfo.sticker;
|
1958 |
|
|
double[] buffer1 = new double[oldLen];
|
1959 |
|
|
double lenFirstOld = Math.sqrt(oldVert[0]*oldVert[0] + oldVert[1]*oldVert[1]);
|
1960 |
|
|
if( foundVertex(newInfo, buffer1, oldLen/2, newVert, oldVert, lenFirstOld, oldSticker, false) ) return true;
|
1961 |
|
|
double[] buffer2 = new double[oldLen];
|
1962 |
|
|
mirrorAllVertices(buffer2, newLen/2, newVert);
|
1963 |
|
|
if( foundVertex(newInfo, buffer1, oldLen/2, buffer2, oldVert, lenFirstOld, oldSticker, true ) ) return true;
|
1964 |
|
|
}
|
1965 |
|
|
|
1966 |
|
|
return false;
|
1967 |
|
|
}
|
1968 |
|
|
|
1969 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1970 |
|
|
|
1971 |
|
|
private double[][] constructVert(double[][] vertices, int[] index)
|
1972 |
|
|
{
|
1973 |
|
|
int len = index.length;
|
1974 |
|
|
double[][] ret = new double[len][4];
|
1975 |
|
|
|
1976 |
|
|
for(int i=0; i<len; i++)
|
1977 |
|
|
{
|
1978 |
|
|
ret[i][0] = vertices[index[i]][0];
|
1979 |
|
|
ret[i][1] = vertices[index[i]][1];
|
1980 |
|
|
ret[i][2] = vertices[index[i]][2];
|
1981 |
|
|
ret[i][3] = 1.0f;
|
1982 |
|
|
}
|
1983 |
|
|
|
1984 |
|
|
return ret;
|
1985 |
|
|
}
|
1986 |
|
|
|
1987 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
1988 |
|
|
|
1989 |
b3c9061a
|
Leszek Koltunski
|
private void prepareAndRoundCorners(MeshBase mesh, double[][] vertices,
|
1990 |
|
|
float[][] corners, int[] cornerIndexes,
|
1991 |
|
|
float[][] centers, int[] centerIndexes )
|
1992 |
b1f2ccf5
|
Leszek Koltunski
|
{
|
1993 |
|
|
int lenV = vertices.length;
|
1994 |
|
|
Static3D[] staticVert = new Static3D[1];
|
1995 |
|
|
Static3D center = new Static3D(0,0,0);
|
1996 |
|
|
|
1997 |
|
|
for(int v=0; v<lenV; v++)
|
1998 |
|
|
{
|
1999 |
|
|
staticVert[0] = new Static3D( (float)vertices[v][0], (float)vertices[v][1], (float)vertices[v][2]);
|
2000 |
|
|
|
2001 |
b3c9061a
|
Leszek Koltunski
|
int cent = centerIndexes[v];
|
2002 |
|
|
|
2003 |
7dc57f89
|
Leszek Koltunski
|
if( cent>=0 )
|
2004 |
|
|
{
|
2005 |
|
|
center.set( centers[cent][0], centers[cent][1], centers[cent][2]);
|
2006 |
|
|
|
2007 |
|
|
int corn = cornerIndexes[v];
|
2008 |
|
|
float strength = corners[corn][0];
|
2009 |
|
|
float radius = corners[corn][1];
|
2010 |
b1f2ccf5
|
Leszek Koltunski
|
|
2011 |
7dc57f89
|
Leszek Koltunski
|
roundCorners(mesh, center, staticVert, strength, radius);
|
2012 |
|
|
}
|
2013 |
b1f2ccf5
|
Leszek Koltunski
|
}
|
2014 |
|
|
}
|
2015 |
|
|
|
2016 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2017 |
|
|
|
2018 |
|
|
private void correctComponents(MeshBase mesh, int numComponents)
|
2019 |
|
|
{
|
2020 |
|
|
int numTexToBeAdded = numComponents-mesh.getNumTexComponents();
|
2021 |
|
|
|
2022 |
|
|
mesh.mergeEffComponents();
|
2023 |
|
|
|
2024 |
|
|
for(int i=0; i<numTexToBeAdded; i++ ) mesh.addEmptyTexComponent();
|
2025 |
|
|
}
|
2026 |
|
|
|
2027 |
31cd7256
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2028 |
|
|
|
2029 |
|
|
private void printTransform(FaceTransform f)
|
2030 |
|
|
{
|
2031 |
|
|
android.util.Log.e("D", "q=("+f.qx+", "+f.qy+", "+f.qz+", "+f.qw+") v=("
|
2032 |
|
|
+f.vx+", "+f.vy+", "+f.vz+") scale="+f.scale+" sticker="+f.sticker);
|
2033 |
|
|
}
|
2034 |
|
|
|
2035 |
b1f2ccf5
|
Leszek Koltunski
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2036 |
|
|
// PUBLIC
|
2037 |
|
|
|
2038 |
|
|
public void printStickerCoords()
|
2039 |
|
|
{
|
2040 |
|
|
int stickers = mStickerCoords.size();
|
2041 |
|
|
|
2042 |
|
|
android.util.Log.d("D", "---- STICKER COORDS ----");
|
2043 |
|
|
|
2044 |
|
|
for(int s=0; s<stickers; s++)
|
2045 |
|
|
{
|
2046 |
|
|
String ver = "{ ";
|
2047 |
|
|
StickerCoords info = mStickerCoords.get(s);
|
2048 |
|
|
int len = info.vertices.length/2;
|
2049 |
|
|
|
2050 |
|
|
for(int i =0; i<len; i++)
|
2051 |
|
|
{
|
2052 |
|
|
if( i!=0 ) ver += ", ";
|
2053 |
|
|
ver += ( (float)info.vertices[2*i]+"f, "+(float)info.vertices[2*i+1]+"f");
|
2054 |
|
|
}
|
2055 |
|
|
|
2056 |
|
|
ver += " }";
|
2057 |
|
|
android.util.Log.d("D", ver);
|
2058 |
|
|
}
|
2059 |
|
|
|
2060 |
|
|
android.util.Log.d("D", "---- END STICKER COORDS ----");
|
2061 |
|
|
}
|
2062 |
|
|
|
2063 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2064 |
|
|
|
2065 |
|
|
public void printFaceTransform()
|
2066 |
|
|
{
|
2067 |
31cd7256
|
Leszek Koltunski
|
android.util.Log.d("D", "---- OLD FACE TRANSFORM ---");
|
2068 |
b1f2ccf5
|
Leszek Koltunski
|
|
2069 |
31cd7256
|
Leszek Koltunski
|
int oldfaces = mOldFaceTransf.size();
|
2070 |
b1f2ccf5
|
Leszek Koltunski
|
|
2071 |
31cd7256
|
Leszek Koltunski
|
for(int f=0; f<oldfaces; f++)
|
2072 |
b1f2ccf5
|
Leszek Koltunski
|
{
|
2073 |
31cd7256
|
Leszek Koltunski
|
printTransform(mOldFaceTransf.get(f));
|
2074 |
|
|
}
|
2075 |
|
|
|
2076 |
|
|
android.util.Log.d("D", "---- NEW FACE TRANSFORM ---");
|
2077 |
|
|
|
2078 |
|
|
int newfaces = mNewFaceTransf.size();
|
2079 |
b1f2ccf5
|
Leszek Koltunski
|
|
2080 |
31cd7256
|
Leszek Koltunski
|
for(int f=0; f<newfaces; f++)
|
2081 |
|
|
{
|
2082 |
|
|
printTransform(mNewFaceTransf.get(f));
|
2083 |
b1f2ccf5
|
Leszek Koltunski
|
}
|
2084 |
|
|
}
|
2085 |
|
|
|
2086 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2087 |
|
|
|
2088 |
|
|
public void clear()
|
2089 |
|
|
{
|
2090 |
|
|
mStickerCoords.clear();
|
2091 |
31cd7256
|
Leszek Koltunski
|
mNewFaceTransf.clear();
|
2092 |
|
|
mOldFaceTransf.clear();
|
2093 |
b1f2ccf5
|
Leszek Koltunski
|
}
|
2094 |
|
|
|
2095 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2096 |
|
|
|
2097 |
|
|
public void createNewFaceTransform( final double[][] vertices, final int[][] indexes)
|
2098 |
|
|
{
|
2099 |
31cd7256
|
Leszek Koltunski
|
FaceTransform ft;
|
2100 |
|
|
int numNew = mNewFaceTransf.size();
|
2101 |
|
|
|
2102 |
|
|
for(int i=0; i<numNew; i++)
|
2103 |
|
|
{
|
2104 |
|
|
ft = mNewFaceTransf.remove(0);
|
2105 |
|
|
mOldFaceTransf.add(ft);
|
2106 |
|
|
}
|
2107 |
b1f2ccf5
|
Leszek Koltunski
|
|
2108 |
|
|
int numFaces = indexes.length;
|
2109 |
31cd7256
|
Leszek Koltunski
|
int numOld = mOldFaceTransf.size();
|
2110 |
b1f2ccf5
|
Leszek Koltunski
|
|
2111 |
31cd7256
|
Leszek Koltunski
|
for (int face=0; face<numFaces; face++)
|
2112 |
b1f2ccf5
|
Leszek Koltunski
|
{
|
2113 |
31cd7256
|
Leszek Koltunski
|
boolean collapsed = false;
|
2114 |
|
|
|
2115 |
|
|
double[][] vert = constructVert(vertices, indexes[face]);
|
2116 |
|
|
FaceTransform newT = constructNewTransform(vert);
|
2117 |
|
|
|
2118 |
|
|
for (int old=0; !collapsed && old<numOld; old++)
|
2119 |
|
|
{
|
2120 |
|
|
ft = mOldFaceTransf.get(old);
|
2121 |
|
|
if (successfullyCollapsedStickers(newT, ft)) collapsed = true;
|
2122 |
|
|
}
|
2123 |
b1f2ccf5
|
Leszek Koltunski
|
|
2124 |
31cd7256
|
Leszek Koltunski
|
for (int pre=0; !collapsed && pre<face; pre++)
|
2125 |
b1f2ccf5
|
Leszek Koltunski
|
{
|
2126 |
31cd7256
|
Leszek Koltunski
|
ft = mNewFaceTransf.get(pre);
|
2127 |
|
|
if (successfullyCollapsedStickers(newT, ft)) collapsed = true;
|
2128 |
b1f2ccf5
|
Leszek Koltunski
|
}
|
2129 |
|
|
|
2130 |
31cd7256
|
Leszek Koltunski
|
mNewFaceTransf.add(newT);
|
2131 |
b1f2ccf5
|
Leszek Koltunski
|
}
|
2132 |
|
|
}
|
2133 |
|
|
|
2134 |
|
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
2135 |
|
|
|
2136 |
|
|
public MeshBase createRoundedSolid(final double[][] vertices, final int[][] vertIndexes,
|
2137 |
|
|
final float[][] bands , final int[] bandIndexes,
|
2138 |
|
|
final float[][] corners , final int[] cornerIndexes,
|
2139 |
b3c9061a
|
Leszek Koltunski
|
final float[][] centers , final int[] centerIndexes,
|
2140 |
b1f2ccf5
|
Leszek Koltunski
|
final int numComponents )
|
2141 |
|
|
{
|
2142 |
|
|
int numFaces = vertIndexes.length;
|
2143 |
|
|
float[] band, bandsComputed;
|
2144 |
|
|
MeshBase[] meshes = new MeshBase[numFaces];
|
2145 |
|
|
FaceTransform fInfo;
|
2146 |
|
|
StickerCoords sInfo;
|
2147 |
|
|
|
2148 |
|
|
for(int face=0; face<numFaces; face++)
|
2149 |
|
|
{
|
2150 |
31cd7256
|
Leszek Koltunski
|
fInfo = mNewFaceTransf.get(face);
|
2151 |
b1f2ccf5
|
Leszek Koltunski
|
sInfo = mStickerCoords.get(fInfo.sticker);
|
2152 |
|
|
|
2153 |
|
|
double[] verts = sInfo.vertices;
|
2154 |
|
|
int lenVerts = verts.length;
|
2155 |
|
|
float[] vertsFloat = new float[lenVerts];
|
2156 |
|
|
for(int i=0; i<lenVerts; i++) vertsFloat[i] = (float)verts[i];
|
2157 |
|
|
|
2158 |
|
|
band = bands[bandIndexes[face]];
|
2159 |
|
|
bandsComputed = computeBands( band[0], (int)band[1], band[2], band[3], (int)band[4]);
|
2160 |
|
|
meshes[face] = new MeshPolygon(vertsFloat,bandsComputed,(int)band[5],(int)band[6]);
|
2161 |
|
|
meshes[face].setEffectAssociation(0,(1<<face),0);
|
2162 |
|
|
}
|
2163 |
|
|
|
2164 |
|
|
MeshBase mesh = new MeshJoined(meshes);
|
2165 |
|
|
Static3D center = new Static3D(0,0,0);
|
2166 |
|
|
|
2167 |
|
|
for(int face=0; face<numFaces; face++)
|
2168 |
|
|
{
|
2169 |
|
|
int assoc = (1<<face);
|
2170 |
31cd7256
|
Leszek Koltunski
|
fInfo = mNewFaceTransf.get(face);
|
2171 |
b1f2ccf5
|
Leszek Koltunski
|
|
2172 |
|
|
float vx = (float)fInfo.vx;
|
2173 |
|
|
float vy = (float)fInfo.vy;
|
2174 |
|
|
float vz = (float)fInfo.vz;
|
2175 |
|
|
float sc = (float)fInfo.scale;
|
2176 |
|
|
float qx = (float)fInfo.qx;
|
2177 |
|
|
float qy = (float)fInfo.qy;
|
2178 |
|
|
float qz = (float)fInfo.qz;
|
2179 |
|
|
float qw = (float)fInfo.qw;
|
2180 |
|
|
|
2181 |
|
|
Static3D scale = new Static3D(sc,sc, fInfo.flip ? -sc : sc);
|
2182 |
|
|
Static3D move3D= new Static3D(vx,vy,vz);
|
2183 |
|
|
Static4D quat = new Static4D(qx,qy,qz,qw);
|
2184 |
|
|
|
2185 |
|
|
mesh.apply(new MatrixEffectScale(scale) ,assoc,-1);
|
2186 |
|
|
mesh.apply(new MatrixEffectQuaternion(quat,center),assoc,-1);
|
2187 |
|
|
mesh.apply(new MatrixEffectMove(move3D) ,assoc,-1);
|
2188 |
|
|
}
|
2189 |
|
|
|
2190 |
b3c9061a
|
Leszek Koltunski
|
prepareAndRoundCorners(mesh, vertices, corners, cornerIndexes, centers, centerIndexes);
|
2191 |
b1f2ccf5
|
Leszek Koltunski
|
|
2192 |
|
|
correctComponents(mesh,numComponents);
|
2193 |
|
|
|
2194 |
|
|
return mesh;
|
2195 |
|
|
}
|
2196 |
ac940e24
|
Leszek Koltunski
|
}
|