Revision 5974d2ae
Added by Leszek Koltunski over 4 years ago
src/main/java/org/distorted/effect/scramble/ScrambleEffectRotations.java | ||
---|---|---|
30 | 30 |
|
31 | 31 |
import java.util.Random; |
32 | 32 |
|
33 |
import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE;
|
|
33 |
import static org.distorted.magic.RubikRenderer.NODE_MESH_SIZE;
|
|
34 | 34 |
|
35 | 35 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
36 | 36 |
|
... | ... | |
78 | 78 |
|
79 | 79 |
mCubeEffects[0] = new MatrixEffectQuaternion(dq, new Static3D(0,0,0)); |
80 | 80 |
|
81 |
float Z = TEXTURE_SIZE/3;
|
|
81 |
float Z = NODE_MESH_SIZE /3;
|
|
82 | 82 |
|
83 | 83 |
Dynamic3D d0 = new Dynamic3D(duration, 0.5f); |
84 | 84 |
d0.setMode(Dynamic.MODE_PATH); |
src/main/java/org/distorted/effect/sizechange/SizeChangeEffectRound.java | ||
---|---|---|
26 | 26 |
import org.distorted.library.type.Dynamic3D; |
27 | 27 |
import org.distorted.library.type.Static3D; |
28 | 28 |
|
29 |
import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE;
|
|
29 |
import static org.distorted.magic.RubikRenderer.NODE_MESH_SIZE;
|
|
30 | 30 |
|
31 | 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
32 | 32 |
|
... | ... | |
34 | 34 |
{ |
35 | 35 |
public int createEffectsPhase0(int duration) |
36 | 36 |
{ |
37 |
float X = TEXTURE_SIZE/3;
|
|
37 |
float X = NODE_MESH_SIZE /3;
|
|
38 | 38 |
|
39 | 39 |
mCubeEffectPosition[0] = new int[] {6,7}; |
40 | 40 |
mCubeEffects[0] = new Effect[mCubeEffectPosition[0].length]; |
... | ... | |
58 | 58 |
|
59 | 59 |
public int createEffectsPhase1(int duration) |
60 | 60 |
{ |
61 |
float X = TEXTURE_SIZE/3;
|
|
61 |
float X = NODE_MESH_SIZE /3;
|
|
62 | 62 |
|
63 | 63 |
mCubeEffectPosition[1] = new int[] {6,7}; |
64 | 64 |
mCubeEffects[1] = new Effect[mCubeEffectPosition[1].length]; |
src/main/java/org/distorted/effect/win/WinEffectGlow.java | ||
---|---|---|
28 | 28 |
import org.distorted.library.type.Static3D; |
29 | 29 |
import org.distorted.library.type.Static4D; |
30 | 30 |
|
31 |
import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE;
|
|
31 |
import static org.distorted.magic.RubikRenderer.NODE_MESH_SIZE;
|
|
32 | 32 |
|
33 | 33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
34 | 34 |
|
... | ... | |
63 | 63 |
degreeDyn.add(new Static1D(2.5f)); |
64 | 64 |
degreeDyn.add(new Static1D(1.0f)); |
65 | 65 |
|
66 |
float centerPoint = TEXTURE_SIZE*0.5f;
|
|
66 |
float centerPoint = NODE_MESH_SIZE *0.5f;
|
|
67 | 67 |
Static3D center = new Static3D(centerPoint,centerPoint,centerPoint); |
68 | 68 |
|
69 | 69 |
mNodeEffects[1] = new VertexEffectSink(degreeDyn,center); |
src/main/java/org/distorted/magic/RubikRenderer.java | ||
---|---|---|
40 | 40 |
public class RubikRenderer implements GLSurfaceView.Renderer, EffectListener |
41 | 41 |
{ |
42 | 42 |
static final float CAMERA_DISTANCE = 0.6f; // 0.6 of the length of min(scrHeight,scrWidth) |
43 |
public static final int TEXTURE_SIZE = 600;
|
|
43 |
public static final int NODE_MESH_SIZE = 600;
|
|
44 | 44 |
|
45 | 45 |
private RubikSurfaceView mView; |
46 | 46 |
private DistortedScreen mScreen; |
src/main/java/org/distorted/object/Cubit.java | ||
---|---|---|
160 | 160 |
float z = position.get2(); |
161 | 161 |
|
162 | 162 |
float nc = parent.mSize*0.5f; |
163 |
int TS = RubikObject.TEXTURE_SIZE; |
|
164 |
Static3D vector = new Static3D(TS*(x-nc), TS*(y-nc), TS*(z-nc)); |
|
163 |
Static3D vector = new Static3D(x-nc, y-nc, z-nc); |
|
165 | 164 |
|
166 | 165 |
mParent = parent; |
167 | 166 |
mMesh = mesh; |
... | ... | |
172 | 171 |
mCurrentPosition = position; |
173 | 172 |
mRotateEffect = new MatrixEffectRotate(mRotationAngle, mRotationAxis, matrCenter); |
174 | 173 |
|
175 |
mEffect = new DistortedEffects(); |
|
174 |
mEffect = new DistortedEffects(1);
|
|
176 | 175 |
mEffect.apply(mParent.mSinkEffect); |
177 | 176 |
mEffect.apply( new MatrixEffectMove(vector) ); |
178 | 177 |
mEffect.apply( new MatrixEffectQuaternion(mQuatScramble, matrCenter)); |
src/main/java/org/distorted/object/RubikObject.java | ||
---|---|---|
42 | 42 |
public abstract class RubikObject extends DistortedNode |
43 | 43 |
{ |
44 | 44 |
static final float OBJECT_SCREEN_RATIO = 0.5f; |
45 |
static final int TEXTURE_SIZE = 100; |
|
46 | 45 |
final float[] LEGAL_QUATS; |
47 | 46 |
|
48 | 47 |
private static final int POST_ROTATION_MILLISEC = 500; |
... | ... | |
51 | 50 |
private Static3D mRotAxis; |
52 | 51 |
private Static3D mMove, mScale, mNodeMove, mNodeScale; |
53 | 52 |
private Static4D mQuatAccumulated; |
54 |
private DistortedTexture mNodeTexture; |
|
55 | 53 |
private Cubit[] mCubits; |
56 | 54 |
|
57 | 55 |
int mSize; |
... | ... | |
74 | 72 |
LEGAL_QUATS = getLegalQuats(); |
75 | 73 |
NUM_CUBITS = getNumCubits(size); |
76 | 74 |
|
77 |
mNodeTexture = texture; |
|
78 | 75 |
mSize = size; |
79 | 76 |
|
80 | 77 |
mRotationAngleStatic = new Static1D(0); |
... | ... | |
88 | 85 |
|
89 | 86 |
mQuatAccumulated = quatAcc; |
90 | 87 |
|
91 |
Static3D sinkCenter = new Static3D(TEXTURE_SIZE*0.5f, TEXTURE_SIZE*0.5f, TEXTURE_SIZE*0.5f);
|
|
88 |
Static3D sinkCenter = new Static3D(0.5f,0.5f,0.5f);
|
|
92 | 89 |
Static3D matrCenter = new Static3D(0,0,0); |
93 |
Static4D region = new Static4D(0,0,0, TEXTURE_SIZE*0.72f);
|
|
90 |
Static4D region = new Static4D(0,0,0,0.72f); |
|
94 | 91 |
|
95 | 92 |
mSinkEffect = new VertexEffectSink( new Static1D(getSinkStrength()), sinkCenter, region ); |
96 | 93 |
mMoveEffect = new MatrixEffectMove(mMove); |
... | ... | |
105 | 102 |
effects.apply(nodeMoveEffect); |
106 | 103 |
|
107 | 104 |
mCubits = new Cubit[NUM_CUBITS]; |
108 |
mTexture = new DistortedTexture(TEXTURE_SIZE,TEXTURE_SIZE);
|
|
105 |
mTexture = new DistortedTexture(); |
|
109 | 106 |
|
110 | 107 |
int vertices = (int)(24.0f/mSize + 2.0f); |
111 | 108 |
int[][] positions = getCubitPositions(size); |
... | ... | |
172 | 169 |
|
173 | 170 |
public void recomputeScaleFactor(int screenWidth, int screenHeight) |
174 | 171 |
{ |
175 |
int texW = mNodeTexture.getWidth();
|
|
176 |
int texH = mNodeTexture.getHeight();
|
|
172 |
int sizeX = getEffects().getStartchX();
|
|
173 |
int sizeY = getEffects().getStartchY();
|
|
177 | 174 |
|
178 |
if( (float)texH/texW > (float)screenHeight/screenWidth )
|
|
175 |
if( (float)sizeY/sizeX > (float)screenHeight/screenWidth )
|
|
179 | 176 |
{ |
180 |
int w = (screenHeight*texW)/texH;
|
|
181 |
float factor = (float)screenHeight/texH;
|
|
177 |
int w = (screenHeight*sizeX)/sizeY;
|
|
178 |
float factor = (float)screenHeight/sizeY;
|
|
182 | 179 |
mNodeMove.set((screenWidth-w)*0.5f ,0, 0); |
183 | 180 |
mNodeScale.set(factor,factor,factor); |
184 | 181 |
} |
185 | 182 |
else |
186 | 183 |
{ |
187 |
int h = (screenWidth*texH)/texW;
|
|
188 |
float factor = (float)screenWidth/texW;
|
|
184 |
int h = (screenWidth*sizeY)/sizeX;
|
|
185 |
float factor = (float)screenWidth/sizeX;
|
|
189 | 186 |
mNodeMove.set(0,(screenHeight-h)*0.5f,0); |
190 | 187 |
mNodeScale.set(factor,factor,factor); |
191 | 188 |
} |
192 | 189 |
|
193 |
float scaleFactor = (OBJECT_SCREEN_RATIO*texW/(TEXTURE_SIZE*mSize));
|
|
190 |
float scaleFactor = (OBJECT_SCREEN_RATIO*sizeX/mSize);
|
|
194 | 191 |
|
195 |
mMove.set( texW*0.5f , texH*0.5f , 0.0f );
|
|
192 |
mMove.set( sizeX*0.5f , sizeY*0.5f , 0.0f );
|
|
196 | 193 |
mScale.set(scaleFactor,scaleFactor,scaleFactor); |
197 | 194 |
} |
198 | 195 |
|
src/main/java/org/distorted/object/RubikObjectList.java | ||
---|---|---|
25 | 25 |
import org.distorted.library.type.Static4D; |
26 | 26 |
import org.distorted.magic.R; |
27 | 27 |
|
28 |
import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE;
|
|
28 |
import static org.distorted.magic.RubikRenderer.NODE_MESH_SIZE;
|
|
29 | 29 |
|
30 | 30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
31 | 31 |
|
... | ... | |
84 | 84 |
|
85 | 85 |
public RubikObject create(Static4D quatCur, Static4D quatAcc) |
86 | 86 |
{ |
87 |
DistortedTexture texture = new DistortedTexture(TEXTURE_SIZE,TEXTURE_SIZE);
|
|
88 |
DistortedEffects effects = new DistortedEffects(); |
|
87 |
DistortedTexture texture = new DistortedTexture(); |
|
88 |
DistortedEffects effects = new DistortedEffects(NODE_MESH_SIZE,NODE_MESH_SIZE,0);
|
|
89 | 89 |
MeshRectangles mesh = new MeshRectangles(20,20); // mesh of the node, not of the cubits |
90 | 90 |
|
91 | 91 |
return new RubikCube(mObjectSize, quatCur, quatAcc, texture, mesh, effects); |
Also available in: Unified diff
Move the 'pre-multiply mesh before applying any effects' thing from [(Xsize of texture, Ysize of texture) x Mesh's zFactor] to Effects.setStretch(sx,sy,sz)