| 59 |
59 |
return mThis;
|
| 60 |
60 |
}
|
| 61 |
61 |
|
|
62 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
63 |
// H - height of the band in the middle
|
|
64 |
// alpha - angle of the edge [0,90]
|
|
65 |
// dist - often in a polygon the distance from edge to center is not 1, but something else.
|
|
66 |
// This is the distance.
|
|
67 |
// K - where to begin the second, much more flat part of the band. [0,1]
|
|
68 |
// N - number of bands. N>=3
|
|
69 |
//
|
|
70 |
// theory: two distinct parts to the band:
|
|
71 |
// 1) (0,B) - steep
|
|
72 |
// 2) (B,1) - flat
|
|
73 |
//
|
|
74 |
// In first part, we have y = g(x) ; in second - y = g(f(x)) where
|
|
75 |
//
|
|
76 |
// g(x) = sqrt( R^2 - (x-D)^2 ) - R*cos(alpha)
|
|
77 |
// f(x) = ((D-B)/(1-B)*x + B*(1-D)/(1-B)
|
|
78 |
// h(x) = R*(sin(alpha) - sin(x))
|
|
79 |
// R = H/(1-cos(alpha))
|
|
80 |
// D = H*sin(alpha)
|
|
81 |
// B = h(K*alpha)
|
|
82 |
//
|
|
83 |
// The N points are taken at:
|
|
84 |
//
|
|
85 |
// 1) in the second part, there are K2 = (N-3)/3 such points
|
|
86 |
// 2) in the first - K1 = (N-3) - K2
|
|
87 |
// 3) also, the 3 points 0,B,1
|
|
88 |
//
|
|
89 |
// so we have the sequence A[i] of N points
|
|
90 |
//
|
|
91 |
// 0
|
|
92 |
// h((i+1)*(1-K)*alpha/(K1+1)) (i=0,1,...,K1-1)
|
|
93 |
// B
|
|
94 |
// (1-B)*(i+1)/(K2+1) + B (i=0,i,...,K2-1)
|
|
95 |
// 1
|
|
96 |
|
|
97 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
98 |
|
|
99 |
private float f(float D, float B, float x)
|
|
100 |
{
|
|
101 |
return ((D-B)*x + B*(1-D))/(1-B);
|
|
102 |
}
|
|
103 |
|
|
104 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
105 |
|
|
106 |
private float g(float R, float D, float x, float cosAlpha)
|
|
107 |
{
|
|
108 |
float d = x-D;
|
|
109 |
return (float)(Math.sqrt(R*R-d*d)-R*cosAlpha);
|
|
110 |
}
|
|
111 |
|
|
112 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
113 |
|
|
114 |
private float h(float R, float sinAlpha, float x)
|
|
115 |
{
|
|
116 |
return R*(sinAlpha-(float)Math.sin(x));
|
|
117 |
}
|
|
118 |
|
|
119 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
120 |
|
|
121 |
private float[] computeBands(float H, int alpha, float dist, float K, int N)
|
|
122 |
{
|
|
123 |
float[] bands = new float[2*N];
|
|
124 |
|
|
125 |
bands[0] = 1.0f;
|
|
126 |
bands[1] = 0.0f;
|
|
127 |
|
|
128 |
float beta = (float)Math.atan(dist*Math.tan(Math.PI*alpha/180));
|
|
129 |
float sinBeta = (float)Math.sin(beta);
|
|
130 |
float cosBeta = (float)Math.cos(beta);
|
|
131 |
float R = cosBeta<1.0f ? H/(1.0f-cosBeta) : 0.0f;
|
|
132 |
float D = R*sinBeta;
|
|
133 |
float B = h(R,sinBeta,K*beta);
|
|
134 |
|
|
135 |
if( D>1.0f )
|
|
136 |
{
|
|
137 |
for(int i=1; i<N; i++)
|
|
138 |
{
|
|
139 |
bands[2*i ] = (float)(N-1-i)/(N-1);
|
|
140 |
bands[2*i+1] = H*(1-bands[2*i]);
|
|
141 |
}
|
|
142 |
}
|
|
143 |
else
|
|
144 |
{
|
|
145 |
int K2 = (int)((N-3)*K);
|
|
146 |
int K1 = (N-3)-K2;
|
|
147 |
|
|
148 |
for(int i=0; i<=K1; i++)
|
|
149 |
{
|
|
150 |
float angle = K*beta + (1-K)*beta*(K1-i)/(K1+1);
|
|
151 |
float x = h(R,sinBeta,angle);
|
|
152 |
bands[2*i+2] = 1.0f - x;
|
|
153 |
bands[2*i+3] = g(R,D,x,cosBeta);
|
|
154 |
}
|
|
155 |
|
|
156 |
for(int i=0; i<=K2; i++)
|
|
157 |
{
|
|
158 |
float x = (1-B)*(i+1)/(K2+1) + B;
|
|
159 |
bands[2*K1+2 + 2*i+2] = 1.0f - x;
|
|
160 |
bands[2*K1+2 + 2*i+3] = g(R,D,f(D,B,x),cosBeta);
|
|
161 |
}
|
|
162 |
}
|
|
163 |
|
|
164 |
bands[2*N-2] = 0.0f;
|
|
165 |
bands[2*N-1] = H;
|
|
166 |
|
|
167 |
return bands;
|
|
168 |
}
|
|
169 |
|
| 62 |
170 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 63 |
171 |
|
| 64 |
172 |
private void roundCorners(MeshBase mesh, Static3D center, Static3D[] vertices, float strength, float regionRadius)
|
| ... | ... | |
| 82 |
190 |
|
| 83 |
191 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 84 |
192 |
|
| 85 |
|
MeshBase createFacesCube(int index)
|
|
193 |
MeshBase createFacesCube(int sizeIndex)
|
| 86 |
194 |
{
|
| 87 |
|
final int MESHES=6;
|
| 88 |
|
MeshBase[] meshes = new MeshPolygon[MESHES];
|
| 89 |
|
int association = 1;
|
|
195 |
MeshBase[] meshes = new MeshPolygon[6];
|
| 90 |
196 |
|
| 91 |
|
float[] bands;
|
| 92 |
|
float D = 0.027f;
|
| 93 |
|
float E = 0.5f-D;
|
| 94 |
|
float[] vertices = { -E,-E, +E,-E, +E,+E, -E,+E };
|
| 95 |
|
int extraI, extraV;
|
|
197 |
float E = 0.5f;
|
|
198 |
int extraI, extraV, num;
|
| 96 |
199 |
|
| 97 |
|
switch(index)
|
|
200 |
switch(sizeIndex)
|
| 98 |
201 |
{
|
| 99 |
|
case 0 : bands = new float[] { 1.0f ,-D,
|
| 100 |
|
1.0f-D/2,-D*0.55f,
|
| 101 |
|
1.0f-D ,-D*0.25f,
|
| 102 |
|
1.0f-2*D, 0.0f,
|
| 103 |
|
0.50f , 0.040f,
|
| 104 |
|
0.0f , 0.048f };
|
| 105 |
|
extraI = 2;
|
| 106 |
|
extraV = 2;
|
| 107 |
|
break;
|
| 108 |
|
case 1 : bands = new float[] { 1.0f ,-D,
|
| 109 |
|
1.0f-D*1.2f,-D*0.55f,
|
| 110 |
|
1.0f-2*D , 0.0f,
|
| 111 |
|
0.50f , 0.040f,
|
| 112 |
|
0.0f , 0.048f };
|
| 113 |
|
extraI = 2;
|
| 114 |
|
extraV = 2;
|
| 115 |
|
break;
|
| 116 |
|
case 2 : bands = new float[] { 1.0f ,-D,
|
| 117 |
|
1.0f-D*1.2f,-D*0.55f,
|
| 118 |
|
1.0f-2*D , 0.0f,
|
| 119 |
|
0.50f , 0.040f,
|
| 120 |
|
0.0f , 0.048f };
|
| 121 |
|
extraI = 1;
|
| 122 |
|
extraV = 2;
|
| 123 |
|
break;
|
| 124 |
|
default: bands = new float[] { 1.0f ,-D,
|
| 125 |
|
1.0f-2*D, 0.0f,
|
| 126 |
|
0.50f , 0.025f,
|
| 127 |
|
0.0f , 0.030f };
|
| 128 |
|
extraI = 1;
|
| 129 |
|
extraV = 1;
|
| 130 |
|
break;
|
|
202 |
case 0 : num = 6; extraI = 2; extraV = 2; break;
|
|
203 |
case 1 : num = 5; extraI = 2; extraV = 2; break;
|
|
204 |
case 2 : num = 5; extraI = 1; extraV = 2; break;
|
|
205 |
default: num = 4; extraI = 1; extraV = 1; break;
|
| 131 |
206 |
}
|
| 132 |
207 |
|
| 133 |
|
meshes[0] = new MeshPolygon(vertices,bands,extraI,extraV);
|
| 134 |
|
meshes[0].setEffectAssociation(0,association,0);
|
|
208 |
float[] vertices = { -E,-E, +E,-E, +E,+E, -E,+E };
|
|
209 |
float[] bands = computeBands(0.048f,35,E,0.7f,num);
|
| 135 |
210 |
|
| 136 |
|
for(int i=1; i<MESHES; i++)
|
| 137 |
|
{
|
| 138 |
|
association <<=1;
|
| 139 |
|
meshes[i] = meshes[0].copy(true);
|
| 140 |
|
meshes[i].setEffectAssociation(0,association,0);
|
| 141 |
|
}
|
|
211 |
meshes[0] = new MeshPolygon(vertices,bands,extraI,extraV);
|
|
212 |
meshes[0].setEffectAssociation(0,1,0);
|
|
213 |
meshes[1] = meshes[0].copy(true);
|
|
214 |
meshes[1].setEffectAssociation(0,2,0);
|
|
215 |
meshes[2] = meshes[0].copy(true);
|
|
216 |
meshes[2].setEffectAssociation(0,4,0);
|
|
217 |
meshes[3] = meshes[0].copy(true);
|
|
218 |
meshes[3].setEffectAssociation(0,8,0);
|
|
219 |
meshes[4] = meshes[0].copy(true);
|
|
220 |
meshes[4].setEffectAssociation(0,16,0);
|
|
221 |
meshes[5] = meshes[0].copy(true);
|
|
222 |
meshes[5].setEffectAssociation(0,32,0);
|
| 142 |
223 |
|
| 143 |
224 |
return new MeshJoined(meshes);
|
| 144 |
225 |
}
|
| ... | ... | |
| 147 |
228 |
|
| 148 |
229 |
MeshBase createFacesSkewbCorner()
|
| 149 |
230 |
{
|
| 150 |
|
float D = 0.02f;
|
|
231 |
MeshBase[] meshes = new MeshBase[6];
|
|
232 |
|
| 151 |
233 |
float E = 0.5f;
|
| 152 |
234 |
float F = SQ2/2;
|
| 153 |
|
|
| 154 |
235 |
float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
|
| 155 |
|
|
| 156 |
|
float[] bands0 = { 1.0f , 0,
|
| 157 |
|
1.0f-2*D, D*0.25f,
|
| 158 |
|
1.0f-4*D, D*0.35f,
|
| 159 |
|
1.0f-8*D, D*0.6f,
|
| 160 |
|
0.60f , D*1.0f,
|
| 161 |
|
0.30f , D*1.375f,
|
| 162 |
|
0.0f , D*1.4f };
|
| 163 |
|
|
| 164 |
|
MeshBase[] meshes = new MeshBase[6];
|
|
236 |
float[] bands0 = computeBands(0.028f,35,E/3,0.7f,7);
|
| 165 |
237 |
|
| 166 |
238 |
meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
|
| 167 |
239 |
meshes[0].setEffectAssociation(0,1,0);
|
| ... | ... | |
| 171 |
243 |
meshes[2].setEffectAssociation(0,4,0);
|
| 172 |
244 |
|
| 173 |
245 |
float[] vertices1 = { 0,0, F,0, F/2,(SQ3/2)*F };
|
| 174 |
|
float[] bands1 = { 1.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f };
|
|
246 |
float[] bands1 = computeBands(0,0,1,0,3);
|
| 175 |
247 |
|
| 176 |
248 |
meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
|
| 177 |
249 |
meshes[3].setEffectAssociation(0,8,0);
|
| ... | ... | |
| 187 |
259 |
|
| 188 |
260 |
MeshBase createFacesSkewbFace()
|
| 189 |
261 |
{
|
| 190 |
|
float D = 0.03f;
|
|
262 |
MeshBase[] meshes = new MeshBase[5];
|
|
263 |
|
| 191 |
264 |
float E = SQ2/4;
|
| 192 |
265 |
float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
|
|
266 |
float[] bands0 = computeBands(0.051f,35,E/2,0.9f,7);
|
| 193 |
267 |
|
| 194 |
|
float[] bands0 = { 1.0f , 0,
|
| 195 |
|
1.0f-D/2, D*0.30f,
|
| 196 |
|
1.0f- D , D*0.50f,
|
| 197 |
|
1.0f-2*D, D*0.80f,
|
| 198 |
|
0.60f , D*1.40f,
|
| 199 |
|
0.30f , D*1.60f,
|
| 200 |
|
0.0f , D*1.70f };
|
| 201 |
|
|
| 202 |
|
MeshBase[] meshes = new MeshBase[5];
|
| 203 |
268 |
meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
|
| 204 |
269 |
meshes[0].setEffectAssociation(0,1,0);
|
| 205 |
270 |
|
| 206 |
271 |
float[] vertices1 = { -E,-SQ3*E, +E,-SQ3*E, 0,0 };
|
| 207 |
|
float[] bands1 = { 1.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f };
|
|
272 |
float[] bands1 = computeBands(0,0,1,0,3);
|
| 208 |
273 |
|
| 209 |
274 |
meshes[1] = new MeshPolygon(vertices1,bands1,0,0);
|
| 210 |
275 |
meshes[1].setEffectAssociation(0,2,0);
|
| ... | ... | |
| 222 |
287 |
|
| 223 |
288 |
MeshBase createFacesOcta()
|
| 224 |
289 |
{
|
| 225 |
|
int association = 1;
|
|
290 |
MeshBase[] meshes = new MeshPolygon[8];
|
| 226 |
291 |
|
| 227 |
|
float C = 0.06f;
|
| 228 |
|
float D = 0.031f;
|
| 229 |
292 |
float E = SQ3/2;
|
| 230 |
293 |
float F = 0.5f;
|
| 231 |
|
|
| 232 |
294 |
float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
|
|
295 |
float[] bands = computeBands(0.05f,35,F,0.8f,6);
|
| 233 |
296 |
|
| 234 |
|
float[] bands = new float[] { 1.0f , 0,
|
| 235 |
|
1.0f -C, D*0.55f,
|
| 236 |
|
1.0f-2*C, D*0.85f,
|
| 237 |
|
1.0f-4*C, D*1.20f,
|
| 238 |
|
0.5f , D*1.40f,
|
| 239 |
|
0.0f , D*1.50f };
|
| 240 |
|
|
| 241 |
|
MeshBase[] meshes = new MeshPolygon[8];
|
| 242 |
297 |
meshes[0] = new MeshPolygon(vertices, bands, 2,2);
|
| 243 |
|
meshes[0].setEffectAssociation(0,association,0);
|
| 244 |
|
|
| 245 |
|
for(int i=1; i<8; i++)
|
| 246 |
|
{
|
| 247 |
|
association <<= 1;
|
| 248 |
|
meshes[i] = meshes[0].copy(true);
|
| 249 |
|
meshes[i].setEffectAssociation(0,association,0);
|
| 250 |
|
}
|
|
298 |
meshes[0].setEffectAssociation(0,1,0);
|
|
299 |
meshes[1] = meshes[0].copy(true);
|
|
300 |
meshes[1].setEffectAssociation(0,2,0);
|
|
301 |
meshes[2] = meshes[0].copy(true);
|
|
302 |
meshes[2].setEffectAssociation(0,4,0);
|
|
303 |
meshes[3] = meshes[0].copy(true);
|
|
304 |
meshes[3].setEffectAssociation(0,8,0);
|
|
305 |
meshes[4] = meshes[0].copy(true);
|
|
306 |
meshes[4].setEffectAssociation(0,16,0);
|
|
307 |
meshes[5] = meshes[0].copy(true);
|
|
308 |
meshes[5].setEffectAssociation(0,32,0);
|
|
309 |
meshes[6] = meshes[0].copy(true);
|
|
310 |
meshes[6].setEffectAssociation(0,64,0);
|
|
311 |
meshes[7] = meshes[0].copy(true);
|
|
312 |
meshes[7].setEffectAssociation(0,128,0);
|
| 251 |
313 |
|
| 252 |
314 |
return new MeshJoined(meshes);
|
| 253 |
315 |
}
|
| ... | ... | |
| 257 |
319 |
MeshBase createFacesTetra()
|
| 258 |
320 |
{
|
| 259 |
321 |
MeshBase[] meshes = new MeshBase[4];
|
| 260 |
|
int association = 1;
|
| 261 |
322 |
|
| 262 |
|
float C = 0.06f;
|
| 263 |
|
float D = 0.035f;
|
| 264 |
323 |
float E = SQ3/2;
|
| 265 |
324 |
float F = 0.5f;
|
| 266 |
|
|
| 267 |
325 |
float[] vertices = { -F,-E/3, +F,-E/3, 0.0f,2*E/3};
|
| 268 |
|
|
| 269 |
|
float[] bands = new float[] { 1.0f , 0,
|
| 270 |
|
1.0f -C, D*0.50f,
|
| 271 |
|
1.0f-2*C, D*0.80f,
|
| 272 |
|
1.0f-4*C, D*1.10f,
|
| 273 |
|
0.5f , D*1.30f,
|
| 274 |
|
0.0f , D*1.35f };
|
|
326 |
float[] bands = computeBands(0.05f,35,F,0.8f,6);
|
| 275 |
327 |
|
| 276 |
328 |
meshes[0] = new MeshPolygon(vertices, bands, 2,2);
|
| 277 |
|
meshes[0].setEffectAssociation(0,association,0);
|
| 278 |
|
|
| 279 |
|
for(int i=1; i<4; i++)
|
| 280 |
|
{
|
| 281 |
|
association <<= 1;
|
| 282 |
|
meshes[i] = meshes[0].copy(true);
|
| 283 |
|
meshes[i].setEffectAssociation(0,association,0);
|
| 284 |
|
}
|
|
329 |
meshes[0].setEffectAssociation(0,1,0);
|
|
330 |
meshes[1] = meshes[0].copy(true);
|
|
331 |
meshes[1].setEffectAssociation(0,2,0);
|
|
332 |
meshes[2] = meshes[0].copy(true);
|
|
333 |
meshes[2].setEffectAssociation(0,4,0);
|
|
334 |
meshes[3] = meshes[0].copy(true);
|
|
335 |
meshes[3].setEffectAssociation(0,8,0);
|
| 285 |
336 |
|
| 286 |
337 |
return new MeshJoined(meshes);
|
| 287 |
338 |
}
|
| ... | ... | |
| 290 |
341 |
|
| 291 |
342 |
MeshBase createFacesDino()
|
| 292 |
343 |
{
|
| 293 |
|
final int MESHES=4;
|
|
344 |
MeshBase[] meshes = new MeshPolygon[4];
|
| 294 |
345 |
|
| 295 |
|
float D = 0.02f;
|
| 296 |
346 |
float E = 0.5f*SQ2;
|
| 297 |
347 |
float F = 0.5f;
|
| 298 |
|
|
| 299 |
|
float[] bands0 = { 1.0f , 0,
|
| 300 |
|
1.0f-2*D, D*0.25f,
|
| 301 |
|
1.0f-4*D, D*0.35f,
|
| 302 |
|
1.0f-8*D, D*0.6f,
|
| 303 |
|
0.60f , D*1.0f,
|
| 304 |
|
0.30f , D*1.375f,
|
| 305 |
|
0.0f , D*1.4f };
|
| 306 |
|
|
| 307 |
348 |
float[] vertices0 = { -F,F/3, 0,-2*F/3, +F,F/3 };
|
|
349 |
float[] bands0 = computeBands(0.028f,30,F/3,0.8f,7);
|
| 308 |
350 |
|
| 309 |
|
MeshBase[] meshes = new MeshPolygon[MESHES];
|
| 310 |
351 |
meshes[0] = new MeshPolygon(vertices0, bands0, 2, 5);
|
| 311 |
352 |
meshes[0].setEffectAssociation(0,1,0);
|
| 312 |
353 |
meshes[1] = meshes[0].copy(true);
|
| 313 |
354 |
meshes[1].setEffectAssociation(0,2,0);
|
| 314 |
355 |
|
| 315 |
|
float[] bands1 = { 1.0f , 0,
|
| 316 |
|
0.50f , 0.10f,
|
| 317 |
|
0.0f , 0.20f };
|
| 318 |
|
|
| 319 |
356 |
float[] vertices1 = { -E/2,-E*(SQ3/6), E/2,-E*(SQ3/6), 0,E*(SQ3/3) };
|
|
357 |
float[] bands1 = computeBands(0.02f,45,F/3,0.2f,3);
|
| 320 |
358 |
|
| 321 |
359 |
meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
|
| 322 |
360 |
meshes[2].setEffectAssociation(0,4,0);
|
| ... | ... | |
| 330 |
368 |
|
| 331 |
369 |
MeshBase createFacesHelicopterCorner()
|
| 332 |
370 |
{
|
| 333 |
|
float D = 0.02f;
|
|
371 |
MeshBase[] meshes = new MeshBase[6];
|
|
372 |
|
| 334 |
373 |
float E = 0.5f;
|
| 335 |
374 |
float F = SQ2/4;
|
| 336 |
|
|
|
375 |
float G = 1.0f/12;
|
| 337 |
376 |
float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
|
| 338 |
|
|
| 339 |
|
float[] bands0 = { 1.0f , 0,
|
| 340 |
|
1.0f-2*D, D*0.25f,
|
| 341 |
|
1.0f-4*D, D*0.35f,
|
| 342 |
|
1.0f-8*D, D*0.6f,
|
| 343 |
|
0.60f , D*1.0f,
|
| 344 |
|
0.30f , D*1.375f,
|
| 345 |
|
0.0f , D*1.4f };
|
| 346 |
|
|
| 347 |
|
MeshBase[] meshes = new MeshBase[6];
|
|
377 |
float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
|
| 348 |
378 |
|
| 349 |
379 |
meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
|
| 350 |
380 |
meshes[0].setEffectAssociation(0,1,0);
|
| ... | ... | |
| 353 |
383 |
meshes[2] = meshes[0].copy(true);
|
| 354 |
384 |
meshes[2].setEffectAssociation(0,4,0);
|
| 355 |
385 |
|
| 356 |
|
float[] vertices1 = { -F,-1.0f/12, +F,-1.0f/12, 0,1.0f/6 };
|
| 357 |
|
float[] bands1 = { 1.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f };
|
| 358 |
|
|
|
386 |
float[] vertices1 = { -F,-G, 0,-G, +F,-G, 0,2*G };
|
|
387 |
float[] bands1 = computeBands(0.00f,0,0,0.0f,3);
|
| 359 |
388 |
meshes[3] = new MeshPolygon(vertices1,bands1,1,5);
|
| 360 |
389 |
meshes[3].setEffectAssociation(0,8,0);
|
| 361 |
390 |
meshes[4] = meshes[3].copy(true);
|
| ... | ... | |
| 372 |
401 |
{
|
| 373 |
402 |
MeshBase[] meshes = new MeshBase[4];
|
| 374 |
403 |
|
| 375 |
|
float D = 0.02f;
|
| 376 |
404 |
float E = 0.5f;
|
| 377 |
405 |
float F = SQ2/4;
|
| 378 |
406 |
float G = 1.0f/12;
|
| 379 |
|
|
| 380 |
407 |
float[] vertices0 = { -E+E/4,E/4, E/4,-E+E/4, E/4,E/4};
|
| 381 |
|
|
| 382 |
|
float[] bands0 = { 1.0f , 0,
|
| 383 |
|
1.0f-2*D, D*0.25f,
|
| 384 |
|
1.0f-4*D, D*0.35f,
|
| 385 |
|
1.0f-8*D, D*0.6f,
|
| 386 |
|
0.60f , D*1.0f,
|
| 387 |
|
0.30f , D*1.375f,
|
| 388 |
|
0.0f , D*1.4f };
|
|
408 |
float[] bands0 = computeBands(0.028f,35,E/4,0.7f,7);
|
| 389 |
409 |
|
| 390 |
410 |
meshes[0] = new MeshPolygon(vertices0, bands0, 3, 3);
|
| 391 |
411 |
meshes[0].setEffectAssociation(0,1,0);
|
| 392 |
412 |
|
| 393 |
413 |
float[] vertices1 = { -F,-G, +F,-G, 0,2*G};
|
| 394 |
|
|
| 395 |
|
float[] bands1 = { 1.0f , 0.0f,
|
| 396 |
|
0.5f , 0.01f,
|
| 397 |
|
0.0f , 0.01f };
|
|
414 |
float[] bands1 = computeBands(0.01f,45,F,0.0f,3);
|
| 398 |
415 |
|
| 399 |
416 |
meshes[1] = new MeshPolygon(vertices1, bands1, 1, 3);
|
| 400 |
417 |
meshes[1].setEffectAssociation(0,2,0);
|
| 401 |
418 |
|
| 402 |
419 |
float[] vertices2 = { -E/2,-F/3, +E/2,-F/3, 0,2*F/3};
|
| 403 |
420 |
|
| 404 |
|
float[] bands2 = { 1.0f , 0.0f,
|
| 405 |
|
0.5f , 0.01f,
|
| 406 |
|
0.0f , 0.01f };
|
| 407 |
|
|
| 408 |
|
meshes[2] = new MeshPolygon(vertices2, bands2, 1, 3);
|
|
421 |
meshes[2] = new MeshPolygon(vertices2, bands1, 1, 3);
|
| 409 |
422 |
meshes[2].setEffectAssociation(0,4,0);
|
| 410 |
423 |
meshes[3] = meshes[2].copy(true);
|
| 411 |
424 |
meshes[3].setEffectAssociation(0,8,0);
|
| ... | ... | |
| 417 |
430 |
|
| 418 |
431 |
MeshBase createFacesRediEdge()
|
| 419 |
432 |
{
|
| 420 |
|
final int MESHES=6;
|
|
433 |
MeshBase[] meshes = new MeshPolygon[6];
|
| 421 |
434 |
|
| 422 |
|
float C = 0.02f;
|
| 423 |
|
float D = 0.02f;
|
| 424 |
435 |
float F = 0.25f;
|
| 425 |
|
|
| 426 |
|
float[] bands0 = { 1.0f , 0,
|
| 427 |
|
1.0f-2*C, D*0.25f,
|
| 428 |
|
1.0f-4*C, D*0.35f,
|
| 429 |
|
1.0f-8*C, D*0.6f,
|
| 430 |
|
0.60f , D*1.0f,
|
| 431 |
|
0.30f , D*1.375f,
|
| 432 |
|
0.0f , D*1.4f };
|
| 433 |
|
|
| 434 |
436 |
float[] vertices0 = { -F,+F, -F,-F, 0, -2*F, +F,-F, +F,+F };
|
|
437 |
float[] bands0 = computeBands(0.038f,35,F,0.7f,7);
|
| 435 |
438 |
|
| 436 |
|
MeshBase[] meshes = new MeshPolygon[MESHES];
|
| 437 |
439 |
meshes[0] = new MeshPolygon(vertices0, bands0, 2, 2);
|
| 438 |
440 |
meshes[0].setEffectAssociation(0,1,0);
|
| 439 |
441 |
meshes[1] = meshes[0].copy(true);
|
| 440 |
442 |
meshes[1].setEffectAssociation(0,2,0);
|
| 441 |
443 |
|
| 442 |
|
float[] bands1 = { 1.0f , 0,
|
| 443 |
|
0.90f , D,
|
| 444 |
|
0.0f , D };
|
| 445 |
|
|
|
444 |
float[] bands1 = computeBands(0.02f,35,F/2,0.2f,3);
|
| 446 |
445 |
float[] vertices1 = { -F/2, +F/2, -F/2, -1.5f*F, 1.5f*F, +F/2 };
|
| 447 |
446 |
|
| 448 |
447 |
meshes[2] = new MeshPolygon(vertices1, bands1, 1, 2);
|
| ... | ... | |
| 450 |
449 |
meshes[3] = meshes[2].copy(true);
|
| 451 |
450 |
meshes[3].setEffectAssociation(0,8,0);
|
| 452 |
451 |
|
| 453 |
|
float[] bands2 = { 1.0f , 0,
|
| 454 |
|
0.90f , D,
|
| 455 |
|
0.0f , D };
|
| 456 |
|
|
| 457 |
452 |
float X = 0.25f*SQ2;
|
| 458 |
453 |
float Y = SQ6/16;
|
| 459 |
|
|
| 460 |
454 |
float[] vertices2 = { -X, Y, -1.5f*X, -Y, +1.5f*X, -Y, +X, Y };
|
| 461 |
455 |
|
| 462 |
|
meshes[4] = new MeshPolygon(vertices2, bands2, 1, 1);
|
|
456 |
meshes[4] = new MeshPolygon(vertices2, bands1, 1, 1);
|
| 463 |
457 |
meshes[4].setEffectAssociation(0,16,0);
|
| 464 |
458 |
meshes[5] = meshes[4].copy(true);
|
| 465 |
459 |
meshes[5].setEffectAssociation(0,32,0);
|
| ... | ... | |
| 471 |
465 |
|
| 472 |
466 |
MeshBase createFacesRediCorner()
|
| 473 |
467 |
{
|
| 474 |
|
final int MESHES=6;
|
| 475 |
|
MeshBase[] meshes = new MeshBase[MESHES];
|
|
468 |
MeshBase[] meshes = new MeshBase[6];
|
| 476 |
469 |
|
| 477 |
|
float C = 0.027f;
|
| 478 |
|
float D = 0.027f;
|
| 479 |
470 |
float E = 0.5f;
|
| 480 |
|
float[] vertices1 = { -E,-E, +E,-E, +E,+E, -E,+E };
|
| 481 |
|
|
| 482 |
|
float[] bands1 = new float[] { 1.0f ,-D,
|
| 483 |
|
1.0f-C/2,-D*0.55f,
|
| 484 |
|
1.0f-C ,-D*0.25f,
|
| 485 |
|
1.0f-2*C, 0.0f,
|
| 486 |
|
0.50f , D*1.5f,
|
| 487 |
|
0.0f , D*1.75f };
|
|
471 |
float[] vertices0 = { -E,-E, +E,-E, +E,+E, -E,+E };
|
|
472 |
float[] bands0 = computeBands(0.06f,35,E,0.7f,6);
|
| 488 |
473 |
|
| 489 |
|
meshes[0] = new MeshPolygon(vertices1,bands1,2,2);
|
|
474 |
meshes[0] = new MeshPolygon(vertices0,bands0,2,2);
|
| 490 |
475 |
meshes[0].setEffectAssociation(0,1,0);
|
| 491 |
476 |
meshes[1] = meshes[0].copy(true);
|
| 492 |
477 |
meshes[1].setEffectAssociation(0,2,0);
|
| ... | ... | |
| 495 |
480 |
|
| 496 |
481 |
float F = SQ2/2;
|
| 497 |
482 |
float X = 0.5f;
|
|
483 |
float G = 0.72f;
|
|
484 |
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 };
|
|
485 |
float[] bands1 = computeBands(0.0f,0,1.0f,0.0f,2);
|
| 498 |
486 |
|
| 499 |
|
float[] vertices2 = { -E,+F, -E+X,0, -E,-F, +E,-F, +E-X,0, +E,+F };
|
| 500 |
|
|
| 501 |
|
float[] bands2 = new float[] { 1.0f,0.0f,
|
| 502 |
|
0.0f,0.0f };
|
| 503 |
|
|
| 504 |
|
meshes[3] = new MeshPolygon(vertices2,bands2,0,0);
|
|
487 |
meshes[3] = new MeshPolygon(vertices1,bands1,0,0);
|
| 505 |
488 |
meshes[3].setEffectAssociation(0,8,0);
|
| 506 |
489 |
meshes[4] = meshes[3].copy(true);
|
| 507 |
490 |
meshes[4].setEffectAssociation(0,16,0);
|
| ... | ... | |
| 511 |
494 |
return new MeshJoined(meshes);
|
| 512 |
495 |
}
|
| 513 |
496 |
|
|
497 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
498 |
// EFFECTS
|
| 514 |
499 |
///////////////////////////////////////////////////////////////////////////////////////////////////
|
| 515 |
500 |
|
| 516 |
501 |
VertexEffect[] createVertexEffectsCube()
|
| ... | ... | |
| 694 |
679 |
float F = 0.5f;
|
| 695 |
680 |
final float ANGLE = (float)((180/Math.PI)*(Math.atan(SQ2)));
|
| 696 |
681 |
|
| 697 |
|
Static1D angle1 = new Static1D(+ANGLE);
|
| 698 |
|
Static1D angle2 = new Static1D(-ANGLE);
|
|
682 |
Static1D angle1 = new Static1D(-ANGLE);
|
|
683 |
Static1D angle2 = new Static1D(+ANGLE);
|
| 699 |
684 |
Static3D axisX = new Static3D(1,0,0);
|
| 700 |
685 |
Static3D axisY = new Static3D(0,1,0);
|
| 701 |
686 |
Static3D axisZ = new Static3D(0,-1,1);
|
| ... | ... | |
| 1081 |
1066 |
verticesType2[0] = new Static3D(-E, 0, 0);
|
| 1082 |
1067 |
verticesType2[1] = new Static3D( 0,-E, 0);
|
| 1083 |
1068 |
verticesType2[2] = new Static3D( 0, 0,-E);
|
| 1084 |
|
roundCorners(mesh,roundingCenter,verticesType2,0.10f,0.20f);
|
|
1069 |
roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
|
| 1085 |
1070 |
|
| 1086 |
1071 |
mesh.mergeEffComponents();
|
| 1087 |
1072 |
|
| ... | ... | |
| 1106 |
1091 |
Static3D[] verticesType2 = new Static3D[2];
|
| 1107 |
1092 |
verticesType2[0] = new Static3D(-E+E/3, E/3 , 0);
|
| 1108 |
1093 |
verticesType2[1] = new Static3D( E/3 ,-E+E/3, 0);
|
| 1109 |
|
roundCorners(mesh,roundingCenter,verticesType2,0.10f,0.20f);
|
|
1094 |
roundCorners(mesh,roundingCenter,verticesType2,0.08f,0.20f);
|
| 1110 |
1095 |
|
| 1111 |
1096 |
mesh.mergeEffComponents();
|
| 1112 |
1097 |
mesh.addEmptyTexComponent();
|
| ... | ... | |
| 1125 |
1110 |
for( VertexEffect effect : effects ) mesh.apply(effect);
|
| 1126 |
1111 |
|
| 1127 |
1112 |
Static3D center = new Static3D(0.0f,-0.75f,-0.75f);
|
| 1128 |
|
Static3D[] vertices = new Static3D[4];
|
|
1113 |
Static3D[] vertices = new Static3D[2];
|
| 1129 |
1114 |
vertices[0] = new Static3D( 0.5f, 0.0f, 0.0f);
|
| 1130 |
1115 |
vertices[1] = new Static3D(-0.5f, 0.0f, 0.0f);
|
| 1131 |
|
vertices[2] = new Static3D(0.0f, 0.0f,-1.5f);
|
| 1132 |
|
vertices[3] = new Static3D(0.0f,-1.5f, 0.0f);
|
| 1133 |
|
|
| 1134 |
1116 |
roundCorners(mesh,center,vertices,0.06f,0.20f);
|
| 1135 |
1117 |
|
| 1136 |
1118 |
mesh.mergeEffComponents();
|
CubitFactory: unify creating MeshPolygon bands.