Revision 17a55777
Added by Leszek Koltunski about 2 years ago
src/main/java/org/distorted/objectlib/helpers/FactoryBandaged.java | ||
---|---|---|
23 | 23 |
abstract public class FactoryBandaged |
24 | 24 |
{ |
25 | 25 |
private ArrayList<float[]> mTmpArray; |
26 |
private float mNX, mNY, mNZ; |
|
27 | 26 |
private float[] mDist3D; |
28 | 27 |
private int[][] mFaceBelongsBitmap; |
29 | 28 |
private float[][] mCuts; |
... | ... | |
331 | 330 |
|
332 | 331 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
333 | 332 |
|
334 |
private void computeVectorFace(float[] prev, float[] curr, float[] next) |
|
333 |
private void computeVectorFace(float[] prev, float[] curr, float[] next, float[] output)
|
|
335 | 334 |
{ |
336 | 335 |
float ax = prev[0]-curr[0]; |
337 | 336 |
float ay = prev[1]-curr[1]; |
... | ... | |
352 | 351 |
by /= lenb; |
353 | 352 |
bz /= lenb; |
354 | 353 |
|
355 |
mNX = ax + bx + ay*bz-az*by; |
|
356 |
mNY = ay + by + az*bx-ax*bz; |
|
357 |
mNZ = az + bz + ax*by-ay*bx; |
|
354 |
output[0] = ay*bz - az*by; |
|
355 |
output[1] = az*bx - ax*bz; |
|
356 |
output[2] = ax*by - ay*bx; |
|
357 |
|
|
358 |
output[3] = ax; |
|
359 |
output[4] = ay; |
|
360 |
output[5] = az; |
|
361 |
|
|
362 |
output[6] = bx; |
|
363 |
output[7] = by; |
|
364 |
output[8] = bz; |
|
365 |
} |
|
366 |
|
|
367 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
368 |
// 'concave' vertices do not get pushed! |
|
369 |
|
|
370 |
private boolean vertexIsConcave(float[][] vecs, int numVecs) |
|
371 |
{ |
|
372 |
for(int i=0; i<numVecs; i++) |
|
373 |
{ |
|
374 |
float[] v1 = vecs[i]; |
|
375 |
|
|
376 |
for(int j=0; j<numVecs; j++) |
|
377 |
{ |
|
378 |
if( i==j ) continue; |
|
379 |
|
|
380 |
float[] v2 = vecs[j]; |
|
381 |
|
|
382 |
float scalar1 = v1[0]*v2[3] + v1[1]*v2[4] + v1[2]*v2[5]; |
|
383 |
float scalar2 = v1[0]*v2[6] + v1[1]*v2[7] + v1[2]*v2[8]; |
|
384 |
|
|
385 |
if( scalar1<0 || scalar2<0 ) return true; |
|
386 |
} |
|
387 |
} |
|
388 |
|
|
389 |
return false; |
|
358 | 390 |
} |
359 | 391 |
|
360 | 392 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
366 | 398 |
int numBordering = 0; |
367 | 399 |
float x=0, y=0, z=0; |
368 | 400 |
|
401 |
float[][] vecs = new float[numFaces][9]; |
|
402 |
int vecIndex = 0; |
|
403 |
|
|
369 | 404 |
for(int f=0; f<numFaces; f++) |
370 | 405 |
{ |
371 | 406 |
int numComponentsInFace = indices[f].length; |
... | ... | |
386 | 421 |
int currIndex=ind[v]; |
387 | 422 |
int nextIndex=ind[next]; |
388 | 423 |
|
389 |
computeVectorFace(vertices[prevIndex], vertices[currIndex], vertices[nextIndex]); |
|
424 |
float[] vec = vecs[vecIndex++]; |
|
425 |
computeVectorFace(vertices[prevIndex], vertices[currIndex], vertices[nextIndex], vec); |
|
390 | 426 |
band|=bandIndices[f]; |
391 | 427 |
v = numVertsInComponent; |
392 | 428 |
c = numComponentsInFace; |
393 | 429 |
numBordering++; |
394 | 430 |
|
395 |
x += mNX;
|
|
396 |
y += mNY;
|
|
397 |
z += mNZ;
|
|
431 |
x += vec[0];
|
|
432 |
y += vec[1];
|
|
433 |
z += vec[2];
|
|
398 | 434 |
} |
399 | 435 |
} |
400 | 436 |
} |
401 | 437 |
} |
402 | 438 |
|
403 |
return ( band==0 || numBordering<3 ) ? null : new float[] { x/numBordering, y/numBordering, z/numBordering}; |
|
439 |
boolean concave = vertexIsConcave(vecs,vecIndex); |
|
440 |
|
|
441 |
return ( concave || band==0 || numBordering<3 ) ? null : new float[] { x/numBordering, y/numBordering, z/numBordering}; |
|
404 | 442 |
} |
405 | 443 |
|
406 | 444 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objectlib/helpers/FactoryBandagedCuboid.java | ||
---|---|---|
25 | 25 |
|
26 | 26 |
} |
27 | 27 |
|
28 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
29 |
|
|
30 |
public static FactoryBandagedCuboid getInstance() |
|
31 |
{ |
|
32 |
if( mThis==null ) mThis = new FactoryBandagedCuboid(); |
|
33 |
return mThis; |
|
34 |
} |
|
35 |
|
|
28 | 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
29 | 37 |
|
30 | 38 |
public float[] elementVertices(int ax, boolean left, int element) |
... | ... | |
165 | 173 |
return diffX>diffY ? Math.max(diffX,diffZ) : Math.max(diffY,diffZ); |
166 | 174 |
} |
167 | 175 |
|
168 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
169 |
// PUBLIC API |
|
170 |
|
|
171 |
public static FactoryBandagedCuboid getInstance() |
|
172 |
{ |
|
173 |
if( mThis==null ) mThis = new FactoryBandagedCuboid(); |
|
174 |
return mThis; |
|
175 |
} |
|
176 |
|
|
177 | 176 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
178 | 177 |
|
179 | 178 |
public float[][] getCuts(int[] numLayers) |
src/main/java/org/distorted/objectlib/helpers/FactoryBandagedPyraminx.java | ||
---|---|---|
13 | 13 |
import static org.distorted.objectlib.main.TwistyObject.SQ6; |
14 | 14 |
|
15 | 15 |
import org.distorted.library.type.Static3D; |
16 |
import org.distorted.objectlib.touchcontrol.TouchControlTetrahedron; |
|
17 | 16 |
|
18 | 17 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
19 | 18 |
|
... | ... | |
28 | 27 |
|
29 | 28 |
} |
30 | 29 |
|
30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
31 |
|
|
32 |
public static FactoryBandagedPyraminx getInstance() |
|
33 |
{ |
|
34 |
if( mThis==null ) mThis = new FactoryBandagedPyraminx(); |
|
35 |
return mThis; |
|
36 |
} |
|
37 |
|
|
31 | 38 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
32 | 39 |
// TODO |
33 | 40 |
|
... | ... | |
72 | 79 |
return 0; |
73 | 80 |
} |
74 | 81 |
|
75 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
76 |
// PUBLIC API |
|
77 |
|
|
78 |
public static FactoryBandagedPyraminx getInstance() |
|
79 |
{ |
|
80 |
if( mThis==null ) mThis = new FactoryBandagedPyraminx(); |
|
81 |
return mThis; |
|
82 |
} |
|
83 |
|
|
84 | 82 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
85 | 83 |
|
86 | 84 |
public float[][] getCuts(int[] numLayers) |
... | ... | |
104 | 102 |
|
105 | 103 |
public Static3D[] getNormals() |
106 | 104 |
{ |
107 |
return TouchControlTetrahedron.FACE_AXIS; |
|
105 |
return new Static3D[] |
|
106 |
{ |
|
107 |
new Static3D( 0, SQ3/3, SQ6/3), |
|
108 |
new Static3D( 0, SQ3/3,-SQ6/3), |
|
109 |
new Static3D(-SQ6/3,-SQ3/3, 0), |
|
110 |
new Static3D( SQ6/3,-SQ3/3, 0), |
|
111 |
}; |
|
108 | 112 |
} |
109 | 113 |
|
110 | 114 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
124 | 128 |
|
125 | 129 |
public float[] getDist3D() |
126 | 130 |
{ |
127 |
return TouchControlTetrahedron.D3D; |
|
131 |
final float d = (SQ6/12)*mNumLayers[0]; |
|
132 |
return new float[] {d,d,d,d}; |
|
128 | 133 |
} |
129 | 134 |
|
130 | 135 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
133 | 138 |
{ |
134 | 139 |
float height= iconMode ? 0.001f : 0.048f; |
135 | 140 |
int[] angle = {60,50,40,32,28,23}; |
136 |
float R = 0.2f;
|
|
141 |
float R = 0.3f;
|
|
137 | 142 |
float S = 0.5f; |
138 | 143 |
int extraI = 0; |
139 | 144 |
int extraV = 0; |
Also available in: Unified diff
do not push concave vertices in.