Revision ccf9fec5
Added by Leszek Koltunski almost 4 years ago
src/main/java/org/distorted/objects/RubikObjectList.java | ||
---|---|---|
19 | 19 |
|
20 | 20 |
package org.distorted.objects; |
21 | 21 |
|
22 |
import android.content.res.Resources; |
|
23 |
|
|
22 | 24 |
import org.distorted.library.main.DistortedEffects; |
23 | 25 |
import org.distorted.library.main.DistortedTexture; |
24 | 26 |
import org.distorted.library.mesh.MeshRectangles; |
... | ... | |
33 | 35 |
{ |
34 | 36 |
CUBE ( |
35 | 37 |
new int[][] { |
36 |
{2 , 12, R.drawable.cube2} , |
|
37 |
{3 , 16, R.drawable.cube3} , |
|
38 |
{4 , 20, R.drawable.cube4} , |
|
39 |
{5 , 24, R.drawable.cube5} |
|
38 |
{2 , 12, R.drawable.cube2, R.raw.cube2} ,
|
|
39 |
{3 , 16, R.drawable.cube3, R.raw.cube3} ,
|
|
40 |
{4 , 20, R.drawable.cube4, R.raw.cube4} ,
|
|
41 |
{5 , 24, R.drawable.cube5, R.raw.cube5}
|
|
40 | 42 |
}, |
41 | 43 |
RubikCube.class, |
42 | 44 |
new RubikCubeMovement() |
... | ... | |
44 | 46 |
|
45 | 47 |
PYRA ( |
46 | 48 |
new int[][] { |
47 |
{3 , 10, R.drawable.pyra3} , |
|
48 |
{4 , 15, R.drawable.pyra4} , |
|
49 |
{5 , 20, R.drawable.pyra5} |
|
49 |
{3 , 10, R.drawable.pyra3, R.raw.pyra3} ,
|
|
50 |
{4 , 15, R.drawable.pyra4, R.raw.pyra4} ,
|
|
51 |
{5 , 20, R.drawable.pyra5, R.raw.pyra5}
|
|
50 | 52 |
}, |
51 | 53 |
RubikPyraminx.class, |
52 | 54 |
new RubikPyraminxMovement() |
... | ... | |
58 | 60 |
public static final int MAX_LEVEL; |
59 | 61 |
public static final int MAX_OBJECT_SIZE; |
60 | 62 |
|
61 |
private final int[] mObjectSizes, mMaxLevels, mIconIDs; |
|
63 |
private final int[] mObjectSizes, mMaxLevels, mIconIDs, mResourceIDs;
|
|
62 | 64 |
private final Class<? extends RubikObject> mObjectClass; |
63 | 65 |
private final RubikObjectMovement mObjectMovementClass; |
64 | 66 |
private static final RubikObjectList[] objects; |
... | ... | |
276 | 278 |
mObjectSizes= new int[length]; |
277 | 279 |
mMaxLevels = new int[length]; |
278 | 280 |
mIconIDs = new int[length]; |
281 |
mResourceIDs= new int[length]; |
|
279 | 282 |
|
280 | 283 |
for(int i=0; i<length; i++) |
281 | 284 |
{ |
282 | 285 |
mObjectSizes[i] = info[i][0]; |
283 | 286 |
mMaxLevels[i] = info[i][1]; |
284 | 287 |
mIconIDs[i] = info[i][2]; |
288 |
mResourceIDs[i] = info[i][3]; |
|
285 | 289 |
} |
286 | 290 |
|
287 | 291 |
mObjectClass = object; |
... | ... | |
311 | 315 |
|
312 | 316 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
313 | 317 |
|
314 |
public RubikObject create(int size, Static4D quatCur, Static4D quatAcc, int[][] moves) |
|
318 |
public int[] getResourceIDs() |
|
319 |
{ |
|
320 |
return mResourceIDs; |
|
321 |
} |
|
322 |
|
|
323 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
324 |
|
|
325 |
public RubikObject create(int size, Static4D quatCur, Static4D quatAcc, int[][] moves, Resources res) |
|
315 | 326 |
{ |
316 | 327 |
DistortedTexture texture = new DistortedTexture(); |
317 | 328 |
DistortedEffects effects = new DistortedEffects(); |
... | ... | |
319 | 330 |
|
320 | 331 |
switch(ordinal()) |
321 | 332 |
{ |
322 |
case 0: return new RubikCube (size, quatCur, quatAcc, texture, mesh, effects, moves); |
|
323 |
case 1: return new RubikPyraminx(size, quatCur, quatAcc, texture, mesh, effects, moves); |
|
333 |
case 0: return new RubikCube (size, quatCur, quatAcc, texture, mesh, effects, moves, res);
|
|
334 |
case 1: return new RubikPyraminx(size, quatCur, quatAcc, texture, mesh, effects, moves, res);
|
|
324 | 335 |
} |
325 | 336 |
|
326 | 337 |
return null; |
Also available in: Unified diff
Read the meshes from .dmesh files (rather than compute them dynamically).
This (along with single-mesh mode) hopefully makes the rendering much faster, while keeping the time needed for Object Change low.
The only downside: this increases the size of the release APK from 6 MB to 9.6 MB.