Revision 5b893eee
Added by Leszek Koltunski over 5 years ago
| src/main/java/org/distorted/effects/objectchange/ObjectChangeEffect.java | ||
|---|---|---|
| 72 | 72 |
private int[] mCubeEffectNumber, mNodeEffectNumber; |
| 73 | 73 |
private int[] mEffectFinished; |
| 74 | 74 |
private boolean[] mPhaseActive; |
| 75 |
private RubikObject[] mObject; |
|
| 76 | 75 |
|
| 76 |
RubikObject[] mObject; |
|
| 77 | 77 |
DistortedScreen mScreen; |
| 78 | 78 |
Effect[][] mCubeEffects; |
| 79 | 79 |
int[][] mCubeEffectPosition; |
| src/main/java/org/distorted/effects/objectchange/ObjectChangeEffectRound.java | ||
|---|---|---|
| 26 | 26 |
import org.distorted.library.type.Dynamic3D; |
| 27 | 27 |
import org.distorted.library.type.Static3D; |
| 28 | 28 |
|
| 29 |
import static org.distorted.objects.RubikObject.NODE_FBO_SIZE; |
|
| 30 |
|
|
| 31 | 29 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 32 | 30 |
|
| 33 | 31 |
class ObjectChangeEffectRound extends ObjectChangeEffect |
| 34 | 32 |
{
|
| 35 | 33 |
public int createEffectsPhase0(int duration) |
| 36 | 34 |
{
|
| 37 |
float X = NODE_FBO_SIZE /3;
|
|
| 35 |
float X = mObject[0].getNodeSize()/3.0f;
|
|
| 38 | 36 |
|
| 39 | 37 |
mCubeEffectPosition[0] = new int[] {2,3};
|
| 40 | 38 |
mCubeEffects[0] = new Effect[mCubeEffectPosition[0].length]; |
| ... | ... | |
| 58 | 56 |
|
| 59 | 57 |
public int createEffectsPhase1(int duration) |
| 60 | 58 |
{
|
| 61 |
float X = NODE_FBO_SIZE /3;
|
|
| 59 |
float X = mObject[0].getNodeSize()/3.0f;
|
|
| 62 | 60 |
|
| 63 | 61 |
mCubeEffectPosition[1] = new int[] {2,3};
|
| 64 | 62 |
mCubeEffects[1] = new Effect[mCubeEffectPosition[1].length]; |
| src/main/java/org/distorted/effects/scramble/ScrambleEffect.java | ||
|---|---|---|
| 69 | 69 |
private int mLastVector; |
| 70 | 70 |
private long mDurationSingleTurn; |
| 71 | 71 |
private Random mRnd; |
| 72 |
private RubikObject mObject; |
|
| 73 | 72 |
private int mNumAxis; |
| 74 | 73 |
private int mBasicAngle; |
| 75 | 74 |
private float[] mRowChances; |
| 76 | 75 |
|
| 76 |
RubikObject mObject; |
|
| 77 | 77 |
Effect[] mNodeEffects; |
| 78 | 78 |
int[] mNodeEffectPosition; |
| 79 | 79 |
Effect[] mCubeEffects; |
| src/main/java/org/distorted/effects/scramble/ScrambleEffectRotations.java | ||
|---|---|---|
| 30 | 30 |
|
| 31 | 31 |
import java.util.Random; |
| 32 | 32 |
|
| 33 |
import static org.distorted.objects.RubikObject.NODE_FBO_SIZE; |
|
| 34 |
|
|
| 35 | 33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 36 | 34 |
|
| 37 | 35 |
public class ScrambleEffectRotations extends ScrambleEffect |
| ... | ... | |
| 78 | 76 |
|
| 79 | 77 |
mCubeEffects[0] = new MatrixEffectQuaternion(dq, new Static3D(0,0,0)); |
| 80 | 78 |
|
| 81 |
float Z = NODE_FBO_SIZE /3;
|
|
| 79 |
float Z = mObject.getNodeSize()/3.0f;
|
|
| 82 | 80 |
|
| 83 | 81 |
Dynamic3D d0 = new Dynamic3D(duration, 0.5f); |
| 84 | 82 |
d0.setMode(Dynamic.MODE_PATH); |
| src/main/java/org/distorted/main/RubikPreRender.java | ||
|---|---|---|
| 107 | 107 |
Context con = mView.getContext(); |
| 108 | 108 |
Resources res = con.getResources(); |
| 109 | 109 |
|
| 110 |
mNewObject = object.create(size, mView.getQuat(), moves, res); |
|
| 110 |
mNewObject = object.create(size, mView.getQuat(), moves, res, mScreenWidth);
|
|
| 111 | 111 |
|
| 112 | 112 |
if( mNewObject!=null ) |
| 113 | 113 |
{
|
| src/main/java/org/distorted/main/RubikRenderer.java | ||
|---|---|---|
| 84 | 84 |
|
| 85 | 85 |
RubikRenderer(RubikSurfaceView v) |
| 86 | 86 |
{
|
| 87 |
final float BRIGHTNESS = 0.1f; |
|
| 87 |
final float BRIGHTNESS = 0.19f;
|
|
| 88 | 88 |
|
| 89 | 89 |
mView = v; |
| 90 | 90 |
mFPS = new Fps(); |
| 91 | 91 |
mScreen = new DistortedScreen(); |
| 92 | 92 |
mScreen.glClearColor(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS, 1.0f); |
| 93 |
//mScreen.showFPS(); |
|
| 93 | 94 |
} |
| 94 | 95 |
|
| 95 | 96 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/objects/RubikCube.java | ||
|---|---|---|
| 100 | 100 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 101 | 101 |
|
| 102 | 102 |
RubikCube(int size, Static4D quat, DistortedTexture texture, |
| 103 |
MeshRectangles mesh, DistortedEffects effects, int[][] moves, Resources res) |
|
| 103 |
MeshRectangles mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
|
|
| 104 | 104 |
{
|
| 105 |
super(size, 60, quat, texture, mesh, effects, moves, RubikObjectList.CUBE, res); |
|
| 105 |
super(size, 60, quat, texture, mesh, effects, moves, RubikObjectList.CUBE, res, scrWidth);
|
|
| 106 | 106 |
} |
| 107 | 107 |
|
| 108 | 108 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/objects/RubikObject.java | ||
|---|---|---|
| 54 | 54 |
{
|
| 55 | 55 |
private static final Static3D CENTER = new Static3D(0,0,0); |
| 56 | 56 |
static final int INTERIOR_COLOR = 0xff000000; |
| 57 |
public static final int NODE_FBO_SIZE = 600; |
|
| 58 | 57 |
private static final int POST_ROTATION_MILLISEC = 500; |
| 59 | 58 |
private static final int TEXTURE_HEIGHT = 128; |
| 60 | 59 |
|
| ... | ... | |
| 65 | 64 |
static float OBJECT_SCREEN_RATIO; |
| 66 | 65 |
|
| 67 | 66 |
private final int NUM_CUBITS; |
| 67 |
private final int mNodeSize; |
|
| 68 | 68 |
private int mRotRowBitmap; |
| 69 | 69 |
private int mRotAxis; |
| 70 | 70 |
private Static3D[] mOrigPos; |
| ... | ... | |
| 90 | 90 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 91 | 91 |
|
| 92 | 92 |
RubikObject(int size, int fov, Static4D quat, DistortedTexture nodeTexture, MeshRectangles nodeMesh, |
| 93 |
DistortedEffects nodeEffects, int[][] moves, RubikObjectList list, Resources res) |
|
| 93 |
DistortedEffects nodeEffects, int[][] moves, RubikObjectList list, Resources res, int screenWidth)
|
|
| 94 | 94 |
{
|
| 95 | 95 |
super(nodeTexture,nodeEffects,nodeMesh); |
| 96 | 96 |
|
| 97 |
resizeFBO(NODE_FBO_SIZE, NODE_FBO_SIZE); |
|
| 97 |
mNodeSize = screenWidth; |
|
| 98 |
|
|
| 99 |
resizeFBO(mNodeSize, mNodeSize); |
|
| 98 | 100 |
|
| 99 | 101 |
mList = list; |
| 100 | 102 |
mOrigPos = getCubitPositions(size); |
| ... | ... | |
| 118 | 120 |
mRotationAngleMiddle = new Static1D(0); |
| 119 | 121 |
mRotationAngleFinal = new Static1D(0); |
| 120 | 122 |
|
| 121 |
float scale = OBJECT_SCREEN_RATIO*NODE_FBO_SIZE/mSize;
|
|
| 123 |
float scale = OBJECT_SCREEN_RATIO*mNodeSize/mSize;
|
|
| 122 | 124 |
mScaleEffect = new MatrixEffectScale(new Static3D(scale,scale,scale)); |
| 123 | 125 |
mQuatEffect = new MatrixEffectQuaternion(quat, CENTER); |
| 124 | 126 |
|
| ... | ... | |
| 616 | 618 |
return speed> 1.3f ? NEAREST*(angle>0 ? 1:-1) : 0; |
| 617 | 619 |
} |
| 618 | 620 |
|
| 621 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 622 |
|
|
| 623 |
public int getNodeSize() |
|
| 624 |
{
|
|
| 625 |
return mNodeSize; |
|
| 626 |
} |
|
| 627 |
|
|
| 619 | 628 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 620 | 629 |
|
| 621 | 630 |
public RubikObjectList getObjectList() |
| src/main/java/org/distorted/objects/RubikObjectList.java | ||
|---|---|---|
| 322 | 322 |
|
| 323 | 323 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 324 | 324 |
|
| 325 |
public RubikObject create(int size, Static4D quat, int[][] moves, Resources res) |
|
| 325 |
public RubikObject create(int size, Static4D quat, int[][] moves, Resources res, int scrWidth)
|
|
| 326 | 326 |
{
|
| 327 | 327 |
DistortedTexture texture = new DistortedTexture(); |
| 328 | 328 |
DistortedEffects effects = new DistortedEffects(); |
| ... | ... | |
| 330 | 330 |
|
| 331 | 331 |
switch(ordinal()) |
| 332 | 332 |
{
|
| 333 |
case 0: return new RubikCube (size, quat, texture, mesh, effects, moves, res); |
|
| 334 |
case 1: return new RubikPyraminx(size, quat, texture, mesh, effects, moves, res); |
|
| 333 |
case 0: return new RubikCube (size, quat, texture, mesh, effects, moves, res, scrWidth);
|
|
| 334 |
case 1: return new RubikPyraminx(size, quat, texture, mesh, effects, moves, res, scrWidth);
|
|
| 335 | 335 |
} |
| 336 | 336 |
|
| 337 | 337 |
return null; |
| src/main/java/org/distorted/objects/RubikPyraminx.java | ||
|---|---|---|
| 100 | 100 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 101 | 101 |
|
| 102 | 102 |
RubikPyraminx(int size, Static4D quat, DistortedTexture texture, |
| 103 |
MeshRectangles mesh, DistortedEffects effects, int[][] moves, Resources res) |
|
| 103 |
MeshRectangles mesh, DistortedEffects effects, int[][] moves, Resources res, int scrWidth)
|
|
| 104 | 104 |
{
|
| 105 |
super(size, 30, quat, texture, mesh, effects, moves, RubikObjectList.PYRA, res); |
|
| 105 |
super(size, 30, quat, texture, mesh, effects, moves, RubikObjectList.PYRA, res, scrWidth);
|
|
| 106 | 106 |
} |
| 107 | 107 |
|
| 108 | 108 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| src/main/java/org/distorted/states/RubikStatePlay.java | ||
|---|---|---|
| 299 | 299 |
public void onClick(View v) |
| 300 | 300 |
{
|
| 301 | 301 |
act.getPreRender().solveObject(); |
| 302 |
mMoves.clear(); |
|
| 302 | 303 |
} |
| 303 | 304 |
}); |
| 304 | 305 |
} |
Also available in: Unified diff
Object node: size of screenWidth.