Revision af88bf2e
Added by Leszek Koltunski about 5 years ago
| src/main/AndroidManifest.xml | ||
|---|---|---|
| 30 | 30 |
<category android:name="android.intent.category.LAUNCHER" /> |
| 31 | 31 |
</intent-filter> |
| 32 | 32 |
</activity> |
| 33 |
|
|
| 34 |
<activity android:name="org.distorted.tutorial.TutorialActivity" android:screenOrientation="portrait"/> |
|
| 33 | 35 |
</application> |
| 34 | 36 |
</manifest> |
| src/main/java/org/distorted/dialogs/RubikDialogInfo.java | ||
|---|---|---|
| 21 | 21 |
|
| 22 | 22 |
import android.app.Dialog; |
| 23 | 23 |
import android.content.DialogInterface; |
| 24 |
import android.content.Intent; |
|
| 24 | 25 |
import android.os.Bundle; |
| 25 | 26 |
import android.util.DisplayMetrics; |
| 26 | 27 |
import android.util.TypedValue; |
| ... | ... | |
| 37 | 38 |
|
| 38 | 39 |
import org.distorted.main.R; |
| 39 | 40 |
import org.distorted.main.RubikActivity; |
| 40 |
import org.distorted.main.RubikPreRender; |
|
| 41 | 41 |
import org.distorted.objects.TwistyObject; |
| 42 |
import org.distorted.tutorial.TutorialActivity; |
|
| 42 | 43 |
|
| 43 | 44 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 44 | 45 |
|
| ... | ... | |
| 73 | 74 |
@Override |
| 74 | 75 |
public void onClick(DialogInterface dialog, int which) |
| 75 | 76 |
{
|
| 77 |
RubikActivity ract = (RubikActivity)getContext(); |
|
| 78 |
Intent myIntent = new Intent(ract, TutorialActivity.class); |
|
| 79 |
//myIntent.putExtra("", value); //Optional parameters
|
|
| 76 | 80 |
|
| 81 |
if( ract!=null ) ract.startActivity(myIntent); |
|
| 77 | 82 |
} |
| 78 | 83 |
}); |
| 79 | 84 |
|
| src/main/java/org/distorted/effects/BaseEffect.java | ||
|---|---|---|
| 29 | 29 |
import org.distorted.effects.win.WinEffect; |
| 30 | 30 |
import org.distorted.library.main.DistortedScreen; |
| 31 | 31 |
import org.distorted.main.R; |
| 32 |
import org.distorted.main.RubikPreRender; |
|
| 33 | 32 |
|
| 34 | 33 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 35 | 34 |
|
| ... | ... | |
| 197 | 196 |
|
| 198 | 197 |
//////////////////////////////////////////////////////////////////////////////// |
| 199 | 198 |
|
| 200 |
public long startEffect(DistortedScreen screen, RubikPreRender pre) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
|
|
| 199 |
public long startEffect(DistortedScreen screen, EffectController cont) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
|
|
| 201 | 200 |
{
|
| 202 | 201 |
Method method1 = mClass.getDeclaredMethod("create", int.class);
|
| 203 | 202 |
|
| 204 | 203 |
Object value1 = method1.invoke(null,mCurrentType); |
| 205 | 204 |
BaseEffect baseEffect = (BaseEffect)value1; |
| 206 | 205 |
|
| 207 |
Method method2 = mClass.getDeclaredMethod("start", int.class, DistortedScreen.class, RubikPreRender.class);
|
|
| 206 |
Method method2 = mClass.getDeclaredMethod("start", int.class, DistortedScreen.class, EffectController.class);
|
|
| 208 | 207 |
|
| 209 | 208 |
Integer translated = translatePos(mCurrentPos)+1; |
| 210 |
Object value2 = method2.invoke(baseEffect,translated,screen,pre);
|
|
| 209 |
Object value2 = method2.invoke(baseEffect,translated,screen,cont);
|
|
| 211 | 210 |
return (Long)value2; |
| 212 | 211 |
} |
| 213 | 212 |
|
| src/main/java/org/distorted/effects/EffectController.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2020 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Magic Cube. // |
|
| 5 |
// // |
|
| 6 |
// Magic Cube 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 |
// Magic Cube 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 Magic Cube. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.effects; |
|
| 21 |
|
|
| 22 |
import org.distorted.library.message.EffectListener; |
|
| 23 |
import org.distorted.main.RubikPreRender; |
|
| 24 |
import org.distorted.objects.TwistyObject; |
|
| 25 |
|
|
| 26 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 27 |
|
|
| 28 |
public interface EffectController extends EffectListener |
|
| 29 |
{
|
|
| 30 |
void addRotation(RubikPreRender.ActionFinishedListener listener, int axis, int rowBitmap, int angle, long duration); |
|
| 31 |
TwistyObject getOldObject(); |
|
| 32 |
TwistyObject getObject(); |
|
| 33 |
int getNumScrambles(); |
|
| 34 |
} |
|
| src/main/java/org/distorted/effects/objectchange/ObjectChangeEffect.java | ||
|---|---|---|
| 24 | 24 |
import org.distorted.library.main.DistortedEffects; |
| 25 | 25 |
import org.distorted.library.main.DistortedScreen; |
| 26 | 26 |
import org.distorted.library.message.EffectListener; |
| 27 |
import org.distorted.main.RubikPreRender;
|
|
| 27 |
import org.distorted.effects.EffectController;
|
|
| 28 | 28 |
import org.distorted.objects.TwistyObject; |
| 29 | 29 |
|
| 30 | 30 |
import java.lang.reflect.Method; |
| ... | ... | |
| 66 | 66 |
} |
| 67 | 67 |
} |
| 68 | 68 |
|
| 69 |
private EffectListener mListener;
|
|
| 69 |
private EffectController mController;
|
|
| 70 | 70 |
private int mDuration; |
| 71 | 71 |
private int[] mEffectReturned; |
| 72 | 72 |
private int[] mCubeEffectNumber, mNodeEffectNumber; |
| ... | ... | |
| 144 | 144 |
assignEffects(1); |
| 145 | 145 |
mScreen.attach(mObject[1]); |
| 146 | 146 |
break; |
| 147 |
case 1: mListener.effectFinished(FAKE_EFFECT_ID);
|
|
| 147 |
case 1: mController.effectFinished(FAKE_EFFECT_ID);
|
|
| 148 | 148 |
break; |
| 149 | 149 |
} |
| 150 | 150 |
} |
| ... | ... | |
| 224 | 224 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 225 | 225 |
|
| 226 | 226 |
@SuppressWarnings("unused")
|
| 227 |
public long start(int duration, DistortedScreen screen, RubikPreRender pre)
|
|
| 227 |
public long start(int duration, DistortedScreen screen, EffectController cont)
|
|
| 228 | 228 |
{
|
| 229 |
mScreen = screen; |
|
| 230 |
mObject[0]= pre.getOldObject();
|
|
| 231 |
mObject[1]= pre.getObject();
|
|
| 232 |
mListener = pre;
|
|
| 233 |
mDuration = duration; |
|
| 229 |
mScreen = screen;
|
|
| 230 |
mObject[0] = cont.getOldObject();
|
|
| 231 |
mObject[1] = cont.getObject();
|
|
| 232 |
mController= cont;
|
|
| 233 |
mDuration = duration;
|
|
| 234 | 234 |
|
| 235 | 235 |
if( mObject[0]!=null ) |
| 236 | 236 |
{
|
| src/main/java/org/distorted/effects/scramble/ScrambleEffect.java | ||
|---|---|---|
| 25 | 25 |
import org.distorted.library.main.DistortedScreen; |
| 26 | 26 |
import org.distorted.library.message.EffectListener; |
| 27 | 27 |
import org.distorted.main.RubikPreRender; |
| 28 |
import org.distorted.effects.EffectController; |
|
| 28 | 29 |
import org.distorted.objects.TwistyObject; |
| 29 | 30 |
|
| 30 | 31 |
import java.lang.reflect.Method; |
| ... | ... | |
| 66 | 67 |
public static final int START_AXIS = -2; |
| 67 | 68 |
public static final int STOP_AXIS = -1; |
| 68 | 69 |
|
| 69 |
private RubikPreRender mPreRender;
|
|
| 70 |
private EffectController mController;
|
|
| 70 | 71 |
private int mEffectReturned; |
| 71 | 72 |
private int mNumDoubleScramblesLeft, mNumScramblesLeft; |
| 72 | 73 |
private int mLastRotAxis, mLastRow; |
| ... | ... | |
| 152 | 153 |
android.util.Log.e("effect", "ERROR: "+mNumDoubleScramblesLeft);
|
| 153 | 154 |
} |
| 154 | 155 |
|
| 155 |
mPreRender.addRotation(this, mLastRotAxis, rowBitmap, angle*(360/mBasicAngle), durationMillis);
|
|
| 156 |
mController.addRotation(this, mLastRotAxis, rowBitmap, angle*(360/mBasicAngle), durationMillis);
|
|
| 156 | 157 |
} |
| 157 | 158 |
else |
| 158 | 159 |
{
|
| ... | ... | |
| 160 | 161 |
|
| 161 | 162 |
if( mEffectReturned == mCubeEffectNumber+mNodeEffectNumber ) |
| 162 | 163 |
{
|
| 163 |
mPreRender.effectFinished(FAKE_EFFECT_ID);
|
|
| 164 |
mController.effectFinished(FAKE_EFFECT_ID);
|
|
| 164 | 165 |
} |
| 165 | 166 |
} |
| 166 | 167 |
} |
| ... | ... | |
| 264 | 265 |
|
| 265 | 266 |
if( mNumScramblesLeft==0 ) |
| 266 | 267 |
{
|
| 267 |
mPreRender.effectFinished(FAKE_EFFECT_ID);
|
|
| 268 |
mController.effectFinished(FAKE_EFFECT_ID);
|
|
| 268 | 269 |
} |
| 269 | 270 |
} |
| 270 | 271 |
|
| ... | ... | |
| 287 | 288 |
|
| 288 | 289 |
if( mNumScramblesLeft==0 ) |
| 289 | 290 |
{
|
| 290 |
mPreRender.effectFinished(FAKE_EFFECT_ID);
|
|
| 291 |
mController.effectFinished(FAKE_EFFECT_ID);
|
|
| 291 | 292 |
} |
| 292 | 293 |
} |
| 293 | 294 |
|
| ... | ... | |
| 299 | 300 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 300 | 301 |
|
| 301 | 302 |
@SuppressWarnings("unused")
|
| 302 |
public long start(int duration, DistortedScreen screen, RubikPreRender pre)
|
|
| 303 |
public long start(int duration, DistortedScreen screen, EffectController cont)
|
|
| 303 | 304 |
{
|
| 304 |
mObject = pre.getObject();
|
|
| 305 |
mPreRender = pre;
|
|
| 305 |
mObject = cont.getObject();
|
|
| 306 |
mController= cont;
|
|
| 306 | 307 |
|
| 307 | 308 |
mObject.solve(); |
| 308 | 309 |
|
| 309 | 310 |
mBasicAngle = mObject.getBasicAngle(); |
| 310 | 311 |
|
| 311 |
int numScrambles = pre.getNumScrambles();
|
|
| 312 |
int numScrambles = cont.getNumScrambles();
|
|
| 312 | 313 |
int dura = (int)(duration*Math.pow(numScrambles,0.6f)); |
| 313 | 314 |
createBaseEffects(dura,numScrambles); |
| 314 | 315 |
createEffects (dura,numScrambles); |
| src/main/java/org/distorted/effects/solve/SolveEffect.java | ||
|---|---|---|
| 24 | 24 |
import org.distorted.library.main.DistortedEffects; |
| 25 | 25 |
import org.distorted.library.main.DistortedScreen; |
| 26 | 26 |
import org.distorted.library.message.EffectListener; |
| 27 |
import org.distorted.main.RubikPreRender;
|
|
| 27 |
import org.distorted.effects.EffectController;
|
|
| 28 | 28 |
import org.distorted.objects.TwistyObject; |
| 29 | 29 |
|
| 30 | 30 |
import java.lang.reflect.Method; |
| ... | ... | |
| 63 | 63 |
} |
| 64 | 64 |
} |
| 65 | 65 |
|
| 66 |
private EffectListener mListener;
|
|
| 66 |
private EffectController mController;
|
|
| 67 | 67 |
private int mDuration; |
| 68 | 68 |
private int mEffectReturned; |
| 69 | 69 |
private int[] mCubeEffectNumber, mNodeEffectNumber; |
| ... | ... | |
| 134 | 134 |
createEffectsPhase1(mDuration); |
| 135 | 135 |
assignEffects(mPhase); |
| 136 | 136 |
break; |
| 137 |
case 1: mListener.effectFinished(FAKE_EFFECT_ID);
|
|
| 137 |
case 1: mController.effectFinished(FAKE_EFFECT_ID);
|
|
| 138 | 138 |
break; |
| 139 | 139 |
} |
| 140 | 140 |
} |
| ... | ... | |
| 197 | 197 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 198 | 198 |
|
| 199 | 199 |
@SuppressWarnings("unused")
|
| 200 |
public long start(int duration, DistortedScreen screen, RubikPreRender pre)
|
|
| 200 |
public long start(int duration, DistortedScreen screen, EffectController cont)
|
|
| 201 | 201 |
{
|
| 202 |
mScreen = screen; |
|
| 203 |
mObject = pre.getObject();
|
|
| 204 |
mListener = pre;
|
|
| 205 |
mDuration = duration; |
|
| 202 |
mScreen = screen;
|
|
| 203 |
mObject = cont.getObject();
|
|
| 204 |
mController= cont;
|
|
| 205 |
mDuration = duration;
|
|
| 206 | 206 |
|
| 207 | 207 |
createEffectsPhase0(mDuration); |
| 208 | 208 |
assignEffects(mPhase); |
| src/main/java/org/distorted/effects/win/WinEffect.java | ||
|---|---|---|
| 24 | 24 |
import org.distorted.library.main.DistortedEffects; |
| 25 | 25 |
import org.distorted.library.main.DistortedScreen; |
| 26 | 26 |
import org.distorted.library.message.EffectListener; |
| 27 |
import org.distorted.main.RubikPreRender;
|
|
| 27 |
import org.distorted.effects.EffectController;
|
|
| 28 | 28 |
import org.distorted.objects.TwistyObject; |
| 29 | 29 |
|
| 30 | 30 |
import java.lang.reflect.Method; |
| ... | ... | |
| 62 | 62 |
} |
| 63 | 63 |
} |
| 64 | 64 |
|
| 65 |
private EffectListener mListener;
|
|
| 65 |
private EffectController mController;
|
|
| 66 | 66 |
private int mDuration; |
| 67 | 67 |
private int mEffectReturned; |
| 68 | 68 |
private int mCubeEffectNumber, mNodeEffectNumber; |
| ... | ... | |
| 142 | 142 |
|
| 143 | 143 |
if( effectID == id ) |
| 144 | 144 |
{
|
| 145 |
if( ++mEffectReturned == total ) mListener.effectFinished(FAKE_EFFECT_ID);
|
|
| 145 |
if( ++mEffectReturned == total ) mController.effectFinished(FAKE_EFFECT_ID);
|
|
| 146 | 146 |
mObject.remove(id); |
| 147 | 147 |
return; |
| 148 | 148 |
} |
| ... | ... | |
| 153 | 153 |
|
| 154 | 154 |
if( effectID == id ) |
| 155 | 155 |
{
|
| 156 |
if( ++mEffectReturned == total ) mListener.effectFinished(FAKE_EFFECT_ID);
|
|
| 156 |
if( ++mEffectReturned == total ) mController.effectFinished(FAKE_EFFECT_ID);
|
|
| 157 | 157 |
mObject.getEffects().abortById(id); |
| 158 | 158 |
return; |
| 159 | 159 |
} |
| ... | ... | |
| 163 | 163 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 164 | 164 |
|
| 165 | 165 |
@SuppressWarnings("unused")
|
| 166 |
public long start(int duration, DistortedScreen screen, RubikPreRender pre)
|
|
| 166 |
public long start(int duration, DistortedScreen screen, EffectController cont)
|
|
| 167 | 167 |
{
|
| 168 |
mScreen = screen; |
|
| 169 |
mObject = pre.getObject();
|
|
| 170 |
mListener = pre;
|
|
| 171 |
mDuration = duration; |
|
| 168 |
mScreen = screen;
|
|
| 169 |
mObject = cont.getObject();
|
|
| 170 |
mController= cont;
|
|
| 171 |
mDuration = duration;
|
|
| 172 | 172 |
|
| 173 | 173 |
createEffects(mDuration); |
| 174 | 174 |
assignEffects(); |
| src/main/java/org/distorted/main/RubikPreRender.java | ||
|---|---|---|
| 37 | 37 |
import org.distorted.dialogs.RubikDialogNewRecord; |
| 38 | 38 |
import org.distorted.dialogs.RubikDialogSolved; |
| 39 | 39 |
import org.distorted.effects.BaseEffect; |
| 40 |
import org.distorted.effects.EffectController; |
|
| 40 | 41 |
import org.distorted.effects.scramble.ScrambleEffect; |
| 41 |
import org.distorted.library.message.EffectListener; |
|
| 42 | 42 |
import org.distorted.objects.TwistyObject; |
| 43 | 43 |
import org.distorted.objects.ObjectList; |
| 44 | 44 |
import org.distorted.scores.RubikScores; |
| ... | ... | |
| 48 | 48 |
|
| 49 | 49 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
| 50 | 50 |
|
| 51 |
public class RubikPreRender implements EffectListener
|
|
| 51 |
public class RubikPreRender implements EffectController
|
|
| 52 | 52 |
{
|
| 53 | 53 |
public interface ActionFinishedListener |
| 54 | 54 |
{
|
| src/main/java/org/distorted/tutorial/TutorialActivity.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Magic Cube. // |
|
| 5 |
// // |
|
| 6 |
// Magic Cube 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 |
// Magic Cube 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 Magic Cube. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.tutorial; |
|
| 21 |
|
|
| 22 |
import android.os.Build; |
|
| 23 |
import android.os.Bundle; |
|
| 24 |
import android.util.DisplayMetrics; |
|
| 25 |
import android.view.View; |
|
| 26 |
import android.view.ViewGroup; |
|
| 27 |
import android.view.WindowManager; |
|
| 28 |
import android.webkit.WebView; |
|
| 29 |
import android.widget.LinearLayout; |
|
| 30 |
|
|
| 31 |
import androidx.appcompat.app.AppCompatActivity; |
|
| 32 |
|
|
| 33 |
import com.google.firebase.analytics.FirebaseAnalytics; |
|
| 34 |
|
|
| 35 |
import org.distorted.dialogs.RubikDialogError; |
|
| 36 |
import org.distorted.main.R; |
|
| 37 |
import org.distorted.objects.ObjectList; |
|
| 38 |
import org.distorted.objects.TwistyObject; |
|
| 39 |
import org.distorted.states.RubikStatePlay; |
|
| 40 |
import org.distorted.states.StateList; |
|
| 41 |
|
|
| 42 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 43 |
|
|
| 44 |
public class TutorialActivity extends AppCompatActivity |
|
| 45 |
{
|
|
| 46 |
public static final float DIALOG_BUTTON_SIZE = 0.06f; |
|
| 47 |
public static final float MENU_BIG_TEXT_SIZE = 0.05f; |
|
| 48 |
|
|
| 49 |
public static final int FLAGS = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
|
| 50 |
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
|
| 51 |
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
|
| 52 |
| View.SYSTEM_UI_FLAG_FULLSCREEN |
|
| 53 |
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; |
|
| 54 |
|
|
| 55 |
public static final int FLAGS2= View.SYSTEM_UI_FLAG_LAYOUT_STABLE |
|
| 56 |
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; |
|
| 57 |
|
|
| 58 |
private boolean mIsLocked; |
|
| 59 |
private FirebaseAnalytics mFirebaseAnalytics; |
|
| 60 |
private static int mScreenWidth, mScreenHeight; |
|
| 61 |
private int mCurrentApiVersion; |
|
| 62 |
private WebView mWebView; |
|
| 63 |
|
|
| 64 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 65 |
|
|
| 66 |
@Override |
|
| 67 |
protected void onCreate(Bundle savedState) |
|
| 68 |
{
|
|
| 69 |
super.onCreate(savedState); |
|
| 70 |
setTheme(R.style.CustomActivityThemeNoActionBar); |
|
| 71 |
setContentView(R.layout.tutorial); |
|
| 72 |
|
|
| 73 |
mIsLocked = false; |
|
| 74 |
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); |
|
| 75 |
|
|
| 76 |
DisplayMetrics displaymetrics = new DisplayMetrics(); |
|
| 77 |
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); |
|
| 78 |
mScreenWidth =displaymetrics.widthPixels; |
|
| 79 |
mScreenHeight=displaymetrics.heightPixels; |
|
| 80 |
|
|
| 81 |
hideNavigationBar(); |
|
| 82 |
cutoutHack(); |
|
| 83 |
} |
|
| 84 |
|
|
| 85 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 86 |
|
|
| 87 |
private void hideNavigationBar() |
|
| 88 |
{
|
|
| 89 |
mCurrentApiVersion = Build.VERSION.SDK_INT; |
|
| 90 |
|
|
| 91 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT) |
|
| 92 |
{
|
|
| 93 |
final View decorView = getWindow().getDecorView(); |
|
| 94 |
|
|
| 95 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 96 |
|
|
| 97 |
decorView.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() |
|
| 98 |
{
|
|
| 99 |
@Override |
|
| 100 |
public void onSystemUiVisibilityChange(int visibility) |
|
| 101 |
{
|
|
| 102 |
if((visibility & View.SYSTEM_UI_FLAG_FULLSCREEN) == 0) |
|
| 103 |
{
|
|
| 104 |
decorView.setSystemUiVisibility(FLAGS); |
|
| 105 |
} |
|
| 106 |
} |
|
| 107 |
}); |
|
| 108 |
} |
|
| 109 |
} |
|
| 110 |
|
|
| 111 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 112 |
|
|
| 113 |
@Override |
|
| 114 |
public void onAttachedToWindow() |
|
| 115 |
{
|
|
| 116 |
super.onAttachedToWindow(); |
|
| 117 |
|
|
| 118 |
final float RATIO = 0.10f; |
|
| 119 |
float width = getScreenWidthInPixels(); |
|
| 120 |
LinearLayout layout = findViewById(R.id.rightBar); |
|
| 121 |
ViewGroup.LayoutParams params = layout.getLayoutParams(); |
|
| 122 |
params.width = (int)(width*RATIO); |
|
| 123 |
layout.setLayoutParams(params); |
|
| 124 |
} |
|
| 125 |
|
|
| 126 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 127 |
// do not avoid cutouts |
|
| 128 |
|
|
| 129 |
private void cutoutHack() |
|
| 130 |
{
|
|
| 131 |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) |
|
| 132 |
{
|
|
| 133 |
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES; |
|
| 134 |
} |
|
| 135 |
} |
|
| 136 |
|
|
| 137 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 138 |
|
|
| 139 |
@Override |
|
| 140 |
public void onWindowFocusChanged(boolean hasFocus) |
|
| 141 |
{
|
|
| 142 |
super.onWindowFocusChanged(hasFocus); |
|
| 143 |
|
|
| 144 |
if(mCurrentApiVersion >= Build.VERSION_CODES.KITKAT && hasFocus) |
|
| 145 |
{
|
|
| 146 |
getWindow().getDecorView().setSystemUiVisibility(FLAGS); |
|
| 147 |
} |
|
| 148 |
} |
|
| 149 |
|
|
| 150 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 151 |
|
|
| 152 |
@Override |
|
| 153 |
protected void onPause() |
|
| 154 |
{
|
|
| 155 |
super.onPause(); |
|
| 156 |
TutorialSurfaceView view = findViewById(R.id.tutorialSurfaceView); |
|
| 157 |
view.onPause(); |
|
| 158 |
} |
|
| 159 |
|
|
| 160 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 161 |
|
|
| 162 |
@Override |
|
| 163 |
protected void onResume() |
|
| 164 |
{
|
|
| 165 |
super.onResume(); |
|
| 166 |
TutorialSurfaceView view = findViewById(R.id.tutorialSurfaceView); |
|
| 167 |
view.onResume(); |
|
| 168 |
view.initialize(); |
|
| 169 |
|
|
| 170 |
boolean success = false; |
|
| 171 |
RubikStatePlay play = (RubikStatePlay) StateList.PLAY.getStateClass(); |
|
| 172 |
int object = play.getObject(); |
|
| 173 |
int size = play.getSize(); |
|
| 174 |
|
|
| 175 |
if( object>=0 && object< ObjectList.NUM_OBJECTS ) |
|
| 176 |
{
|
|
| 177 |
ObjectList obj = ObjectList.getObject(object); |
|
| 178 |
int[] sizes = obj.getSizes(); |
|
| 179 |
int sizeIndex = ObjectList.getSizeIndex(object,size); |
|
| 180 |
|
|
| 181 |
if( sizeIndex>=0 && sizeIndex<sizes.length ) |
|
| 182 |
{
|
|
| 183 |
success = true; |
|
| 184 |
view.getPreRender().changeObject(obj,size); |
|
| 185 |
} |
|
| 186 |
} |
|
| 187 |
/* |
|
| 188 |
if( !success ) |
|
| 189 |
{
|
|
| 190 |
ObjectList obj = ObjectList.getObject(RubikStatePlay.DEF_OBJECT); |
|
| 191 |
int s = RubikStatePlay.DEF_SIZE; |
|
| 192 |
|
|
| 193 |
play.setObjectAndSize(this,obj,s); |
|
| 194 |
view.getPreRender().changeObject(obj,s); |
|
| 195 |
} |
|
| 196 |
*/ |
|
| 197 |
} |
|
| 198 |
|
|
| 199 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 200 |
|
|
| 201 |
@Override |
|
| 202 |
protected void onDestroy() |
|
| 203 |
{
|
|
| 204 |
super.onDestroy(); |
|
| 205 |
} |
|
| 206 |
|
|
| 207 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 208 |
|
|
| 209 |
void OpenGLError() |
|
| 210 |
{
|
|
| 211 |
RubikDialogError errDiag = new RubikDialogError(); |
|
| 212 |
errDiag.show(getSupportFragmentManager(), null); |
|
| 213 |
} |
|
| 214 |
|
|
| 215 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 216 |
// PUBLIC API |
|
| 217 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 218 |
|
|
| 219 |
public FirebaseAnalytics getAnalytics() |
|
| 220 |
{
|
|
| 221 |
return mFirebaseAnalytics; |
|
| 222 |
} |
|
| 223 |
|
|
| 224 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 225 |
|
|
| 226 |
public TwistyObject getObject() |
|
| 227 |
{
|
|
| 228 |
TutorialSurfaceView view = findViewById(R.id.rubikSurfaceView); |
|
| 229 |
TutorialPreRender pre = view.getPreRender(); |
|
| 230 |
return pre.getObject(); |
|
| 231 |
} |
|
| 232 |
|
|
| 233 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 234 |
|
|
| 235 |
public int getScreenWidthInPixels() |
|
| 236 |
{
|
|
| 237 |
return mScreenWidth; |
|
| 238 |
} |
|
| 239 |
|
|
| 240 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 241 |
|
|
| 242 |
public int getScreenHeightInPixels() |
|
| 243 |
{
|
|
| 244 |
return mScreenHeight; |
|
| 245 |
} |
|
| 246 |
|
|
| 247 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 248 |
|
|
| 249 |
public TutorialPreRender getPreRender() |
|
| 250 |
{
|
|
| 251 |
TutorialSurfaceView view = findViewById(R.id.tutorialSurfaceView); |
|
| 252 |
return view.getPreRender(); |
|
| 253 |
} |
|
| 254 |
|
|
| 255 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 256 |
|
|
| 257 |
public static int getDrawableSize() |
|
| 258 |
{
|
|
| 259 |
if( mScreenHeight<1000 ) |
|
| 260 |
{
|
|
| 261 |
return 0; |
|
| 262 |
} |
|
| 263 |
if( mScreenHeight<1600 ) |
|
| 264 |
{
|
|
| 265 |
return 1; |
|
| 266 |
} |
|
| 267 |
if( mScreenHeight<1900 ) |
|
| 268 |
{
|
|
| 269 |
return 2; |
|
| 270 |
} |
|
| 271 |
|
|
| 272 |
return 3; |
|
| 273 |
} |
|
| 274 |
|
|
| 275 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 276 |
|
|
| 277 |
public static int getDrawable(int small, int medium, int big, int huge) |
|
| 278 |
{
|
|
| 279 |
int size = getDrawableSize(); |
|
| 280 |
|
|
| 281 |
switch(size) |
|
| 282 |
{
|
|
| 283 |
case 0 : return small; |
|
| 284 |
case 1 : return medium; |
|
| 285 |
case 2 : return big; |
|
| 286 |
default: return huge; |
|
| 287 |
} |
|
| 288 |
} |
|
| 289 |
|
|
| 290 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 291 |
|
|
| 292 |
public boolean isVertical() |
|
| 293 |
{
|
|
| 294 |
TutorialSurfaceView view = findViewById(R.id.tutorialSurfaceView); |
|
| 295 |
return view.isVertical(); |
|
| 296 |
} |
|
| 297 |
|
|
| 298 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 299 |
|
|
| 300 |
public void toggleLock() |
|
| 301 |
{
|
|
| 302 |
mIsLocked = !mIsLocked; |
|
| 303 |
} |
|
| 304 |
|
|
| 305 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 306 |
|
|
| 307 |
public boolean isLocked() |
|
| 308 |
{
|
|
| 309 |
StateList state = StateList.getCurrentState(); |
|
| 310 |
|
|
| 311 |
if( state== StateList.PLAY || state== StateList.READ || state== StateList.SOLV ) |
|
| 312 |
{
|
|
| 313 |
return mIsLocked; |
|
| 314 |
} |
|
| 315 |
|
|
| 316 |
return false; |
|
| 317 |
} |
|
| 318 |
|
|
| 319 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 320 |
|
|
| 321 |
public boolean retLocked() |
|
| 322 |
{
|
|
| 323 |
return mIsLocked; |
|
| 324 |
} |
|
| 325 |
} |
|
| src/main/java/org/distorted/tutorial/TutorialPreRender.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2020 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Magic Cube. // |
|
| 5 |
// // |
|
| 6 |
// Magic Cube 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 |
// Magic Cube 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 Magic Cube. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.tutorial; |
|
| 21 |
|
|
| 22 |
import android.content.Context; |
|
| 23 |
import android.content.res.Resources; |
|
| 24 |
|
|
| 25 |
import org.distorted.effects.BaseEffect; |
|
| 26 |
import org.distorted.effects.EffectController; |
|
| 27 |
import org.distorted.objects.ObjectList; |
|
| 28 |
import org.distorted.objects.TwistyObject; |
|
| 29 |
import org.distorted.main.RubikPreRender.ActionFinishedListener; |
|
| 30 |
|
|
| 31 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 32 |
|
|
| 33 |
public class TutorialPreRender implements EffectController |
|
| 34 |
{
|
|
| 35 |
private ActionFinishedListener mAddActionListener; |
|
| 36 |
private TutorialSurfaceView mView; |
|
| 37 |
private boolean mFinishRotation, mRemoveRotation, mAddRotation, |
|
| 38 |
mSetQuat, mChangeObject, mSetupObject, mSolveObject, |
|
| 39 |
mInitializeObject, mResetAllTextureMaps, mRemovePatternRotation; |
|
| 40 |
private boolean mCanPlay; |
|
| 41 |
private boolean mIsSolved; |
|
| 42 |
private ObjectList mNextObject; |
|
| 43 |
private int mNextSize; |
|
| 44 |
private long mRotationFinishedID; |
|
| 45 |
private int mScreenWidth; |
|
| 46 |
private int[][] mNextMoves; |
|
| 47 |
private TwistyObject mOldObject, mNewObject; |
|
| 48 |
private int mAddRotationAxis, mAddRotationRowBitmap, mAddRotationAngle; |
|
| 49 |
private long mAddRotationDuration; |
|
| 50 |
private long mAddRotationID, mRemoveRotationID; |
|
| 51 |
private int mNearestAngle; |
|
| 52 |
|
|
| 53 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 54 |
|
|
| 55 |
TutorialPreRender(TutorialSurfaceView view) |
|
| 56 |
{
|
|
| 57 |
mView = view; |
|
| 58 |
|
|
| 59 |
mFinishRotation = false; |
|
| 60 |
mRemoveRotation = false; |
|
| 61 |
mAddRotation = false; |
|
| 62 |
mSetQuat = false; |
|
| 63 |
mChangeObject = false; |
|
| 64 |
mSetupObject = false; |
|
| 65 |
mSolveObject = false; |
|
| 66 |
mCanPlay = true; |
|
| 67 |
mOldObject = null; |
|
| 68 |
mNewObject = null; |
|
| 69 |
mScreenWidth = 0; |
|
| 70 |
|
|
| 71 |
mRemovePatternRotation= false; |
|
| 72 |
} |
|
| 73 |
|
|
| 74 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 75 |
|
|
| 76 |
private void createObjectNow(ObjectList object, int size, int[][] moves) |
|
| 77 |
{
|
|
| 78 |
if( mOldObject!=null ) mOldObject.releaseResources(); |
|
| 79 |
mOldObject = mNewObject; |
|
| 80 |
|
|
| 81 |
Context con = mView.getContext(); |
|
| 82 |
Resources res = con.getResources(); |
|
| 83 |
|
|
| 84 |
mNewObject = object.create(size, mView.getQuat(), moves, res, mScreenWidth); |
|
| 85 |
|
|
| 86 |
if( mNewObject!=null ) |
|
| 87 |
{
|
|
| 88 |
mNewObject.createTexture(); |
|
| 89 |
mView.setMovement(object.getObjectMovementClass()); |
|
| 90 |
|
|
| 91 |
if( mScreenWidth!=0 ) |
|
| 92 |
{
|
|
| 93 |
mNewObject.recomputeScaleFactor(mScreenWidth); |
|
| 94 |
} |
|
| 95 |
|
|
| 96 |
mIsSolved = mNewObject.isSolved(); |
|
| 97 |
} |
|
| 98 |
} |
|
| 99 |
|
|
| 100 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 101 |
|
|
| 102 |
private void doEffectNow(BaseEffect.Type type) |
|
| 103 |
{
|
|
| 104 |
try |
|
| 105 |
{
|
|
| 106 |
type.startEffect(mView.getRenderer().getScreen(),this); |
|
| 107 |
} |
|
| 108 |
catch( Exception ex ) |
|
| 109 |
{
|
|
| 110 |
mCanPlay= true; |
|
| 111 |
} |
|
| 112 |
} |
|
| 113 |
|
|
| 114 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 115 |
|
|
| 116 |
private void removePatternRotation() |
|
| 117 |
{
|
|
| 118 |
mRemovePatternRotation = true; |
|
| 119 |
} |
|
| 120 |
|
|
| 121 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 122 |
|
|
| 123 |
private void removePatternRotationNow() |
|
| 124 |
{
|
|
| 125 |
mRemovePatternRotation=false; |
|
| 126 |
mNewObject.removeRotationNow(); |
|
| 127 |
mAddActionListener.onActionFinished(mRemoveRotationID); |
|
| 128 |
} |
|
| 129 |
|
|
| 130 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 131 |
|
|
| 132 |
private void removeRotationNow() |
|
| 133 |
{
|
|
| 134 |
mRemoveRotation=false; |
|
| 135 |
mNewObject.removeRotationNow(); |
|
| 136 |
|
|
| 137 |
boolean solved = mNewObject.isSolved(); |
|
| 138 |
|
|
| 139 |
if( solved && !mIsSolved ) |
|
| 140 |
{
|
|
| 141 |
doEffectNow( BaseEffect.Type.WIN ); |
|
| 142 |
} |
|
| 143 |
else |
|
| 144 |
{
|
|
| 145 |
mCanPlay = true; |
|
| 146 |
} |
|
| 147 |
|
|
| 148 |
mIsSolved = solved; |
|
| 149 |
} |
|
| 150 |
|
|
| 151 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 152 |
|
|
| 153 |
private void removeRotation() |
|
| 154 |
{
|
|
| 155 |
mRemoveRotation = true; |
|
| 156 |
} |
|
| 157 |
|
|
| 158 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 159 |
|
|
| 160 |
private void addRotationNow() |
|
| 161 |
{
|
|
| 162 |
mAddRotation = false; |
|
| 163 |
mAddRotationID = mNewObject.addNewRotation( mAddRotationAxis, mAddRotationRowBitmap, |
|
| 164 |
mAddRotationAngle, mAddRotationDuration, this); |
|
| 165 |
} |
|
| 166 |
|
|
| 167 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 168 |
|
|
| 169 |
private void finishRotationNow() |
|
| 170 |
{
|
|
| 171 |
mFinishRotation = false; |
|
| 172 |
mCanPlay = false; |
|
| 173 |
mRotationFinishedID = mNewObject.finishRotationNow(this, mNearestAngle); |
|
| 174 |
|
|
| 175 |
if( mRotationFinishedID==0 ) // failed to add effect - should never happen |
|
| 176 |
{
|
|
| 177 |
mCanPlay = true; |
|
| 178 |
} |
|
| 179 |
} |
|
| 180 |
|
|
| 181 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 182 |
|
|
| 183 |
private void changeObjectNow() |
|
| 184 |
{
|
|
| 185 |
mChangeObject = false; |
|
| 186 |
|
|
| 187 |
if ( mNewObject==null || mNewObject.getObjectList()!=mNextObject || mNewObject.getNumLayers()!=mNextSize) |
|
| 188 |
{
|
|
| 189 |
mCanPlay = false; |
|
| 190 |
createObjectNow(mNextObject, mNextSize, null); |
|
| 191 |
doEffectNow( BaseEffect.Type.SIZECHANGE ); |
|
| 192 |
} |
|
| 193 |
} |
|
| 194 |
|
|
| 195 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 196 |
|
|
| 197 |
private void setupObjectNow() |
|
| 198 |
{
|
|
| 199 |
mSetupObject = false; |
|
| 200 |
|
|
| 201 |
if ( mNewObject==null || mNewObject.getObjectList()!=mNextObject || mNewObject.getNumLayers()!=mNextSize) |
|
| 202 |
{
|
|
| 203 |
mCanPlay = false; |
|
| 204 |
createObjectNow(mNextObject, mNextSize, mNextMoves); |
|
| 205 |
doEffectNow( BaseEffect.Type.SIZECHANGE ); |
|
| 206 |
} |
|
| 207 |
else |
|
| 208 |
{
|
|
| 209 |
mNewObject.initializeObject(mNextMoves); |
|
| 210 |
} |
|
| 211 |
} |
|
| 212 |
|
|
| 213 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 214 |
|
|
| 215 |
private void solveObjectNow() |
|
| 216 |
{
|
|
| 217 |
mSolveObject = false; |
|
| 218 |
mCanPlay = false; |
|
| 219 |
doEffectNow( BaseEffect.Type.SOLVE ); |
|
| 220 |
} |
|
| 221 |
|
|
| 222 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 223 |
|
|
| 224 |
private void initializeObjectNow() |
|
| 225 |
{
|
|
| 226 |
mInitializeObject = false; |
|
| 227 |
mNewObject.initializeObject(mNextMoves); |
|
| 228 |
} |
|
| 229 |
|
|
| 230 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 231 |
|
|
| 232 |
private void resetAllTextureMapsNow() |
|
| 233 |
{
|
|
| 234 |
mResetAllTextureMaps = false; |
|
| 235 |
|
|
| 236 |
if( mNewObject!=null ) mNewObject.resetAllTextureMaps(); |
|
| 237 |
} |
|
| 238 |
|
|
| 239 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 240 |
|
|
| 241 |
private void setQuatNow() |
|
| 242 |
{
|
|
| 243 |
mSetQuat = false; |
|
| 244 |
mView.setQuat(); |
|
| 245 |
} |
|
| 246 |
|
|
| 247 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 248 |
// |
|
| 249 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 250 |
|
|
| 251 |
void setScreenSize(int width) |
|
| 252 |
{
|
|
| 253 |
if( mNewObject!=null ) |
|
| 254 |
{
|
|
| 255 |
mNewObject.createTexture(); |
|
| 256 |
mNewObject.recomputeScaleFactor(width); |
|
| 257 |
} |
|
| 258 |
|
|
| 259 |
mScreenWidth = width; |
|
| 260 |
} |
|
| 261 |
|
|
| 262 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 263 |
|
|
| 264 |
void finishRotation(int nearestAngle) |
|
| 265 |
{
|
|
| 266 |
mNearestAngle = nearestAngle; |
|
| 267 |
mFinishRotation = true; |
|
| 268 |
} |
|
| 269 |
|
|
| 270 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 271 |
|
|
| 272 |
void changeObject(ObjectList object, int size) |
|
| 273 |
{
|
|
| 274 |
if( size>0 ) |
|
| 275 |
{
|
|
| 276 |
mChangeObject = true; |
|
| 277 |
mNextObject = object; |
|
| 278 |
mNextSize = size; |
|
| 279 |
} |
|
| 280 |
} |
|
| 281 |
|
|
| 282 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 283 |
|
|
| 284 |
void setQuatOnNextRender() |
|
| 285 |
{
|
|
| 286 |
mSetQuat = true; |
|
| 287 |
} |
|
| 288 |
|
|
| 289 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 290 |
|
|
| 291 |
void preRender() |
|
| 292 |
{
|
|
| 293 |
if( mSetQuat ) setQuatNow(); |
|
| 294 |
if( mFinishRotation ) finishRotationNow(); |
|
| 295 |
if( mRemoveRotation ) removeRotationNow(); |
|
| 296 |
if( mChangeObject ) changeObjectNow(); |
|
| 297 |
if( mSetupObject ) setupObjectNow(); |
|
| 298 |
if( mSolveObject ) solveObjectNow(); |
|
| 299 |
if( mAddRotation ) addRotationNow(); |
|
| 300 |
if( mInitializeObject ) initializeObjectNow(); |
|
| 301 |
if( mResetAllTextureMaps ) resetAllTextureMapsNow(); |
|
| 302 |
if( mRemovePatternRotation ) removePatternRotationNow(); |
|
| 303 |
} |
|
| 304 |
|
|
| 305 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 306 |
// PUBLIC API |
|
| 307 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 308 |
|
|
| 309 |
public void addRotation(ActionFinishedListener listener, int axis, int rowBitmap, int angle, long duration) |
|
| 310 |
{
|
|
| 311 |
mAddRotation = true; |
|
| 312 |
|
|
| 313 |
mAddActionListener = listener; |
|
| 314 |
mAddRotationAxis = axis; |
|
| 315 |
mAddRotationRowBitmap = rowBitmap; |
|
| 316 |
mAddRotationAngle = angle; |
|
| 317 |
mAddRotationDuration = duration; |
|
| 318 |
} |
|
| 319 |
|
|
| 320 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 321 |
|
|
| 322 |
public void initializeObject(int[][] moves) |
|
| 323 |
{
|
|
| 324 |
mInitializeObject = true; |
|
| 325 |
mNextMoves = moves; |
|
| 326 |
} |
|
| 327 |
|
|
| 328 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 329 |
|
|
| 330 |
public int getNumScrambles() |
|
| 331 |
{
|
|
| 332 |
return 0; |
|
| 333 |
} |
|
| 334 |
|
|
| 335 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 336 |
|
|
| 337 |
public void solveObject() |
|
| 338 |
{
|
|
| 339 |
if( mCanPlay ) |
|
| 340 |
{
|
|
| 341 |
mSolveObject = true; |
|
| 342 |
} |
|
| 343 |
} |
|
| 344 |
|
|
| 345 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 346 |
|
|
| 347 |
public void resetAllTextureMaps() |
|
| 348 |
{
|
|
| 349 |
mResetAllTextureMaps = true; |
|
| 350 |
} |
|
| 351 |
|
|
| 352 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 353 |
|
|
| 354 |
public TwistyObject getObject() |
|
| 355 |
{
|
|
| 356 |
return mNewObject; |
|
| 357 |
} |
|
| 358 |
|
|
| 359 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 360 |
|
|
| 361 |
public TwistyObject getOldObject() |
|
| 362 |
{
|
|
| 363 |
return null; |
|
| 364 |
} |
|
| 365 |
|
|
| 366 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 367 |
|
|
| 368 |
public void effectFinished(final long effectID) |
|
| 369 |
{
|
|
| 370 |
if( effectID == mRotationFinishedID ) |
|
| 371 |
{
|
|
| 372 |
mRotationFinishedID = 0; |
|
| 373 |
removeRotation(); |
|
| 374 |
} |
|
| 375 |
else if( effectID == mAddRotationID ) |
|
| 376 |
{
|
|
| 377 |
mAddRotationID = 0; |
|
| 378 |
mRemoveRotationID = effectID; |
|
| 379 |
removePatternRotation(); |
|
| 380 |
} |
|
| 381 |
else |
|
| 382 |
{
|
|
| 383 |
mCanPlay = true; |
|
| 384 |
} |
|
| 385 |
} |
|
| 386 |
} |
|
| src/main/java/org/distorted/tutorial/TutorialRenderer.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Magic Cube. // |
|
| 5 |
// // |
|
| 6 |
// Magic Cube 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 |
// Magic Cube 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 Magic Cube. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.tutorial; |
|
| 21 |
|
|
| 22 |
import android.opengl.GLSurfaceView; |
|
| 23 |
|
|
| 24 |
import org.distorted.library.main.DistortedScreen; |
|
| 25 |
|
|
| 26 |
import javax.microedition.khronos.egl.EGLConfig; |
|
| 27 |
import javax.microedition.khronos.opengles.GL10; |
|
| 28 |
|
|
| 29 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 30 |
|
|
| 31 |
public class TutorialRenderer implements GLSurfaceView.Renderer |
|
| 32 |
{
|
|
| 33 |
private TutorialSurfaceView mView; |
|
| 34 |
private DistortedScreen mScreen; |
|
| 35 |
|
|
| 36 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 37 |
|
|
| 38 |
TutorialRenderer(TutorialSurfaceView v) |
|
| 39 |
{
|
|
| 40 |
final float BRIGHTNESS = 0.30f; |
|
| 41 |
|
|
| 42 |
mView = v; |
|
| 43 |
mScreen = new DistortedScreen(); |
|
| 44 |
mScreen.glClearColor(BRIGHTNESS, BRIGHTNESS, BRIGHTNESS, 1.0f); |
|
| 45 |
} |
|
| 46 |
|
|
| 47 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 48 |
|
|
| 49 |
@Override |
|
| 50 |
public void onDrawFrame(GL10 glUnused) |
|
| 51 |
{
|
|
| 52 |
long time = System.currentTimeMillis(); |
|
| 53 |
mView.getPreRender().preRender(); |
|
| 54 |
mScreen.render(time); |
|
| 55 |
} |
|
| 56 |
|
|
| 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 58 |
|
|
| 59 |
@Override |
|
| 60 |
public void onSurfaceChanged(GL10 glUnused, int width, int height) |
|
| 61 |
{
|
|
| 62 |
mScreen.resize(width,height); |
|
| 63 |
mView.setScreenSize(width,height); |
|
| 64 |
mView.getPreRender().setScreenSize(width); |
|
| 65 |
} |
|
| 66 |
|
|
| 67 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 68 |
|
|
| 69 |
@Override |
|
| 70 |
public void onSurfaceCreated(GL10 glUnused, EGLConfig config) |
|
| 71 |
{
|
|
| 72 |
|
|
| 73 |
} |
|
| 74 |
|
|
| 75 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 76 |
|
|
| 77 |
DistortedScreen getScreen() |
|
| 78 |
{
|
|
| 79 |
return mScreen; |
|
| 80 |
} |
|
| 81 |
} |
|
| src/main/java/org/distorted/tutorial/TutorialSurfaceView.java | ||
|---|---|---|
| 1 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 2 |
// Copyright 2019 Leszek Koltunski // |
|
| 3 |
// // |
|
| 4 |
// This file is part of Magic Cube. // |
|
| 5 |
// // |
|
| 6 |
// Magic Cube 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 |
// Magic Cube 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 Magic Cube. If not, see <http://www.gnu.org/licenses/>. // |
|
| 18 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 19 |
|
|
| 20 |
package org.distorted.tutorial; |
|
| 21 |
|
|
| 22 |
import android.app.ActivityManager; |
|
| 23 |
import android.content.Context; |
|
| 24 |
import android.content.pm.ConfigurationInfo; |
|
| 25 |
import android.opengl.GLES30; |
|
| 26 |
import android.opengl.GLSurfaceView; |
|
| 27 |
import android.util.AttributeSet; |
|
| 28 |
import android.util.DisplayMetrics; |
|
| 29 |
import android.view.MotionEvent; |
|
| 30 |
|
|
| 31 |
import com.google.firebase.crashlytics.FirebaseCrashlytics; |
|
| 32 |
|
|
| 33 |
import org.distorted.library.type.Static2D; |
|
| 34 |
import org.distorted.library.type.Static4D; |
|
| 35 |
import org.distorted.objects.Movement; |
|
| 36 |
import org.distorted.objects.TwistyObject; |
|
| 37 |
import org.distorted.states.RubikStateSolving; |
|
| 38 |
import org.distorted.states.StateList; |
|
| 39 |
|
|
| 40 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 41 |
|
|
| 42 |
public class TutorialSurfaceView extends GLSurfaceView |
|
| 43 |
{
|
|
| 44 |
private static final int NUM_SPEED_PROBES = 10; |
|
| 45 |
private static final int INVALID_POINTER_ID = -1; |
|
| 46 |
|
|
| 47 |
// Moving the finger from the middle of the vertical screen to the right edge will rotate a |
|
| 48 |
// given face by SWIPING_SENSITIVITY/2 degrees. |
|
| 49 |
private final static int SWIPING_SENSITIVITY = 240; |
|
| 50 |
// Moving the finger by 0.3 of an inch will start a Rotation. |
|
| 51 |
private final static float ROTATION_SENSITIVITY = 0.3f; |
|
| 52 |
|
|
| 53 |
private final Static4D CAMERA_POINT = new Static4D(0, 0, 1, 0); |
|
| 54 |
|
|
| 55 |
private TutorialRenderer mRenderer; |
|
| 56 |
private TutorialPreRender mPreRender; |
|
| 57 |
private Movement mMovement; |
|
| 58 |
private boolean mDragging, mBeginningRotation, mContinuingRotation; |
|
| 59 |
private int mScreenWidth, mScreenHeight, mScreenMin; |
|
| 60 |
|
|
| 61 |
private float mRotAngle, mInitDistance; |
|
| 62 |
private int mPtrID1, mPtrID2; |
|
| 63 |
private float mX, mY; |
|
| 64 |
private float mStartRotX, mStartRotY; |
|
| 65 |
private float mAxisX, mAxisY; |
|
| 66 |
private float mRotationFactor; |
|
| 67 |
private int mCurrentAxis, mCurrentRow; |
|
| 68 |
private float mCurrentAngle, mCurrRotSpeed; |
|
| 69 |
private float[] mLastX; |
|
| 70 |
private float[] mLastY; |
|
| 71 |
private long[] mLastT; |
|
| 72 |
private int mFirstIndex, mLastIndex; |
|
| 73 |
private int mDensity; |
|
| 74 |
|
|
| 75 |
private static Static4D mQuat= new Static4D(-0.25189602f,0.3546389f,0.009657208f,0.90038127f); |
|
| 76 |
private static Static4D mTemp= new Static4D(0,0,0,1); |
|
| 77 |
|
|
| 78 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 79 |
|
|
| 80 |
void setScreenSize(int width, int height) |
|
| 81 |
{
|
|
| 82 |
mScreenWidth = width; |
|
| 83 |
mScreenHeight= height; |
|
| 84 |
|
|
| 85 |
mScreenMin = Math.min(width, height); |
|
| 86 |
} |
|
| 87 |
|
|
| 88 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 89 |
|
|
| 90 |
boolean isVertical() |
|
| 91 |
{
|
|
| 92 |
return mScreenHeight>mScreenWidth; |
|
| 93 |
} |
|
| 94 |
|
|
| 95 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 96 |
|
|
| 97 |
TutorialRenderer getRenderer() |
|
| 98 |
{
|
|
| 99 |
return mRenderer; |
|
| 100 |
} |
|
| 101 |
|
|
| 102 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 103 |
|
|
| 104 |
TutorialPreRender getPreRender() |
|
| 105 |
{
|
|
| 106 |
return mPreRender; |
|
| 107 |
} |
|
| 108 |
|
|
| 109 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 110 |
|
|
| 111 |
void setQuat() |
|
| 112 |
{
|
|
| 113 |
mQuat.set(mTemp); |
|
| 114 |
} |
|
| 115 |
|
|
| 116 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 117 |
|
|
| 118 |
Static4D getQuat() |
|
| 119 |
{
|
|
| 120 |
return mQuat; |
|
| 121 |
} |
|
| 122 |
|
|
| 123 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 124 |
|
|
| 125 |
void setMovement(Movement movement) |
|
| 126 |
{
|
|
| 127 |
mMovement = movement; |
|
| 128 |
} |
|
| 129 |
|
|
| 130 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 131 |
|
|
| 132 |
private Static4D quatFromDrag(float dragX, float dragY) |
|
| 133 |
{
|
|
| 134 |
float axisX = dragY; // inverted X and Y - rotation axis is perpendicular to (dragX,dragY) |
|
| 135 |
float axisY = dragX; // Why not (-dragY, dragX) ? because Y axis is also inverted! |
|
| 136 |
float axisZ = 0; |
|
| 137 |
float axisL = (float)Math.sqrt(axisX*axisX + axisY*axisY + axisZ*axisZ); |
|
| 138 |
|
|
| 139 |
if( axisL>0 ) |
|
| 140 |
{
|
|
| 141 |
axisX /= axisL; |
|
| 142 |
axisY /= axisL; |
|
| 143 |
axisZ /= axisL; |
|
| 144 |
|
|
| 145 |
float ratio = axisL; |
|
| 146 |
ratio = ratio - (int)ratio; // the cos() is only valid in (0,Pi) |
|
| 147 |
|
|
| 148 |
float cosA = (float)Math.cos(Math.PI*ratio); |
|
| 149 |
float sinA = (float)Math.sqrt(1-cosA*cosA); |
|
| 150 |
|
|
| 151 |
return new Static4D(axisX*sinA, axisY*sinA, axisZ*sinA, cosA); |
|
| 152 |
} |
|
| 153 |
|
|
| 154 |
return new Static4D(0f, 0f, 0f, 1f); |
|
| 155 |
} |
|
| 156 |
|
|
| 157 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 158 |
// cast the 3D axis we are currently rotating along (which is already casted to the surface of the |
|
| 159 |
// currently touched face AND converted into a 4D vector - fourth 0) to a 2D in-screen-surface axis |
|
| 160 |
|
|
| 161 |
private void computeCurrentAxis(Static4D axis) |
|
| 162 |
{
|
|
| 163 |
Static4D result = rotateVectorByQuat(axis, mQuat); |
|
| 164 |
|
|
| 165 |
mAxisX =result.get0(); |
|
| 166 |
mAxisY =result.get1(); |
|
| 167 |
|
|
| 168 |
float len = (float)Math.sqrt(mAxisX*mAxisX + mAxisY*mAxisY); |
|
| 169 |
mAxisX /= len; |
|
| 170 |
mAxisY /= len; |
|
| 171 |
} |
|
| 172 |
|
|
| 173 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 174 |
// return quat1*quat2 |
|
| 175 |
|
|
| 176 |
public static Static4D quatMultiply( Static4D quat1, Static4D quat2 ) |
|
| 177 |
{
|
|
| 178 |
float qx = quat1.get0(); |
|
| 179 |
float qy = quat1.get1(); |
|
| 180 |
float qz = quat1.get2(); |
|
| 181 |
float qw = quat1.get3(); |
|
| 182 |
|
|
| 183 |
float rx = quat2.get0(); |
|
| 184 |
float ry = quat2.get1(); |
|
| 185 |
float rz = quat2.get2(); |
|
| 186 |
float rw = quat2.get3(); |
|
| 187 |
|
|
| 188 |
float tx = rw*qx - rz*qy + ry*qz + rx*qw; |
|
| 189 |
float ty = rw*qy + rz*qx + ry*qw - rx*qz; |
|
| 190 |
float tz = rw*qz + rz*qw - ry*qx + rx*qy; |
|
| 191 |
float tw = rw*qw - rz*qz - ry*qy - rx*qx; |
|
| 192 |
|
|
| 193 |
return new Static4D(tx,ty,tz,tw); |
|
| 194 |
} |
|
| 195 |
|
|
| 196 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 197 |
// rotate 'vector' by quat ( i.e. return quat*vector*(quat^-1) ) |
|
| 198 |
|
|
| 199 |
public static Static4D rotateVectorByQuat(Static4D vector, Static4D quat) |
|
| 200 |
{
|
|
| 201 |
float qx = quat.get0(); |
|
| 202 |
float qy = quat.get1(); |
|
| 203 |
float qz = quat.get2(); |
|
| 204 |
float qw = quat.get3(); |
|
| 205 |
|
|
| 206 |
Static4D quatInverted= new Static4D(-qx,-qy,-qz,qw); |
|
| 207 |
Static4D tmp = quatMultiply(quat,vector); |
|
| 208 |
|
|
| 209 |
return quatMultiply(tmp,quatInverted); |
|
| 210 |
} |
|
| 211 |
|
|
| 212 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 213 |
// rotate 'vector' by quat^(-1) ( i.e. return (quat^-1)*vector*quat ) |
|
| 214 |
|
|
| 215 |
public static Static4D rotateVectorByInvertedQuat(Static4D vector, Static4D quat) |
|
| 216 |
{
|
|
| 217 |
float qx = quat.get0(); |
|
| 218 |
float qy = quat.get1(); |
|
| 219 |
float qz = quat.get2(); |
|
| 220 |
float qw = quat.get3(); |
|
| 221 |
|
|
| 222 |
Static4D quatInverted= new Static4D(-qx,-qy,-qz,qw); |
|
| 223 |
Static4D tmp = quatMultiply(quatInverted,vector); |
|
| 224 |
|
|
| 225 |
return quatMultiply(tmp,quat); |
|
| 226 |
} |
|
| 227 |
|
|
| 228 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 229 |
|
|
| 230 |
private void addSpeedProbe(float x, float y) |
|
| 231 |
{
|
|
| 232 |
long currTime = System.currentTimeMillis(); |
|
| 233 |
boolean theSame = mLastIndex==mFirstIndex; |
|
| 234 |
|
|
| 235 |
mLastIndex++; |
|
| 236 |
if( mLastIndex>=NUM_SPEED_PROBES ) mLastIndex=0; |
|
| 237 |
|
|
| 238 |
mLastT[mLastIndex] = currTime; |
|
| 239 |
mLastX[mLastIndex] = x; |
|
| 240 |
mLastY[mLastIndex] = y; |
|
| 241 |
|
|
| 242 |
if( mLastIndex==mFirstIndex) |
|
| 243 |
{
|
|
| 244 |
mFirstIndex++; |
|
| 245 |
if( mFirstIndex>=NUM_SPEED_PROBES ) mFirstIndex=0; |
|
| 246 |
} |
|
| 247 |
|
|
| 248 |
if( theSame ) |
|
| 249 |
{
|
|
| 250 |
mLastT[mFirstIndex] = currTime; |
|
| 251 |
mLastX[mFirstIndex] = x; |
|
| 252 |
mLastY[mFirstIndex] = y; |
|
| 253 |
} |
|
| 254 |
} |
|
| 255 |
|
|
| 256 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 257 |
|
|
| 258 |
private void computeCurrentSpeedInInchesPerSecond() |
|
| 259 |
{
|
|
| 260 |
long firstTime = mLastT[mFirstIndex]; |
|
| 261 |
long lastTime = mLastT[mLastIndex]; |
|
| 262 |
float fX = mLastX[mFirstIndex]; |
|
| 263 |
float fY = mLastY[mFirstIndex]; |
|
| 264 |
float lX = mLastX[mLastIndex]; |
|
| 265 |
float lY = mLastY[mLastIndex]; |
|
| 266 |
|
|
| 267 |
long timeDiff = lastTime-firstTime; |
|
| 268 |
|
|
| 269 |
mLastIndex = 0; |
|
| 270 |
mFirstIndex= 0; |
|
| 271 |
|
|
| 272 |
mCurrRotSpeed = timeDiff>0 ? 1000*retFingerDragDistanceInInches(fX,fY,lX,lY)/timeDiff : 0; |
|
| 273 |
} |
|
| 274 |
|
|
| 275 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 276 |
|
|
| 277 |
private float retFingerDragDistanceInInches(float xFrom, float yFrom, float xTo, float yTo) |
|
| 278 |
{
|
|
| 279 |
float xDist = mScreenWidth*(xFrom-xTo); |
|
| 280 |
float yDist = mScreenHeight*(yFrom-yTo); |
|
| 281 |
float distInPixels = (float)Math.sqrt(xDist*xDist + yDist*yDist); |
|
| 282 |
|
|
| 283 |
return distInPixels/mDensity; |
|
| 284 |
} |
|
| 285 |
|
|
| 286 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
| 287 |
|
|
| 288 |
private void setUpDragOrRotate(float x, float y) |
|
| 289 |
{
|
|
| 290 |
Static4D touchPoint = new Static4D(x, y, 0, 0); |
|
| 291 |
Static4D rotatedTouchPoint= rotateVectorByInvertedQuat(touchPoint, mQuat); |
|
| 292 |
Static4D rotatedCamera= rotateVectorByInvertedQuat(CAMERA_POINT, mQuat); |
|
| 293 |
|
|
| 294 |
if( mMovement!=null && mMovement.faceTouched(rotatedTouchPoint,rotatedCamera) ) |
|
| 295 |
{
|
|
| 296 |
mDragging = false; |
|
| 297 |
mContinuingRotation = false; |
|
| 298 |
mBeginningRotation = true; |
|
| 299 |
} |
|
| 300 |
else |
|
| 301 |
{
|
|
Also available in: Unified diff
New 'tutorial' activity.