Revision f10a88a8
Added by Leszek Koltunski over 3 years ago
src/main/java/org/distorted/objects/TwistyBandagedAbstract.java | ||
---|---|---|
22 | 22 |
import android.content.res.Resources; |
23 | 23 |
|
24 | 24 |
import org.distorted.helpers.FactoryCubit; |
25 |
import org.distorted.helpers.ObjectShape; |
|
25 | 26 |
import org.distorted.helpers.ObjectSticker; |
26 | 27 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
27 | 28 |
import org.distorted.library.main.DistortedEffects; |
... | ... | |
165 | 166 |
|
166 | 167 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
167 | 168 |
|
168 |
int getCubitVariant(int cubit) |
|
169 |
int getNumCubits() |
|
170 |
{ |
|
171 |
return getPositions().length; |
|
172 |
} |
|
173 |
|
|
174 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
175 |
|
|
176 |
private float[] getCubitPosition(int cubit) |
|
169 | 177 |
{ |
170 | 178 |
float[][] pos = getPositions(); |
171 | 179 |
|
172 |
if( cubit>=0 && cubit<pos.length ) |
|
173 |
{ |
|
174 |
int numPoints = pos[cubit].length/3; |
|
175 |
return numPoints==8 ? 4 : numPoints-1; |
|
176 |
} |
|
180 |
return ( cubit>=0 && cubit< pos.length ) ? pos[cubit] : null; |
|
181 |
} |
|
177 | 182 |
|
178 |
return 1; |
|
183 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
184 |
|
|
185 |
private int getQuatIndex(int cubit) |
|
186 |
{ |
|
187 |
int[] indices = getQuatIndices(); |
|
188 |
return ( cubit>=0 && cubit< indices.length ) ? indices[cubit] : 0; |
|
179 | 189 |
} |
180 | 190 |
|
181 | 191 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
182 | 192 |
|
183 |
int getNumCubits()
|
|
193 |
private Static4D getQuat(int cubit, int numLayers)
|
|
184 | 194 |
{ |
185 |
return getPositions().length;
|
|
195 |
return INIT_QUATS[getQuatIndex(cubit)];
|
|
186 | 196 |
} |
187 | 197 |
|
188 | 198 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
189 | 199 |
|
190 |
private float[] getCubitPosition(int cubit) |
|
200 |
private int getNumCubitVariants(int numLayers) |
|
201 |
{ |
|
202 |
return mDimensions.length; |
|
203 |
} |
|
204 |
|
|
205 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
206 |
|
|
207 |
int getCubitVariant(int cubit, int numLayers) |
|
191 | 208 |
{ |
192 | 209 |
float[][] pos = getPositions(); |
193 | 210 |
|
194 |
return ( cubit>=0 && cubit< pos.length ) ? pos[cubit] : null; |
|
211 |
if( cubit>=0 && cubit<pos.length ) |
|
212 |
{ |
|
213 |
int numPoints = pos[cubit].length/3; |
|
214 |
return numPoints==8 ? 4 : numPoints-1; |
|
215 |
} |
|
216 |
|
|
217 |
return 1; |
|
195 | 218 |
} |
196 | 219 |
|
197 | 220 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
198 | 221 |
|
199 |
private int getQuatIndex(int cubit)
|
|
222 |
ObjectShape getObjectShape(int cubit, int numLayers)
|
|
200 | 223 |
{ |
201 |
int[] indices = getQuatIndices();
|
|
224 |
int variant = getCubitVariant(cubit,numLayers);
|
|
202 | 225 |
|
203 |
return ( cubit>=0 && cubit< indices.length ) ? indices[cubit] : 0; |
|
226 |
final int[][] vert_indices = |
|
227 |
{ |
|
228 |
{2,3,1,0}, |
|
229 |
{7,6,4,5}, |
|
230 |
{4,0,1,5}, |
|
231 |
{7,3,2,6}, |
|
232 |
{6,2,0,4}, |
|
233 |
{3,7,5,1}, |
|
234 |
}; |
|
235 |
|
|
236 |
float defHeight = 0.048f; |
|
237 |
int[] bandIndices = new int[] { 0,0,1,1,2,2 }; |
|
238 |
float[][] corners = new float[][] { {0.04f,0.15f} }; |
|
239 |
int[] cornerIndices = new int[] { 0,0,0,0,0,0,0,0 }; |
|
240 |
int[] centerIndices = new int[] { 0,1,2,3,4,5,6,7 }; |
|
241 |
|
|
242 |
int X = mDimensions[variant][0]; |
|
243 |
int Y = mDimensions[variant][1]; |
|
244 |
int Z = mDimensions[variant][2]; |
|
245 |
|
|
246 |
int maxXY = Math.max(X,Y); |
|
247 |
int maxXZ = Math.max(X,Z); |
|
248 |
int maxYZ = Math.max(Y,Z); |
|
249 |
|
|
250 |
double[][] vertices = |
|
251 |
{ |
|
252 |
{+0.5f*X,+0.5f*Y,+0.5f*Z}, |
|
253 |
{+0.5f*X,+0.5f*Y,-0.5f*Z}, |
|
254 |
{+0.5f*X,-0.5f*Y,+0.5f*Z}, |
|
255 |
{+0.5f*X,-0.5f*Y,-0.5f*Z}, |
|
256 |
{-0.5f*X,+0.5f*Y,+0.5f*Z}, |
|
257 |
{-0.5f*X,+0.5f*Y,-0.5f*Z}, |
|
258 |
{-0.5f*X,-0.5f*Y,+0.5f*Z}, |
|
259 |
{-0.5f*X,-0.5f*Y,-0.5f*Z} |
|
260 |
}; |
|
261 |
|
|
262 |
float[][] bands= new float[][] |
|
263 |
{ |
|
264 |
{defHeight/maxYZ,65,0.25f,0.5f,5,1,2}, |
|
265 |
{defHeight/maxXZ,65,0.25f,0.5f,5,1,2}, |
|
266 |
{defHeight/maxXY,65,0.25f,0.5f,5,1,2} |
|
267 |
}; |
|
268 |
|
|
269 |
float[][] centers = new float[][] |
|
270 |
{ |
|
271 |
{+0.5f*(X-1),+0.5f*(Y-1),+0.5f*(Z-1)}, |
|
272 |
{+0.5f*(X-1),+0.5f*(Y-1),-0.5f*(Z-1)}, |
|
273 |
{+0.5f*(X-1),-0.5f*(Y-1),+0.5f*(Z-1)}, |
|
274 |
{+0.5f*(X-1),-0.5f*(Y-1),-0.5f*(Z-1)}, |
|
275 |
{-0.5f*(X-1),+0.5f*(Y-1),+0.5f*(Z-1)}, |
|
276 |
{-0.5f*(X-1),+0.5f*(Y-1),-0.5f*(Z-1)}, |
|
277 |
{-0.5f*(X-1),-0.5f*(Y-1),+0.5f*(Z-1)}, |
|
278 |
{-0.5f*(X-1),-0.5f*(Y-1),-0.5f*(Z-1)} |
|
279 |
}; |
|
280 |
|
|
281 |
return new ObjectShape(vertices,vert_indices,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null); |
|
204 | 282 |
} |
205 | 283 |
|
206 | 284 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
207 | 285 |
|
208 | 286 |
MeshBase createCubitMesh(int cubit, int numLayers) |
209 | 287 |
{ |
288 |
int variant = getCubitVariant(cubit,numLayers); |
|
289 |
|
|
210 | 290 |
if( mMeshes==null ) |
211 | 291 |
{ |
212 | 292 |
FactoryCubit factory = FactoryCubit.getInstance(); |
213 | 293 |
factory.clear(); |
214 |
int LEN = mDimensions.length; |
|
215 |
mMeshes = new MeshBase[LEN]; |
|
216 |
|
|
217 |
final int[][] vert_indices = |
|
218 |
{ |
|
219 |
{2,3,1,0}, |
|
220 |
{7,6,4,5}, |
|
221 |
{4,0,1,5}, |
|
222 |
{7,3,2,6}, |
|
223 |
{6,2,0,4}, |
|
224 |
{3,7,5,1}, |
|
225 |
}; |
|
226 |
|
|
227 |
float defHeight = 0.048f; |
|
228 |
int[] bandIndexes = new int[] { 0,0,1,1,2,2 }; |
|
229 |
float[][] corners = new float[][] { {0.04f,0.15f} }; |
|
230 |
int[] cornerIndexes = new int[] { 0,0,0,0,0,0,0,0 }; |
|
231 |
int[] centerIndexes = new int[] { 0,1,2,3,4,5,6,7 }; |
|
232 |
|
|
233 |
for(int i=0; i<LEN; i++) |
|
234 |
{ |
|
235 |
int X = mDimensions[i][0]; |
|
236 |
int Y = mDimensions[i][1]; |
|
237 |
int Z = mDimensions[i][2]; |
|
238 |
|
|
239 |
int maxXY = Math.max(X,Y); |
|
240 |
int maxXZ = Math.max(X,Z); |
|
241 |
int maxYZ = Math.max(Y,Z); |
|
242 |
|
|
243 |
double[][] vertices = |
|
244 |
{ |
|
245 |
{+0.5f*X,+0.5f*Y,+0.5f*Z}, |
|
246 |
{+0.5f*X,+0.5f*Y,-0.5f*Z}, |
|
247 |
{+0.5f*X,-0.5f*Y,+0.5f*Z}, |
|
248 |
{+0.5f*X,-0.5f*Y,-0.5f*Z}, |
|
249 |
{-0.5f*X,+0.5f*Y,+0.5f*Z}, |
|
250 |
{-0.5f*X,+0.5f*Y,-0.5f*Z}, |
|
251 |
{-0.5f*X,-0.5f*Y,+0.5f*Z}, |
|
252 |
{-0.5f*X,-0.5f*Y,-0.5f*Z} |
|
253 |
}; |
|
254 |
|
|
255 |
float[][] bands= new float[][] |
|
256 |
{ |
|
257 |
{defHeight/maxYZ,65,0.25f,0.5f,5,1,2}, |
|
258 |
{defHeight/maxXZ,65,0.25f,0.5f,5,1,2}, |
|
259 |
{defHeight/maxXY,65,0.25f,0.5f,5,1,2} |
|
260 |
}; |
|
261 |
|
|
262 |
float[][] centers = new float[][] |
|
263 |
{ |
|
264 |
{+0.5f*(X-1),+0.5f*(Y-1),+0.5f*(Z-1)}, |
|
265 |
{+0.5f*(X-1),+0.5f*(Y-1),-0.5f*(Z-1)}, |
|
266 |
{+0.5f*(X-1),-0.5f*(Y-1),+0.5f*(Z-1)}, |
|
267 |
{+0.5f*(X-1),-0.5f*(Y-1),-0.5f*(Z-1)}, |
|
268 |
{-0.5f*(X-1),+0.5f*(Y-1),+0.5f*(Z-1)}, |
|
269 |
{-0.5f*(X-1),+0.5f*(Y-1),-0.5f*(Z-1)}, |
|
270 |
{-0.5f*(X-1),-0.5f*(Y-1),+0.5f*(Z-1)}, |
|
271 |
{-0.5f*(X-1),-0.5f*(Y-1),-0.5f*(Z-1)} |
|
272 |
}; |
|
273 |
|
|
274 |
factory.createNewFaceTransform(vertices,vert_indices); |
|
275 |
mMeshes[i] = factory.createRoundedSolid(vertices,vert_indices, |
|
276 |
bands, bandIndexes, |
|
277 |
corners, cornerIndexes, |
|
278 |
centers, centerIndexes, |
|
279 |
getNumCubitFaces(), null ); |
|
280 |
} |
|
294 |
mMeshes = new MeshBase[getNumCubitVariants(numLayers)]; |
|
295 |
} |
|
296 |
|
|
297 |
if( mMeshes[variant]==null ) |
|
298 |
{ |
|
299 |
ObjectShape shape = getObjectShape(cubit,numLayers); |
|
300 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
301 |
factory.createNewFaceTransform(shape); |
|
302 |
mMeshes[variant] = factory.createRoundedSolid(shape); |
|
281 | 303 |
} |
282 | 304 |
|
283 |
int variant = getCubitVariant(cubit); |
|
284 | 305 |
MeshBase mesh = mMeshes[variant].copy(true); |
285 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( INIT_QUATS[getQuatIndex(cubit)], new Static3D(0,0,0) );
|
|
306 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit,numLayers), new Static3D(0,0,0) );
|
|
286 | 307 |
mesh.apply(quat,0xffffffff,0); |
287 | 308 |
|
288 | 309 |
return mesh; |
... | ... | |
408 | 429 |
|
409 | 430 |
int getFaceColor(int cubit, int cubitface, int numLayers) |
410 | 431 |
{ |
411 |
int variant = getCubitVariant(cubit); |
|
432 |
int variant = getCubitVariant(cubit,numLayers);
|
|
412 | 433 |
int[] dim = mDimensions[variant]; |
413 | 434 |
float[] pos = getCubitPosition(cubit); |
414 | 435 |
int stickerIndex = getStickerIndex(cubitface,dim); |
src/main/java/org/distorted/objects/TwistyCube.java | ||
---|---|---|
22 | 22 |
import android.content.res.Resources; |
23 | 23 |
|
24 | 24 |
import org.distorted.helpers.FactoryCubit; |
25 |
import org.distorted.helpers.ObjectShape; |
|
25 | 26 |
import org.distorted.helpers.ObjectSticker; |
27 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
|
26 | 28 |
import org.distorted.library.main.DistortedEffects; |
27 | 29 |
import org.distorted.library.main.DistortedTexture; |
28 | 30 |
import org.distorted.library.mesh.MeshBase; |
... | ... | |
137 | 139 |
super(size, size, quat, texture, mesh, effects, moves, ObjectList.CUBE, res, scrWidth); |
138 | 140 |
} |
139 | 141 |
|
142 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
143 |
|
|
144 |
private Static4D getQuat(int cubit, int numLayers) |
|
145 |
{ |
|
146 |
return QUATS[0]; |
|
147 |
} |
|
148 |
|
|
149 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
150 |
|
|
151 |
private int getNumCubitVariants(int numLayers) |
|
152 |
{ |
|
153 |
return 1; |
|
154 |
} |
|
155 |
|
|
156 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
157 |
|
|
158 |
int getCubitVariant(int cubit, int numLayers) |
|
159 |
{ |
|
160 |
return 0; |
|
161 |
} |
|
162 |
|
|
163 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
164 |
|
|
165 |
ObjectShape getObjectShape(int cubit, int numLayers) |
|
166 |
{ |
|
167 |
int extraI, extraV, num; |
|
168 |
float height; |
|
169 |
|
|
170 |
switch(numLayers) |
|
171 |
{ |
|
172 |
case 2 : num = 6; extraI = 2; extraV = 2; height = 0.045f; break; |
|
173 |
case 3 : num = 5; extraI = 2; extraV = 2; height = 0.045f; break; |
|
174 |
case 4 : num = 5; extraI = 1; extraV = 1; height = 0.045f; break; |
|
175 |
default: num = 5; extraI = 0; extraV = 0; height = 0.045f; break; |
|
176 |
} |
|
177 |
|
|
178 |
float[][] bands = new float[][] { {height,35,0.5f,0.7f,num,extraI,extraV} }; |
|
179 |
int[] bandIndices = new int[] { 0,0,0,0,0,0}; |
|
180 |
float[][] corners = new float[][] { {0.036f,0.12f} }; |
|
181 |
int[] cornerIndices = new int[] { 0,0,0,0,0,0,0,0 }; |
|
182 |
float[][] centers = new float[][] { {0.0f, 0.0f, 0.0f} }; |
|
183 |
int[] centerIndices = new int[] { 0,0,0,0,0,0,0,0 }; |
|
184 |
|
|
185 |
return new ObjectShape(VERTICES,VERT_INDEXES,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null); |
|
186 |
} |
|
187 |
|
|
140 | 188 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
141 | 189 |
|
142 | 190 |
MeshBase createCubitMesh(int cubit, int numLayers) |
143 | 191 |
{ |
192 |
int variant = getCubitVariant(cubit,numLayers); |
|
193 |
|
|
144 | 194 |
if( mMeshes==null ) |
145 | 195 |
{ |
146 | 196 |
FactoryCubit factory = FactoryCubit.getInstance(); |
147 | 197 |
factory.clear(); |
148 |
mMeshes = new MeshBase[1];
|
|
198 |
mMeshes = new MeshBase[getNumCubitVariants(numLayers)];
|
|
149 | 199 |
} |
150 | 200 |
|
151 |
if( mMeshes[0]==null )
|
|
201 |
if( mMeshes[variant]==null )
|
|
152 | 202 |
{ |
153 |
int extraI, extraV, num; |
|
154 |
float height; |
|
155 |
|
|
156 |
switch(numLayers) |
|
157 |
{ |
|
158 |
case 2 : num = 6; extraI = 2; extraV = 2; height = 0.045f; break; |
|
159 |
case 3 : num = 5; extraI = 2; extraV = 2; height = 0.045f; break; |
|
160 |
case 4 : num = 5; extraI = 1; extraV = 1; height = 0.045f; break; |
|
161 |
default: num = 5; extraI = 0; extraV = 0; height = 0.045f; break; |
|
162 |
} |
|
163 |
|
|
164 |
float[][] bands = new float[][] { {height,35,0.5f,0.7f,num,extraI,extraV} }; |
|
165 |
int[] bandIndexes = new int[] { 0,0,0,0,0,0}; |
|
166 |
float[][] corners = new float[][] { {0.036f,0.12f} }; |
|
167 |
int[] cornerIndexes = new int[] { 0,0,0,0,0,0,0,0 }; |
|
168 |
float[][] centers = new float[][] { {0.0f, 0.0f, 0.0f} }; |
|
169 |
int[] centerIndexes = new int[] { 0,0,0,0,0,0,0,0 }; |
|
170 |
|
|
203 |
ObjectShape shape = getObjectShape(cubit,numLayers); |
|
171 | 204 |
FactoryCubit factory = FactoryCubit.getInstance(); |
172 |
|
|
173 |
factory.createNewFaceTransform(VERTICES,VERT_INDEXES); |
|
174 |
mMeshes[0] = factory.createRoundedSolid(VERTICES, VERT_INDEXES, |
|
175 |
bands, bandIndexes, |
|
176 |
corners, cornerIndexes, |
|
177 |
centers, centerIndexes, |
|
178 |
getNumCubitFaces(), null ); |
|
205 |
factory.createNewFaceTransform(shape); |
|
206 |
mMeshes[variant] = factory.createRoundedSolid(shape); |
|
179 | 207 |
} |
180 | 208 |
|
181 |
return mMeshes[0].copy(true); |
|
209 |
MeshBase mesh = mMeshes[variant].copy(true); |
|
210 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit,numLayers), new Static3D(0,0,0) ); |
|
211 |
mesh.apply(quat,0xffffffff,0); |
|
212 |
|
|
213 |
return mesh; |
|
182 | 214 |
} |
183 | 215 |
|
184 | 216 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
277 | 309 |
|
278 | 310 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
279 | 311 |
|
280 |
int getFaceColor(int cubit, int cubitface, int size)
|
|
312 |
int getFaceColor(int cubit, int cubitface, int numLayers)
|
|
281 | 313 |
{ |
282 |
return CUBITS[cubit].mRotationRow[cubitface/2] == (cubitface%2==0 ? (1<<(size-1)):1) ? cubitface : NUM_FACES;
|
|
314 |
return CUBITS[cubit].mRotationRow[cubitface/2] == (cubitface%2==0 ? (1<<(numLayers-1)):1) ? cubitface : NUM_FACES;
|
|
283 | 315 |
} |
284 | 316 |
|
285 | 317 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
src/main/java/org/distorted/objects/TwistyDiamond.java | ||
---|---|---|
22 | 22 |
import android.content.res.Resources; |
23 | 23 |
|
24 | 24 |
import org.distorted.helpers.FactoryCubit; |
25 |
import org.distorted.helpers.ObjectShape; |
|
25 | 26 |
import org.distorted.helpers.ObjectSticker; |
26 | 27 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
27 | 28 |
import org.distorted.library.main.DistortedEffects; |
... | ... | |
378 | 379 |
|
379 | 380 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
380 | 381 |
|
381 |
private Static4D getQuat(int cubit, int numLayers, int numO)
|
|
382 |
private Static4D getQuat(int cubit, int numLayers) |
|
382 | 383 |
{ |
384 |
int numO = getNumOctahedrons(numLayers); |
|
385 |
|
|
383 | 386 |
if( cubit<numO ) return QUATS[0]; |
384 | 387 |
|
385 | 388 |
switch( retFaceTetraBelongsTo(cubit-numO, numLayers) ) |
... | ... | |
399 | 402 |
|
400 | 403 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
401 | 404 |
|
402 |
MeshBase createCubitMesh(int cubit, int numLayers)
|
|
405 |
private int getNumCubitVariants(int numLayers)
|
|
403 | 406 |
{ |
404 |
if( mMeshes==null ) |
|
405 |
{ |
|
406 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
407 |
factory.clear(); |
|
408 |
mMeshes = new MeshBase[2]; |
|
409 |
} |
|
407 |
return 2; |
|
408 |
} |
|
410 | 409 |
|
411 |
MeshBase mesh; |
|
412 |
int numO = getNumOctahedrons(numLayers); |
|
410 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
411 |
|
|
412 |
int getCubitVariant(int cubit, int numLayers) |
|
413 |
{ |
|
414 |
return cubit<getNumOctahedrons(numLayers) ? 0 : 1; |
|
415 |
} |
|
416 |
|
|
417 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
418 |
|
|
419 |
ObjectShape getObjectShape(int cubit, int numLayers) |
|
420 |
{ |
|
421 |
int variant = getCubitVariant(cubit,numLayers); |
|
413 | 422 |
int N = numLayers>3 ? 5:6; |
414 | 423 |
int E = numLayers>3 ? 1:2; |
415 | 424 |
|
416 |
if( cubit<numO )
|
|
425 |
if( variant==0 )
|
|
417 | 426 |
{ |
418 |
if( mMeshes[0]==null ) |
|
419 |
{ |
|
420 |
float[][] bands = new float[][] { {0.05f,35,0.5f,0.8f,N,E,E} }; |
|
421 |
int[] bandIndexes = new int[] { 0,0,0,0,0,0,0,0 }; |
|
422 |
float[][] corners = new float[][] { {0.04f,0.20f} }; |
|
423 |
int[] cornerIndexes = new int[] { 0,0,0,0,0,0 }; |
|
424 |
float[][] centers = new float[][] { {0.0f, 0.0f, 0.0f} }; |
|
425 |
int[] centerIndexes = new int[] { 0,0,0,0,0,0 }; |
|
426 |
|
|
427 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
428 |
|
|
429 |
factory.createNewFaceTransform(VERTICES_OCTA,VERT_INDEXES_OCTA); |
|
430 |
mMeshes[0] = factory.createRoundedSolid(VERTICES_OCTA, VERT_INDEXES_OCTA, |
|
431 |
bands, bandIndexes, |
|
432 |
corners, cornerIndexes, |
|
433 |
centers, centerIndexes, |
|
434 |
getNumCubitFaces(), null ); |
|
435 |
} |
|
436 |
mesh = mMeshes[0].copy(true); |
|
427 |
float[][] bands = new float[][] { {0.05f,35,0.5f,0.8f,N,E,E} }; |
|
428 |
int[] bandIndices = new int[] { 0,0,0,0,0,0,0,0 }; |
|
429 |
float[][] corners = new float[][] { {0.04f,0.20f} }; |
|
430 |
int[] cornerIndices = new int[] { 0,0,0,0,0,0 }; |
|
431 |
float[][] centers = new float[][] { {0.0f, 0.0f, 0.0f} }; |
|
432 |
int[] centerIndices = new int[] { 0,0,0,0,0,0 }; |
|
433 |
return new ObjectShape(VERTICES_OCTA,VERT_INDEXES_OCTA,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null); |
|
437 | 434 |
} |
438 | 435 |
else |
439 | 436 |
{ |
440 |
if( mMeshes[1]==null ) |
|
441 |
{ |
|
442 |
float[][] bands = new float[][] { {0.05f,35,0.5f,0.8f,N,E,E} }; |
|
443 |
int[] bandIndexes = new int[] { 0,0,0,0 }; |
|
444 |
float[][] corners = new float[][] { {0.08f,0.15f} }; |
|
445 |
int[] cornerIndexes = new int[] { 0,0,0,0 }; |
|
446 |
float[][] centers = new float[][] { {0.0f, 0.0f, 0.0f} }; |
|
447 |
int[] centerIndexes = new int[] { 0,0,0,0 }; |
|
448 |
|
|
449 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
450 |
|
|
451 |
factory.createNewFaceTransform(VERTICES_TETRA,VERT_INDEXES_TETRA); |
|
452 |
mMeshes[1] = factory.createRoundedSolid(VERTICES_TETRA, VERT_INDEXES_TETRA, |
|
453 |
bands, bandIndexes, |
|
454 |
corners, cornerIndexes, |
|
455 |
centers, centerIndexes, |
|
456 |
getNumCubitFaces(), null ); |
|
457 |
} |
|
458 |
mesh = mMeshes[1].copy(true); |
|
437 |
float[][] bands = new float[][] { {0.05f,35,0.5f,0.8f,N,E,E} }; |
|
438 |
int[] bandIndices = new int[] { 0,0,0,0 }; |
|
439 |
float[][] corners = new float[][] { {0.08f,0.15f} }; |
|
440 |
int[] cornerIndices = new int[] { 0,0,0,0 }; |
|
441 |
float[][] centers = new float[][] { {0.0f, 0.0f, 0.0f} }; |
|
442 |
int[] centerIndices = new int[] { 0,0,0,0 }; |
|
443 |
return new ObjectShape(VERTICES_TETRA,VERT_INDEXES_TETRA,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null); |
|
444 |
} |
|
445 |
} |
|
446 |
|
|
447 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
448 |
|
|
449 |
MeshBase createCubitMesh(int cubit, int numLayers) |
|
450 |
{ |
|
451 |
int variant = getCubitVariant(cubit,numLayers); |
|
452 |
|
|
453 |
if( mMeshes==null ) |
|
454 |
{ |
|
455 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
456 |
factory.clear(); |
|
457 |
mMeshes = new MeshBase[getNumCubitVariants(numLayers)]; |
|
458 |
} |
|
459 |
|
|
460 |
if( mMeshes[variant]==null ) |
|
461 |
{ |
|
462 |
ObjectShape shape = getObjectShape(cubit,numLayers); |
|
463 |
FactoryCubit factory = FactoryCubit.getInstance(); |
|
464 |
factory.createNewFaceTransform(shape); |
|
465 |
mMeshes[variant] = factory.createRoundedSolid(shape); |
|
459 | 466 |
} |
460 | 467 |
|
461 |
Static4D sQ = getQuat(cubit,numLayers,numO);
|
|
462 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( sQ, new Static3D(0,0,0) );
|
|
468 |
MeshBase mesh = mMeshes[variant].copy(true);
|
|
469 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit,numLayers), new Static3D(0,0,0) );
|
|
463 | 470 |
mesh.apply(quat,0xffffffff,0); |
464 | 471 |
|
465 | 472 |
return mesh; |
src/main/java/org/distorted/objects/TwistyDino.java | ||
---|---|---|
22 | 22 |
import android.content.res.Resources; |
23 | 23 |
|
24 | 24 |
import org.distorted.helpers.FactoryCubit; |
25 |
import org.distorted.helpers.ObjectShape; |
|
25 | 26 |
import org.distorted.helpers.ObjectSticker; |
26 | 27 |
import org.distorted.library.effect.MatrixEffectQuaternion; |
27 | 28 |
import org.distorted.library.main.DistortedEffects; |
... | ... | |
177 | 178 |
return CENTERS; |
178 | 179 |
} |
179 | 180 |
|
181 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
182 |
|
|
183 |
private Static4D getQuat(int cubit, int numLayers) |
|
184 |
{ |
|
185 |
return QUATS[cubit]; |
|
186 |
} |
|
187 |
|
|
188 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
189 |
|
|
190 |
private int getNumCubitVariants(int numLayers) |
|
191 |
{ |
|
192 |
return 1; |
|
193 |
} |
|
194 |
|
|
195 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
196 |
|
|
197 |
int getCubitVariant(int cubit, int numLayers) |
|
198 |
{ |
|
199 |
return 0; |
|
200 |
} |
|
201 |
|
|
202 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
203 |
|
|
204 |
ObjectShape getObjectShape(int cubit, int numLayers) |
|
205 |
{ |
|
206 |
float[][] bands= new float[][] { {0.035f,30,0.16f,0.8f,6,2,2}, {0.010f,30,0.16f,0.2f,6,2,2} }; |
|
207 |
int[] bandIndices = new int[] { 0,0,1,1 }; |
|
208 |
float[][] corners = new float[][] { {0.07f,0.40f}, {0.05f,0.30f} }; |
|
209 |
int[] cornerIndices = new int[] { 0,0,1,1 }; |
|
210 |
float[][] centers = new float[][] { {0.0f, -0.75f, -0.75f} }; |
|
211 |
int[] centerIndices = new int[] { 0,0,0,0 }; |
|
212 |
|
|
213 |
return new ObjectShape(VERTICES,VERT_INDEXES,bands,bandIndices,corners,cornerIndices,centers,centerIndices,getNumCubitFaces(), null); |
|
214 |
} |
|
215 |
|
|
180 | 216 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
181 | 217 |
|
182 | 218 |
MeshBase createCubitMesh(int cubit, int numLayers) |
183 | 219 |
{ |
220 |
int variant = getCubitVariant(cubit,numLayers); |
|
221 |
|
|
184 | 222 |
if( mMeshes==null ) |
185 | 223 |
{ |
186 | 224 |
FactoryCubit factory = FactoryCubit.getInstance(); |
187 | 225 |
factory.clear(); |
188 |
mMeshes = new MeshBase[1];
|
|
226 |
mMeshes = new MeshBase[getNumCubitVariants(numLayers)];
|
|
189 | 227 |
} |
190 | 228 |
|
191 |
if( mMeshes[0]==null )
|
|
229 |
if( mMeshes[variant]==null )
|
|
192 | 230 |
{ |
193 |
float[][] bands= new float[][] |
|
194 |
{ |
|
195 |
{0.035f,30,0.16f,0.8f,6,2,2}, |
|
196 |
{0.010f,30,0.16f,0.2f,6,2,2} |
|
197 |
}; |
|
198 |
int[] bandIndexes = new int[] { 0,0,1,1 }; |
|
199 |
float[][] corners = new float[][] { {0.07f,0.40f}, {0.05f,0.30f} }; |
|
200 |
int[] cornerIndexes = new int[] { 0,0,1,1 }; |
|
201 |
float[][] centers = new float[][] { {0.0f, -0.75f, -0.75f} }; |
|
202 |
int[] centerIndexes = new int[] { 0,0,0,0 }; |
|
203 |
|
|
231 |
ObjectShape shape = getObjectShape(cubit,numLayers); |
|
204 | 232 |
FactoryCubit factory = FactoryCubit.getInstance(); |
205 |
|
|
206 |
factory.createNewFaceTransform(VERTICES,VERT_INDEXES); |
|
207 |
mMeshes[0] = factory.createRoundedSolid(VERTICES, VERT_INDEXES, |
|
208 |
bands, bandIndexes, |
|
209 |
corners, cornerIndexes, |
|
210 |
centers, centerIndexes, |
|
211 |
getNumCubitFaces(), null ); |
|
233 |
factory.createNewFaceTransform(shape); |
|
234 |
mMeshes[variant] = factory.createRoundedSolid(shape); |
|
212 | 235 |
} |
213 | 236 |
|
214 |
MeshBase mesh = mMeshes[0].copy(true);
|
|
215 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( QUATS[cubit], new Static3D(0,0,0) );
|
|
237 |
MeshBase mesh = mMeshes[variant].copy(true);
|
|
238 |
MatrixEffectQuaternion quat = new MatrixEffectQuaternion( getQuat(cubit,numLayers), new Static3D(0,0,0) );
|
|
216 | 239 |
mesh.apply(quat,0xffffffff,0); |
217 | 240 |
|
218 | 241 |
return mesh; |
src/main/java/org/distorted/objects/TwistyObject.java | ||
---|---|---|
246 | 246 |
int sizeIndex = ObjectList.getSizeIndex(list.ordinal(),mNumLayers); |
247 | 247 |
int resourceID= list.getResourceIDs()[sizeIndex]; |
248 | 248 |
|
249 |
if( resourceID!=0 ) |
|
249 |
if( false)//resourceID!=0 )
|
|
250 | 250 |
{ |
251 | 251 |
InputStream is = res.openRawResource(resourceID); |
252 | 252 |
DataInputStream dos = new DataInputStream(is); |
Also available in: Unified diff
Move 1) bandaged 3x3 2) normals cubes 3) octahedrons 4) both dinos to the new cubit creation scheme.