Revision e56c3711
Added by Leszek Koltunski over 5 years ago
.gitignore | ||
---|---|---|
1 |
/build |
|
2 |
distorted-cube.iml |
|
1 |
# built application files |
|
2 |
*.apk |
|
3 |
*.ap_ |
|
4 |
|
|
5 |
# files for the dex VM |
|
6 |
*.dex |
|
7 |
|
|
8 |
# Java class files |
|
9 |
*.class |
|
10 |
|
|
11 |
# built native files (uncomment if you build your own) |
|
12 |
# *.o |
|
13 |
# *.so |
|
14 |
|
|
15 |
# generated files |
|
16 |
bin/ |
|
17 |
gen/ |
|
18 |
|
|
19 |
# Ignore gradle files |
|
20 |
.gradle/ |
|
21 |
build/ |
|
22 |
|
|
23 |
# Local configuration file (sdk path, etc) |
|
24 |
local.properties |
|
25 |
|
|
26 |
# Proguard folder generated by Eclipse |
|
27 |
proguard/ |
|
28 |
|
|
29 |
# Eclipse Metadata |
|
30 |
.metadata/ |
|
31 |
|
|
32 |
# Mac OS X clutter |
|
33 |
*.DS_Store |
|
34 |
|
|
35 |
# Windows clutter |
|
36 |
Thumbs.db |
|
37 |
|
|
38 |
# Intellij IDEA (see https://intellij-support.jetbrains.com/entries/23393067) |
|
39 |
.idea/workspace.xml |
|
40 |
.idea/tasks.xml |
|
41 |
.idea/datasources.xml |
|
42 |
.idea/dataSources.ids |
|
43 |
|
|
44 |
# yes, ignore the .iml |
|
45 |
*.iml |
src/main/java/org/distorted/effect/TransitionEffectRound.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2019 Leszek Koltunski // |
|
3 |
// // |
|
4 |
// This file is part of Distorted. // |
|
5 |
// // |
|
6 |
// Distorted is free software: you can redistribute it and/or modify // |
|
7 |
// it under the terms of the GNU General Public License as published by // |
|
8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
9 |
// (at your option) any later version. // |
|
10 |
// // |
|
11 |
// Distorted is distributed in the hope that it will be useful, // |
|
12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
14 |
// GNU General Public License for more details. // |
|
15 |
// // |
|
16 |
// You should have received a copy of the GNU General Public License // |
|
17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
|
18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
19 |
|
|
20 |
package org.distorted.effect; |
|
21 |
|
|
22 |
import org.distorted.library.effect.Effect; |
|
23 |
import org.distorted.library.effect.MatrixEffectMove; |
|
24 |
import org.distorted.library.effect.MatrixEffectScale; |
|
25 |
import org.distorted.library.type.Dynamic3D; |
|
26 |
import org.distorted.library.type.Static3D; |
|
27 |
|
|
28 |
import static org.distorted.magic.RubikRenderer.TEXTURE_SIZE; |
|
29 |
|
|
30 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
31 |
|
|
32 |
class TransitionEffectRound extends TransitionEffect |
|
33 |
{ |
|
34 |
TransitionEffectRound() |
|
35 |
{ |
|
36 |
final int DURATION_IN_MILLIS = 10000; |
|
37 |
|
|
38 |
mOldCubeEffectPosition = new int[] {2, 2}; |
|
39 |
mOldCubeEffects = new Effect[mOldCubeEffectPosition.length]; |
|
40 |
|
|
41 |
Dynamic3D oldCube0 = new Dynamic3D(DURATION_IN_MILLIS, 0.5f); |
|
42 |
oldCube0.add(new Static3D(0,0,0)); |
|
43 |
oldCube0.add(new Static3D(TEXTURE_SIZE,0,0)); |
|
44 |
oldCube0.add(new Static3D(0,0,0)); |
|
45 |
mOldCubeEffects[0] = new MatrixEffectMove(oldCube0); |
|
46 |
|
|
47 |
Dynamic3D oldCube1 = new Dynamic3D(DURATION_IN_MILLIS, 0.5f); |
|
48 |
oldCube1.add(new Static3D(1.0f, 1.0f, 1.0f)); |
|
49 |
oldCube1.add(new Static3D(0.01f, 0.01f, 0.01f)); |
|
50 |
mOldCubeEffects[1] = new MatrixEffectScale(oldCube1); |
|
51 |
|
|
52 |
|
|
53 |
mNewCubeEffectPosition = new int[] {2, 2}; |
|
54 |
mNewCubeEffects = new Effect[mNewCubeEffectPosition.length]; |
|
55 |
|
|
56 |
Dynamic3D newCube0 = new Dynamic3D(DURATION_IN_MILLIS, 0.5f); |
|
57 |
newCube0.add(new Static3D(0,0,0)); |
|
58 |
newCube0.add(new Static3D(-TEXTURE_SIZE,0,0)); |
|
59 |
newCube0.add(new Static3D(0,0,0)); |
|
60 |
mNewCubeEffects[0] = new MatrixEffectMove(newCube0); |
|
61 |
|
|
62 |
Dynamic3D newCube1 = new Dynamic3D(DURATION_IN_MILLIS, 0.5f); |
|
63 |
newCube1.add(new Static3D(0.01f, 0.01f, 0.01f)); |
|
64 |
newCube1.add(new Static3D(1.0f, 1.0f, 1.0f)); |
|
65 |
mNewCubeEffects[1] = new MatrixEffectScale(newCube1); |
|
66 |
} |
|
67 |
|
|
68 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
69 |
// enable all effects used in this Transition. Called by reflection from the parent class. |
|
70 |
// Matrix Effects do not have to be enabled. |
|
71 |
|
|
72 |
@SuppressWarnings("unused") |
|
73 |
static void enable() |
|
74 |
{ |
|
75 |
|
|
76 |
} |
|
77 |
} |
|
78 |
|
src/main/java/org/distorted/effect/TransitionEffectScale.java | ||
---|---|---|
1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
2 |
// Copyright 2019 Leszek Koltunski // |
|
3 |
// // |
|
4 |
// This file is part of Distorted. // |
|
5 |
// // |
|
6 |
// Distorted is free software: you can redistribute it and/or modify // |
|
7 |
// it under the terms of the GNU General Public License as published by // |
|
8 |
// the Free Software Foundation, either version 2 of the License, or // |
|
9 |
// (at your option) any later version. // |
|
10 |
// // |
|
11 |
// Distorted is distributed in the hope that it will be useful, // |
|
12 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
13 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
14 |
// GNU General Public License for more details. // |
|
15 |
// // |
|
16 |
// You should have received a copy of the GNU General Public License // |
|
17 |
// along with Distorted. If not, see <http://www.gnu.org/licenses/>. // |
|
18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
19 |
|
|
20 |
package org.distorted.effect; |
|
21 |
|
|
22 |
import org.distorted.library.effect.Effect; |
|
23 |
import org.distorted.library.effect.MatrixEffectScale; |
|
24 |
import org.distorted.library.type.Dynamic3D; |
|
25 |
import org.distorted.library.type.Static3D; |
|
26 |
|
|
27 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
28 |
|
|
29 |
class TransitionEffectScale extends TransitionEffect |
|
30 |
{ |
|
31 |
TransitionEffectScale() |
|
32 |
{ |
|
33 |
final int DURATION_IN_MILLIS = 1000; |
|
34 |
|
|
35 |
mOldCubeEffectPosition = new int[] {5}; |
|
36 |
mOldCubeEffects = new Effect[mOldCubeEffectPosition.length]; |
|
37 |
|
|
38 |
Dynamic3D oldCube0 = new Dynamic3D(DURATION_IN_MILLIS, 0.5f); |
|
39 |
oldCube0.add(new Static3D(1.0f, 1.0f, 1.0f)); |
|
40 |
oldCube0.add(new Static3D(0.01f, 0.01f, 0.01f)); |
|
41 |
mOldCubeEffects[0] = new MatrixEffectScale(oldCube0); |
|
42 |
|
|
43 |
|
|
44 |
mNewCubeEffectPosition = new int[] {5}; |
|
45 |
mNewCubeEffects = new Effect[mNewCubeEffectPosition.length]; |
|
46 |
|
|
47 |
Dynamic3D newCube0 = new Dynamic3D(DURATION_IN_MILLIS, 0.5f); |
|
48 |
newCube0.add(new Static3D(0.01f, 0.01f, 0.01f)); |
|
49 |
newCube0.add(new Static3D(1.0f, 1.0f, 1.0f)); |
|
50 |
mNewCubeEffects[0] = new MatrixEffectScale(newCube0); |
|
51 |
} |
|
52 |
|
|
53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
54 |
// enable all effects used in this Transition. Called by reflection from the parent class. |
|
55 |
// Matrix Effects do not have to be enabled. |
|
56 |
|
|
57 |
@SuppressWarnings("unused") |
|
58 |
static void enable() |
|
59 |
{ |
|
60 |
|
|
61 |
} |
|
62 |
} |
|
63 |
|
src/main/java/org/distorted/magic/RubikRenderer.java | ||
---|---|---|
236 | 236 |
|
237 | 237 |
boolean createCube(int newSize) |
238 | 238 |
{ |
239 |
if( mCanDrag && mCanRotate ) |
|
239 |
if( mCanDrag && mCanRotate && newSize != mNewCube.getSize() )
|
|
240 | 240 |
{ |
241 | 241 |
mNextCubeSize = newSize; |
242 | 242 |
return true; |
243 | 243 |
} |
244 | 244 |
|
245 |
android.util.Log.e("renderer", "cannot change, drag="+mCanDrag+" rotate="+mCanRotate); |
|
246 |
|
|
247 | 245 |
return false; |
248 | 246 |
} |
249 | 247 |
|
... | ... | |
251 | 249 |
|
252 | 250 |
void createCubeNow(int newSize) |
253 | 251 |
{ |
254 |
int oldSize = mNewCube==null ? 0 : mNewCube.getSize(); |
|
255 |
|
|
256 |
if( oldSize!=newSize ) |
|
257 |
{ |
|
258 |
if( mOldCube!=null ) mOldCube.releaseResources(); |
|
259 |
mOldCube = mNewCube; |
|
252 |
if( mOldCube!=null ) mOldCube.releaseResources(); |
|
253 |
mOldCube = mNewCube; |
|
260 | 254 |
|
261 |
DistortedTexture texture = new DistortedTexture(TEXTURE_SIZE,TEXTURE_SIZE);
|
|
262 |
DistortedEffects effects = new DistortedEffects();
|
|
255 |
DistortedTexture texture = new DistortedTexture(TEXTURE_SIZE,TEXTURE_SIZE); |
|
256 |
DistortedEffects effects = new DistortedEffects(); |
|
263 | 257 |
|
264 |
mNewCube = new RubikCube(newSize, mQuatCurrent, mQuatAccumulated, texture, mMesh, effects);
|
|
265 |
mNewCube.createTexture();
|
|
258 |
mNewCube = new RubikCube(newSize, mQuatCurrent, mQuatAccumulated, texture, mMesh, effects); |
|
259 |
mNewCube.createTexture(); |
|
266 | 260 |
|
267 |
if( mScreenWidth!=0 ) |
|
268 |
{ |
|
269 |
recomputeScaleFactor(mScreenWidth,mScreenHeight); |
|
270 |
} |
|
261 |
if( mScreenWidth!=0 ) |
|
262 |
{ |
|
263 |
recomputeScaleFactor(mScreenWidth,mScreenHeight); |
|
271 | 264 |
} |
272 | 265 |
} |
273 | 266 |
|
Also available in: Unified diff
2 new effects; bugfix.