Revision 49f67f9b
Added by Leszek Koltunski about 4 years ago
src/main/java/org/distorted/object/RubikPyraminx.java | ||
---|---|---|
46 | 46 |
private static final Static3D[] AXIS = new Static3D[] |
47 | 47 |
{ |
48 | 48 |
new Static3D( 0, 1, 0 ), |
49 |
new Static3D( SQ2*SQ3/3, -1.0f/3, -SQ2/3 ),
|
|
49 |
new Static3D( 0, -1.0f/3, 2*SQ2/3 ),
|
|
50 | 50 |
new Static3D(-SQ2*SQ3/3, -1.0f/3, -SQ2/3 ), |
51 |
new Static3D( 0, -1.0f/3, 2*SQ2/3 )
|
|
51 |
new Static3D( SQ2*SQ3/3, -1.0f/3, -SQ2/3 )
|
|
52 | 52 |
}; |
53 | 53 |
|
54 | 54 |
private static final int[] FACE_COLORS = new int[] |
... | ... | |
64 | 64 |
SQ3/3, -SQ3/3, SQ3/6, -SQ3/6, SQ2*SQ3/3, -SQ2*SQ3/3, SQ2*SQ3/6, -SQ2*SQ3/6 |
65 | 65 |
}; |
66 | 66 |
|
67 |
private Static4D[] mRotArray; |
|
68 |
|
|
67 | 69 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
68 | 70 |
|
69 | 71 |
RubikPyraminx(int size, Static4D quatCur, Static4D quatAcc, DistortedTexture texture, MeshRectangles mesh, DistortedEffects effects) |
... | ... | |
73 | 75 |
|
74 | 76 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
75 | 77 |
|
78 |
private void emitRow(float x, float y, float z, float dx, float dy, float dz, int n, Static4D rot, Static3D[] array, int index) |
|
79 |
{ |
|
80 |
for(int i=0; i<n; i++) |
|
81 |
{ |
|
82 |
mRotArray[i+index] = rot; |
|
83 |
array[i+index] = new Static3D(x+0.5f,y+SQ2*SQ3/12,z+SQ3/6); |
|
84 |
x += dx; |
|
85 |
y += dy; |
|
86 |
z += dz; |
|
87 |
} |
|
88 |
} |
|
89 |
|
|
90 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
91 |
|
|
92 |
private int emitLowermost(float x, float y, float z, int n, Static3D[] array) |
|
93 |
{ |
|
94 |
int added = 0; |
|
95 |
|
|
96 |
for(int i=n; i>=1; i--) |
|
97 |
{ |
|
98 |
emitRow(x,y,z, 1,0,0, i, null, array, added); |
|
99 |
added += i; |
|
100 |
x += 0.5f; |
|
101 |
y += 0.0f; |
|
102 |
z += SQ3/2; |
|
103 |
} |
|
104 |
|
|
105 |
return added; |
|
106 |
} |
|
107 |
|
|
108 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
109 |
|
|
110 |
private int emitUpper(float x, float y, float z, int n, Static3D[] array, int index) |
|
111 |
{ |
|
112 |
if( n>1 ) |
|
113 |
{ |
|
114 |
emitRow(x,y,z, 1,0,0, n-1, null, array, index); |
|
115 |
index += (n-1); |
|
116 |
emitRow(x+0.5f,y,z+SQ3/2, 0.5f,0,SQ3/2, n-1, null, array, index); |
|
117 |
index += (n-1); |
|
118 |
emitRow( x+n-1,y,z, -0.5f, 0, SQ3/2, n-1, null, array, index); |
|
119 |
index += (n-1); |
|
120 |
} |
|
121 |
else |
|
122 |
{ |
|
123 |
mRotArray[index] = null; |
|
124 |
array[index] = new Static3D(x+0.5f,y+SQ2*SQ3/12,z+SQ3/6); |
|
125 |
index++; |
|
126 |
} |
|
127 |
|
|
128 |
return index; |
|
129 |
} |
|
130 |
|
|
131 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
132 |
// size^2 + 3*(size-1) in the lowermost layer, then 6*(size-2) in the next, 6*(size-3) in the next, |
|
133 |
// ... 6 in the forelast, 1 in the last = 4size^2 - 6size +4 (if size>1) |
|
134 |
|
|
76 | 135 |
Static3D[] getCubitPositions(int size) |
77 | 136 |
{ |
78 |
int numCubits = (size*size*size + 6*size*size -4*size)/3;
|
|
137 |
int numCubits = size>1 ? 2*size*size-4*size+4:1;//4*size*size - 6*size +4 : 1;
|
|
79 | 138 |
Static3D[] tmp = new Static3D[numCubits]; |
139 |
mRotArray = new Static4D[numCubits]; |
|
140 |
|
|
141 |
int currentIndex = emitLowermost( -0.5f*size, -(SQ2*SQ3/12)*size, -(SQ3/6)*size, size, tmp); |
|
80 | 142 |
|
81 |
int currentPosition = 0; |
|
82 |
/* |
|
83 |
?? |
|
143 |
for(int i=size-1; i>=1; i--) |
|
84 | 144 |
{ |
85 |
tmp[currentPosition++] = new Static3D(x,y,z);
|
|
145 |
currentIndex = emitUpper( -0.5f*i, ((SQ2*SQ3)/12)*(3*size-4*i), -(SQ3/6)*i, i, tmp, currentIndex);
|
|
86 | 146 |
} |
87 |
*/ |
|
147 |
|
|
88 | 148 |
return tmp; |
89 | 149 |
} |
90 | 150 |
|
... | ... | |
116 | 176 |
int xoffset = face*TEXTURE_HEIGHT; |
117 | 177 |
float STROKE = 0.05f*TEXTURE_HEIGHT; |
118 | 178 |
float OFF = STROKE/2 -1; |
119 |
float OFF2 = 0.577f*TEXTURE_HEIGHT + OFF;
|
|
179 |
float OFF2 = 0.5f*TEXTURE_HEIGHT + OFF; |
|
120 | 180 |
float HEIGHT = TEXTURE_HEIGHT - OFF; |
121 | 181 |
float RADIUS = TEXTURE_HEIGHT/12; |
122 |
float ARC1_H = 0.31f*TEXTURE_HEIGHT;
|
|
182 |
float ARC1_H = 0.2f*TEXTURE_HEIGHT;
|
|
123 | 183 |
float ARC1_W = TEXTURE_HEIGHT*0.5f; |
124 |
float ARC2_W = 0.152f*TEXTURE_HEIGHT;
|
|
125 |
float ARC2_H = 0.91f*TEXTURE_HEIGHT;
|
|
126 |
float ARC3_W = 0.847f*TEXTURE_HEIGHT;
|
|
184 |
float ARC2_W = 0.153f*TEXTURE_HEIGHT;
|
|
185 |
float ARC2_H = 0.905f*TEXTURE_HEIGHT;
|
|
186 |
float ARC3_W = TEXTURE_HEIGHT-ARC2_W;
|
|
127 | 187 |
|
128 | 188 |
paint.setAntiAlias(true); |
129 | 189 |
paint.setStrokeWidth(STROKE); |
Also available in: Unified diff
Progress with Pyraminx.