gautrais 7 jaren geleden
bovenliggende
commit
cb90b3a653
100 gewijzigde bestanden met toevoegingen van 308 en 8380 verwijderingen
  1. 7 8
      app/app.iml
  2. 4 17
      app/src/main/AndroidManifest.xml
  3. BIN
      app/src/main/assets/accueil.jpg
  4. BIN
      app/src/main/assets/error.jpg
  5. 13 6
      app/src/main/assets/game_medium
  6. BIN
      app/src/main/assets/intro_fin.mp3
  7. BIN
      app/src/main/assets/jardin.jpg
  8. BIN
      app/src/main/assets/ludo.jpg
  9. BIN
      app/src/main/assets/milieu.mp3
  10. BIN
      app/src/main/assets/mpg.jpg
  11. BIN
      app/src/main/assets/propsect.jpg
  12. 7 10
      app/src/main/assets/ressources.res
  13. 0 582
      app/src/main/java/app/mar/activities/ARActivity.java
  14. 1 9
      app/src/main/java/app/mar/activities/ChallengeDriver.java
  15. 10 35
      app/src/main/java/app/mar/activities/HostActivity.java
  16. 0 5
      app/src/main/java/app/mar/activities/IRequestCode.java
  17. 0 1
      app/src/main/java/app/mar/activities/LoadingActivity.java
  18. 0 208
      app/src/main/java/app/mar/activities/MenuActivity.java
  19. 0 162
      app/src/main/java/app/mar/activities/ModelViewerActivity.java
  20. 0 248
      app/src/main/java/app/mar/activities/SettingsActivity.java
  21. 21 125
      app/src/main/java/app/mar/activities/fragments/ChallengeFragment.java
  22. 2 1
      app/src/main/java/app/mar/activities/fragments/QCMFragment.java
  23. 9 47
      app/src/main/java/app/mar/activities/fragments/QRCodeFragment.java
  24. 4 1
      app/src/main/java/app/mar/activities/fragments/QuestionFragment.java
  25. 10 29
      app/src/main/java/app/mar/activities/viewers/ImageViewerActivity.java
  26. 14 4
      app/src/main/java/app/mar/activities/viewers/MediaViewerAcitvity.java
  27. 2 1
      app/src/main/java/app/mar/activities/viewers/ResourceListActivity.java
  28. 19 9
      app/src/main/java/app/mar/activities/viewers/TestVideoActivity.java
  29. 12 0
      app/src/main/java/app/mar/exceptions/BadChallengeConfigException.java
  30. 11 0
      app/src/main/java/app/mar/exceptions/BadConfigFileException.java
  31. 11 0
      app/src/main/java/app/mar/exceptions/BadGameConfigException.java
  32. 11 0
      app/src/main/java/app/mar/exceptions/BadResourceConfigException.java
  33. 13 0
      app/src/main/java/app/mar/exceptions/BadResourceTypeException.java
  34. 11 0
      app/src/main/java/app/mar/exceptions/BadStageConfigException.java
  35. 13 0
      app/src/main/java/app/mar/exceptions/ResourceFileNotFoundException.java
  36. 11 0
      app/src/main/java/app/mar/exceptions/ResourceNotFoundException.java
  37. 0 138
      app/src/main/java/app/mar/game/Area.java
  38. 3 0
      app/src/main/java/app/mar/game/Event.java
  39. 4 85
      app/src/main/java/app/mar/game/Game.java
  40. 18 10
      app/src/main/java/app/mar/game/Indice.java
  41. 0 42
      app/src/main/java/app/mar/game/LocatedResources.java
  42. 0 133
      app/src/main/java/app/mar/game/Place.java
  43. 0 148
      app/src/main/java/app/mar/game/Player.java
  44. 15 92
      app/src/main/java/app/mar/game/Resource.java
  45. 0 9
      app/src/main/java/app/mar/game/ResourceManager.java
  46. 13 6
      app/src/main/java/app/mar/game/challenges/Challenge.java
  47. 0 11
      app/src/main/java/app/mar/game/challenges/GeoIndice.java
  48. 0 7
      app/src/main/java/app/mar/game/challenges/IGeoTreasure.java
  49. 3 1
      app/src/main/java/app/mar/game/challenges/QCM.java
  50. 10 4
      app/src/main/java/app/mar/game/challenges/QRCodeTreasure.java
  51. 6 3
      app/src/main/java/app/mar/game/challenges/Question.java
  52. 0 21
      app/src/main/java/app/mar/game/challenges/TextIndice.java
  53. 0 17
      app/src/main/java/app/mar/game/challenges/Treasure.java
  54. 0 85
      app/src/main/java/app/mar/ui/CameraPreview.java
  55. 0 103
      app/src/main/java/app/mar/ui/CustomToggleButton.java
  56. 6 2
      app/src/main/java/app/mar/ui/MediaView.java
  57. 0 12
      app/src/main/java/app/mar/ui/OnToggleListener.java
  58. 0 43
      app/src/main/java/app/mar/ui/RotateButton.java
  59. 0 77
      app/src/main/java/app/mar/ui/SelectButton.java
  60. 4 18
      app/src/main/java/app/mar/utils/AndroidResources.java
  61. 0 76
      app/src/main/java/app/mar/utils/GpsStub.java
  62. 0 227
      app/src/main/java/app/mar/utils/SensorsManager.java
  63. 0 86
      app/src/main/java/app/mar/utils/Settings.java
  64. 0 154
      app/src/main/java/app/mar/utils/SlideBuffer.java
  65. 7 6
      app/src/main/java/app/mar/utils/files/FileManager.java
  66. 3 1
      app/src/main/java/app/mar/utils/files/JSONAssetsManager.java
  67. 0 136
      app/src/main/java/app/mar/utils/geometry/GPSPoint.java
  68. 0 98
      app/src/main/java/app/mar/utils/geometry/Point.java
  69. 0 118
      app/src/main/java/app/mar/utils/geometry/Shape.java
  70. 0 17
      app/src/main/java/min3d/Min3d.java
  71. 0 46
      app/src/main/java/min3d/Shared.java
  72. 0 84
      app/src/main/java/min3d/Utils.java
  73. 0 187
      app/src/main/java/min3d/animation/AnimationObject3d.java
  74. 0 103
      app/src/main/java/min3d/animation/KeyFrame.java
  75. 0 160
      app/src/main/java/min3d/core/Color4BufferList.java
  76. 0 190
      app/src/main/java/min3d/core/FacesBufferedList.java
  77. 0 149
      app/src/main/java/min3d/core/ManagedLightList.java
  78. 0 157
      app/src/main/java/min3d/core/Number3dBufferList.java
  79. 0 491
      app/src/main/java/min3d/core/Object3d.java
  80. 0 137
      app/src/main/java/min3d/core/Object3dContainer.java
  81. 0 153
      app/src/main/java/min3d/core/RenderCaps.java
  82. 0 684
      app/src/main/java/min3d/core/Renderer.java
  83. 0 218
      app/src/main/java/min3d/core/RendererActivity.java
  84. 0 297
      app/src/main/java/min3d/core/Scene.java
  85. 0 155
      app/src/main/java/min3d/core/TextureList.java
  86. 0 165
      app/src/main/java/min3d/core/TextureManager.java
  87. 0 137
      app/src/main/java/min3d/core/UvBufferList.java
  88. 0 183
      app/src/main/java/min3d/core/Vertices.java
  89. 0 8
      app/src/main/java/min3d/interfaces/IDirtyManaged.java
  90. 0 6
      app/src/main/java/min3d/interfaces/IDirtyParent.java
  91. 0 20
      app/src/main/java/min3d/interfaces/IObject3dContainer.java
  92. 0 39
      app/src/main/java/min3d/interfaces/ISceneController.java
  93. 0 114
      app/src/main/java/min3d/objectPrimitives/Box.java
  94. 0 142
      app/src/main/java/min3d/objectPrimitives/HollowCylinder.java
  95. 0 57
      app/src/main/java/min3d/objectPrimitives/Rectangle.java
  96. 0 106
      app/src/main/java/min3d/objectPrimitives/SkyBox.java
  97. 0 127
      app/src/main/java/min3d/objectPrimitives/Sphere.java
  98. 0 115
      app/src/main/java/min3d/objectPrimitives/Torus.java
  99. 0 429
      app/src/main/java/min3d/parser/AParser.java
  100. 0 27
      app/src/main/java/min3d/parser/IParser.java

+ 7 - 8
app/app.iml

@@ -70,13 +70,6 @@
       <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
       <sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
-      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
-      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
-      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
-      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
-      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
-      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
       <sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
       <sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
       <sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
@@ -84,7 +77,13 @@
       <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
       <sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
       <sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
-      <excludeFolder url="file://$MODULE_DIR$/build/intermediates/applicationId" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
       <excludeFolder url="file://$MODULE_DIR$/build/intermediates/build-info" />

+ 4 - 17
app/src/main/AndroidManifest.xml

@@ -22,20 +22,14 @@
         android:supportsRtl="true"
         android:theme="@style/AppTheme"
         tools:replace="android:icon">
-        <activity android:name=".ARActivity" />
         <activity
-            android:name=".ImageViewerActivity"
+            android:name=".viewers.ImageViewerActivity"
             android:theme="@style/AppTheme.NoActionBar.Fullscreen" />
         <activity
-            android:name=".ResourceListActivity"
+            android:name=".viewers.ResourceListActivity"
             android:configChanges="orientation|keyboardHidden|screenSize"
             android:label="@string/title_activity_resource_list"
             android:screenOrientation="portrait" />
-        <activity
-            android:name=".SettingsActivity"
-            android:configChanges="orientation|keyboardHidden"
-            android:label="@string/title_activity_settings"
-            android:screenOrientation="portrait" />
         <activity android:name=".PermissionActivity">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
@@ -44,24 +38,17 @@
             </intent-filter>
         </activity>
         <activity
-            android:name=".MediaViewerAcitvity"
-            android:theme="@style/AppTheme.NoActionBar.Fullscreen" />
-        <activity
-            android:name=".ModelViewerActivity"
+            android:name=".viewers.MediaViewerAcitvity"
             android:theme="@style/AppTheme.NoActionBar.Fullscreen" />
         <activity
             android:name=".CreditsActivity"
             android:theme="@style/AppTheme.NoActionBar.Fullscreen" />
-        <activity
-            android:name=".MenuActivity"
-            android:label="@string/title_activity_qrcode"
-            android:theme="@style/AppTheme.NoActionBar" />
         <activity
             android:name=".HostActivity"
             android:label="@string/title_activity_host"
             android:theme="@style/AppTheme.NoActionBar" />
         <activity
-            android:name=".TestVideoActivity"
+            android:name=".viewers.TestVideoActivity"
             android:label="@string/title_activity_test_video"
             android:theme="@style/AppTheme.NoActionBar" />
         <activity

BIN
app/src/main/assets/accueil.jpg


BIN
app/src/main/assets/error.jpg


+ 13 - 6
app/src/main/assets/game_medium

@@ -43,7 +43,7 @@
 				"type" : "QRCodeTreasure",
 				"name" : "MPG_Qr",
 				"bad_message" : "C'est pas le bon !",
-				"qr_value" : "2",
+				"qr_value" : "1",
 				"resource" : "mpg",
 				"indices" : [
 					{
@@ -234,16 +234,14 @@
 				"type" : "QRCodeTreasure",
 				"name" : "Jardin ludothèque",
 				"bad_message" : "C'est pas le bon !",
-				"qr_value" : "3",
+				"qr_value" : "1",
 				"resource" : "ludo",
 				"indices" : [
 					{
-						"type" : "text",
 						"text" : "Je vais emprunter un Uno ou Jungle Speed",
 						"penality": 1
 					},
 					{
-						"type" : "text",
 						"text" : "Ne pas sonner SVP !",
 						 "penality": 1
 					}
@@ -253,7 +251,9 @@
 				"type": "Question",
 				"name" : "QuestionLudo",
 				"bad_message" : "Non !",
+				"question" : "Devant la porte (proche du QR Code) vous devriez trouver une enigme avec des place de parking. Sur quelle place est garée la voiture ?",
 				"good_message" : "Brillant !",
+				"resource" : "ludo",
 				"answer" : "97",
 				"indices" : [
 					{
@@ -284,6 +284,8 @@
 				"bad_message" : "Non !",
 				"good_message" : "Bravo !",
 				"answer" : "ABBA",
+				"resource" : "jardin",
+				"question" : "Trouver blabla...",
 				"indices" : [
 					{
 						"type" : "text",
@@ -307,6 +309,8 @@
 				"bad_message" : "Non !",
 				"good_message" : "Bravo !",
 				"answer" : "Trop cuite",
+				"resource" : "accueil",
+				"question" : "Trouver blabla...",
 				"indices" : [
 					{
 						"type" : "text",
@@ -328,7 +332,8 @@
 				"type" : "QRCodeTreasure",
 				"name" : "ProspectusQr",
 				"bad_message" : "Non !",
-				"qr_value" : "4",
+				"qr_value" : "1",
+				"resource" : "propsect",
 				"indices" : [
 					{
 						"type" : "text",
@@ -354,9 +359,11 @@
 			{
 				"type" : "Question",
 				"name" : "accueilQuestion",
+				"question" : "Trouver blabla...",
 				"bad_message" : "Non !",
 				"good_message" : "Bravo !",
 				"answer" : "Trop cuite",
+				"resource" : "accueil",
 				"indices" : [
 					{
 						"type" : "text",
@@ -367,7 +374,7 @@
 				"penality" : 1
 			}
 		],
-	"resources" : [],
+	"resources" : ["fin"],
 	"charIndex" : 6
 }	],
 	"credits" : 

BIN
app/src/main/assets/intro_fin.mp3


BIN
app/src/main/assets/jardin.jpg


BIN
app/src/main/assets/ludo.jpg


BIN
app/src/main/assets/milieu.mp3


BIN
app/src/main/assets/mpg.jpg


BIN
app/src/main/assets/propsect.jpg


+ 7 - 10
app/src/main/assets/ressources.res

@@ -8,19 +8,12 @@
 		"title" : "Un nouveau message",
 		"type" : "Audio",
 		"display" : true
-	},	
-	"_intro" : {
-		"comment" : "Nous avons reçu un étrange message...",
-		"title" : "Un étrange message",
-		"type" : "Audio",
-		"display" : true
 	},
 	"intro" : {
 		"comment" : "Nous avons reçu un étrange message...",
 		"title" : "Un étrange message",
-		"type" : "Image",
-		"display" : true,
-		"file" : "creche.jpg"
+		"type" : "Audio",
+		"display" : true
 	},
 	"fin" : {
 		"comment" : "Nous avons réussi !",
@@ -30,5 +23,9 @@
 	},
 	"creche": {"type" : "Image"},
 	"bib" : {"type" : "Image"},
-	"ludo" :  {"type" : "Image"}
+	"ludo" :  {"type" : "Image"},
+	"jardin" :  {"type" : "Image"},
+	"accueil" :  {"type" : "Image"},
+	"propsect" :  {"type" : "Image"},
+	"error" : {"type" : "Image"}
 }

+ 0 - 582
app/src/main/java/app/mar/activities/ARActivity.java

@@ -1,582 +0,0 @@
-package app.mar.activities;
-import android.content.Intent;
-import android.content.pm.ActivityInfo;
-import android.content.res.Resources;
-import android.graphics.PixelFormat;
-import android.hardware.Camera;
-import android.os.Bundle;
-import android.os.Handler;
-import android.view.View;
-import android.view.ViewTreeObserver;
-import android.view.Window;
-import android.view.WindowManager;
-import android.widget.Button;
-import android.widget.FrameLayout;
-import android.widget.ImageView;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-import java.util.ArrayList;
-
-import app.mar.ui.CameraPreview;
-import app.mar.utils.Settings;
-import app.mar.game.Area;
-import app.mar.game.Game;
-import app.mar.game.Place;
-import app.mar.game.Player;
-import app.mar.game.Resource;
-import app.mar.game.challenges.ARTreasure;
-import app.mar.game.challenges.Challenge;
-import app.mar.game.challenges.ChallengeReturn;
-import app.mar.utils.geometry.GPSPoint;
-import min3d.core.Object3d;
-import min3d.core.RendererActivity;
-import min3d.vos.CameraVo;
-import min3d.vos.Light;
-import min3d.vos.LightType;
-import min3d.vos.Number3d;
-
-
-public class ARActivity extends RendererActivity
-{
-
-    protected ARTreasure    mTreasure=null;
-    protected Area          mArea=null;
-
-    private final Object mLock = new Object();
-    protected boolean isPausing=false;
-    protected static GPSPoint mLocation;
-    protected static boolean mLocationUpdated=false;
-
-
-    protected int mViewWidth;
-    protected int mViewHeight;
-    protected boolean mDetect=false;
-    protected boolean mInArea=false;
-    private Game mGame;
-    private  Boolean  mUpdate = true;
-    private Handler mCustomHandler = new Handler();
-
-    private boolean mIsResource = false;
-
-    //UI
-    private CameraPreview mImageSurfaceView;
-    private Camera camera;
-    private FrameLayout cameraPreviewLayout;
-    private Button mOkButton;
-    protected TextView mTvDistance;
-    protected TextView mTvAngle;
-    protected TextView mTvGPS;
-    protected RelativeLayout mRlRoot;
-    protected ImageView mIvWhite;
-    protected ImageView mIvRed;
-    protected ImageView mIvGreen;
-    protected ImageView mIvNone;
-    public static final int REQUEST_CODE = 2003;
-
-    public void init()
-    {
-        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
-
-
-
-        cameraPreviewLayout = (FrameLayout)findViewById(R.id.camera_preview);
-        camera = checkDeviceCamera();
-        mImageSurfaceView = new CameraPreview(ARActivity.this, camera);
-
-
-        mOkButton = (Button) findViewById(R.id.button_catch);
-        mOkButton.setVisibility(View.INVISIBLE);
-        if(cameraPreviewLayout.getChildCount()<2)
-        {
-            cameraPreviewLayout.addView(_glSurfaceView,0);
-            cameraPreviewLayout.addView(mImageSurfaceView,0);
-        }
-
-    }
-
-    private Camera checkDeviceCamera() {
-        Camera mCamera = null;
-        try {
-            mCamera = Camera.open();
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return mCamera;
-    }
-
-    protected void onCreateSetContentView()
-    {
-        //init();
-
-    }
-
-    @Override
-    protected void glSurfaceViewConfig()
-    {
-        // !important
-        _glSurfaceView.setEGLConfigChooser(8,8,8,8, 16, 0);
-        _glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
-    }
-
-    @Override
-    public void initScene()
-    {
-        // !important
-        scene.clear();
-        scene.backgroundColor().setAll(0x00000000);
-        //scene.lights().add(new Light());
-        //scene.lights().add(new Light());
-
-        Light myLight = new Light();
-        myLight.position.setZ(0);
-        myLight.position.setY(100);
-        myLight.type(LightType.POSITIONAL);
-        scene.lights().add(myLight);
-
-
-        //IParser myParser = Parser.createParser(Parser.Type.OBJ, getResources(), "app.brest.testmin3d:raw/face_obj", true);
-        //myParser.parse();
-
-
-
-    }
-
-    protected Number3d pos(float deltaAngle, int _radius)
-    {
-        float radius = _radius;
-        return new Number3d((float)(radius*Math.sin(deltaAngle)),
-                0,
-                (float)(15+radius*Math.cos(deltaAngle))
-        );
-    }
-
-    private Runnable updateTimerThread = new Runnable() {
-
-        public void run() {
-            mCustomHandler.postDelayed(this, 10);
-        }
-
-    };
-
-    protected long mLedPeriode=0;
-    protected long mLedLastTick=0;
-    protected boolean mLedState=false;
-    protected void updateLed(boolean detected,  double dist)
-    {
-        //si detecte
-        if(detected)
-        {
-            mIvWhite.getHandler().post(new Runnable() { public void run() {mIvWhite.setVisibility(View.VISIBLE);}});
-            mIvGreen.getHandler().post(new Runnable() { public void run() {mIvGreen.setVisibility(View.VISIBLE);}});
-            mIvRed.getHandler().post(new Runnable() { public void run() {mIvRed.setVisibility(View.INVISIBLE);}});
-            mInArea=mDetect=true;
-        }
-        //si dans une zone
-        else if(dist>=0)
-        {
-            if(dist<5) mLedPeriode=5;
-            else if(dist>=5 && dist<50) mLedPeriode=(int)((dist-4)*10);
-            else mLedPeriode=500;
-            if(System.currentTimeMillis()>mLedLastTick+mLedPeriode)
-            {
-                mLedLastTick=System.currentTimeMillis();
-                if(mLedState)
-                {
-                    mLedState=false;
-                    mIvWhite.getHandler().post(new Runnable() { public void run() {mIvWhite.setVisibility(View.INVISIBLE);}});
-                }else
-                {
-                    mLedState=true;
-                    mIvWhite.getHandler().post(new Runnable() { public void run() {mIvWhite.setVisibility(View.VISIBLE);}});
-                }
-            }
-
-            mIvGreen.getHandler().post(new Runnable() { public void run() {mIvGreen.setVisibility(View.INVISIBLE);}});
-            mIvRed.getHandler().post(new Runnable() { public void run() {mIvRed.setVisibility(View.VISIBLE);}});
-            mInArea=true;
-            mDetect=false;
-        }
-        //si rien
-        else
-        {
-            mIvWhite.getHandler().post(new Runnable() { public void run() {mIvWhite.setVisibility(View.INVISIBLE);}});
-            mIvGreen.getHandler().post(new Runnable() { public void run() {mIvGreen.setVisibility(View.INVISIBLE);}});
-            mIvRed.getHandler().post(new Runnable() { public void run() {mIvRed.setVisibility(View.INVISIBLE);}});
-            mInArea=mDetect=false;
-        }
-    }
-    protected String updateArSceneResource(Resource rr, Place p, String toDisplay)
-    {
-        Object3d oo = rr.get3DModel(this);
-        CameraVo v = new CameraVo();
-
-        if(mGame.getSettings().isARMode()) {
-            double distCoef = (p.getDistance(mGame.getPlayer()) / 50) * 0.8;
-            distCoef += 0.2;
-            double x = 0;
-
-
-            if (distCoef > 1) distCoef = 1.0;
-
-            double theta = -(-mGame.getPlayer().getOrientationY() + 135 - (0.5 * Math.atan(p.getDistance(mGame.getPlayer()) / 1.6) * 180 / Math.PI) % 360);
-            while (theta < -180) theta += 360;
-            while (theta > 180) theta -= 360;
-            oo.position().y = -25 + (float) (50 * Math.sin(-theta * Math.PI / 180.0));
-
-            double alpha = ((float) (mGame.getPlayer().getAngleWith(p))-mGame.getPlayer().getOrientationX() );// - mGame.getPlayer().getOrientationZ();
-            oo.position().z = -(float)(90*distCoef*Math.cos(alpha*Math.PI/180.0));
-            oo.position().x = -(float) (90 * distCoef * Math.sin(alpha * Math.PI / 180.0));
-
-
-
-            if (mGame.getSettings().isAreaDebug()) {
-
-                toDisplay += "Azimuth: " + dts(alpha) + "°\nAngle:"+mGame.getPlayer().getAngleWith(p) +"\nPosition (" + dts(oo.position().x) + ", " + dts(oo.position().y)
-                        + ", " + dts(oo.position().z) + ")\nAngle Rel:"+dts(alpha)+" : "+dts(mGame.getPlayer().getAngleWith(p))+" - "+dts(mGame.getPlayer().getOrientationX())+"\n";
-                toDisplay+=" oo = { "+oo.position().x+", "+oo.position().y+", "+oo.position().z+" }\n";
-            }
-        }else
-        {
-            oo.position().y = 0;
-            oo.position().z = -20;
-            oo.position().x = 0;
-        }
-
-        //vX = (float) (mGame.getPlayer().getAngleWith(p));
-        scene.camera(v);
-        scene.addChild(oo);
-        return toDisplay;
-    }
-
-
-
-    protected boolean updateSceneResource()
-    {
-
-        ArrayList<Resource> res = mGame.getResourcesNextToPlayer(mArea);
-        Place place = mArea.getPlace();
-        Player player = mGame.getPlayer();
-        double distance = -1;
-
-        String toDisplay ="";
-        boolean detected = false;
-        boolean isAR = mGame.getSettings().isARMode();
-        // String dete = "Detected:\n";
-        scene.clear();
-
-
-        if(mGame.getSettings().isAreaDebug())
-        {
-            String str = "Zone : ";
-            if(player.getPosition()!=null)
-            {
-                distance=mArea.getDistance(player);
-                str+="\t"+mArea.getName()+" : "+((int)mArea.getDistance(player))+" m";
-            }
-            else
-                str+="\t"+mArea.getName()+" : ?";
-
-            if(mGame.getSettings().isARMode())
-            {
-                str+=player.getAngleWith(place)+" °";
-            }
-            toDisplay+=str+"\n\n";
-
-        }
-
-
-        if (mArea.isOnArea(player)) {
-            if(mGame.getSettings().isAreaDebug()) toDisplay+="Resources détectées: \n";
-            detected = true;
-            if(mGame.getSettings().isARMode()) mGame.getPlayer().freezePosition(place.getLocation());
-
-            toDisplay=updateArSceneResource(res.get(0), place, toDisplay);
-        }
-
-        if(isAR && res.size()==0) mGame.getPlayer().releasePosition();
-
-        updateLed(detected, distance);
-
-
-
-        //affichage en debug
-        final String td = toDisplay;
-        final TextView xv = (TextView)findViewById(R.id.text_area);
-        xv.getHandler().post(new Runnable() { public void run() { xv.setText(td);  } });
-
-
-        //affichage de la distance dans l'HUD
-        final String dete2 = String.format ("%.1f", distance);
-        mTvDistance.getHandler().post(new Runnable() {
-            public void run() {
-                mTvDistance.setText(dete2);
-            }
-        });
-
-        if(mGame.getSettings().isARMode())
-            return scene.numChildren()>0;
-        else
-            return res.size()>0;
-    }
-
-    protected void onList()
-    {
-        Intent intent = new Intent(this, ARActivity.class);
-        intent.putExtra("game", mGame);
-        startActivity(intent);
-    }
-
-    protected void moveView(View v, int x, int y, int w, int h)
-    {
-        RelativeLayout.LayoutParams l = new RelativeLayout.LayoutParams(w, h);
-        l.leftMargin = x;
-        l.topMargin = y;
-        v.setLayoutParams(l);
-    }
-
-
-
-    private void loadUI()
-    {
-        mTvDistance=(TextView)findViewById(R.id.tv_distance);
-        mTvAngle=(TextView)findViewById(R.id.tv_angle);
-        mTvGPS=(TextView)findViewById(R.id.tv_gps);
-        mRlRoot=(RelativeLayout) findViewById(R.id.rl_root);
-        mIvWhite=(ImageView)findViewById(R.id.iv_white);
-        mIvRed=(ImageView)findViewById(R.id.iv_red);
-        mIvGreen=(ImageView)findViewById(R.id.iv_green);
-        mIvNone=(ImageView)findViewById(R.id.iv_none);
-
-        ViewTreeObserver vto = mRlRoot.getViewTreeObserver();
-        vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
-            @Override
-            public void onGlobalLayout() {
-                mRlRoot.getViewTreeObserver().removeGlobalOnLayoutListener(this);
-                int w =mViewWidth  = mRlRoot.getMeasuredWidth();
-                int h =mViewHeight = mRlRoot.getMeasuredHeight();
-
-                mTvGPS.setTextSize(pxToDp((int)(h*0.100f/3.5)));
-                mTvGPS.setText("N ?°\nE ?°");
-                mTvAngle.setTextSize(pxToDp((int)(h*0.121f/3.5)));
-                mTvDistance.setTextSize(pxToDp((int)(h*0.046f)));
-
-                moveView(mTvAngle, (int)(0.03*w), (int)(0.864f*h), (int)(0.291f*w), (int)(0.121*h ));
-                moveView(mTvGPS, w-(int)(0.32f*w), (int)(0.875f*h),(int)(0.3*w), (int)(0.121*h));
-                moveView(mTvDistance, w-mTvDistance.getWidth()-(int)(0.36f*w), (int)(0.033f*h), mTvGPS.getWidth(), (int)(0.121*h));
-
-                moveView(mIvNone, (int)(w/4.0), 0, (int)(w/2.0), (int)(0.06f*h));
-                moveView(mIvWhite, (int)(w*0.269), (int)(0.034*h), (int)(w*0.03333), (int)(0.02286f*h));
-                moveView(mIvRed, (int)(w*0.702), (int)(0.034*h), (int)(w*0.03333), (int)(0.02286f*h));
-                moveView(mIvGreen, (int)(w*0.702), (int)(0.034*h), (int)(w*0.03333), (int)(0.02286f*h));
-            }
-        });
-    }
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState)
-    {
-        super.onCreate(savedInstanceState);
-        requestWindowFeature(Window.FEATURE_NO_TITLE);
-        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
-        setContentView(R.layout.activity_ar);
-        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
-
-        mGame = Game.game();
-        mGame.newSensorManager(this);
-        loadUI();
-
-        Challenge c = mGame.getCurrentChallenge();
-        if(c!=null)
-        {
-            if(c instanceof ARTreasure)
-            {
-                mTreasure = (ARTreasure)c;
-                mArea = mTreasure.getArea();
-            }else
-            {
-                Toast.makeText(this,"Erreur interne: Pas de Trésor a chercher", Toast.LENGTH_LONG).show();
-            }
-        }
-        else
-        {
-            Toast.makeText(this,"Erreur interne: Pas de Challenge a effectuer", Toast.LENGTH_LONG).show();
-        }
-    }
-
-
-
-
-    @Override
-    /**
-     * Verifie si on doit afficher des resources et gere le bouton de capture
-     */
-    public  void updateScene()
-    {
-        synchronized (mUpdate)
-        {
-            if(!mUpdate) return;
-
-            //Precache du modèle 3D
-            synchronized (mLock) {
-                if (!isPausing) {
-                    mGame.precache3DResource(this);
-                    mIsResource = updateSceneResource();
-                }else
-                {
-                    scene.clear();
-                    mGame.removeCached3DModels();
-                }
-            }
-
-            if(mIsResource) {
-                mOkButton.getHandler().post(new Runnable() {
-                    public void run() {
-                        mOkButton.setVisibility(View.VISIBLE);
-                    }
-                });
-            }else
-            {
-                mOkButton.getHandler().post(new Runnable() {
-                    public void run() {
-                        mOkButton.setVisibility(View.INVISIBLE);
-                    }
-                });
-
-            }
-            mTvAngle.getHandler().post(new Runnable() {
-                public void run() {
-                    NumberFormat formatter = new DecimalFormat("#0.0");
-                    /*mTvAngle.setText("X : "+formatter.format(mGame.getPlayer().getOrientation())+"°\nY : "+
-                            formatter.format(mGame.getPlayer().getOrientationY())
-                            +"°\nZ : "+formatter.format(mGame.getPlayer().getOrientationZ())+"°");*/
-
-
-                }
-            });
-
-            setGpsText();
-        }
-
-    }
-
-    protected String dts(double d, int n)
-    {
-        String str = "#0";
-        if(n>0)
-        {
-            str+=".";
-            for(int i=0; i<n; i++) str+="0";
-        }
-        NumberFormat formatter = new DecimalFormat(str);
-        return formatter.format(d);
-    }
-
-    protected String dts(double d)
-    {
-        return dts(d,2);
-    }
-
-
-    @Override
-    protected  void onResume() {
-        super.onResume();
-        init();
-        mGame.onResume();
-        scene.clear();
-        synchronized (mLock)
-        {
-            isPausing=false;
-        }
-    }
-    @Override
-    protected  void onPause()
-    {
-        synchronized (mLock)
-        {
-            isPausing=true;
-        }
-        super.onPause();
-        mGame.onPause(this);
-        scene.clear();
-        cameraPreviewLayout.removeViewAt(0);
-        cameraPreviewLayout.removeViewAt(0);
-
-    }
-
-    public void finish()
-    {
-        mGame.stopSensors();
-        super.finish();
-    }
-
-    public void setGpsText()
-    {
-        if(mLocationUpdated) {
-            final GPSPoint gps = mLocation;
-            mTvGPS.getHandler().post(new Runnable() {
-
-                public void run() {
-
-                    NumberFormat formatter = new DecimalFormat("#0.0000000");
-                    NumberFormat formatter2 = new DecimalFormat("#0.0");
-                    mTvGPS.setText("N "+formatter.format(gps.getX()) + "°\nE " + formatter.format(gps.getY()) + "°\n+/- "+formatter2.format(gps.getAccuracy())+" m");
-                }
-            });
-            mLocationUpdated=false;
-        }
-    }
-
-
-    public void onSaveInstanceState(Bundle savedInstanceState) {
-        // Save the user's current game state
-        savedInstanceState.putSerializable("game", mGame);
-
-        // Always call the superclass so it can save the view hierarchy state
-        super.onSaveInstanceState(savedInstanceState);
-    }
-
-    public void onClickPickUp(View v)
-    {
-        synchronized (mUpdate) {mUpdate=false;}
-        mGame.setReturn(new ChallengeReturn(mTreasure, ChallengeReturn.SUCCESS, "Très bien !"));
-        finish();
-    }
-
-
-    public static void setLocation(GPSPoint p)
-    {
-        mLocation = p;
-        mLocationUpdated=true;
-    }
-
-
-    public static int dpToPx(int dp)
-    {
-        return (int) (dp * Resources.getSystem().getDisplayMetrics().density);
-    }
-
-    public static int pxToDp(int px)
-    {
-        return (int) (px / Resources.getSystem().getDisplayMetrics().density);
-    }
-
-
-
-    public void onClickScreen(View v)
-
-    {
-        if(mIsResource)
-            onClickPickUp(v);
-        else if(Settings.getSettings().isGPSDebug())
-            mGame.getPlayer().nextStub();
-        else {
-
-        }
-    }
-
-}

+ 1 - 9
app/src/main/java/app/mar/activities/ChallengeDriver.java

@@ -2,13 +2,11 @@ package app.mar.activities;
 
 import android.app.Activity;
 import android.net.Uri;
-import android.view.View;
 
-import app.mar.game.Area;
+import app.mar.activities.fragments.ChallengeFragment;
 import app.mar.game.Game;
 import app.mar.game.Resource;
 import app.mar.game.challenges.Challenge;
-import app.mar.game.scheduler.Scheduler;
 
 public interface ChallengeDriver extends ChallengeFragment.OnFragmentInteractionListener {
     public void challengeValidate(Challenge c, Game g, ChallengeDriver cd);
@@ -17,12 +15,6 @@ public interface ChallengeDriver extends ChallengeFragment.OnFragmentInteraction
     public void onFragmentInteraction(Uri uri);
     public void onReady(Challenge chall);
 
-
-    public void   startLocalisation();
-    public void   resumeLocalisation();
-    public void   pauseLocalisation();
-    public double getDistanceWith(Area a);
-    public double getAccuracy();
     public void   startResource(Resource r);
 
 

+ 10 - 35
app/src/main/java/app/mar/activities/HostActivity.java

@@ -14,19 +14,22 @@ import android.widget.TextView;
 import java.util.Timer;
 import java.util.TimerTask;
 
-import app.mar.game.Area;
-import app.mar.game.Bomb;
+import app.mar.activities.fragments.ChallengeFragment;
+import app.mar.activities.fragments.QCMFragment;
+import app.mar.activities.fragments.QRCodeFragment;
+import app.mar.activities.fragments.QuestionFragment;
+import app.mar.activities.viewers.ImageViewerActivity;
+import app.mar.activities.viewers.MediaViewerAcitvity;
+import app.mar.activities.viewers.ResourceListActivity;
+import app.mar.activities.viewers.TestVideoActivity;
 import app.mar.game.Game;
 import app.mar.game.Resource;
 import app.mar.game.Stage;
 import app.mar.game.challenges.Challenge;
-import app.mar.game.challenges.Indice;
-import app.mar.game.scheduler.ChallengeTask;
+import app.mar.game.Indice;
 import app.mar.game.scheduler.Scheduler;
 import app.mar.game.scheduler.SpecialTask;
-import app.mar.game.scheduler.Task;
 import app.mar.utils.AndroidResources;
-import app.mar.utils.L;
 
 
 public class HostActivity extends Activity implements ChallengeDriver{
@@ -73,7 +76,6 @@ public class HostActivity extends Activity implements ChallengeDriver{
         mUIButtonIndice = (Button) findViewById(R.id.btn_indice);
         mUIButtonValid = (Button) findViewById(R.id.btn_valid);
 
-        ErrorActivity.error(this, "Salut", "ça va ?");
         Log.e("-----", "Game.game()");
         mGame=Game.game();
 
@@ -146,18 +148,6 @@ public class HostActivity extends Activity implements ChallengeDriver{
     }
 
 
-
-    @Override
-    public double getDistanceWith(Area a) {
-        return a.getDistance(mGame.getPlayer());
-    }
-
-    @Override
-    public double getAccuracy() {
-        return mGame.getPlayer().getSensorsManager().getPosition().getAccuracy();
-    }
-
-
     @Override
     public void onFragmentInteraction(Uri uri) {}
 
@@ -244,7 +234,7 @@ public class HostActivity extends Activity implements ChallengeDriver{
 
         Challenge c = mGame.nextChallenge(this);
         Stage s = mGame.getCurrentStage();
-        Log.e("___SCHEDULER_PRESQUE","\t->"+ c);
+//        Log.e("___SCHEDULER_PRESQUE","\t->"+ c +" stage : "+s.getName());
         if(c!=null)
         {
             mGame.getScheduler().append(c);
@@ -271,7 +261,6 @@ public class HostActivity extends Activity implements ChallengeDriver{
         switch (requestCode)
         {
             case CreditsActivity.REQUEST_CODE:
-            case ModelViewerActivity.REQUEST_CODE:
             case MediaViewerAcitvity.REQUEST_CODE:
             case TestVideoActivity.REQUEST_CODE:
             case BombActivity.REQUEST_CODE:
@@ -335,20 +324,6 @@ public class HostActivity extends Activity implements ChallengeDriver{
         mGame.save(this);
     }
 
-    @Override
-    public void startLocalisation() {
-        mGame.newSensorManager(this);
-    }
-
-    @Override
-    public void resumeLocalisation() {
-        mGame.onResume();
-    }
-
-    @Override
-    public void pauseLocalisation() {
-        mGame.onPause(this);
-    }
 
     @Override
     public void onBackPressed()

+ 0 - 5
app/src/main/java/app/mar/activities/IRequestCode.java

@@ -1,5 +0,0 @@
-package app.mar.activities;
-
-public interface IRequestCode {
-    public int getRequestCode();
-}

+ 0 - 1
app/src/main/java/app/mar/activities/LoadingActivity.java

@@ -42,7 +42,6 @@ public class LoadingActivity extends AppCompatActivity {
             if (g != null ) {
                 game = g;
                 Game.setGame(game);
-                game.newSensorManager(this);
                 Toast.makeText(this, "Chargement", Toast.LENGTH_SHORT).show();
             } else {
                 game = new Game("game_medium", this);

+ 0 - 208
app/src/main/java/app/mar/activities/MenuActivity.java

@@ -1,208 +0,0 @@
-package app.mar.activities;
-
-import android.app.Activity;
-import android.content.Intent;
-import android.content.res.Resources;
-import android.graphics.Point;
-import android.os.Handler;
-import android.os.Bundle;
-import android.view.Display;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.RelativeLayout;
-import android.widget.Toast;
-
-import app.mar.game.Resource;
-import app.mar.ui.RotateButton;
-import app.mar.utils.AndroidResources;
-import app.mar.game.Game;
-
-public  class  MenuActivity extends Activity implements View.OnClickListener {
-
-    protected int mWidth;
-    protected int mHeight;
-    protected Game mGame;
-
-    protected RelativeLayout mRootLayout;
-    protected Handler mCustomHandler = new Handler();
-    //private final int COLOR_BACKGROUND = ;
-    protected final int COLOR_SHAPE = R.color.dull_2;
-    protected final int COLOR_BACKGROUND_SECOND = R.color.dull_3;
-    protected final int COLOR_OTHER = R.color.dull_4;
-    protected final int COLOR_TEXT = R.color.dull_5;
-
-    protected Button mIbScanner;
-    protected Button mBBriefing;
-    protected Button mBInvotory;
-    protected Button mBMap;
-    protected Button mBOptions;
-    protected View mBMenu;
-    protected Button mBSend;
-    protected int mHOffset=0;
-
-
-    protected  void refreshMenuStyle(){}
-
-    protected void setUpMenuStyle(){}
-
-    private void updateSize()
-    {
-        Display display = getWindowManager().getDefaultDisplay();
-        Point size = new Point();
-        display.getSize(size);
-        mWidth = size.x;
-        mHeight = size.y;
-        mHOffset=mHeight/15;
-    }
-
-    protected void moveView(View v, int x, int y, int w, int h)
-    {
-        RelativeLayout.LayoutParams l = new RelativeLayout.LayoutParams(w, h);
-        l.leftMargin = x;
-        l.topMargin = y;
-        v.setLayoutParams(l);
-    }
-
-    protected void moveView(View v, int x, int y)
-    {
-        moveView(v, x, y, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
-    }
-
-
-    protected Button newButton(String text, float angle)
-    {
-        Button b = new RotateButton(this,angle);
-        b.setText(text);
-        mRootLayout.addView(b);
-        b.setBackgroundResource(R.drawable.uibutton);
-        b.setTextColor(getResources().getColor(R.color.dull_4));
-        b.setTextSize(18);
-        b.setOnClickListener(this);
-        return b;
-    }
-
-    protected Button newButton(String text)
-    {
-        return newButton(text, 0);
-    }
-
-
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-
-        setContentView(R.layout.activity_new_menu);
-        mRootLayout = (RelativeLayout) findViewById(R.id.menu_root);
-        if(Game.game()==null)
-        {
-            Game g = Game.load(this);
-            if (g != null ) {
-                mGame = g;
-                Game.setGame(mGame);
-                mGame.newSensorManager(this);
-                Toast.makeText(this, "Chargement", Toast.LENGTH_SHORT).show();
-            } else {
-                mGame = new Game("game_medium", this);
-                Game.setGame(mGame);
-                Toast.makeText(this, "Nouveau Jeu", Toast.LENGTH_SHORT).show();
-            }
-        }
-
-        updateSize();
-
-        Intent intent = new Intent(this, HostActivity.class);
-        startActivity(intent);
-        finish();
-
-        setUpMenuStyle();
-        refreshMenuStyle();
-
-        mCustomHandler.postDelayed(updateTimerThread, 10);
-    }
-
-
-    public void onOptionsClick(View v)
-    {
-        Intent intent = new Intent(this, SettingsActivity.class);
-        intent.putExtra("game", mGame);
-        startActivity(intent);
-    }
-
-
-    public void onCarteClick(View v)
-    {
-        Intent intent = AndroidResources.getMapIntent(this, mGame);
-        startActivity(intent);
-    }
-
-
-    public void onScannerClick(View v)
-    {
-        Intent intent = new Intent(this, ARActivity.class);
-        intent.putExtra("game", mGame);
-        startActivity(intent);
-    }
-
-
-    public void onInventaireClick(View v)
-    {
-        Intent intent = new Intent(this, ResourceListActivity.class);
-        intent.putExtra("game", mGame);
-        startActivity(intent);
-    }
-
-    public void onCredits(View v)
-    {
-        Intent intent = new Intent(this, CreditsActivity.class);
-        startActivity(intent);
-    }
-
-
-    public void onInfoClick(View v) {
-        /*Stage s = mGame.getCurrentStage();
-        Resource r = (s!=null)?s.getResource(): null;
-
-        Intent intent = AndroidResources.getViewerIntent(this, r);
-        startActivity(intent);*/
-    }
-
-
-
-    @Override
-    public void onClick(View view) {
-        if(view == mBBriefing) onInfoClick(view);
-        else if(view == mIbScanner) onScannerClick(view);
-        else if(view == mBMap) onCarteClick(view);
-        else if(view == mBInvotory) onInventaireClick(view);
-        else if(view == mBOptions) onOptionsClick(view);
-    }
-
-    public void onResume()
-    {
-        super.onResume();
-        mGame = Game.game();
-        refreshMenuStyle();
-    }
-
-
-    private Runnable updateTimerThread = new Runnable() {
-
-        public void run() {
-
-            mCustomHandler.postDelayed(this, 10);
-        }
-
-    };
-
-    public static int dpToPx(int dp)
-    {
-        return (int) (dp * Resources.getSystem().getDisplayMetrics().density);
-    }
-
-    public static int pxToDp(int px)
-    {
-        return (int) (px / Resources.getSystem().getDisplayMetrics().density);
-    }
-}

+ 0 - 162
app/src/main/java/app/mar/activities/ModelViewerActivity.java

@@ -1,162 +0,0 @@
-package app.mar.activities;
-
-import android.support.v4.view.MotionEventCompat;
-import android.os.Bundle;
-import android.view.MotionEvent;
-import android.view.View;
-import android.widget.Button;
-import android.widget.FrameLayout;
-import android.widget.TextView;
-
-import app.mar.utils.FontChangeCrawler;
-import app.mar.game.Resource;
-import app.mar.utils.geometry.Point;
-import min3d.core.Object3d;
-import min3d.core.RendererActivity;
-import min3d.vos.CameraVo;
-import min3d.vos.Light;
-import min3d.vos.LightType;
-
-public class ModelViewerActivity extends RendererActivity  implements View.OnTouchListener {
-    public static final int REQUEST_CODE = 29;
-    private Resource mResource;
-    private Button mInfo;
-    private TextView mTitle;
-    private FrameLayout mFrameLayout;
-
-    protected float mPreviousX;
-    protected float mPreviousY;
-    protected float mPreviousDist=0;
-    protected CameraVo mCamera = new CameraVo();
-    protected boolean mIsZooming = false;
-    protected boolean mIsMoving = false;
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_model_viewer);
-
-        mInfo = (Button) findViewById(R.id.info);
-        mFrameLayout = (FrameLayout) findViewById(R.id.frame_viewer);
-        mTitle = (TextView) findViewById(R.id.title);
-
-        if(getIntent().hasExtra("resource"))
-        {
-            mResource = (Resource) getIntent().getSerializableExtra("resource");
-            if(mResource!=null) setTitle(mResource.getTitle());
-            mFrameLayout.addView(_glSurfaceView);
-            mTitle.setText(mResource.getTitle());
-        }else
-        {
-            mTitle.setText("Error: Res not found");
-        }
-        FontChangeCrawler.setFont(this);
-
-
-    }
-
-    public void onClickInfo(View v)
-    {
-
-    }
-
-    public void initScene()
-    {
-
-        scene.backgroundColor().setAll(0x00000000);
-
-        Light myLight = new Light();
-        myLight.position.setZ(0);
-        myLight.position.setY(0);
-        myLight.type(LightType.POSITIONAL);
-
-        scene.lights().add(myLight);
-        Object3d oo = mResource.get3DModel(this);
-        oo.position().z=mResource.getPosition().z;
-        oo.position().y=mResource.getPosition().y;
-        oo.position().x=mResource.getPosition().x;
-        oo.position().z-=20;
-        mCamera.frustum.zFar(0.1f);
-        mCamera.frustum.zFar(1000);
-        scene.addChild(mResource.get3DModel(this));
-    }
-
-    @Override
-    public void updateScene() {
-
-    }
-
-    @Override
-    public boolean onTouch(View view, MotionEvent motionEvent) {
-        float x = motionEvent.getX();
-        float y = motionEvent.getY();
-        final int action = motionEvent.getAction()%256;
-        int index = MotionEventCompat.getActionIndex(motionEvent);
-
-        if (motionEvent.getPointerCount() > 1) {
-            switch (action) {
-                case MotionEvent.ACTION_MOVE:
-                {
-                    if(!mIsZooming) break;
-                    Point a = new Point(motionEvent.getX(0), motionEvent.getY(0));
-                    Point b = new Point(motionEvent.getX(1), motionEvent.getY(1));
-                    double d = a.getDistanceWith(b);
-                    double delta = d - mPreviousDist;
-                    mCamera.position.z+=delta/2;
-                    mPreviousDist = (float)a.getDistanceWith(b);
-                    scene.camera(mCamera);
-                    break;
-                }
-                case MotionEvent.ACTION_POINTER_DOWN:
-                case MotionEvent.ACTION_DOWN: {
-                    Point a = new Point(motionEvent.getX(0), motionEvent.getY(0));
-                    Point b = new Point(motionEvent.getX(1), motionEvent.getY(1));
-                    mPreviousDist = (float)a.getDistanceWith(b);
-                    mIsZooming=true;
-                    break;
-                }
-                case MotionEvent.ACTION_UP:
-                case MotionEvent.ACTION_POINTER_UP:
-                case MotionEvent.ACTION_CANCEL:
-                    mIsZooming=false;
-                    mIsMoving=false;
-                    break;
-            }
-
-
-        }
-        else {
-            mIsZooming=false;
-            switch (motionEvent.getAction()) {
-                case MotionEvent.ACTION_MOVE:
-                {
-                    if(!mIsMoving) break;
-                    float dx = x - mPreviousX;
-                    float dy = y - mPreviousY;
-                    Object3d oo = mResource.get3DModel(this);
-
-                    oo.rotation().y += dx / 3;
-                    oo.rotation().x += dy / 3;
-                    _glSurfaceView.requestRender();
-
-
-                    break;
-                }
-                case MotionEvent.ACTION_DOWN:
-                    mIsMoving=true;
-                    break;
-                case MotionEvent.ACTION_UP:
-                case MotionEvent.ACTION_CANCEL:
-                    mIsMoving=false;
-                    mIsZooming=false;
-                    break;
-            }
-            mPreviousX = x;
-            mPreviousY = y;
-        }
-
-
-        return true;
-
-    }
-}

+ 0 - 248
app/src/main/java/app/mar/activities/SettingsActivity.java

@@ -1,248 +0,0 @@
-package app.mar.activities;
-
-
-import android.app.Activity;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.preference.PreferenceActivity;
-import android.support.v7.app.AlertDialog;
-import android.view.View;
-import android.widget.Button;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import android.widget.Toast;
-
-import app.mar.ui.CustomToggleButton;
-import app.mar.ui.SelectButton;
-import app.mar.ui.OnToggleListener;
-import app.mar.utils.FontChangeCrawler;
-import app.mar.utils.Settings;
-import app.mar.game.Game;
-
-/**
- * A {@link PreferenceActivity} that presents a set of application settings. On
- * handset devices, settings are presented as a single list. On tablets,
- * settings are split by category, with category headers shown to the left of
- * the list of settings.
- * <p/>
- * See <a href="http://developer.android.com/design/patterns/settings.html">
- * Android Design: Settings</a> for design guidelines and the <a
- * href="http://developer.android.com/guide/topics/ui/settings.html">Settings
- * API Guide</a> for more information on developing a Settings UI.
- */
-public class SettingsActivity extends Activity implements OnToggleListener, View.OnClickListener {
-
-    protected Game         mGame;
-    protected LinearLayout mRoot;
-    protected LinearLayout mRootDev;
-    protected CustomToggleButton mAccelerometer;
-    protected CustomToggleButton mGPS;
-    protected CustomToggleButton mPlaces;
-    protected CustomToggleButton mAreas;
-    protected CustomToggleButton mDev;
-    protected CustomToggleButton mRA;
-    protected SelectButton mSensorLatency;
-    protected View mReset;
-    protected View mCheat;
-    protected Button mOk;
-
-
-
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_settings);
-
-        mGame = Game.game();
-        mRootDev=new LinearLayout(this);
-        mRootDev.setOrientation(LinearLayout.VERTICAL);
-        mAccelerometer = new CustomToggleButton(this);
-        mGPS = new CustomToggleButton(this);
-        mDev = new CustomToggleButton(this);
-        mDev.setOnClickListener((OnToggleListener)this);
-        mPlaces=new CustomToggleButton(this);
-        mRA=new CustomToggleButton(this);
-        mAreas=new CustomToggleButton(this);
-        mSensorLatency = new SelectButton(this, Settings.SENSORS_LATENCIES);
-        mCheat = newButton("Avoir toutes les ressources");
-        mReset = newButton("Supprimer la sauvegarde");
-        mRoot = (LinearLayout)findViewById(R.id.root_layout);
-        mOk = (Button)findViewById(R.id.sbutok);
-        addSelection("Latence des capteurs:", mSensorLatency, mRoot);
-        addAction("", mReset, mRoot);
-        addOptionBool("Mode Réalitée augmentée", mRA, mRoot);
-        addOptionBool("Mode développeur:", mDev, mRoot);
-        mRoot.addView(mRootDev);
-        addOptionBool("GPS préprogrammé:", mGPS, mRootDev);
-        addOptionBool("Afficher les zones:", mAreas, mRootDev);
-        addOptionBool("Afficher les ressources:", mPlaces, mRootDev);
-        addAction("", mCheat, mRootDev);
-        preset();
-        FontChangeCrawler.setFont(this);
-    }
-
-    protected View newButton(String text)
-    {
-        TextView b = new TextView(this);
-        b.setText(text);
-        b.setTextColor(getResources().getColor(R.color.dull_4));
-        b.setOnClickListener(this);
-        return b;
-    }
-
-    private void reset()
-    {
-        final Activity context = this;
-        AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
-        builder1.setMessage("Cette action va supprimer toute la sauvegarde. La progression dans le jeu reviendra donc a 0. Êtes-vous sûr de vouloir continuer ?");
-        builder1.setCancelable(true);
-
-        builder1.setPositiveButton(
-                "Supprimer",
-                new DialogInterface.OnClickListener() {
-                    public void onClick(DialogInterface dialog, int id) {
-                        Game.setGame(new Game("game_medium", context));
-                        Toast.makeText(context, "Suppression effectuée", Toast.LENGTH_SHORT);
-                        dialog.cancel();
-                    }
-                });
-
-        builder1.setNegativeButton(
-                "Ne pas supprimer",
-                new DialogInterface.OnClickListener() {
-                    public void onClick(DialogInterface dialog, int id) {
-                        dialog.cancel();
-                    }
-                });
-
-        AlertDialog alert11 = builder1.create();
-        alert11.show();
-    }
-
-    public void onClick(View v)
-    {
-        if(v==mOk)
-        {
-            setResults();
-            finish();
-        }
-        else if(v==mReset)
-        {
-            reset();
-            setResults();
-        }else if(v==mCheat)
-        {
-            //mGame.pickAllResoucres();
-        }
-    }
-
-    public void addOptionBool(String name, CustomToggleButton v, LinearLayout root)
-    {
-        LinearLayout ll = new LinearLayout(this);
-        TextView tv = new TextView(this);
-        tv.setText(name);
-        tv.setTextColor(getResources().getColor(R.color.dull_4));
-
-        ll.setOrientation(LinearLayout.HORIZONTAL);
-        ll.addView(tv);
-        ll.addView(v);
-        root.addView(ll);
-        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
-        lp.setMargins(30, 30, 25, 5);
-        ll.setLayoutParams(lp);
-        lp=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
-        lp.setMargins(0, 0, 40 , 40);
-        tv.setLayoutParams(lp);
-        v.setLayoutParams(new LinearLayout.LayoutParams(150, 80));
-        newSeparator(root);
-    }
-
-    public void addAction(String name, View v, LinearLayout root)
-    {
-        LinearLayout ll = new LinearLayout(this);
-        ll.setOrientation(LinearLayout.HORIZONTAL);
-        ll.addView(v);
-        root.addView(ll);
-
-        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
-        lp.setMargins(30, 30, 25, 5);
-        ll.setLayoutParams(lp);
-        v.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 60));
-        newSeparator(root);
-    }
-
-    public void addSelection(String name, SelectButton v, LinearLayout root)
-    {
-        LinearLayout ll = new LinearLayout(this);
-        TextView tv = new TextView(this);
-        tv.setText(name);
-        tv.setTextColor(getResources().getColor(R.color.dull_4));
-
-        ll.setOrientation(LinearLayout.VERTICAL);
-        ll.addView(tv);
-        ll.addView(v);
-        root.addView(ll);
-        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
-        lp.setMargins(30, 30, 25, 5);
-        ll.setLayoutParams(lp);
-        lp=new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
-        lp.setMargins(90, 0, 0 , 0);
-        v.setLayoutParams(lp);
-        //v.setLayoutParams(new LinearLayout.LayoutParams(150, 60));
-        newSeparator(root);
-    }
-
-    public View newSeparator(LinearLayout root)
-    {
-        View v = new View(this);
-        v.setBackgroundColor(getResources().getColor(R.color.dull_3));
-        root.addView(v);
-        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 2);
-        lp.setMargins(30, 30, 0,0);
-        v.setLayoutParams(lp);
-        return v;
-    }
-
-
-    private void setResults()
-    {
-        mGame.getSettings().setDevelopperMode(mDev.getState());
-        mGame.getSettings().setGPSDebug(mGPS.getState());
-        mGame.getSettings().setAreaDebug(mAreas.getState());
-        mGame.getSettings().setARMode(mRA.getState());
-        mGame.getSettings().setResourceDebug(mPlaces.getState());
-        mGame.getSettings().setSensorLatency(mSensorLatency.getState());
-        Settings.setSettings(mGame.getSettings());
-        mGame.save(this);
-        mGame.getPlayer().newSensorManager(this);
-    }
-
-    private void updateVisibility()
-    {
-        int x = mDev.getState()?View.VISIBLE:View.GONE;
-        mRootDev.setVisibility(x);
-    }
-
-    private void preset()
-    {
-        mDev.setState(mGame.getSettings().isDevelopperMode());
-        mGPS.setState(mGame.getSettings().isGPSDebug());
-        mAreas.setState(mGame.getSettings().isAreaDebug());
-        mPlaces.setState(mGame.getSettings().isResourceDebug());
-        mRA.setState(mGame.getSettings().isARMode());
-        mSensorLatency.setState(mGame.getSettings().getSensorLatency());
-        updateVisibility();
-    }
-
-    @Override
-    public void onToggle(View v) {
-        if(v==mDev) updateVisibility();
-    }
-
-    @Override
-    public void onOn(View v) {}
-
-    @Override
-    public void onOff(View v) {}
-
-
-}

+ 21 - 125
app/src/main/java/app/mar/activities/ChallengeFragment.java → app/src/main/java/app/mar/activities/fragments/ChallengeFragment.java

@@ -1,12 +1,10 @@
-package app.mar.activities;
+package app.mar.activities.fragments;
 
 import android.app.Activity;
 import android.app.Fragment;
 import android.content.Context;
 import android.graphics.Bitmap;
-import android.graphics.Color;
 import android.graphics.Typeface;
-import android.graphics.drawable.Drawable;
 import android.net.Uri;
 import android.os.Bundle;
 import android.util.Log;
@@ -15,7 +13,6 @@ import android.view.KeyEvent;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.view.textclassifier.TextClassifier;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.TextView;
@@ -23,17 +20,15 @@ import android.widget.Toast;
 
 import java.util.ArrayList;
 import java.util.Timer;
-import java.util.TimerTask;
 
-import app.mar.game.Area;
+import app.mar.activities.ChallengeDriver;
+import app.mar.activities.R;
+import app.mar.exceptions.ResourceFileNotFoundException;
+import app.mar.exceptions.ResourceNotFoundException;
 import app.mar.game.Resource;
 import app.mar.game.ResourceManager;
 import app.mar.game.challenges.Challenge;
-import app.mar.game.challenges.GeoIndice;
-import app.mar.game.challenges.IGeoTreasure;
-import app.mar.game.challenges.Indice;
-import app.mar.game.challenges.TextIndice;
-import app.mar.utils.L;
+import app.mar.game.Indice;
 import app.mar.utils.files.FileManager;
 import uk.co.senab.photoview.PhotoViewAttacher;
 
@@ -44,29 +39,19 @@ public abstract class ChallengeFragment extends Fragment {
 
 
     protected LinearLayout  mUITextIndices;
-    protected TextView      mUIGeoIndice;
     protected LinearLayout  mUIGlobalIndice;
     protected Challenge     mChallenge;
     protected ImageView     mImage;
     private PhotoViewAttacher mAttacher;
 
-    protected Timer         mTimer;
-
-    private Runnable mTimerTick = new Runnable() {
-        public void run() {
-            onGeoUpdateTimer();
-        }
-    };
-
-
     protected void onInitChallenge(Challenge c)
     {
+        Log.e("--------","Init challenge '"+c.getName()+"'  -> '"+c.getResourceName()+"'");
         if(c!=null) setImageResource(c.getResourceName());
     }
 
     public boolean onBackPressed()
     {
-        stopGeoUpdateTimer();
         return true;
     }
 
@@ -74,7 +59,12 @@ public abstract class ChallengeFragment extends Fragment {
     {
         Resource r = ResourceManager.getInstance().get(res);
 
-        if(r!=null && r.isImage() )
+        if(r==null)
+        {
+            throw new ResourceNotFoundException(res);
+        }
+
+        if( r.isImage() )
         {
             String name = r.getName();
             String path = r.getFile();
@@ -82,28 +72,21 @@ public abstract class ChallengeFragment extends Fragment {
             Bitmap bmp=null;
             try {
                  bmp = FileManager.openImage(getActivity(), path);
+                 Log.e("------", "File found : "+path);
             } catch (Exception e) {
                 e.printStackTrace();
-                Toast.makeText(getActivity(), "Impossible de charger '"+name+"' ('"+path+"')", Toast.LENGTH_LONG).show();
+                throw new ResourceFileNotFoundException(r);
             }
 
             mImage.setImageBitmap(bmp);
             mAttacher = new PhotoViewAttacher(mImage);
             mAttacher.setMaximumScale(20);
         }
-        else
-        {
-
-        }
     }
 
     public void resetUi()
     {
         getDriver().setVisibilityView(R.id.btn_indice, View.VISIBLE);
-        if(mUIGeoIndice!=null)
-        {
-            mUIGeoIndice.setVisibility(View.GONE);
-        }
         if(mUITextIndices!=null)
         {
             mUITextIndices.removeAllViews();
@@ -120,7 +103,7 @@ public abstract class ChallengeFragment extends Fragment {
         TextView tv = new TextView(getActivity());
         tv.setTextColor(0xff70e030);
         tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
-        tv.setText("  Indice "+(indInd+1)+" : "+((TextIndice) ind).getText());
+        tv.setText("  Indice "+(indInd+1)+" : "+ind.getText());
         tv.setTypeface(null, Typeface.BOLD);
         return  tv;
     }
@@ -134,15 +117,8 @@ public abstract class ChallengeFragment extends Fragment {
         {
             Indice ind = inds.get(i);
             if(!ind.isDiscovered()) return;
-            if(ind instanceof GeoIndice && mUIGeoIndice!=null)
-            {
-                mUIGlobalIndice.setVisibility(View.VISIBLE);
-                mUIGeoIndice.setVisibility(View.VISIBLE);
-                startGeoUpdateTimer();
-            }else if(ind instanceof TextIndice && mUITextIndices!=null)
-            {
-                mUITextIndices.addView(createTextView(ind, indInd));
-            }
+            mUITextIndices.addView(createTextView(ind, indInd));
+
         }
         //si on arrive ici, ca veut dire que tous les indices ont ete découvert
         getDriver().setVisibilityView(R.id.btn_indice, View.INVISIBLE);
@@ -154,29 +130,15 @@ public abstract class ChallengeFragment extends Fragment {
         int indInd = mChallenge.getIndiceIndex();
         if(ind!=null)
         {
-            if(getActivity() instanceof  ChallengeDriver)
+            if(getActivity() instanceof ChallengeDriver)
             {
-                if(ind instanceof GeoIndice)
-                {
-                    if(mUIGeoIndice!=null)
-                    {
-                        mUIGlobalIndice.setVisibility(View.VISIBLE);
-                        mUIGeoIndice.setVisibility(View.VISIBLE);
-                        startGeoUpdateTimer();
-                        ind.discover();
-                        return ind;
-                    }
-                    return null;
-                }else if(ind instanceof TextIndice)
-                {
-                    if(mUITextIndices!=null)
-                    {
+
+                    if(mUITextIndices!=null) {
                         mUIGlobalIndice.setVisibility(View.VISIBLE);
                         mUITextIndices.addView(createTextView(ind, indInd));
                         ind.discover();
                         return ind;
                     }
-                }
             }
         }
         return null;
@@ -195,7 +157,6 @@ public abstract class ChallengeFragment extends Fragment {
         // Inflate the layout for this fragment
         View v = inflater.inflate(res, container, false);
         mUITextIndices= (LinearLayout) v.findViewById(R.id.ll_textIndices);
-        mUIGeoIndice= (TextView) v.findViewById(R.id.tv_geoIndice);
         mUIGlobalIndice = (LinearLayout) v.findViewById(R.id.ll_rootIndices);
         mImage = (ImageView) v.findViewById(R.id.iv_img);
         return v;
@@ -241,21 +202,12 @@ public abstract class ChallengeFragment extends Fragment {
         ready();
     }
 
-    @Override
-    public void onStop() {
-        super.onStop();
-        stopGeoUpdateTimer();
-    }
-
 
     public void onResume() {
         super.onResume();
         if(mChallenge!=null) updateIndices();
     }
 
-    public void onPause() {
-        super.onPause();
-    }
 
     public boolean onKeyDown(int keyCode, KeyEvent event) {
         return false;
@@ -298,62 +250,6 @@ public abstract class ChallengeFragment extends Fragment {
 
 
 
-    //
-    // Timer géolocalisation
-    //
-
-    protected void onGeoUpdateTimer()
-    {
-        IGeoTreasure gt = null;
-        gt=(IGeoTreasure) mChallenge;
-
-        Area a = gt.getArea();
-
-        ChallengeDriver cd = getDriver();
-
-        if(cd==null)
-        {
-            stopGeoUpdateTimer();
-        }else
-        {
-            int d=(int) cd.getDistanceWith(a);
-            int accuracy = -1;
-            try{
-                accuracy = (int) cd.getAccuracy();
-            }catch(Exception e)
-            {
-            }
-            if(d>=0 && accuracy>=0) mUIGeoIndice.setText("Distance "+d+" m  (+/- "+accuracy+" m)");
-            else mUIGeoIndice.setText("Géolocalisation en cours ...");
-
-        }
-
-    }
-
-    protected void stopGeoUpdateTimer()
-    {
-        if(mTimer!=null) mTimer.cancel();
-    }
-
-    protected void startGeoUpdateTimer()
-    {
-        mTimer = new Timer();
-        mTimer.schedule(new TimerTask() {
-            @Override
-            public void run() {
-                timerCallback();
-            }
-
-        }, 0, 1000);
-    }
-
-    private void timerCallback()
-    {
-        Activity a = getActivity();
-        if(a!=null) a.runOnUiThread(mTimerTick);
-        else stopGeoUpdateTimer();
-    }
-
 
     //
     // Fin de Timer géolacalisation

+ 2 - 1
app/src/main/java/app/mar/activities/QCMFragment.java → app/src/main/java/app/mar/activities/fragments/QCMFragment.java

@@ -1,4 +1,4 @@
-package app.mar.activities;
+package app.mar.activities.fragments;
 
 import android.app.ActionBar;
 import android.os.Bundle;
@@ -14,6 +14,7 @@ import android.widget.Toast;
 
 import java.util.ArrayList;
 
+import app.mar.activities.R;
 import app.mar.game.Game;
 import app.mar.game.challenges.Challenge;
 import app.mar.game.challenges.QCM;

+ 9 - 47
app/src/main/java/app/mar/activities/QRCodeFragment.java → app/src/main/java/app/mar/activities/fragments/QRCodeFragment.java

@@ -1,12 +1,10 @@
-package app.mar.activities;
+package app.mar.activities.fragments;
 
 import android.app.Activity;
 import android.content.pm.PackageManager;
-import android.graphics.Color;
 import android.os.Bundle;
 import android.app.Fragment;
 import android.util.Log;
-import android.util.TypedValue;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -25,15 +23,12 @@ import com.journeyapps.barcodescanner.DecoratedBarcodeView;
 
 import java.util.List;
 
-import app.mar.game.Area;
+import app.mar.activities.ChallengeDriver;
+import app.mar.activities.R;
 import app.mar.game.Game;
 import app.mar.game.challenges.Challenge;
-import app.mar.game.challenges.GeoIndice;
-import app.mar.game.challenges.IGeoTreasure;
-import app.mar.game.challenges.Indice;
-import app.mar.game.challenges.QRCodeGeoTreasure;
+import app.mar.game.Indice;
 import app.mar.game.challenges.QRCodeTreasure;
-import app.mar.game.challenges.TextIndice;
 
 
 /**
@@ -103,9 +98,6 @@ public class QRCodeFragment extends ChallengeFragment  implements
         {
             mQr=null;
         }
-        if( (c instanceof QRCodeGeoTreasure) ) {
-            getDriver().startLocalisation();
-        }
         getDriver().setVisibilityView(R.id.btn_valid, View.INVISIBLE);
 
     }
@@ -144,7 +136,6 @@ public class QRCodeFragment extends ChallengeFragment  implements
         tvQuestion=v.findViewById(R.id.tv_question);
 
         mUITextIndices2= (LinearLayout) v.findViewById(R.id.ll_textIndices2);
-        mUIGeoIndice2= (TextView) v.findViewById(R.id.tv_geoIndice2);
         mUIGlobalIndice2 = (LinearLayout) v.findViewById(R.id.ll_rootIndices2);
 
         if (!hasFlash()) {
@@ -160,19 +151,6 @@ public class QRCodeFragment extends ChallengeFragment  implements
 
 
 
-
-    @Override
-    public void onStart() {
-        super.onStart();
-        getDriver().resumeLocalisation();
-    }
-
-    @Override
-    public void onStop() {
-        super.onStop();
-        getDriver().pauseLocalisation();
-    }
-
     @Override
     public void onResume() {
         super.onResume();
@@ -240,7 +218,6 @@ public class QRCodeFragment extends ChallengeFragment  implements
             barcodeScannerView.pause();
             Activity act = getActivity();
             getDriver().challengeValidate(mChallenge, mGame, (ChallengeDriver)getActivity());
-            stopGeoUpdateTimer();
         }else
         {
             Toast.makeText(getActivity(), mQr.getBadQRMessage(), Toast.LENGTH_LONG).show();
@@ -277,33 +254,18 @@ public class QRCodeFragment extends ChallengeFragment  implements
 
         if(indice!=null && getActivity() instanceof  ChallengeDriver)
         {
-            if(indice instanceof GeoIndice)
-            {
-                if(mUIGeoIndice2!=null)
-                {
-                    mUIGlobalIndice2.setVisibility(View.VISIBLE);
-                    mUIGeoIndice2.setVisibility(View.VISIBLE);
-                    startGeoUpdateTimer();
-                }
-            }else if(indice instanceof TextIndice)
+
+            if(mUITextIndices2!=null)
             {
-                if(mUITextIndices2!=null)
-                {
-                    mUIGlobalIndice2.setVisibility(View.VISIBLE);
-                    mUITextIndices2.addView(createTextView(indice, indInd));
-                }
+                mUIGlobalIndice2.setVisibility(View.VISIBLE);
+                mUITextIndices2.addView(createTextView(indice, indInd));
             }
+
         }
 
         return indice;
     }
 
-    @Override
-    protected void onGeoUpdateTimer()
-    {
-        super.onGeoUpdateTimer();
-        mUIGeoIndice2.setText(mUIGeoIndice.getText());
-    }
 
     @Override
     public void possibleResultPoints(List<ResultPoint> resultPoints) {

+ 4 - 1
app/src/main/java/app/mar/activities/QuestionFragment.java → app/src/main/java/app/mar/activities/fragments/QuestionFragment.java

@@ -1,4 +1,4 @@
-package app.mar.activities;
+package app.mar.activities.fragments;
 
 import android.os.Bundle;
 import android.app.Fragment;
@@ -10,6 +10,7 @@ import android.widget.ImageView;
 import android.widget.TextView;
 import android.widget.Toast;
 
+import app.mar.activities.R;
 import app.mar.game.challenges.Challenge;
 import app.mar.game.challenges.Question;
 
@@ -85,6 +86,8 @@ public class QuestionFragment extends ChallengeFragment  {
 
     @Override
     protected void onResetUi() {
+        mUIResponse.setText("");
         mUIResponse.setHint("Entrer votre réponse");
+        getDriver().setVisibilityView(R.id.btn_valid, View.VISIBLE);
     }
 }

+ 10 - 29
app/src/main/java/app/mar/activities/ImageViewerActivity.java → app/src/main/java/app/mar/activities/viewers/ImageViewerActivity.java

@@ -1,4 +1,4 @@
-package app.mar.activities;
+package app.mar.activities.viewers;
 
 import android.graphics.Bitmap;
 import android.os.Bundle;
@@ -9,7 +9,8 @@ import android.widget.ImageView;
 import android.widget.TextView;
 import android.widget.Toast;
 
-import app.mar.utils.FontChangeCrawler;
+import app.mar.activities.R;
+import app.mar.exceptions.BadResourceTypeException;
 import app.mar.game.Resource;
 import app.mar.utils.files.FileManager;
 import uk.co.senab.photoview.PhotoViewAttacher;
@@ -24,23 +25,15 @@ public class ImageViewerActivity extends AppCompatActivity {
     public static final int REQUEST_CODE = 30;
     private Resource mResource;
     private ImageView mImageView;
-    private Button mButton;
     private PhotoViewAttacher mAttacher;
 
 
-    public static final int CONTENT_NULL=0;
-    public static final int CONTENT_MAP=1;
-    public static final int CONTENT_INFO=2;
-    public static final int CONTENT_IMAGE=3;
-    public static final int CONTENT_3D=4;
-    protected int mContent=CONTENT_NULL;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_viewer);
         mImageView = (ImageView) findViewById(R.id.imageView);
-        mButton = (Button) findViewById(R.id.info);
         if(getIntent().hasExtra("resource"))
         {
             mResource = (Resource) getIntent().getSerializableExtra("resource");
@@ -50,12 +43,11 @@ public class ImageViewerActivity extends AppCompatActivity {
         final TextView title = (TextView) findViewById(R.id.title);
         title.setVisibility(View.VISIBLE);
 
-        if(mResource != null && !getIntent().hasExtra("information") && !getIntent().hasExtra("map"))
+        if(mResource != null )
         {
             title.setText(mResource.getTitle());
             if(mResource.isImage())
             {
-                mContent=CONTENT_IMAGE;
                 Bitmap bmp=null;
                 Toast.makeText(this, "Chargement de '"+mResource.getName()+"'", Toast.LENGTH_SHORT).show();
                 try {
@@ -69,35 +61,24 @@ public class ImageViewerActivity extends AppCompatActivity {
                 mAttacher = new PhotoViewAttacher(mImageView);
                 mAttacher.setMaximumScale(20);
 
+            }else
+            {
+                title.setText("Erreur: ");
+                throw  new BadResourceTypeException(mResource, Resource.IMAGE);
             }
 
         } else
         {
-            title.setText("Erreur");
+            title.setText("Erreur ressource invalide");
+            throw new RuntimeException("Erreur ressource invalide");
         }
 
     }
 
-    public void onClickInfo(View v)
-    {
-
-    }
-
 
     public void onClick(View v)
     {
-        if(mContent==CONTENT_IMAGE) {
-
-            final TextView title = (TextView) findViewById(R.id.title);
-            if (title.getVisibility() == View.VISIBLE) {
-                title.setVisibility(View.GONE);
-                mButton.setVisibility(View.GONE);
-            } else {
 
-                title.setVisibility(View.VISIBLE);
-                mButton.setVisibility(View.VISIBLE);
-            }
-        }
     }
 
 }

+ 14 - 4
app/src/main/java/app/mar/activities/MediaViewerAcitvity.java → app/src/main/java/app/mar/activities/viewers/MediaViewerAcitvity.java

@@ -1,4 +1,4 @@
-package app.mar.activities;
+package app.mar.activities.viewers;
 
 import android.app.Activity;
 import android.content.Intent;
@@ -14,6 +14,9 @@ import android.widget.ImageView;
 import android.widget.SeekBar;
 import android.widget.TextView;
 
+import app.mar.activities.R;
+import app.mar.exceptions.BadResourceTypeException;
+import app.mar.exceptions.ResourceFileNotFoundException;
 import app.mar.ui.MediaView;
 import app.mar.utils.FontChangeCrawler;
 import app.mar.game.Resource;
@@ -64,7 +67,10 @@ public class MediaViewerAcitvity extends AppCompatActivity implements MediaPlaye
         if(getIntent().hasExtra("resource"))
         {
             mResource = (Resource) getIntent().getSerializableExtra("resource");
-            if(mResource==null) return;
+            if(mResource==null)
+            {
+                throw  new RuntimeException("Ressource non valide");
+            }
 
             mTitle.setText(mResource.getTitle());
 
@@ -73,12 +79,16 @@ public class MediaViewerAcitvity extends AppCompatActivity implements MediaPlaye
             {
                 mImageView.setVisibility(View.VISIBLE);
             }
-            else
+            else if (mResource.isVideo())
             {
                 mImageView.setVisibility(View.GONE);
+            }else
+            {
+                throw new BadResourceTypeException(mResource, Resource.AUDIO+" ou "+Resource.VIDEO);
             }
 
-            mMediaView.play(path);
+            boolean b = mMediaView.play(path);
+            if(!b) throw new ResourceFileNotFoundException(mResource);
         }
 
 

+ 2 - 1
app/src/main/java/app/mar/activities/ResourceListActivity.java → app/src/main/java/app/mar/activities/viewers/ResourceListActivity.java

@@ -1,4 +1,4 @@
-package app.mar.activities;
+package app.mar.activities.viewers;
 
 import android.app.Activity;
 import android.os.Bundle;
@@ -7,6 +7,7 @@ import android.widget.ListView;
 
 import java.util.ArrayList;
 
+import app.mar.activities.R;
 import app.mar.game.Game;
 import app.mar.ui.ResourceArrayAdapter;
 import app.mar.utils.*;

+ 19 - 9
app/src/main/java/app/mar/activities/TestVideoActivity.java → app/src/main/java/app/mar/activities/viewers/TestVideoActivity.java

@@ -1,12 +1,9 @@
-package app.mar.activities;
+package app.mar.activities.viewers;
 
 import android.media.MediaPlayer;
 import android.os.Bundle;
 import android.os.Handler;
-import android.support.design.widget.FloatingActionButton;
-import android.support.design.widget.Snackbar;
 import android.support.v7.app.AppCompatActivity;
-import android.support.v7.widget.Toolbar;
 import android.view.View;
 import android.widget.Button;
 import android.widget.FrameLayout;
@@ -16,9 +13,11 @@ import android.widget.SeekBar;
 import android.widget.TextView;
 import android.widget.Toast;
 
+import app.mar.activities.R;
+import app.mar.exceptions.BadResourceTypeException;
+import app.mar.exceptions.ResourceFileNotFoundException;
 import app.mar.game.Resource;
 import app.mar.ui.MediaView;
-import app.mar.utils.FontChangeCrawler;
 
 
 public class TestVideoActivity extends AppCompatActivity implements MediaPlayer.OnSeekCompleteListener,
@@ -65,7 +64,10 @@ public class TestVideoActivity extends AppCompatActivity implements MediaPlayer.
         {
             Toast.makeText(this, "OK", Toast.LENGTH_LONG).show();
             mResource = (Resource) getIntent().getSerializableExtra("resource");
-            if(mResource==null) return;
+            if(mResource==null)
+            {
+                throw  new RuntimeException("Ressource non valide");
+            }
 
             mTitle.setText(mResource.getTitle());
 
@@ -74,13 +76,21 @@ public class TestVideoActivity extends AppCompatActivity implements MediaPlayer.
             {
                 mImageView.setVisibility(View.VISIBLE);
             }
-            else
+            else if(mResource.isVideo())
             {
                 mImageView.setVisibility(View.GONE);
             }
+            else
+            {
+                throw new BadResourceTypeException(mResource, Resource.AUDIO+" ou "+Resource.VIDEO);
+            }
 
-            mMediaView.play(path);
-        }else
+            boolean b = mMediaView.play(path);
+            if(!b) throw new ResourceFileNotFoundException(mResource);
+
+        }else {
+            throw  new RuntimeException("La ressource n'a pas été passé sous la clé 'resource'");
+        }
             Toast.makeText(this, "FAIL", Toast.LENGTH_LONG).show();
 
 

+ 12 - 0
app/src/main/java/app/mar/exceptions/BadChallengeConfigException.java

@@ -0,0 +1,12 @@
+package app.mar.exceptions;
+
+
+public class BadChallengeConfigException extends BadConfigFileException {
+    public BadChallengeConfigException(String  r){
+        super(r);
+    }
+
+    public BadChallengeConfigException(String r, Throwable throwable) {
+        super(r, throwable);
+    }
+}

+ 11 - 0
app/src/main/java/app/mar/exceptions/BadConfigFileException.java

@@ -0,0 +1,11 @@
+package app.mar.exceptions;
+
+public class BadConfigFileException extends RuntimeException {
+    public BadConfigFileException(String  r){
+        super(r);
+    }
+
+    public BadConfigFileException(String r, Throwable throwable) {
+        super(r, throwable);
+    }
+}

+ 11 - 0
app/src/main/java/app/mar/exceptions/BadGameConfigException.java

@@ -0,0 +1,11 @@
+package app.mar.exceptions;
+
+public class BadGameConfigException extends BadConfigFileException {
+    public BadGameConfigException(String  r){
+        super(r);
+    }
+
+    public BadGameConfigException(String r, Throwable throwable) {
+        super(r, throwable);
+    }
+}

+ 11 - 0
app/src/main/java/app/mar/exceptions/BadResourceConfigException.java

@@ -0,0 +1,11 @@
+package app.mar.exceptions;
+
+public class BadResourceConfigException extends BadConfigFileException {
+    public BadResourceConfigException(String  r){
+        super(r);
+    }
+
+    public BadResourceConfigException(String r, Throwable throwable) {
+        super(r, throwable);
+    }
+}

+ 13 - 0
app/src/main/java/app/mar/exceptions/BadResourceTypeException.java

@@ -0,0 +1,13 @@
+package app.mar.exceptions;
+
+import app.mar.game.Resource;
+
+public class BadResourceTypeException  extends RuntimeException{
+    public BadResourceTypeException(Resource r, String type){
+        super("Ressource '"+r.getName()+"' de type '"+r.getType()+"' était attendue avec un type: '"+type+"'");
+    }
+
+    public BadResourceTypeException(Resource r, String type, Throwable throwable) {
+        super("Ressource '"+r.getName()+"' de type '"+r.getType()+"' était attendue avec un type: '"+type+"'", throwable);
+    }
+}

+ 11 - 0
app/src/main/java/app/mar/exceptions/BadStageConfigException.java

@@ -0,0 +1,11 @@
+package app.mar.exceptions;
+
+public class BadStageConfigException extends BadConfigFileException {
+    public BadStageConfigException(String  r){
+        super(r);
+    }
+
+    public BadStageConfigException(String r, Throwable throwable) {
+        super(r, throwable);
+    }
+}

+ 13 - 0
app/src/main/java/app/mar/exceptions/ResourceFileNotFoundException.java

@@ -0,0 +1,13 @@
+package app.mar.exceptions;
+
+import app.mar.game.Resource;
+
+public class ResourceFileNotFoundException extends RuntimeException {
+    public ResourceFileNotFoundException(Resource r) {
+        super("Fichier de la ressource '"+r.getName()+"' ('"+r.getFile()+"') non trouvée.");
+    }
+
+    public ResourceFileNotFoundException(Resource r, Throwable throwable) {
+        super("Fichier de la ressource '"+r.getName()+"' ('"+r.getFile()+"') non trouvée.", throwable);
+    }
+}

+ 11 - 0
app/src/main/java/app/mar/exceptions/ResourceNotFoundException.java

@@ -0,0 +1,11 @@
+package app.mar.exceptions;
+
+public class ResourceNotFoundException extends RuntimeException {
+    public ResourceNotFoundException(String name) {
+        super("Ressource non trouvée: '"+name+"'");
+    }
+
+    public ResourceNotFoundException(String name, Throwable throwable) {
+        super("Ressource non trouvée: '"+name+"'", throwable);
+    }
+}

+ 0 - 138
app/src/main/java/app/mar/game/Area.java

@@ -1,138 +0,0 @@
-package app.mar.game;
-
-import android.app.Activity;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-
-import app.mar.utils.L;
-import app.mar.utils.geometry.GPSPoint;
-import app.mar.utils.geometry.Shape;
-
-/**
- * Created by ptitcois on 19/08/16.
- */
-public class Area  implements Serializable {
-
-    protected String                mName;
-    protected Shape                 mShape = new Shape();
-    protected Place                 mPlaces;
-
-    protected ArrayList<String>     mResourceName = new ArrayList<String>();
-
-
-    public Area(Game g, JSONObject root, Activity act)
-    {
-        try {
-            mName = root.getString("name");
-
-            JSONArray ja = root.getJSONArray("coordinates");
-            for(int i=0; i<ja.length(); i++) {
-                JSONArray jaa = ja.getJSONArray(i);
-                mShape.add(new GPSPoint(jaa.getDouble(0), jaa.getDouble(1)));
-            }
-
-            mPlaces = new Place(root.getJSONObject("point"));
-
-        } catch (JSONException e) {
-            e.printStackTrace();
-        }
-
-        try {
-            String res []  = root.getString("resource").split(";");
-            for(int i=0; i<res.length; i++)
-            {
-                g.registerResource(res[i], act);
-                mResourceName.add(res[i]);
-            }
-        } catch (JSONException e) {
-            L.info("In Area '"+mName+"' : resource field not found");
-        }
-
-    }
-
-    public String getName() {
-        return mName;
-    }
-
-    public ArrayList<String> getResourceNames() {
-        return mResourceName;
-    }
-
-
-    public String getResourceName(int i) {
-        return mResourceName.get(i);
-    }
-
-    public int countResource() {
-        return mResourceName.size();
-    }
-
-    public Shape getShape() {
-        return mShape;
-    }
-
-    public Place getPlace() {
-        return mPlaces;
-    }
-
-    /*
-    public JSONObject getJson()
-    {
-        JSONObject jo = new JSONObject();
-
-        try {
-            jo.put(mPlaces.getJson());
-            jo.put("points", ja);
-            jo.put("coordinates", mShape.getJson());
-            jo.put("name", mName);
-            jo.put("resource", mResourceName);
-        }catch( Exception e)
-        {
-            e.printStackTrace();
-        }
-        return jo;
-    }*/
-
-    public boolean isOnArea(Player p)
-    {
-        GPSPoint player = p.getPosition();
-        if(player == null)
-            return false;
-
-        return mShape.contains(player);
-
-    }
-
-
-    public boolean isOnPlace(Player p)
-    {
-        if(mPlaces.isPlayerOn(p))
-                return true;
-        return false;
-    }
-
-    public boolean isOnDirection(Player p)
-    {
-
-        if(mPlaces.isOnDirection(p))
-                return true;
-        return false;
-    }
-
-    public double getDistance(Player p)
-    {
-        return mPlaces.getDistance(p);
-    }
-
-    public String toString(Player p)
-    {
-        String str = "";
-        str+="["+mName+" "+mPlaces.getDistance(p)+" m ]";
-        return str;
-    }
-}

+ 3 - 0
app/src/main/java/app/mar/game/Event.java

@@ -16,6 +16,8 @@ import java.lang.reflect.Method;
 import java.util.ArrayList;
 
 import app.mar.activities.ChallengeDriver;
+import app.mar.exceptions.BadConfigFileException;
+import app.mar.exceptions.BadGameConfigException;
 
 public class Event implements Serializable {
 
@@ -77,6 +79,7 @@ public class Event implements Serializable {
             mMethod = j.getString("method");
         } catch (JSONException e) {
             e.printStackTrace();
+            throw new BadConfigFileException("(Event) Bad parameter 'method'");
         }
 
         try {

+ 4 - 85
app/src/main/java/app/mar/game/Game.java

@@ -3,7 +3,6 @@ package app.mar.game;
 import android.app.Activity;
 import android.content.Context;
 import android.util.Log;
-import android.widget.Toast;
 
 import org.json.JSONArray;
 import org.json.JSONException;
@@ -18,13 +17,11 @@ import java.io.Serializable;
 import java.util.ArrayList;
 
 import app.mar.activities.ChallengeDriver;
+import app.mar.exceptions.BadGameConfigException;
 import app.mar.game.challenges.Challenge;
 import app.mar.game.challenges.ChallengeReturn;
-import app.mar.game.challenges.Treasure;
 import app.mar.game.scheduler.Scheduler;
 import app.mar.game.scheduler.SpecialTask;
-import app.mar.utils.SensorsManager;
-import app.mar.utils.Settings;
 import app.mar.utils.files.JSONAssetsManager;
 
 /**
@@ -39,8 +36,6 @@ public class Game  implements Serializable {
     protected Stage            mCurrentStage=null;
     protected int              mCurrentStageIndex=-1;
 
-    protected Player           mPlayer;
-    protected Settings         mSettings = new Settings();
     protected Inventaire       mInventaire;
     protected Scheduler        mSched = new Scheduler();
 
@@ -57,7 +52,7 @@ public class Game  implements Serializable {
         JSONObject root = JSONAssetsManager.load(act, name);
         mName=name;
         mInventaire=new Inventaire();
-        mPlayer = new Player(act);
+
         try {
             JSONArray arr = root.getJSONArray("stages");
             for(int i=0; i<arr.length(); i++)
@@ -67,6 +62,7 @@ public class Game  implements Serializable {
             loge("Erreur le nombre d'étape n'est pas renseigné:");
             loge(e.getMessage());
             loge(e.getStackTrace().toString());
+            throw new BadGameConfigException("Bad parameter 'stages'");
         }
 
 
@@ -77,19 +73,13 @@ public class Game  implements Serializable {
             loge("Erreur le password:");
             loge(e.getMessage());
             loge(e.getStackTrace().toString());
+            throw new BadGameConfigException("Bad parameter 'password'");
         }
 
         mCurrentStageIndex=-1;
         if(mStages.size()>0)
             mCurrentStage=mStages.get(0);
 
-
-        if(!mPlayer.hasMagneticField() || !mPlayer.hasAcceleromter())
-        {
-            mSettings.setARMode(false);
-            if(!mPlayer.hasMagneticField()) Toast.makeText(act, "Votre dispositif n'a pas de boussole. Le mode RA ne peut fonctionner et a été désactivé", Toast.LENGTH_LONG).show();
-            else if(!mPlayer.hasAcceleromter()) Toast.makeText(act, "Votre dispositif n'a pas d'accélerometre. Le mode RA ne peut fonctionner et a été désactivé", Toast.LENGTH_LONG).show();
-        }
     }
 
     public Stage getCurrentStage()
@@ -130,9 +120,6 @@ public class Game  implements Serializable {
         mResources.addResource(name, act);
     }
 
-    public Settings getSettings(){return mSettings;}
-    public void setSettings(Settings s){ mSettings=s;}
-
     public String getName() {
         return mName;
     }
@@ -192,7 +179,6 @@ public class Game  implements Serializable {
             obj.mResources.setInstance();
             return obj;
         } catch (Exception e) {
-            e.printStackTrace();
             return null;
         }
     }
@@ -227,21 +213,9 @@ public class Game  implements Serializable {
     public void onPause(Activity context)
     {
         save(context);
-        mPlayer.onPause();
-        removeCached3DModels();
     }
 
 
-    public void onResume()
-    {
-        mPlayer.onResume();
-    }
-
-    public void setSensorsManager(SensorsManager sm)
-    {
-        mPlayer.setSensorsManager(sm);
-    }
-
     /**
      * Permet de recuperer une ressource par son nom
      * @param name Le nom de la ressource
@@ -252,62 +226,7 @@ public class Game  implements Serializable {
         return mResources.get(name);
     }
 
-    /**
-     * Charge la ressource 3d quand on entre dans une zone
-     * @param contecxt Contexte
-     * @return Vrai en cas de succes, faux pour une erreur
-     */
-    synchronized public void precache3DResource(Activity contecxt)
-    {
-        Challenge c = getCurrentChallenge();
-        if(c instanceof Treasure)
-        {
-        }
-    }
 
-    /**
-     *
-     * renvoie la liste des ressources sur lesquelles le joueur est présent
-     * @return la liste des ressources sur lesquelles le joueur est présent
-     */
-    public ArrayList<Resource> getResourcesNextToPlayer(Area a)
-    {
-        ArrayList<Resource> r = new ArrayList<Resource>();
-        ArrayList<String> rs = a.getResourceNames();
-
-        for(int i=0; i<rs.size(); i++)
-            r.add(findResource(rs.get(i)));
-
-        return r;
-    }
-
-    public Player getPlayer()
-    {
-        return mPlayer;
-    }
-
-
-    public void removeCached3DModels()
-    {
-        mResources.deleteAll3DModel();
-    }
-
-    public void newSensorManager(Activity act)
-    {
-        mPlayer.newSensorManager(act);
-        if(!mPlayer.hasMagneticField() || !mPlayer.hasAcceleromter())
-            mSettings.setARMode(false);
-    }
-
-    public void restartSensors()
-    {
-        mPlayer.getSensorsManager().restartSensors();
-    }
-
-    public void stopSensors()
-    {
-        mPlayer.getSensorsManager().stopSensors();
-    }
 
     public static void setGame(Game m)
     {

+ 18 - 10
app/src/main/java/app/mar/game/challenges/Indice.java → app/src/main/java/app/mar/game/Indice.java

@@ -1,34 +1,42 @@
-package app.mar.game.challenges;
+package app.mar.game;
 
 import org.json.JSONException;
 import org.json.JSONObject;
 
 import java.io.Serializable;
 
-public abstract class Indice implements Serializable {
+import app.mar.exceptions.BadConfigFileException;
+
+public class Indice implements Serializable {
     protected  float mPenality=-1;
     protected  boolean mIsDiscovered=false;
+    protected String mText="";
 
     public Indice(JSONObject root)
     {
         try {
             mPenality = (float) root.getDouble("penality");
         } catch (JSONException e) {
+            throw new BadConfigFileException("(Indice) Bad parameter 'penality'");
+        }
+
+
+        try {
+            mText = root.getString("text");
+        } catch (JSONException e) {
+            e.printStackTrace();
+            throw new BadConfigFileException("(Indice) Bad parameter 'text'");
         }
     }
 
+    public String getText() {
+        return mText;
+    }
 
 
     public static Indice fromJSONObject(JSONObject root)
     {
-        String type=null;
-        try {
-            type = root.getString("type");
-        } catch (JSONException e) {
-        }
-        if(type.compareToIgnoreCase("text")==0) return new TextIndice(root);
-        else if(type.compareToIgnoreCase("geo")==0) return new GeoIndice(root);
-        else return null;
+        return new Indice(root);
     }
 
     public boolean isDiscovered() { return mIsDiscovered; }

+ 0 - 42
app/src/main/java/app/mar/game/LocatedResources.java

@@ -1,42 +0,0 @@
-package app.mar.game;
-
-import java.util.ArrayList;
-
-/**
- * Created by ptitcois on 21/10/16.
- */
-public class LocatedResources {
-    private Place mPlace = null;
-    private ArrayList<Resource> mResources = new ArrayList<Resource>();
-    public LocatedResources(ArrayList<Resource> r, Place p) { mPlace=p; mResources=r;}
-    public LocatedResources(ArrayList<Resource> r) {mResources=r;}
-    public LocatedResources(Place p) { mPlace=p;}
-    public LocatedResources() {}
-
-    public Place getPlace() {
-        return mPlace;
-    }
-
-    public void setPlace(Place mPlace) {
-        this.mPlace = mPlace;
-    }
-
-    public ArrayList<Resource> getResources() {
-        return mResources;
-    }
-
-    public Resource getResource(int i) {
-        return mResources.get(i);
-    }
-
-    public int count() {
-        return mResources.size();
-    }
-
-    public void setResource(ArrayList<Resource> mResource) {
-        this.mResources = mResource;
-    }
-    public void addResource(Resource mResource) {
-        this.mResources.add(mResource);
-    }
-}

+ 0 - 133
app/src/main/java/app/mar/game/Place.java

@@ -1,133 +0,0 @@
-package app.mar.game;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.io.Serializable;
-
-import app.mar.utils.geometry.GPSPoint;
-
-/**
- * Created by ptitcois on 19/08/16.
- */
-public class Place  implements Serializable {
-    public Place(JSONObject root)
-    {
-
-        try {
-            JSONArray arr = root.getJSONArray("coordinates");
-            mLocation = new GPSPoint(arr.getDouble(0), arr.getDouble(1));
-            mRadius = root.getDouble("radius");
-            mField = root.getDouble("field");
-            mAngle = root.getDouble("angle");
-            mUseAngle = root.getBoolean("useAngle");
-        } catch (JSONException e) {
-            e.printStackTrace();
-        }
-
-    }
-
-    protected GPSPoint  mLocation;
-    protected double    mRadius;
-    protected double    mField;
-    protected double    mAngle;
-    protected boolean   mUseAngle;
-    public GPSPoint getLocation() {
-        return mLocation;
-    }
-
-    public double getRadius() {
-        return mRadius;
-    }
-
-    public double getField() {
-        return mField;
-    }
-
-    public double getAngle() {
-        return mAngle;
-    }
-
-    public JSONObject getJson()
-    {
-        JSONObject js = new JSONObject();
-        JSONArray ja = new JSONArray();
-        try {
-            ja.put(mLocation.getY());
-            ja.put(mLocation.getY());
-            js.put("coordinates", ja);
-            js.put("radius", ""+mRadius);
-            js.put("field", ""+mField);
-            js.put("angle", ""+mAngle);
-            js.put("useAngle", ""+mUseAngle);
-        } catch (JSONException e) {
-            e.printStackTrace();
-        }
-        return js;
-    }
-
-    public boolean isPlayerOn(Player p)
-    {
-        GPSPoint pp = p.getPosition();
-        if(pp==null || p.getSensorsManager().getPosition()==null) return false;
-
-        return mLocation.getDistanceWith(pp)<=mRadius+p.getSensorsManager().getPosition().getAccuracy();
-    }
-
-
-    public boolean isOnDirection(Player p)
-    {
-        boolean ret;
-        //si utilisation de angle et field
-        if(mUseAngle)
-        {
-            float angle = p.getOrientation()%360;
-            while (angle < 0) angle += 360;
-            double min = mAngle - mField / 2;
-            double max = mAngle + mField / 2;
-
-
-            if (min < 0) {
-                min += 360;
-                ret = angle >= min || angle <= max;
-            } else if (max >= 360) {
-                max -= 360;
-                ret = angle <= max || (angle >= min);
-            } else {
-                ret = (angle <= max && angle >= min);
-            }
-        }
-        else
-        //si par rapport au coordonnées gps
-        {
-            float pangle=p.getOrientation()%360;
-            while (pangle < 0) pangle += 360;
-            float dir = (float)p.getPosition().getAngleWith(mLocation);
-            double min = dir - mField / 2;
-            double max = dir + mField / 2;
-            if (min < 0) {
-                min += 360;
-                ret = pangle >= min || pangle <= max;
-            } else if (max >= 360) {
-                max -= 360;
-                ret = pangle <= max || (pangle >= min);
-            } else {
-                ret = (pangle <= max && pangle >= min);
-            }
-        }
-        return ret;
-    }
-
-    public boolean isUseAngle()
-    {
-        return mUseAngle;
-    }
-
-    public double getDistance(Player p)
-    {
-        if(mLocation==null) return -1;
-        return mLocation.getDistanceWith(p.getPosition());
-    }
-
-}

+ 0 - 148
app/src/main/java/app/mar/game/Player.java

@@ -1,148 +0,0 @@
-package app.mar.game;
-
-import android.app.Activity;
-
-import java.io.Serializable;
-
-import app.mar.utils.SensorsManager;
-import app.mar.utils.geometry.GPSPoint;
-
-/**
- * Created by ptitcois on 20/08/16.
- */
-public class Player implements Serializable{
-    protected transient SensorsManager mSensors;
-
-    private static final int STATE_SEARCHING=0;
-    private static final int STATE_FOUND=1;
-    private int mState=STATE_FOUND;
-    private GPSPoint mFreezedPosition;
-
-    public Player(Activity sm)
-    {
-        mSensors=new SensorsManager(sm);
-    }
-
-    public void setSensorsManager(SensorsManager sm)
-    {
-        mSensors=sm;
-    }
-
-    public SensorsManager getSensorsManager()
-    {
-        return mSensors;
-    }
-
-    public void onPause()
-    {
-        mSensors.onPause();
-    }
-
-    public boolean hasMagneticField() {
-        return mSensors.hasMagneticField();
-    }
-
-    public boolean hasAcceleromter() {
-        return mSensors.hasAcceleromter();
-    }
-
-    public void onResume()
-    {
-        if(mSensors!=null)
-            mSensors.onResume();
-    }
-
-
-    public float getOrientation()
-    {
-        return mSensors.getOrientation();
-    }
-
-    public float getOrientationX()
-    {
-
-        return mSensors.getAzimuth();
-    }
-
-    public float getOrientationY()
-    {
-
-        return mSensors.getAngleY();
-    }
-
-
-    public float getOrientationZ()
-    {
-        return mSensors.getAngleZ();
-    }
-
-    public double getAngleWith(Place p)
-    {
-        double d=getPosition().getAngleWith(p.getLocation());;
-        while(d<0) d+=360;
-        return d;
-    }
-
-    public double getXWith(Place p)
-    {
-        return getPosition().getDistanceXWith(p.getLocation());
-    }
-
-    public double getYWith(Place p)
-    {
-        return getPosition().getDistanceYWith(p.getLocation());
-    }
-
-    public double getRelXWith(Place p)
-    {
-        return getPosition().getRelXWith(p.getLocation());
-    }
-
-    public double getRelYWith(Place p)
-    {
-        return getPosition().getRelYWith(p.getLocation());
-    }
-
-    public void newSensorManager(Activity act)
-    {
-        mSensors = new SensorsManager(act);
-    }
-
-    public void nextStub()
-    {
-        mSensors.nextStub();
-    }
-
-    public GPSPoint getPosition()
-    {
-        return mSensors.getPosition();
-        /*
-        if(mState==STATE_SEARCHING || mSensors.useGpsStub())
-            return mSensors.getPosition();
-        else
-            return mFreezedPosition;
-            */
-    }
-
-    public void freezePosition()
-    {
-        return ;
-        /*mState=STATE_FOUND;
-        mFreezedPosition=mSensors.getPosition().copy();*/
-    }
-
-    public void freezePosition(GPSPoint target)
-    {
-        return ;
-        /*if( mState==STATE_SEARCHING
-                || (mSensors.getPosition()!=null &&  mFreezedPosition!=null &&
-                mSensors.getPosition().getDistanceWith(target) < mFreezedPosition.getDistanceWith(target)))
-            mFreezedPosition=mSensors.getPosition().copy();
-        mState=STATE_FOUND;*/
-    }
-
-    public void releasePosition()
-    {
-        mState=STATE_SEARCHING;
-    }
-}

+ 15 - 92
app/src/main/java/app/mar/game/Resource.java

@@ -13,22 +13,17 @@ import org.json.JSONObject;
 import java.io.Serializable;
 import java.util.ArrayList;
 
+import app.mar.exceptions.BadConfigFileException;
+import app.mar.exceptions.BadResourceConfigException;
+import app.mar.exceptions.ResourceFileNotFoundException;
+import app.mar.exceptions.ResourceNotFoundException;
 import app.mar.utils.files.JSONAssetsManager;
-import min3d.core.Object3d;
-import min3d.parser.IParser;
-import min3d.parser.Parser;
-import min3d.vos.Number3d;
-
 /**
  * Created by ptitcois on 19/08/16.
  */
 public class Resource implements Serializable {
 
     protected String mName;
-    protected transient Object3d  m3DModel = null;
-    protected Number3d mPosition = new Number3d(0,0,0);
-    protected Number3d mRotation = new Number3d(0,0,0);
-    protected Number3d mScale = new Number3d(1,1,1);
     protected String mComment = "null";
     protected boolean isLoaded = false;
     protected boolean mIsDisplay = false;
@@ -91,15 +86,14 @@ public class Resource implements Serializable {
     {
         initResourceList(act);
         Game.logv( "--- Chargement de la ressource '"+mName+"' --- ");
-        JSONObject obj = JSONAssetsManager.load(act, mName+"_res");
-        if(obj==null) obj = JSONAssetsManager.load(act, mName+".res");
+        JSONObject obj = JSONAssetsManager.load(act, mName+".res");
         if(obj==null) obj = getRessourceDataFromList(mName);
         if(obj == null)
         {
             Game.loge("\tLa ressource '"+mName+"' est introuvable.");
             setNotFound(mName);
             Game.fail();
-            return;
+            throw new ResourceNotFoundException(mName);
         }
 
         //mandatory
@@ -109,6 +103,7 @@ public class Resource implements Serializable {
         {
             Game.loge("\tLa ressource '"+mName+"' n'a pas d'attribut 'type' valide (String)");
             e.printStackTrace();
+            throw new BadResourceConfigException("Bad parameter 'type' ");
         }
 
         try {
@@ -133,24 +128,6 @@ public class Resource implements Serializable {
             mFile=null;
         }
 
-
-        try {
-            mPosition.x = (float) obj.getJSONArray("position").getDouble(0);
-            mPosition.y = (float) obj.getJSONArray("position").getDouble(1);
-            mPosition.z = (float) obj.getJSONArray("position").getDouble(2);
-
-
-            mRotation.x = (float) obj.getJSONArray("rotation").getDouble(0);
-            mRotation.y = (float) obj.getJSONArray("rotation").getDouble(1);
-            mRotation.z = (float) obj.getJSONArray("rotation").getDouble(2);
-
-
-            mScale.x = (float) obj.getJSONArray("scale").getDouble(0);
-            mScale.y = (float) obj.getJSONArray("scale").getDouble(1);
-            mScale.z = (float) obj.getJSONArray("scale").getDouble(2);
-        }catch (JSONException e) {
-        }
-
         try {
             mIsDisplay=(boolean) obj.getBoolean("display");
         } catch (JSONException e) {
@@ -162,22 +139,6 @@ public class Resource implements Serializable {
         return mFile!=null;
     }
 
-    public void loadModel(Activity context)
-    {
-        get3DModel(context);
-    }
-
-    public Number3d getPosition() {
-        return mPosition;
-    }
-
-    public Number3d getRotation() {
-        return mRotation;
-    }
-
-    public Number3d getScale() {
-        return mScale;
-    }
 
     public Resource(String name, Activity act)
     {
@@ -220,67 +181,29 @@ public class Resource implements Serializable {
     }
 
 
-
-    public Object3d get3DModel(Activity context)
-    {
-        if(m3DModel==null)
-        {
-            IParser myParser = Parser.createParser(context, Parser.Type.OBJ,  mName+"_obj",true);
-            myParser.parse();
-
-            m3DModel = myParser.getParsedObject();
-            m3DModel.position().x = mPosition.x; m3DModel.position().y = mPosition.y; m3DModel.position().z = mPosition.z;
-            m3DModel.rotation().x = mRotation.x; m3DModel.rotation().y = mRotation.y; m3DModel.rotation().z = mRotation.z;
-            m3DModel.rotation().x+=45;
-            //m3DModel.rotation().y+=-180;
-
-            //m3DModel.rotation().y=90;
-            m3DModel.scale().x = mScale.x; m3DModel.scale().y = mScale.y; m3DModel.scale().z = mScale.z;
-        }
-        return m3DModel;
-
-    }
-
-
-
-    public void delete3DModel()
-    {
-        m3DModel = null;
-    }
-
-    public boolean is3DModelLoaded()
-    {
-        return m3DModel!=null;
-    }
-
-    public void scale3DModel(float factor)
-    {
-        if(m3DModel!=null)
-            m3DModel.scale().x = m3DModel.scale().y = m3DModel.scale().z = factor;
-    }
-
     public String toString()
     {
         return mTitle;
     }
 
+    public static final String IMAGE = "Image";
+    public static final String VIDEO = "Video";
+    public static final String AUDIO = "Audio";
+
+
     public boolean isAudio()
     {
-        return mType.toLowerCase().compareTo("audio")==0;
+        return mType.toLowerCase().compareTo(AUDIO.toLowerCase())==0;
     }
 
     public boolean isVideo()
     {
-        return mType.toLowerCase().compareTo("video")==0;
-    }
-    public boolean is3D()
-    {
-        return mType.toLowerCase().compareTo("3d")==0;
+        return mType.toLowerCase().compareTo(VIDEO.toLowerCase())==0;
     }
 
     public boolean isImage()
     {
-        return mType.toLowerCase().compareTo("image")==0;
+        return mType.toLowerCase().compareTo(IMAGE.toLowerCase())==0;
     }
 
     public boolean isDisplay() {

+ 0 - 9
app/src/main/java/app/mar/game/ResourceManager.java

@@ -59,14 +59,5 @@ public class ResourceManager implements Serializable{
         return s;
     }
 
-    /**
-     * Enleve le Modele 3D de la cache
-     */
-    public void deleteAll3DModel()
-    {
-        String[] keys = getResourceList();
-        for(int i=0; i<keys.length; i++)
-            mResources.get(keys[i]).delete3DModel();
-    }
 
 }

+ 13 - 6
app/src/main/java/app/mar/game/challenges/Challenge.java

@@ -13,9 +13,11 @@ import java.lang.reflect.InvocationTargetException;
 import java.util.ArrayList;
 
 import app.mar.activities.ChallengeDriver;
+import app.mar.exceptions.BadChallengeConfigException;
+import app.mar.exceptions.BadResourceTypeException;
 import app.mar.game.Event;
 import app.mar.game.Game;
-import app.mar.game.Resource;
+import app.mar.game.Indice;
 
 public abstract class Challenge implements Serializable{
 
@@ -44,19 +46,22 @@ public abstract class Challenge implements Serializable{
             mType = root.getString("type");
         } catch (JSONException e) {
             e.printStackTrace();
+            throw new BadChallengeConfigException("Bad parameter 'type' :  "+e.getMessage());
         }
 
         try {
             mName = root.getString("name");
         } catch (JSONException e) {
             e.printStackTrace();
+            throw new BadChallengeConfigException("Bad parameter 'name' : "+e.getMessage());
         }
 
         try {
             mResource = root.getString("resource");
             g.registerResource(mResource, act);
         } catch (JSONException e) {
-            mResource=null;
+            mResource="error";
+            throw new BadChallengeConfigException("Bad parameter 'resource' : "+e.getMessage());
         }
 
 
@@ -83,7 +88,6 @@ public abstract class Challenge implements Serializable{
             JSONArray arr = root.getJSONArray("event_end");
             for(int i=0; i<arr.length(); i++)
                 mEndEvent.add(new Event(arr.getJSONObject(i)));
-
         } catch (JSONException e) {
         }
 
@@ -97,7 +101,6 @@ public abstract class Challenge implements Serializable{
             for(int i=0; i<arr.length(); i++)
                 mIndices.add(Indice.fromJSONObject(arr.getJSONObject(i)));
         } catch (JSONException e) {
-            e.printStackTrace();
         }
 
         try {
@@ -111,7 +114,7 @@ public abstract class Challenge implements Serializable{
 
         try {
             mPenality = root.getInt("penality");
-        } catch(JSONException e){}
+        } catch(JSONException e){mPenality=0;}
 
     }
 
@@ -167,6 +170,7 @@ public abstract class Challenge implements Serializable{
     public static Challenge callChallengeConstructor(String classe, Game g,JSONObject o, Activity a)
     {
         Constructor constr = getChallengeConstructor(classe);
+        Log.e("--------", "callChallenge : '"+classe+"' ");
         try {
             return ((Challenge) constr.newInstance(g, o, a));
         } catch (InstantiationException e) {
@@ -174,7 +178,10 @@ public abstract class Challenge implements Serializable{
         } catch (IllegalAccessException e) {
             e.printStackTrace();
         } catch (InvocationTargetException e) {
-            e.printStackTrace();
+            e.getCause().printStackTrace();
+            if(e.getCause() instanceof  RuntimeException)
+                throw (RuntimeException)e.getCause();
+            throw  new RuntimeException("Erreur dans l'invocation du challenge : "+e.getCause().getMessage()+" ("+e.getCause().getClass().toString()+")");
         }
         return null;
     }

+ 0 - 11
app/src/main/java/app/mar/game/challenges/GeoIndice.java

@@ -1,11 +0,0 @@
-package app.mar.game.challenges;
-
-import org.json.JSONObject;
-
-public class GeoIndice extends Indice {
-
-    public GeoIndice(JSONObject root) {
-        super(root);
-    }
-
-}

+ 0 - 7
app/src/main/java/app/mar/game/challenges/IGeoTreasure.java

@@ -1,7 +0,0 @@
-package app.mar.game.challenges;
-
-import app.mar.game.Area;
-
-public interface IGeoTreasure {
-    public Area getArea();
-}

+ 3 - 1
app/src/main/java/app/mar/game/challenges/QCM.java

@@ -8,7 +8,8 @@ import org.json.JSONObject;
 
 import java.util.ArrayList;
 
-import app.mar.activities.QCMFragment;
+import app.mar.activities.fragments.QCMFragment;
+import app.mar.exceptions.BadChallengeConfigException;
 import app.mar.game.Game;
 
 public class QCM extends Question{
@@ -32,6 +33,7 @@ public class QCM extends Question{
         }catch(JSONException e)
         {
             e.printStackTrace();
+            throw new BadChallengeConfigException("Bad parameter 'choices'");
         }
     }
 

+ 10 - 4
app/src/main/java/app/mar/game/challenges/QRCodeTreasure.java

@@ -5,11 +5,11 @@ import android.app.Activity;
 import org.json.JSONException;
 import org.json.JSONObject;
 
-import app.mar.activities.QRCodeFragment;
+import app.mar.activities.fragments.QRCodeFragment;
+import app.mar.exceptions.BadChallengeConfigException;
 import app.mar.game.Game;
-import app.mar.game.Resource;
 
-public class QRCodeTreasure extends Treasure {
+public class QRCodeTreasure extends Challenge {
 
     protected String mQRValue;
     protected String mBadQRMessage;
@@ -25,10 +25,16 @@ public class QRCodeTreasure extends Treasure {
 
         try {
             mQRValue = root.getString("qr_value");
-            mBadQRMessage = root.getString("bad_message");
 
         } catch (JSONException e) {
             e.printStackTrace();
+            throw new BadChallengeConfigException("Bad parameter 'qr_value'");
+        }
+
+        try {
+            mBadQRMessage = root.getString("bad_message");
+        } catch (JSONException e) {
+            mBadQRMessage="";
         }
 
         try {

+ 6 - 3
app/src/main/java/app/mar/game/challenges/Question.java

@@ -8,7 +8,8 @@ import org.json.JSONObject;
 
 import java.util.ArrayList;
 
-import app.mar.activities.QuestionFragment;
+import app.mar.activities.fragments.QuestionFragment;
+import app.mar.exceptions.BadChallengeConfigException;
 import app.mar.game.Game;
 import app.mar.utils.Levenshtein;
 
@@ -32,6 +33,7 @@ public class Question extends Challenge {
             mQuestion = root.getString("question");
         } catch (JSONException e) {
             e.printStackTrace();
+            throw new BadChallengeConfigException("Bad parameter 'question' ('"+mName+"')");
         }
 
         try {
@@ -46,12 +48,13 @@ public class Question extends Challenge {
                     mAnswer.add(js.getString(i));
             }catch(JSONException ee) {
                 ee.printStackTrace();
+                throw new BadChallengeConfigException("Bad parameter 'answer'");
             }
         }
 
 
-        try {mGoodMessage = root.getString("good_message"); } catch (JSONException e) {}
-        try {mBadMessage = root.getString("bad_message"); } catch (JSONException e) {}
+        try {mGoodMessage = root.getString("good_message"); } catch (JSONException e) {mGoodMessage="";}
+        try {mBadMessage = root.getString("bad_message"); } catch (JSONException e) {mBadMessage="";}
     }
 
 

+ 0 - 21
app/src/main/java/app/mar/game/challenges/TextIndice.java

@@ -1,21 +0,0 @@
-package app.mar.game.challenges;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-public class TextIndice extends Indice {
-    protected String mText="";
-
-    public TextIndice(JSONObject root) {
-        super(root);
-
-        try {
-            mText = root.getString("text");
-        } catch (JSONException e) {
-        }
-    }
-
-    public String getText() {
-        return mText;
-    }
-}

+ 0 - 17
app/src/main/java/app/mar/game/challenges/Treasure.java

@@ -1,17 +0,0 @@
-package app.mar.game.challenges;
-
-import android.app.Activity;
-
-import org.json.JSONObject;
-
-import app.mar.game.Game;
-
-public abstract class Treasure extends Challenge {
-
-
-    public Treasure(Game g, JSONObject root, Class c, Activity a) {
-        super(g, root, c,a );
-
-    }
-
-}

+ 0 - 85
app/src/main/java/app/mar/ui/CameraPreview.java

@@ -1,85 +0,0 @@
-package app.mar.ui;
-
-/**
- * Created by ptitcois on 17/08/16.
- */
-
-import java.io.IOException;
-
-import android.content.Context;
-import android.hardware.Camera;
-import android.util.Log;
-import android.view.SurfaceHolder;
-import android.view.SurfaceView;
-
-public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback {
-
-    private Camera mCamera;
-    private SurfaceHolder mHolder;
-
-    public CameraPreview(Context context, Camera camera) {
-        super(context);
-        this.mCamera = camera;
-        this.mHolder = getHolder();
-        this.mHolder.addCallback(this);
-    }
-
-    @Override
-    public void surfaceCreated(SurfaceHolder holder) {
-        try {
-            this.mCamera.setPreviewDisplay(holder);
-            this.mCamera.startPreview();
-
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-    }
-
-
-
-
-
-    @Override
-    public void surfaceDestroyed(SurfaceHolder holder) {
-        this.getHolder().removeCallback(this);
-        this.mCamera.stopPreview();
-        this.mCamera.release();
-    }
-
-    public void surfaceChanged(SurfaceHolder holder, int format, int width, int height)
-    {
-        if (mHolder.getSurface() == null) {
-            // preview surface does not exist
-            return;
-        }
-
-
-        // stop preview before making changes
-        try {
-            mCamera.stopPreview();
-        } catch (Exception e) {
-            // ignore: tried to stop a non-existent preview
-        }
-
-        // make any resize, rotate or reformatting changes here
-        if (this.getResources().getConfiguration().orientation != getResources().getConfiguration().ORIENTATION_LANDSCAPE) {
-
-            mCamera.setDisplayOrientation(90);
-
-        } else {
-
-            mCamera.setDisplayOrientation(0);
-
-        }
-        // start preview with new settings
-        try {
-            mCamera.setPreviewDisplay(mHolder);
-            mCamera.startPreview();
-
-        } catch (Exception e) {
-            Log.d("TAG", "Error starting camera preview: " + e.getMessage());
-        }
-
-    }
-}
-

+ 0 - 103
app/src/main/java/app/mar/ui/CustomToggleButton.java

@@ -1,103 +0,0 @@
-package app.mar.ui;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.view.View;
-import android.widget.Button;
-
-import app.mar.activities.R;
-
-/**
- * Created by ptitcois on 31/10/16.
- */
-public class CustomToggleButton extends Button implements View.OnClickListener {
-
-    protected boolean mState=false;
-    protected OnToggleListener mListener = null;
-
-
-    public CustomToggleButton(Context context, boolean state) {
-        super(context);
-        mState=state;
-        init();
-    }
-
-    public CustomToggleButton(Context context) {
-        super(context);
-        init();
-    }
-
-    public CustomToggleButton(Context context, boolean state, OnToggleListener l) {
-        super(context);
-        mState=state;
-        mListener=l;
-        init();
-
-    }
-
-    public CustomToggleButton(Context context, AttributeSet attrs) {
-        super(context, attrs);
-        init();
-    }
-
-    public CustomToggleButton(Context context, AttributeSet attrs, int defStyleAttr) {
-        super(context, attrs, defStyleAttr);
-        init();
-    }
-
-    protected void init()
-    {
-        super.setOnClickListener(this);
-        setHeight(50);
-        update();
-    }
-
-    protected void update()
-    {
-        if(mState) onOn();
-        else onOff();
-    }
-
-    protected void onOn()
-    {
-        setText("On");
-        setTextColor(getResources().getColor(R.color.dull_4));
-        setBackgroundResource(R.drawable.togglebutton_on);
-        setHeight(50);
-        if(mListener!=null) mListener.onOn(this);
-    }
-
-    protected void onOff()
-    {
-        setText("Off");
-        setTextColor(getResources().getColor(R.color.dull_4));
-        setBackgroundResource(R.drawable.togglebutton_off);
-        setHeight(50);
-
-        if(mListener!=null) mListener.onOff(this);
-    }
-
-    public boolean getState()
-    {
-        return mState;
-    }
-
-    public void setState(boolean s)
-    {
-        mState=s;
-        update();
-    }
-
-
-    public void setOnClickListener(OnToggleListener l)
-    {
-        mListener=l;
-    }
-
-    @Override
-    public void onClick(View view) {
-        mState=!mState;
-        update();
-        if(mListener!=null) mListener.onToggle(this);
-    }
-}

+ 6 - 2
app/src/main/java/app/mar/ui/MediaView.java

@@ -9,8 +9,10 @@ import android.view.SurfaceHolder;
 import android.view.SurfaceView;
 import android.view.View;
 
+import java.io.FileNotFoundException;
 import java.io.IOException;
 
+import app.mar.exceptions.ResourceFileNotFoundException;
 import app.mar.utils.files.FileManager;
 
 /**
@@ -62,17 +64,18 @@ public class MediaView extends SurfaceView implements View.OnClickListener,Surfa
 
     }
 
-    public void play(String path)
+    public boolean play(String path)
     {
         final MediaView x=this;
         AssetFileDescriptor afd;
         mPlayer = new MediaPlayer();
         afd = FileManager.getAfdMedia(mContext, path);
-        Log.e("------", "Playing '"+path+"'");
+       if(afd==null) return false;
         try {
             mPlayer.setDataSource(afd.getFileDescriptor(),afd.getStartOffset(), afd.getLength());
         } catch (IOException e) {
             e.printStackTrace();
+
         }
         mPlayer.prepareAsync();
         mPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@@ -85,6 +88,7 @@ public class MediaView extends SurfaceView implements View.OnClickListener,Surfa
                     mOnStart.onStart(x);
             }
         });
+        return true;
 
     }
     @Override

+ 0 - 12
app/src/main/java/app/mar/ui/OnToggleListener.java

@@ -1,12 +0,0 @@
-package app.mar.ui;
-
-import android.view.View;
-
-/**
- * Created by ptitcois on 31/10/16.
- */
-public interface OnToggleListener {
-    public void onToggle(View v);
-    public void onOn(View v);
-    public void onOff(View v);
-}

+ 0 - 43
app/src/main/java/app/mar/ui/RotateButton.java

@@ -1,43 +0,0 @@
-package app.mar.ui;
-
-import android.content.Context;
-import android.graphics.Canvas;
-import android.util.AttributeSet;
-import android.widget.Button;
-
-/**
- * Created by ptitcois on 23/10/16.
- */
-public class RotateButton extends Button {
-    private float mAngle = 45;
-    public RotateButton(Context context) {
-        super(context);
-
-    }
-
-
-    public RotateButton(Context context, float angle) {
-        super(context);
-        mAngle=angle;
-    }
-
-    public RotateButton(Context context, AttributeSet attrs) {
-        super(context, attrs);
-    }
-
-    @Override
-    protected void onDraw(Canvas canvas) {
-        canvas.save();
-        canvas.rotate(mAngle, getWidth() / 2, getHeight() / 2);
-        super.onDraw(canvas);
-        canvas.restore();
-    }
-
-    public float getAngle() {
-        return mAngle;
-    }
-
-    public void setAngle(float mAngle) {
-        this.mAngle = mAngle;
-    }
-}

+ 0 - 77
app/src/main/java/app/mar/ui/SelectButton.java

@@ -1,77 +0,0 @@
-package app.mar.ui;
-
-import android.content.Context;
-import android.view.View;
-import android.widget.Button;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import app.mar.activities.R;
-
-/**
- * Created by ptitcois on 31/10/16.
- */
-public class SelectButton extends LinearLayout implements View.OnClickListener {
-    protected String[] mData;
-    protected Button mLeft;
-    protected Button mRight;
-    protected TextView mText;
-    protected int mState = 0;
-    protected int mHeight=70;
-    protected void setLParams(View v, int w, int h)
-    {
-        LayoutParams l =new LayoutParams(w,h);
-        l.setMargins(0,0,0,0);
-        v.setLayoutParams(l);
-    }
-
-    public SelectButton(Context context, String[] m) {
-        super(context);
-        setOrientation(HORIZONTAL);
-        mData=m;
-        mLeft = new Button(context);
-        mLeft.setBackgroundResource(R.drawable.arrow_left);
-        mLeft.setOnClickListener(this);
-
-        mRight = new Button(context);
-        mRight.setBackgroundResource(R.drawable.arrow_right);
-        mRight.setOnClickListener(this);
-
-        mText = new TextView(context);
-        if(mData.length>0)
-            mText.setText(mData[mState]);
-
-
-        addView(mLeft);
-        addView(mText);
-        addView(mRight);
-        setLParams(mLeft, mHeight, mHeight);
-        setLParams(mRight, mHeight, mHeight);
-        setLParams(mText, 200 , mHeight);
-        mText.setTextColor(getResources().getColor(R.color.dull_4));
-
-    }
-
-    public void setState(int i)
-    {
-        if(mData.length>i)
-            mText.setText(mData[mState=i]);
-    }
-
-    public int getState()
-    {
-        return mState;
-    }
-
-    @Override
-    public void onClick(View view) {
-        if(view==mLeft)
-        {
-            mState=(mState-1<0) ? (mData.length-1) : (mState-1);
-        }else if(view==mRight)
-        {
-            mState=(mState==mData.length-1) ? 0 : (mState+1);
-        }
-        mText.setText(mData[mState]);
-    }
-}

+ 4 - 18
app/src/main/java/app/mar/utils/AndroidResources.java

@@ -1,31 +1,21 @@
 package app.mar.utils;
 
-import android.app.Activity;
 import android.content.Context;
 import android.content.Intent;
 import android.graphics.drawable.Drawable;
 import android.net.Uri;
 
-import app.mar.activities.ImageViewerActivity;
-import app.mar.activities.MediaViewerAcitvity;
-import app.mar.activities.ModelViewerActivity;
-import app.mar.activities.TestVideoActivity;
+import app.mar.activities.viewers.ImageViewerActivity;
+import app.mar.activities.viewers.MediaViewerAcitvity;
+import app.mar.activities.viewers.TestVideoActivity;
 import app.mar.game.Game;
 import app.mar.game.Resource;
-import min3d.core.Object3d;
-import min3d.parser.IParser;
-import min3d.parser.Parser;
 
 /**
  * Created by ptitcois on 14/03/17.
  */
 public class AndroidResources {
-    public static Object3d getModel(Activity context, String name)
-    {
-        IParser myParser = Parser.createParser(context, Parser.Type.OBJ, context.getResources(), "app.brest.testmin3d:raw/"+name+"_obj",true);
-        myParser.parse();
-        return myParser.getParsedObject();
-    }
+
 
     private static Uri _getAudioVideo(String name, String suffix)
     {
@@ -55,8 +45,6 @@ public class AndroidResources {
             return MediaViewerAcitvity.REQUEST_CODE;
         else if( re.isVideo())
             return TestVideoActivity.REQUEST_CODE;
-        else if(re.is3D())
-            return ModelViewerActivity.REQUEST_CODE;
         else
             return ImageViewerActivity.REQUEST_CODE;
     }
@@ -67,8 +55,6 @@ public class AndroidResources {
             intent = new Intent(c, MediaViewerAcitvity.class);
         else if( re.isVideo())
             intent = new Intent(c, TestVideoActivity.class);
-        else if(re.is3D())
-            intent= new Intent(c, ModelViewerActivity.class);
         else if(re.isImage())
             intent= new Intent(c, ImageViewerActivity.class);
 

+ 0 - 76
app/src/main/java/app/mar/utils/GpsStub.java

@@ -1,76 +0,0 @@
-package app.mar.utils;
-
-import android.util.Log;
-
-import java.util.ArrayList;
-
-import app.mar.utils.geometry.GPSPoint;
-
-/**
- * Created by ptitcois on 24/10/16.
- */
-public class GpsStub {
-    protected ArrayList<GPSPoint> mStubs = new ArrayList<GPSPoint>();
-    protected boolean mIsActive;
-    protected int mI = 0;
-
-    public GpsStub(boolean act)
-    {
-        mIsActive=act;
-    }
-
-    public GpsStub(String r)
-    {
-        mIsActive=true;
-        add(r);
-    }
-
-
-    public void add(GPSPoint p)
-    {
-        mStubs.add(p);
-    }
-
-    public void add(String p)
-    {
-        String r[] = p.split(";");
-        for(int i=0; i<r.length; i++)
-            addLine(r[i]);
-    }
-
-    private void addLine(String str)
-    {
-        GPSPoint p =  null;
-        double lon=0, lat=0, acc=0;
-        String res[] = str.split("\\s+");
-        try {
-            if (res.length > 0) lon = (double) Double.parseDouble(res[0]);
-            if (res.length > 1) lat = (double) Double.parseDouble(res[1]);
-        }catch (Exception e)
-        {
-        }
-
-        try {
-            if (res.length > 2) acc = (double) Double.parseDouble(res[2]);
-        }catch (Exception e)
-        {
-        }
-
-        add(new GPSPoint(lon, lat,(float) acc));
-    }
-
-    public GPSPoint next()
-    {
-        if(mStubs.size()>0)
-        {
-            GPSPoint p = mStubs.get(mI);
-            mI++;
-            if(mI==mStubs.size())
-                mI=0;
-            return p;
-        }
-        else return null;
-    }
-
-
-}

+ 0 - 227
app/src/main/java/app/mar/utils/SensorsManager.java

@@ -1,227 +0,0 @@
-package app.mar.utils;
-
-import android.Manifest;
-import android.app.Activity;
-import android.content.Intent;
-import android.content.pm.PackageManager;
-import android.hardware.Sensor;
-import android.hardware.SensorEvent;
-import android.hardware.SensorEventListener;
-import android.hardware.SensorManager;
-import android.location.Location;
-import android.location.LocationListener;
-import android.location.LocationManager;
-import android.os.Bundle;
-import android.provider.Settings;
-import android.support.v4.app.ActivityCompat;
-import android.widget.Toast;
-
-import app.mar.activities.ARActivity;
-import app.mar.activities.R;
-import app.mar.utils.geometry.GPSPoint;
-
-/**
- * Created by ptitcois on 18/08/16.
- */
-public class SensorsManager implements SensorEventListener, LocationListener {
-
-    //public final boolean USE_GPS_STUB=true;
-    private SensorManager mSensorManager;
-    private Sensor mAccelerometer;
-    private Sensor mMagnetometer;
-    private float[] mLastAccelerometer = new float[3];
-    private float[] mLastMagnetometer = new float[3];
-    private boolean mLastAccelerometerSet = false;
-    private boolean mLastMagnetometerSet = false;
-    private float[] mR = new float[9];
-    private float[] mOrientation = new float[3];
-    private float mCurrentDegreeX = 0f;
-    private float mCurrentDegreeY = 0f;
-    private float mCurrentDegreeZ = 0f;
-    private SlideBuffer mBufferX;
-    private SlideBuffer mBufferY;
-    private SlideBuffer mBufferZ;
-    private LocationManager mLocationManager;
-    private double mLatitude;
-    private double mLongitude;
-    private float mAccuracy;
-    private boolean mIsLocalised = false;
-    private Activity mParent;
-    private GpsStub mStub=null;
-    private boolean mHasAcceleromter = true;
-    private boolean mHasMagneticField = true;
-
-    public float getAzimuth() {
-        return mBufferX.average();
-    }
-
-
-    public float getAzimuthStep() {
-        return ((int)mBufferX.average()/10)*10;
-    }
-
-    public float getAngleY() {
-        return mBufferY.average();
-    }
-
-    public float getAngleZ() {
-        return mBufferZ.average();
-    }
-
-    public float getOrientation() {
-        return getAzimuth();
-    }
-
-    public boolean useGpsStub()
-    {
-        return app.mar.utils.Settings.getSettings().isGPSDebug();
-    }
-
-    public GPSPoint getPosition()
-    {
-        if(!mIsLocalised) return null;
-        return new GPSPoint(mLongitude, mLatitude, mAccuracy);
-    }
-
-    public boolean hasMagneticField() {
-        return mHasMagneticField;
-    }
-
-    public boolean hasAcceleromter() {
-        return mHasAcceleromter;
-    }
-
-    public SensorsManager(Activity parent ){
-        mParent = parent;
-        mLocationManager = (LocationManager) parent.getSystemService(parent.LOCATION_SERVICE);
-
-        mSensorManager = (SensorManager) parent.getSystemService(parent.SENSOR_SERVICE);
-        mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
-        mMagnetometer = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
-
-        mHasMagneticField = mMagnetometer!=null;
-        mHasAcceleromter = mAccelerometer!=null;
-
-        mBufferX = new SlideBuffer(app.mar.utils.Settings.getSettings().getSensorLatency());
-        mBufferY = new SlideBuffer(app.mar.utils.Settings.getSettings().getSensorLatency());
-        mBufferZ = new SlideBuffer(app.mar.utils.Settings.getSettings().getSensorLatency());
-
-        //debug du GPS "GPS Préprogrammé"
-        if(useGpsStub()) {
-            mIsLocalised=true;
-            mStub=new GpsStub(parent.getResources().getString(R.string.gps_stub));
-            nextStub();
-        }
-    }
-
-    public void onResume() {
-        restartSensors();
-    }
-
-
-    public void restartSensors()
-    {
-        boolean a = mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME);
-        boolean b = mSensorManager.registerListener(this, mMagnetometer, SensorManager.SENSOR_DELAY_GAME);
-
-        if (ActivityCompat.checkSelfPermission(mParent, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
-                ActivityCompat.checkSelfPermission(mParent, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
-
-        }
-
-        if (!mLocationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
-            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
-            mParent.startActivity(intent);
-        }
-
-        mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 400, 1, this);
-        mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 400, 1, this);
-    }
-
-    public void onPause() {
-        stopSensors();
-    }
-
-    public void stopSensors()
-    {
-        mSensorManager.unregisterListener(this, mAccelerometer);
-        mSensorManager.unregisterListener(this, mMagnetometer);
-        if (ActivityCompat.checkSelfPermission(mParent, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
-                && ActivityCompat.checkSelfPermission(mParent, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
-            return;
-        }
-        mLocationManager.removeUpdates(this);
-    }
-
-    public void onSensorChanged(SensorEvent event) {
-        if (event.sensor == mAccelerometer && event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
-            String str="";
-            System.arraycopy(event.values, 0, mLastAccelerometer, 0, event.values.length);
-            mLastAccelerometerSet = true;
-        } else if (event.sensor == mMagnetometer) {
-            System.arraycopy(event.values, 0, mLastMagnetometer, 0, event.values.length);
-            mLastMagnetometerSet = true;
-        }
-        if (mLastAccelerometerSet && mLastMagnetometerSet) {
-            SensorManager.getRotationMatrix(mR, null, mLastAccelerometer, mLastMagnetometer);
-            SensorManager.getOrientation(mR, mOrientation);
-            float azimuthInRadians = mOrientation[0];
-            float azimuthInDegress = (float)(Math.toDegrees(azimuthInRadians)+360)%360;
-
-            mCurrentDegreeX = -azimuthInDegress;
-            while(mCurrentDegreeX<0) mCurrentDegreeX+=360;
-            mBufferX.enqueue(mCurrentDegreeX);
-
-            mBufferY.enqueue((float)(Math.toDegrees(mOrientation[1])+360)%360);
-            mBufferZ.enqueue((float)(Math.toDegrees(mOrientation[2])+360)%360);
-        }
-    }
-
-    /*
-     *
-     * GPS
-     *
-     */
-
-
-    @Override
-    public void onAccuracyChanged(Sensor sensor, int i) {}
-
-
-    @Override
-    public void onLocationChanged(Location location) {
-        mIsLocalised=true;
-        if(!useGpsStub()) {
-            mLongitude = location.getLongitude();
-            mLatitude = location.getLatitude();
-            mAccuracy = location.getAccuracy();
-        }
-
-        ARActivity.setLocation(new GPSPoint(mLatitude, mLongitude, mAccuracy));
-        //Toast.makeText(mParent,  "Longitude: "+location.getLongitude()+ " Latitude: "+location.getLatitude(), Toast.LENGTH_LONG).show();
-    }
-
-
-
-    @Override
-    public void onStatusChanged(String s, int i, Bundle bundle) {}
-
-    @Override
-    public void onProviderEnabled(String s) {}
-
-    @Override
-    public void onProviderDisabled(String s) {}
-
-    public void nextStub()
-    {
-        if(useGpsStub())
-        {
-            GPSPoint stub = mStub.next();
-            if(stub==null) return;
-            mLongitude=stub.getX();
-            mLatitude=stub.getY();
-            mAccuracy=stub.getAccuracy();
-            ARActivity.setLocation(new GPSPoint(mLatitude, mLongitude, mAccuracy));
-        }
-    }
-}

+ 0 - 86
app/src/main/java/app/mar/utils/Settings.java

@@ -1,86 +0,0 @@
-package app.mar.utils;
-
-import java.io.Serializable;
-
-/**
- * Created by ptitcois on 22/08/16.
- */
-public class Settings implements Serializable{
-
-    transient static Settings mSettings = new Settings();
-
-    transient public static final String[] SENSORS_LATENCIES = {"Très rapide", "Rapide", "Normale", "Longue", "Très longue"};
-    protected boolean mAccelerometerDebug = false;
-    protected boolean mGPSDebug = false;
-    protected boolean mAreaDebug = false;
-    protected boolean mResourceDebug = false;
-    protected boolean mDevelopperMode = false;
-    protected int     mSensorLatency = 2; // 0 -> 4
-    protected boolean mARMode = true;
-
-    public Settings()
-    {
-
-    }
-
-    public boolean isAccelerometerDebug() {
-        return mAccelerometerDebug;
-    }
-
-    public void setAccelerometerDebug(boolean mAccelerometerDebug) {
-        this.mAccelerometerDebug = mAccelerometerDebug;
-    }
-
-    public boolean isGPSDebug() {
-        return mDevelopperMode && mGPSDebug;
-    }
-
-    public void setGPSDebug(boolean mGPSDebug) {
-        this.mGPSDebug = mGPSDebug;
-    }
-
-    public boolean isAreaDebug() {
-        return mDevelopperMode && mAreaDebug;
-    }
-
-    public void setAreaDebug(boolean mAreaDebug) {
-        this.mAreaDebug = mAreaDebug;
-    }
-
-    public boolean isResourceDebug() {
-        return mDevelopperMode && mResourceDebug;
-    }
-
-    public void setResourceDebug(boolean mResourceDebug) {
-        this.mResourceDebug = mResourceDebug;
-    }
-
-    public boolean isDevelopperMode() {
-        return mDevelopperMode;
-    }
-
-    public void setDevelopperMode(boolean mDevelopperMode) {
-        this.mDevelopperMode = mDevelopperMode;
-    }
-
-    public int getSensorLatency() {
-        return mSensorLatency;
-    }
-
-    public void setSensorLatency(int mSensorLatency) {
-        this.mSensorLatency = mSensorLatency;
-    }
-
-    public boolean isARMode() {
-        return mARMode;
-    }
-
-    public void setARMode(boolean mARMode) {
-        this.mARMode = mARMode;
-    }
-
-    public static Settings getSettings() { return mSettings; }
-    public static void setSettings(Settings s){mSettings=s;}
-
-
-}

+ 0 - 154
app/src/main/java/app/mar/utils/SlideBuffer.java

@@ -1,154 +0,0 @@
-package app.mar.utils;
-
-/*
-public class SlideBuffer {
-    private float mData;
-    private int mSize;
-    private int mHead;
-
-    public SlideBuffer(int size)
-    {
-        mData = 0;
-        mSize = 0;
-        mHead =0;
-    }
-
-    public void enqueue(float val)
-    {
-        mData= mData + 0.5f*(val-mData);
-    }
-
-    public float average()
-    {
-        return mData;
-    }
-
-}*/
-
-public class SlideBuffer {
-    private float mDataSin;
-    private float mDataCos;
-    private float mCoef = 0.1f;
-    private final static float[] SENSORS_COEFS = {0.4f, 0.2f, 0.1f, 0.05f, 0.025f};
-    private int mSize;
-    private int mHead;
-
-    public SlideBuffer(int latency_level)
-    {
-        mCoef=SENSORS_COEFS[latency_level];
-        mDataSin = 0;
-        mDataCos = 0;
-        mSize = 0;
-        mHead =0;
-    }
-
-    public void setLatencyLevel(int x)
-    {
-        mCoef=SENSORS_COEFS[x];
-    }
-
-    public void enqueue(float _val)
-    {
-        float val = -_val-90;
-        mDataSin= mDataSin + mCoef*((float)Math.sin(val*Math.PI/180)-mDataSin);
-        mDataCos= mDataCos + mCoef*((float)Math.cos(val*Math.PI/180)-mDataCos);
-    }
-
-    public float average()
-    {
-        return (float)( (((Math.atan2(mDataCos, mDataSin))*180/Math.PI)+180f) % 360);
-    }
-
-}
-
-/*
-public class SlideBuffer {
-    private float mDataCos[] ;
-    private float mDataSin[];
-    private int mSize;
-    private int mI=0;
-    private int mHead;
-
-    public SlideBuffer(int size)
-    {
-        mSize = size;
-        mHead =0;
-        mDataCos = new float[size];
-        mDataSin = new float[size];
-    }
-
-    public void enqueue(float val)
-    {
-        //mData= mData + 0.5f*(val-mData);
-        mDataCos[mI]=(float)Math.cos(val);
-        mDataSin[mI]=(float)Math.sin(val);
-        mI=(mI+1)%mSize;
-
-    }
-
-    public float average()
-    {
-        float avSin=0, avCos=0;
-        for(int i=0; i<mSize; i++)
-        {
-            avSin+=mDataSin[i];
-            avCos+=mDataCos[i];
-        }
-        avSin/=mSize;
-        avCos/=mSize;
-        return (float)((Math.PI+Math.atan2(avCos, avSin))*180/Math.PI);
-    }
-
-}
-*/
-
-
-/*
-package app.brest.utils;
-
-import java.util.ArrayList;
-
-public class SlideBuffer {
-    private float[] mData;
-    private float[] mTmp;
-    private int mSize;
-    private int mHead;
-
-    public SlideBuffer(int size)
-    {
-        mData = new float[size];
-        mTmp = new float[size];
-        mSize = 0;
-        mHead =0;
-    }
-
-    public void enqueue(float val)
-    {
-
-        mData[mHead] = val;
-        mHead=(mHead+1)%mData.length;
-        if(mSize<mData.length) mSize++;
-    }
-
-    private float[] exponentialSmoothing( float[] input, float[] output_mkv, float alpha ) {
-        if ( output_mkv == null )
-            return input;
-        for ( int i=0; i<input.length; i++ ) {
-            output_mkv[i] = output_mkv[i] + alpha * (input[i] - output_mkv[i]);
-        }
-        return output_mkv;
-    }
-
-    public float average()
-    {
-
-            float acc=0;
-            for(int i=0; i<mSize; i++)
-                acc+=mData[i];
-            return acc/mSize;
-    }
-
-
-
-}
-*/

+ 7 - 6
app/src/main/java/app/mar/utils/files/FileManager.java

@@ -36,7 +36,6 @@ public class FileManager {
         try {
             is = a.getAssets().open(path);
         } catch (IOException e) {
-            e.printStackTrace();
         }
         return is;
     }
@@ -64,10 +63,12 @@ public class FileManager {
         for(int i=0; i<IMG_EXT.length; i++)
         {
             InputStream is = openFile(a, path+IMG_EXT[i]);
-            if(is!=null)
+            if(is!=null) {
+                Log.e("------", "Image found at '"+(path+IMG_EXT[i])+"'");
                 return is;
+            }
         }
-        return null;
+        throw  new RuntimeException("Image '"+path+"' non trouvé (en cherchant les extensions");
     }
 
     public static Bitmap openImage(Context a,String path) throws Exception {
@@ -76,10 +77,11 @@ public class FileManager {
         Bitmap bitmap = null;
         try {
             is = testIimage(a, path);
-            bitmap = BitmapFactory.decodeStream(is);
         } catch (IOException e) {
-            e.printStackTrace();
         }
+
+        bitmap = BitmapFactory.decodeStream(is);
+
         return bitmap;
     }
 
@@ -99,7 +101,6 @@ public class FileManager {
                 if(is!=null)
                     return is;
             } catch (IOException e) {
-                //e.printStackTrace();
             }
         }
         return null;

+ 3 - 1
app/src/main/java/app/mar/utils/files/JSONAssetsManager.java

@@ -13,6 +13,7 @@ import java.io.InputStream;
  * Created by ptitcois on 27/03/17.
  */
 public class JSONAssetsManager {
+
     public static JSONObject load(Activity context, String name)
     {
         InputStream inputStream = null;
@@ -23,6 +24,7 @@ public class JSONAssetsManager {
         }
         ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
 
+
         int ctr;
         try {
             ctr = inputStream.read();
@@ -32,7 +34,7 @@ public class JSONAssetsManager {
             }
             inputStream.close();
         } catch (Exception e) {
-            e.printStackTrace();
+            return null;
         }
         Log.v("Text Data", byteArrayOutputStream.toString());
         try {

+ 0 - 136
app/src/main/java/app/mar/utils/geometry/GPSPoint.java

@@ -1,136 +0,0 @@
-package app.mar.utils.geometry;
-
-import java.io.Serializable;
-
-import app.mar.utils.L;
-
-/**
- * Created by ptitcois on 16/08/16.
- */
-public class GPSPoint extends app.mar.utils.geometry.Point  implements Serializable {
-    protected float mAccuracy;
-
-
-
-    public GPSPoint()
-    {
-        mX=mY=0.0;
-    }
-
-    public GPSPoint(Point b)
-    {
-        mX=b.mX;
-        mY=b.mY;
-    }
-
-    public GPSPoint(double x, double y)
-    {
-        mX=x;
-        mY=y;
-    }
-
-    public GPSPoint(double x, double y, float acc)
-    {
-        mX=x;
-        mY=y;
-        mAccuracy=acc;
-    }
-
-    public GPSPoint copy()
-    {
-        return new GPSPoint(mX, mY, mAccuracy);
-    }
-
-    public float getAccuracy()
-    {
-        return mAccuracy;
-    }
-
-    public void setAccuracy(float acc)
-    {
-        mAccuracy=acc;
-    }
-
-    public double getDistanceWith(Point b)
-    {
-        if(b==null) return -1;
-		double theta = mY - b.mY;
-		double dist = Math.sin(deg2rad(mX)) * Math.sin(deg2rad(b.mX)) + Math.cos(deg2rad(mX)) * Math.cos(deg2rad(b.mX)) * Math.cos(deg2rad(theta));
-		dist = Math.acos(dist);
-		dist = rad2deg(dist);
-		dist = dist * 60 * 1.1515;
-		dist = dist * 1.609344 *1000;
-
-		return (dist);
-	}
-    
-    private static double rad2deg(double rad) {
-		return (rad * 180 / Math.PI);
-	}
-    
-    private static double deg2rad(double deg) {
-		return (deg * Math.PI / 180.0);
-	}
-
-    public double getDistanceXWith(GPSPoint _b)
-    {
-        Point b = new GPSPoint(_b);
-        b.mY=mY;
-
-        return getDistanceWith(b);
-    }
-
-    public double getRelXWith(GPSPoint _b)
-    {
-        return _b.mX-mX;
-    }
-
-
-    public double getDistanceYWith(GPSPoint _b)
-    {
-        Point b = new GPSPoint(_b);
-        b.mX=mX;
-
-        return getDistanceWith(b);
-    }
-
-
-
-
-    public double getRelYWith(GPSPoint _b)
-    {
-
-        return _b.mY-mY;
-    }
-
-    public double getAngleWith(GPSPoint p)
-    {
-        double dx = getRelXWith(p);
-        double dy = getRelYWith(p);
-        if(dy>0) return -Math.atan(dx/dy)*180/Math.PI;
-        else return 180-Math.atan(dx/dy)*180/Math.PI;
-    }
-
-    public String toString()
-    {
-        return "("+mX+", "+mY+" : "+mAccuracy+")";
-
-    }
-    /*
-            Opposé
-        _________________
-         \               |
-           \             |
-             \           |
-               \         |  Adjacent
-                 \       |
-                   \     |
-                     \ /\|
-                       \ |
-                         \Alpha=Atan(oppose/adjacent)=atan(x/y)
-
-
-
-
-     */
-}

+ 0 - 98
app/src/main/java/app/mar/utils/geometry/Point.java

@@ -1,98 +0,0 @@
-package app.mar.utils.geometry;
-
-import java.io.Serializable;
-
-/**
- * Created by ptitcois on 16/08/16.
- */
-
-
-public class Point  implements Serializable {
-    protected  double mX;
-    protected  double mY;
-
-    public Point()
-    {
-        mX=mY=0.0;
-    }
-
-    public Point(Point b)
-    {
-        mX=b.mX;
-        mY=b.mY;
-    }
-
-    public Point(double x, double y)
-    {
-        mX=x;
-        mY=y;
-    }
-
-
-    void setX(double x)
-    {
-        mX=x;
-    }
-
-    void setY(double y)
-    {
-        mY=y;
-    }
-
-    void set(double x, double y)
-    {
-        mX=x;
-        mY=y;
-    }
-
-    public double getDistanceWith(Point b)
-    {
-        double dx = b.mX - mX;
-        double dy = b.mY - mY;
-
-        if(dx<0) dx=-dx;
-        if(dy<0) dy=-dy;
-
-        return Math.sqrt(dx*dx + dy*dy);
-    }
-
-    public String toString()
-    {
-    	return "("+mX+", "+mY+")";
-    }
-    
-    public double getAngleRadWith(Point b)
-    {
-        double dx = b.mX - mX;
-        double dy = b.mY - mY;
-
-        return Math.atan(dx/dy);
-    }
-
-    public double getAngleDegWith(Point b)
-    {
-        return getAngleRadWith(b) *180/Math.PI;
-    }
-
-
-    public double getX(){return mX;}
-    public double getY(){return mY;}
-
-    public double getDistanceXWith(Point _b)
-    {
-        Point b = new Point(_b);
-        b.mY=mY;
-
-        return getDistanceWith(b);
-    }
-
-
-    public double getDistanceYWith(Point _b)
-    {
-        Point b = new Point(_b);
-        b.mX=mX;
-
-        return getDistanceWith(b);
-    }
-
-}

+ 0 - 118
app/src/main/java/app/mar/utils/geometry/Shape.java

@@ -1,118 +0,0 @@
-package app.mar.utils.geometry;
-/**
- * Created by François Gautrais on 16/08/16.
- * Support also GPS Shape (By using GPSPoint)
- */
-
-import org.json.JSONArray;
-import org.json.JSONException;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-
-public class Shape  implements Serializable {
-    protected ArrayList<Point> mPoints = new ArrayList<Point>();
-
-    public Shape()
-    {
-
-    }
-
-    public Shape(Point a)
-    {
-        mPoints.add(a);
-    }
-
-    public Shape(Point a, Point b)
-    {
-        mPoints.add(a);
-        mPoints.add(b);
-    }
-
-    public Shape(Point a, Point b, Point c)
-    {
-        mPoints.add(a);
-        mPoints.add(b);
-        mPoints.add(c);
-    }
-    
-    public void add(Point p)
-    {
-    	mPoints.add(p);
-    }
-
-    public boolean contains(Point p)
-    {
-        int nok=0;
-        int nerr=0;
-        for(int i=0; i<mPoints.size(); i++)
-        {
-            boolean ok=false;
-            for(int j=0; j<mPoints.size()-2; j++)
-            {
-                int k=(j+1+i)%mPoints.size();
-                int l=(j+2+i)%mPoints.size();
-                ok=isInTriangle(mPoints.get(i), mPoints.get(k), mPoints.get(l), p);
-                if(ok) break;
-            }
-            if(ok) nok++;
-            else nerr++;
-        }
-
-        return (nok>0);
-    }
-
-
-    
-    static boolean  moreOrLess(double a, double b)
-    {
-    	double marge = a>b?a/1000:b/1000;
-    	double res = a - b;
-    	if(res<0) res=-res;
-    	return res<marge;
-    }
-    
-    
-
-    public static boolean isInTriangle(Point a, Point b, Point c, Point p)
-    {
-    		double A = getTriangleSurface (a,b,c);
-    	 
-    	   /* Calculate area of triangle PBC */  
-    	   double A1 = getTriangleSurface (p,b, c);
-    	   /* Calculate area of triangle PAC */  
-    	   double A2 = getTriangleSurface (a, p, c);
-    	 
-    	   /* Calculate area of triangle PAB */   
-    	   double A3 = getTriangleSurface (a, b, p);
-
-    	   return moreOrLess(A ,A1 + A2 + A3);
-    }
-    public static double getTriangleSurface(Point a, Point b, Point c)
-    {
-        double A,B,C,p;
-        A=a.getDistanceWith(b);
-        B=b.getDistanceWith(c);
-        C=c.getDistanceWith(a);
-        p=(A+B+C)/2;
-
-        return Math.sqrt(p*(p-A)*(p-B)*(p-C));
-    }
-
-    public JSONArray getJson()
-    {
-        JSONArray ar = new JSONArray();
-        try {
-            for(int i=0; i<mPoints.size(); i++)
-            {
-                JSONArray arr = new JSONArray();
-                arr.put(mPoints.get(i).getY());
-                arr.put(mPoints.get(i).getX());
-                ar.put(arr);
-            }
-        } catch (JSONException e) {
-            e.printStackTrace();
-        }
-        return ar;
-    }
-}

+ 0 - 17
app/src/main/java/min3d/Min3d.java

@@ -1,17 +0,0 @@
-package min3d;
-
-public class Min3d 
-{
-	public static final String TAG = "Min3D";
-	
-	/*
-	 * Project homepage: 	http://code.google.com/p/min3d
-	 * License:				MIT
-	 * 
-	 * Author: 				Lee Felarca
-	 * Website:				http://www.zeropointnine.com/blog
-	 *
-	 * Author: 				Dennis Ippel
-	 * Author blog:			http://www.rozengain.com/blog/
-	 */
-}

+ 0 - 46
app/src/main/java/min3d/Shared.java

@@ -1,46 +0,0 @@
-package min3d;
-
-import min3d.core.TextureManager;
-import min3d.core.Renderer;
-import android.content.Context;
-
-/**
- * Holds static references to TextureManager, Renderer, and the application Context. 
- */
-public class Shared 
-{
-	private static Context _context;
-	private static Renderer _renderer;
-	private static TextureManager _textureManager;
-
-	
-	public static Context context()
-	{
-		return _context;
-	}
-	public static void context(Context $c)
-	{
-		_context = $c;
-	}
-
-	public static Renderer renderer()
-	{
-		return _renderer;
-	}
-	public static void renderer(Renderer $r)
-	{
-		_renderer = $r;
-	}
-	
-	/**
-	 * You must access the TextureManager instance through this accessor
-	 */
-	public static TextureManager textureManager()
-	{
-		return _textureManager;
-	}
-	public static void textureManager(TextureManager $bm)
-	{
-		_textureManager = $bm;
-	}
-}

+ 0 - 84
app/src/main/java/min3d/Utils.java

@@ -1,84 +0,0 @@
-package min3d;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.FloatBuffer;
-
-import min3d.core.Object3d;
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-
-
-public class Utils 
-{
-	public static final float DEG = (float)(Math.PI / 180f);
-		
-	private static final int BYTES_PER_FLOAT = 4;  
-	
-	/**
-	 * Convenience method to create a Bitmap given a Context's drawable resource ID. 
-	 */
-	public static Bitmap makeBitmapFromResourceId(Context $context, int $id)
-	{
-		InputStream is = $context.getResources().openRawResource($id);
-		
-		Bitmap bitmap;
-		try {
-		   bitmap = BitmapFactory.decodeStream(is);
-		} finally {
-		   try {
-		      is.close();
-		   } catch(IOException e) {
-		      // Ignore.
-		   }
-		}
-	      
-		return bitmap;
-	}
-	
-	/**
-	 * Convenience method to create a Bitmap given a drawable resource ID from the application Context. 
-	 */
-	public static Bitmap makeBitmapFromResourceId(int $id)
-	{
-		return makeBitmapFromResourceId(Shared.context(), $id);
-	}
-
-
-	/**
-	 * Add two triangles to the Object3d's faces using the supplied indices
-	 */
-	public static void addQuad(Object3d $o, int $upperLeft, int $upperRight, int $lowerRight, int $lowerLeft)
-	{
-		$o.faces().add((short)$upperLeft, (short)$lowerRight, (short)$upperRight);
-		$o.faces().add((short)$upperLeft, (short)$lowerLeft, (short)$lowerRight);
-	}
-	
-	public static FloatBuffer makeFloatBuffer3(float $a, float $b, float $c)
-	{
-		ByteBuffer b = ByteBuffer.allocateDirect(3 * BYTES_PER_FLOAT);
-		b.order(ByteOrder.nativeOrder());
-		FloatBuffer buffer = b.asFloatBuffer();
-		buffer.put($a);
-		buffer.put($b);
-		buffer.put($c);
-		buffer.position(0);
-		return buffer;
-	}
-
-	public static FloatBuffer makeFloatBuffer4(float $a, float $b, float $c, float $d)
-	{
-		ByteBuffer b = ByteBuffer.allocateDirect(4 * BYTES_PER_FLOAT);
-		b.order(ByteOrder.nativeOrder());
-		FloatBuffer buffer = b.asFloatBuffer();
-		buffer.put($a);
-		buffer.put($b);
-		buffer.put($c);
-		buffer.put($d);
-		buffer.position(0);
-		return buffer;
-	}
-}

+ 0 - 187
app/src/main/java/min3d/animation/AnimationObject3d.java

@@ -1,187 +0,0 @@
-package min3d.animation;
-
-import min3d.core.FacesBufferedList;
-import min3d.core.Object3d;
-import min3d.core.TextureList;
-import min3d.core.Vertices;
-
-public class AnimationObject3d extends Object3d {
-	private int numFrames;
-	private KeyFrame[] frames;
-	private int currentFrameIndex;
-	private long startTime;
-	private long currentTime;
-	private boolean isPlaying;
-	private float interpolation;
-	private float fps = 70;
-	private boolean updateVertices = true;	
-	private String currentFrameName;
-	private int loopStartIndex;
-	private boolean loop = false;
-
-	public AnimationObject3d(int $maxVertices, int $maxFaces, int $numFrames) {
-		super($maxVertices, $maxFaces);
-		this.numFrames = $numFrames;
-		this.frames = new KeyFrame[numFrames];
-		this.currentFrameIndex = 0;
-		this.isPlaying = false;
-		this.interpolation = 0;
-		this._animationEnabled = true;
-	}
-	
-	public AnimationObject3d(Vertices $vertices, FacesBufferedList $faces, TextureList $textures, KeyFrame[] $frames)
-	{
-		super($vertices, $faces, $textures);
-		numFrames = $frames.length;
-		frames = $frames;
-	}
-
-	public int getCurrentFrame() {
-		return currentFrameIndex;
-	}
-
-	public void addFrame(KeyFrame frame) {
-		frames[currentFrameIndex++] = frame;
-	}
-
-	public void setFrames(KeyFrame[] frames) {
-		this.frames = frames;
-	}
-
-	public void play() {
-		startTime = System.currentTimeMillis();
-		isPlaying = true;
-		currentFrameName = null;
-		loop = false;
-	}
-
-	public void play(String name) {
-		currentFrameIndex = 0;
-		currentFrameName = name;
-
-		for (int i = 0; i < numFrames; i++) {
-			if (frames[i].getName().equals(name))
-			{
-				loopStartIndex = currentFrameIndex = i;
-				break;
-			}
-		}
-
-		startTime = System.currentTimeMillis();
-		isPlaying = true;
-	}
-	
-	public void play(String name, boolean loop) {
-		this.loop = loop;
-		play(name);
-	}
-
-	public void stop() {
-		isPlaying = false;
-		currentFrameIndex = 0;
-	}
-
-	public void pause() {
-		isPlaying = false;
-	}
-
-	public void update() {
-		if (!isPlaying || !updateVertices)
-			return;
-		currentTime = System.currentTimeMillis();
-		KeyFrame currentFrame = frames[currentFrameIndex];
-		KeyFrame nextFrame = frames[(currentFrameIndex + 1) % numFrames];
-		
-		if(currentFrameName != null && !currentFrameName.equals(currentFrame.getName()))
-		{
-			if(!loop)
-				stop();
-			else
-				currentFrameIndex = loopStartIndex;
-			return;
-		}
-		
-		float[] currentVerts = currentFrame.getVertices();
-		float[] nextVerts = nextFrame.getVertices();
-		float[] currentNormals = currentFrame.getNormals();
-		float[] nextNormals = nextFrame.getNormals();
-		int numVerts = currentVerts.length;
-		
-		float[] interPolatedVerts = new float[numVerts];
-		float[] interPolatedNormals = new float[numVerts];
-
-		for (int i = 0; i < numVerts; i += 3) {
-			interPolatedVerts[i] = currentVerts[i] + interpolation * (nextVerts[i] - currentVerts[i]);
-			interPolatedVerts[i + 1] = currentVerts[i + 1] + interpolation * (nextVerts[i + 1] - currentVerts[i + 1]);
-			interPolatedVerts[i + 2] = currentVerts[i + 2] + interpolation 	* (nextVerts[i + 2] - currentVerts[i + 2]);
-			interPolatedNormals[i] = currentNormals[i] + interpolation * (nextNormals[i] - currentNormals[i]);
-			interPolatedNormals[i + 1] = currentNormals[i + 1] + interpolation * (nextNormals[i + 1] - currentNormals[i + 1]);
-			interPolatedNormals[i + 2] = currentNormals[i + 2] + interpolation * (nextNormals[i + 2] - currentNormals[i + 2]);
-		}
-
-		interpolation += fps * (currentTime - startTime) / 1000;
-		
-		vertices().overwriteNormals(interPolatedNormals);
-		vertices().overwriteVerts(interPolatedVerts);
-	
-		if (interpolation > 1) {
-			interpolation = 0;
-			currentFrameIndex++;
-
-			if (currentFrameIndex >= numFrames)
-				currentFrameIndex = 0;
-		}
-		
-		startTime = System.currentTimeMillis();
-	}
-
-	public float getFps() {
-		return fps;
-	}
-
-	public void setFps(float fps) {
-		this.fps = fps;
-	}
-	
-	public Object3d clone(boolean cloneData)
-	{
-		Vertices v = cloneData ? _vertices.clone() : _vertices;
-		FacesBufferedList f = cloneData ? _faces.clone() : _faces;
-		//KeyFrame[] fr = cloneData ? getClonedFrames() : frames;
-		
-		AnimationObject3d clone = new AnimationObject3d(v, f, _textures, frames);
-		clone.position().x = position().x;
-		clone.position().y = position().y;
-		clone.position().z = position().z;
-		clone.rotation().x = rotation().x;
-		clone.rotation().y = rotation().y;
-		clone.rotation().z = rotation().z;
-		clone.scale().x = scale().x;
-		clone.scale().y = scale().y;
-		clone.scale().z = scale().z;
-		clone.setFps(fps);
-		clone.animationEnabled(animationEnabled());
-		return clone;
-	}
-	
-	public KeyFrame[] getClonedFrames()
-	{
-		int len = frames.length;
-		KeyFrame[] cl = new KeyFrame[len];
-		
-		for(int i=0; i<len; i++)
-		{
-			cl[i] = frames[i].clone();
-		}
-		
-		return cl;
-	}
-
-	public boolean getUpdateVertices() {
-		return updateVertices;
-	}
-
-	public void setUpdateVertices(boolean updateVertices) {
-		this.updateVertices = updateVertices;
-	}
-}

+ 0 - 103
app/src/main/java/min3d/animation/KeyFrame.java

@@ -1,103 +0,0 @@
-package min3d.animation;
-
-import min3d.vos.Number3d;
-
-public class KeyFrame {
-	private String name;
-	private float[] vertices;
-	private float[] normals;
-
-	private int[] indices;
-	
-	public KeyFrame(String name, float[] vertices)
-	{
-		this.name = name;
-		this.vertices = vertices;
-	}
-
-	public KeyFrame(String name, float[] vertices, float[] normals)
-	{
-		this(name, vertices);
-		this.normals = normals;
-	}
-	
-	public String getName() {
-		return name;
-	}
-
-	public float[] getVertices() {
-		return vertices;
-	}
-
-	public int[] getIndices() {
-		return indices;
-	}
-
-	public float[] getNormals() {
-		return normals;
-	}
-	
-	public void setIndices(int[] indices) {
-		this.indices = indices;
-		float[] compressed = vertices;
-		vertices = new float[indices.length*3];
-		int len = indices.length;
-		int vi = 0;
-		int ii = 0;
-		int normalIndex = 0;
-		
-		for(int i=0; i<len; i++)
-		{
-			ii = indices[i] * 3;
-			vertices[vi++] = compressed[ii];
-			vertices[vi++] = compressed[ii + 1];
-			vertices[vi++] = compressed[ii + 2];
-		}
-		
-		normals = new float[vertices.length];
-		int vertLen = vertices.length;
-		
-		for(int i=0; i<vertLen; i+=9)
-		{
-			Number3d normal = calculateFaceNormal(
-					new Number3d(vertices[i], vertices[i+1], vertices[i+2]),
-					new Number3d(vertices[i+3], vertices[i+4], vertices[i+5]),
-					new Number3d(vertices[i+6], vertices[i+7], vertices[i+8])
-					);
-			normals[normalIndex++] = normal.x;
-			normals[normalIndex++] = normal.y;
-			normals[normalIndex++] = normal.z;
-			normals[normalIndex++] = normal.x;
-			normals[normalIndex++] = normal.y;
-			normals[normalIndex++] = normal.z;
-			normals[normalIndex++] = normal.x;
-			normals[normalIndex++] = normal.y;
-			normals[normalIndex++] = normal.z;
-		}
-	}
-	
-	public Number3d calculateFaceNormal(Number3d v1, Number3d v2, Number3d v3)
-	{
-		Number3d vector1 = Number3d.subtract(v2, v1);
-		Number3d vector2 = Number3d.subtract(v3, v1);
-		
-		Number3d normal = new Number3d();
-		normal.x = (vector1.y * vector2.z) - (vector1.z * vector2.y);
-		normal.y = -((vector2.z * vector1.x) - (vector2.x * vector1.z));
-		normal.z = (vector1.x * vector2.y) - (vector1.y * vector2.x);
-		
-		double normFactor = Math.sqrt((normal.x * normal.x) + (normal.y * normal.y) + (normal.z * normal.z));
-		
-		normal.x /= normFactor;
-		normal.y /= normFactor;
-		normal.z /= normFactor;
-		
-		return normal;
-	}
-	
-	public KeyFrame clone()
-	{
-		KeyFrame k = new KeyFrame(name, vertices.clone(), normals.clone());
-		return k;
-	}
-}

+ 0 - 160
app/src/main/java/min3d/core/Color4BufferList.java

@@ -1,160 +0,0 @@
-package min3d.core;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-
-import min3d.vos.Color4;
-
-
-public class Color4BufferList
-{
-	public static final int PROPERTIES_PER_ELEMENT = 4;
-	public static final int BYTES_PER_PROPERTY = 1;
-
-	private ByteBuffer _b;
-	private int _numElements;
-	
-	public Color4BufferList(ByteBuffer $b, int $size)
-	{
-		_b = ByteBuffer.allocate($b.limit() * BYTES_PER_PROPERTY);
-		_b.put($b);
-		_numElements = $size;
-	}
-	
-	public Color4BufferList(int $maxElements)
-	{
-		int numBytes = $maxElements * PROPERTIES_PER_ELEMENT * BYTES_PER_PROPERTY;
-		_b = ByteBuffer.allocateDirect(numBytes); 
-		_b.order(ByteOrder.nativeOrder());
-	}
-	
-	/**
-	 * The number of items in the list. 
-	 */
-	public int size()
-	{
-		return _numElements;
-	}
-	
-	/**
-	 * The _maximum_ number of items that the list can hold, as defined on instantiation.
-	 * (Not to be confused with the Buffer's capacity)
-	 */
-	public int capacity()
-	{
-		return _b.capacity() / PROPERTIES_PER_ELEMENT;
-	}
-	
-	/**
-	 * Clear object in preparation for garbage collection
-	 */
-	public void clear()
-	{
-		_b.clear();
-	}
-
-	public Color4 getAsColor4(int $index)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		return new Color4( _b.get(), _b.get(), _b.get(), _b.get() );
-	}
-	
-	public void putInColor4(int $index, Color4 $color4)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		$color4.r = (short)_b.get();
-		$color4.g = (short)_b.get();
-		$color4.b = (short)_b.get();
-		$color4.a = (short)_b.get();
-	}
-
-	public short getPropertyR(int $index)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		return (short)_b.get();
-	}
-	public short getPropertyG(int $index)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT + 1);
-		return (short)_b.get();
-	}
-	public float getPropertyB(int $index)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT + 2);
-		return (short)_b.get();
-	}
-	public float getPropertyA(int $index)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT + 3);
-		return (short)_b.get();
-	}
-	
-	//
-	
-	public void add(Color4 $c)
-	{
-		set( _numElements, $c );
-		_numElements++;
-	}
-	
-	public void add(short $r, short $g, short $b, short $a)
-	{
-		set(_numElements, $r, $g, $b, $a);
-		_numElements++;
-	}
-	
-	public void set(int $index, Color4 $c)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		_b.put((byte)$c.r);
-		_b.put((byte)$c.g);
-		_b.put((byte)$c.b);
-		_b.put((byte)$c.a);
-		
-		// Rem, OpenGL takes in color in this order: r,g,b,a -- _not_ a,r,g,b
-	}
-
-	public void set(int $index, short $r, short $g, short $b, short $a)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		_b.put((byte)$r);
-		_b.put((byte)$g);
-		_b.put((byte)$b);
-		_b.put((byte)$a);
-	}
-	
-	public void setPropertyR(int $index, short $r)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		_b.put((byte)$r);
-	}
-	public void setPropertyG(int $index, short $g)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT + 1);
-		_b.put((byte)$g);
-	}
-	public void setPropertyB(int $index, short $b)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT + 2);
-		_b.put((byte)$b);
-	}
-	public void setPropertyA(int $index, short $a)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT + 3);
-		_b.put((byte)$a);
-	}
-	
-	//
-	
-	public ByteBuffer buffer()
-	{
-		return _b;
-	}
-	
-	public Color4BufferList clone()
-	{
-		_b.position(0);
-		Color4BufferList c = new Color4BufferList(_b, size());
-		return c;
-	}
-}

+ 0 - 190
app/src/main/java/min3d/core/FacesBufferedList.java

@@ -1,190 +0,0 @@
-package min3d.core;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.ShortBuffer;
-
-import min3d.vos.Face;
-
-public class FacesBufferedList
-{
-	public static final int PROPERTIES_PER_ELEMENT = 3;
-	public static final int BYTES_PER_PROPERTY = 2;
-
-	private ShortBuffer _b;
-	private int _numElements;
-
-	private int _renderSubsetStartIndex = 0;
-	private int _renderSubsetLength = 1;
-	private boolean _renderSubsetEnabled = false;
-	
-	public FacesBufferedList(ShortBuffer $b, int $size)
-	{
-		ByteBuffer bb = ByteBuffer.allocateDirect($b.limit() * BYTES_PER_PROPERTY); 
-		bb.order(ByteOrder.nativeOrder());
-		_b = bb.asShortBuffer();
-		_b.put($b);
-		_numElements = $size;
-	}
-	
-	public FacesBufferedList(int $maxElements)
-	{
-		ByteBuffer b = ByteBuffer.allocateDirect($maxElements * PROPERTIES_PER_ELEMENT * BYTES_PER_PROPERTY); 
-		b.order(ByteOrder.nativeOrder());
-		_b = b.asShortBuffer();
-	}
-	
-	/**
-	 * The number of items in the list. 
-	 */
-	public int size()
-	{
-		return _numElements;
-	}
-	
-	
-	/**
-	 * The _maximum_ number of items that the list can hold, as defined on instantiation.
-	 * (Not to be confused with the Buffer's capacity)
-	 */
-	public int capacity()
-	{
-		return _b.capacity() / PROPERTIES_PER_ELEMENT;
-	}
-	
-	/**
-	 * Clear object in preparation for garbage collection
-	 */
-	public void clear()
-	{
-		_b.clear();
-	}
-
-	public Face get(int $index)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		return new Face( _b.get(), _b.get(), _b.get() );
-	}
-	
-	public void putInFace(int $index, Face $face)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		$face.a = (short)_b.get();
-		$face.b = (short)_b.get();
-		$face.c = (short)_b.get();
-	}
-	
-	public short getPropertyA(int $index)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		return (short)_b.get();
-	}
-	public short getPropertyB(int $index)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT + 1);
-		return (short)_b.get();
-	}
-	public float getPropertyC(int $index)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT + 2);
-		return (short)_b.get();
-	}
-
-	/**
-	 * Enables rendering only a subset of faces (renderSubset must be set to true) 
-	 * This mechanism could be expanded to render multiple 'subsets' of the list of faces...
-	 */
-	public void renderSubsetStartIndex(int $num)
-	{
-		_renderSubsetStartIndex = $num;
-	}
-	public int renderSubsetStartIndex()
-	{
-		return _renderSubsetStartIndex;
-	}
-	public void renderSubsetLength(int $num)
-	{
-		_renderSubsetLength = $num;
-	}
-	public int renderSubsetLength()
-	{
-		return _renderSubsetLength;
-	}
-	
-	/**
-	 * If true, Renderer will only draw the faces as defined by 
-	 * renderSubsetStartIndex and renderSubsetLength  
-	 */
-	public boolean renderSubsetEnabled()
-	{
-		return _renderSubsetEnabled;
-	}
-	public void renderSubsetEnabled(boolean $b)
-	{
-		_renderSubsetEnabled = $b;
-	}
-	
-	//
-	
-	public void add(Face $f)
-	{
-		set( _numElements, $f );
-		_numElements++;
-	}
-	
-	public void add(int $a, int $b, int $c) {
-		add((short)$a, (short)$b, (short)$c);
-	}
-	
-	public void add(short $a, short $b, short $c)
-	{
-		set(_numElements, $a, $b, $c);
-		_numElements++;
-	}
-	
-	public void set(int $index, Face $face)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		_b.put($face.a);
-		_b.put($face.b);
-		_b.put($face.c);
-	}
-
-	public void set(int $index, short $a, short $b, short $c)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		_b.put($a);
-		_b.put($b);
-		_b.put($c);
-	}
-	
-	public void setPropertyA(int $index, short $a)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		_b.put($a);
-	}
-	public void setPropertyB(int $index, short $b)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT + 1);
-		_b.put($b);
-	}
-	public void setPropertyC(int $index, short $c)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT + 2);
-		_b.put($c);
-	}
-	
-	//
-	
-	public ShortBuffer buffer()
-	{
-		return _b;
-	}
-	
-	public FacesBufferedList clone()
-	{
-		_b.position(0);
-		FacesBufferedList c = new FacesBufferedList(_b, size());
-		return c;
-	}
-}

+ 0 - 149
app/src/main/java/min3d/core/ManagedLightList.java

@@ -1,149 +0,0 @@
-package min3d.core;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import android.util.Log;
-
-import min3d.Min3d;
-import min3d.vos.Light;
-
-public class ManagedLightList 
-{
-	// List of Light objects
-	private ArrayList<Light> _lights;
-
-	// Map Light objects to GL_LIGHT indices
-	private HashMap<Light, Integer> _lightToGlIndex;
-
-	// 'Pool' of available GL_LIGHT id's
-	private ArrayList<Integer> _availGlIndices;
-
-	// Array of which GL_LIGHTS are enabled, where index corresponds to
-	// GL_LIGHT[index]
-	private boolean[] _glIndexEnabled;
-
-	// Array of dirty flags, where index corresponds to GL_LIGHT[index]
-	private boolean[] _glIndexEnabledDirty;
-
-	// "GL index" here means an int from 0 to 8 that corresponds to
-	// the int constants GL10.GL_LIGHT0 to GL10.GL_LIGHT7
-
-	public ManagedLightList() 
-	{
-		reset();
-	}
-
-	public void reset() 
-	{
-		Log.i(Min3d.TAG, "ManagedLightList.reset()");
-
-		_availGlIndices = new ArrayList<Integer>();
-		for (int i = 0; i < Renderer.NUM_GLLIGHTS; i++) {
-			_availGlIndices.add(i);
-		}
-
-		_lightToGlIndex = new HashMap<Light, Integer>();
-
-		_glIndexEnabled = new boolean[Renderer.NUM_GLLIGHTS];
-		_glIndexEnabledDirty = new boolean[Renderer.NUM_GLLIGHTS];
-		for (int i = 0; i < Renderer.NUM_GLLIGHTS; i++) {
-			_glIndexEnabled[i] = false;
-			_glIndexEnabledDirty[i] = true;
-		}
-
-		_lights = new ArrayList<Light>();
-	}
-
-	public boolean add(Light $light) 
-	{
-		if (_lights.contains($light)) {
-			return false;
-		}
-
-		if (_lights.size() > Renderer.NUM_GLLIGHTS)
-			throw new Error("Exceeded maximum number of Lights");
-
-		boolean result = _lights.add($light);
-
-		int glIndex = _availGlIndices.remove(0);
-
-		_lightToGlIndex.put($light, glIndex);
-
-		_glIndexEnabled[glIndex] = true;
-		_glIndexEnabledDirty[glIndex] = true;
-		
-		return result;
-	}
-
-	public void remove(Light $light) 
-	{
-		boolean result = _lights.remove($light);
-
-		if (!result) return;
-
-		int glIndex = _lightToGlIndex.get($light);
-		
-		_availGlIndices.add(glIndex);
-
-		_glIndexEnabled[glIndex] = false;
-		_glIndexEnabledDirty[glIndex] = true;
-	}
-
-	public void removeAll() 
-	{
-		reset();
-	}
-
-	public int size() 
-	{
-		return _lights.size();
-	}
-
-	public Light get(int $index) 
-	{
-		return _lights.get($index);
-	}
-
-	public Light[] toArray() {
-		return (Light[]) _lights.toArray(new Light[_lights.size()]);
-	}
-
-	/**
-	 * Used by Renderer
-	 */
-	int getGlIndexByLight(Light $light) /* package-private */
-	{
-		return _lightToGlIndex.get($light);
-	}
-
-	/**
-	 * Used by Renderer
-	 */
-	Light getLightByGlIndex(int $glIndex) /* package-private */
-	{
-		for (int i = 0; i < _lights.size(); i++) 
-		{
-			Light light = _lights.get(i);
-			if (_lightToGlIndex.get(light) == $glIndex)
-				return light;
-		}
-		return null;
-	}
-
-	/**
-	 * Used by Renderer
-	 */
-	boolean[] glIndexEnabledDirty() /* package-private */
-	{
-		return _glIndexEnabledDirty;
-	}
-
-	/**
-	 * Used by Renderer
-	 */
-	boolean[] glIndexEnabled() /* package-private */
-	{
-		return _glIndexEnabled;
-	}
-}

+ 0 - 157
app/src/main/java/min3d/core/Number3dBufferList.java

@@ -1,157 +0,0 @@
-package min3d.core;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.FloatBuffer;
-
-import min3d.vos.Number3d;
-
-public class Number3dBufferList
-{
-	public static final int PROPERTIES_PER_ELEMENT = 3;
-	public static final int BYTES_PER_PROPERTY = 4;
-
-	private FloatBuffer _b;
-	private int _numElements = 0;
-	
-	public Number3dBufferList(FloatBuffer $b, int $size)
-	{
-		ByteBuffer bb = ByteBuffer.allocateDirect($b.limit() * BYTES_PER_PROPERTY); 
-		bb.order(ByteOrder.nativeOrder());
-		_b = bb.asFloatBuffer();
-		_b.put($b);
-		_numElements = $size;
-	}
-	
-	public Number3dBufferList(int $maxElements)
-	{
-		int numBytes = $maxElements * PROPERTIES_PER_ELEMENT * BYTES_PER_PROPERTY;
-		ByteBuffer bb = ByteBuffer.allocateDirect(numBytes); 
-		bb.order(ByteOrder.nativeOrder());
-		
-		_b  = bb.asFloatBuffer();
-	}
-	
-	/**
-	 * The number of items in the list. 
-	 */
-	public int size()
-	{
-		return _numElements;
-	}
-	
-	/**
-	 * The _maximum_ number of items that the list can hold, as defined on instantiation.
-	 * (Not to be confused with the Buffer's capacity)
-	 */
-	public int capacity()
-	{
-		return _b.capacity() / PROPERTIES_PER_ELEMENT;
-	}
-	
-	/**
-	 * Clear object in preparation for garbage collection
-	 */
-	public void clear()
-	{
-		_b.clear();
-	}
-	
-	//
-	
-	public Number3d getAsNumber3d(int $index)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		return new Number3d( _b.get(), _b.get(), _b.get() );
-	}
-	
-	public void putInNumber3d(int $index, Number3d $number3d)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		$number3d.x = _b.get();
-		$number3d.y = _b.get();
-		$number3d.z = _b.get();
-	}
-	
-	public float getPropertyX(int $index)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		return _b.get();
-	}
-	public float getPropertyY(int $index)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT + 1);
-		return _b.get();
-	}
-	public float getPropertyZ(int $index)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT + 2);
-		return _b.get();
-	}
-	
-	//
-	
-	public void add(Number3d $n)
-	{
-		set( _numElements, $n );
-		_numElements++;
-	}
-	
-	public void add(float $x, float $y, float $z)
-	{
-		set( _numElements, $x,$y,$z );
-		_numElements++;
-	}
-	
-	public void set(int $index, Number3d $n)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		_b.put($n.x);
-		_b.put($n.y);
-		_b.put($n.z);
-	}
-
-	public void set(int $index, float $x, float $y, float $z)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		_b.put($x);
-		_b.put($y);
-		_b.put($z);
-	}
-	
-	public void setPropertyX(int $index, float $x)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		_b.put($x);
-	}
-	public void setPropertyY(int $index, float $y)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT + 1);
-		_b.put($y);
-	}
-	public void setPropertyZ(int $index, float $z)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT + 2);
-		_b.put($z);
-	}
-	
-	//
-	
-	public FloatBuffer buffer()
-	{
-		return _b;
-	}
-	
-	public void overwrite(float[] $newVals)
-	{
-		_b.position(0);
-		_b.put($newVals);
-	}
-	
-	public Number3dBufferList clone()
-	{
-		_b.position(0);
-		Number3dBufferList c = new Number3dBufferList(_b, size());
-		return c;
-	}
-}

+ 0 - 491
app/src/main/java/min3d/core/Object3d.java

@@ -1,491 +0,0 @@
-package min3d.core;
-
-import java.util.ArrayList;
-
-import javax.microedition.khronos.opengles.GL10;
-
-import android.util.Log;
-
-import min3d.interfaces.IObject3dContainer;
-import min3d.vos.Color4;
-import min3d.vos.Number3d;
-import min3d.vos.RenderType;
-import min3d.vos.ShadeModel;
-
-/**
- * @author Lee
- */
-public class Object3d
-{
-	private String _name;
-	
-	private RenderType _renderType = RenderType.TRIANGLES;
-	
-	private boolean _isVisible = true;
-	private boolean _vertexColorsEnabled = true;
-	private boolean _doubleSidedEnabled = false;
-	private boolean _texturesEnabled = true;
-	private boolean _normalsEnabled = true;
-	private boolean _ignoreFaces = false;
-	private boolean _colorMaterialEnabled = false;
-	private boolean _lightingEnabled = true;
-
-	private Number3d _position = new Number3d(0,0,0);
-	private Number3d _rotation = new Number3d(0,0,0);
-	private Number3d _scale = new Number3d(1,1,1);
-
-	private Color4 _defaultColor = new Color4();
-	
-	private ShadeModel _shadeModel = ShadeModel.SMOOTH;
-	private float _pointSize = 3f;
-	private boolean _pointSmoothing = true;
-	private float _lineWidth = 1f;
-	private boolean _lineSmoothing = false;
-
-	
-	protected ArrayList<Object3d> _children;
-	
-	protected Vertices _vertices; 
-	protected TextureList _textures;
-	protected FacesBufferedList _faces;
-
-	protected boolean _animationEnabled = false;
-	
-	private Scene _scene;
-	private IObject3dContainer _parent;
-
-	/**
-	 * Maximum number of vertices and faces must be specified at instantiation.
-	 */
-	public Object3d(int $maxVertices, int $maxFaces)
-	{
-		_vertices = new Vertices($maxVertices, true,true,true);
-		_faces = new FacesBufferedList($maxFaces);
-		_textures = new TextureList();
-	}
-	
-	/**
-	 * Adds three arguments 
-	 */
-	public Object3d(int $maxVertices, int $maxFaces, Boolean $useUvs, Boolean $useNormals, Boolean $useVertexColors)
-	{
-		_vertices = new Vertices($maxVertices, $useUvs,$useNormals,$useVertexColors);
-		_faces = new FacesBufferedList($maxFaces);
-		_textures = new TextureList();
-	}
-	
-	/**
-	 * This constructor is convenient for cloning purposes 
-	 */
-	public Object3d(Vertices $vertices, FacesBufferedList $faces, TextureList $textures)
-	{
-		_vertices = $vertices;
-		_faces = $faces;
-		_textures = $textures;
-	}
-	
-	/**
-	 * Holds references to vertex position list, vertex u/v mappings list, vertex normals list, and vertex colors list
-	 */
-	public Vertices vertices()
-	{
-		return _vertices;
-	}
-
-	/**
-	 * List of object's faces (ie, index buffer) 
-	 */
-	public FacesBufferedList faces()
-	{
-		return _faces;
-	}
-	
-	public TextureList textures()
-	{
-		return _textures;
-	}
-	
-	/**
-	 * Determines if object will be rendered.
-	 * Default is true. 
-	 */
-	public boolean isVisible()
-	{
-		return _isVisible;
-	}
-	public void isVisible(Boolean $b)
-	{
-		_isVisible = $b;
-	}
-	
-	/**
-	 * Determines if backfaces will be rendered (ie, doublesided = true).
-	 * Default is false.
-	 */
-	public boolean doubleSidedEnabled()
-	{
-		return _doubleSidedEnabled;
-	}
-	public void doubleSidedEnabled(boolean $b)
-	{
-		_doubleSidedEnabled = $b;
-	}
-	
-	/**
-	 * Determines if object uses GL_COLOR_MATERIAL or not.
-	 * Default is false.
-	 */
-	public boolean colorMaterialEnabled()
-	{
-		return _colorMaterialEnabled;
-	}
-	
-	public boolean lightingEnabled() {
-		return _lightingEnabled;
-	}
-
-	public void lightingEnabled(boolean $b) {
-		this._lightingEnabled = $b;
-	}
-
-	public void colorMaterialEnabled(boolean $b)
-	{
-		_colorMaterialEnabled = $b;
-	}
-
-	/**
-	 * Determines whether animation is enabled or not. If it is enabled
-	 * then this should be an AnimationObject3d instance.
-	 * This is part of the Object3d class so there's no need to cast
-	 * anything during the render loop when it's not necessary.
-	 */
-	public boolean animationEnabled()
-	{
-		return _animationEnabled;
-	}
-	public void animationEnabled(boolean $b)
-	{
-		_animationEnabled = $b;
-	}
-	/**
-	 * Determines if per-vertex colors will be using for rendering object.
-	 * If false, defaultColor property will dictate object color.
-	 * If object has no per-vertex color information, setting is ignored.
-	 * Default is true. 
-	 */
-	public boolean vertexColorsEnabled()
-	{
-		return _vertexColorsEnabled;
-	}
-	public void vertexColorsEnabled(Boolean $b)
-	{
-		_vertexColorsEnabled = $b;
-	}
-
-	/**
-	 * Determines if textures (if any) will used for rendering object.
-	 * Default is true.  
-	 */
-	public boolean texturesEnabled()
-	{
-		return _texturesEnabled;
-	}
-	public void texturesEnabled(Boolean $b)
-	{
-		_texturesEnabled = $b;
-	}
-	
-	/**
-	 * Determines if object will be rendered using vertex light normals.
-	 * If false, no lighting is used on object for rendering.
-	 * Default is true.
-	 */
-	public boolean normalsEnabled()
-	{
-		return _normalsEnabled;
-	}
-	public void normalsEnabled(boolean $b)
-	{
-		_normalsEnabled = $b;
-	}
-
-	/**
-	 * When true, Renderer draws using vertex points list, rather than faces list.
-	 * (ie, using glDrawArrays instead of glDrawElements) 
-	 * Default is false.
-	 */
-	public boolean ignoreFaces()
-	{
-		return _ignoreFaces;
-	}
-	public void ignoreFaces(boolean $b)
-	{
-		_ignoreFaces = $b;
-	}	
-	
-	/**
-	 * Options are: TRIANGLES, LINES, and POINTS
-	 * Default is TRIANGLES.
-	 */
-	public RenderType renderType()
-	{
-		return _renderType;
-	}
-	public void renderType(RenderType $type)
-	{
-		_renderType = $type;
-	}
-	
-	/**
-	 * Possible values are ShadeModel.SMOOTH and ShadeModel.FLAT.
-	 * Default is ShadeModel.SMOOTH.
-	 * @return
-	 */
-	public ShadeModel shadeModel()
-	{
-		return _shadeModel;
-	}
-	public void shadeModel(ShadeModel $shadeModel)
-	{
-		_shadeModel = $shadeModel;
-	}
-	
-	/**
-	 * Convenience 'pass-thru' method  
-	 */
-	public Number3dBufferList points()
-	{
-		return _vertices.points();
-	}
-	
-	/**
-	 * Convenience 'pass-thru' method  
-	 */
-	public UvBufferList uvs()
-	{
-		return _vertices.uvs();
-	}
-	
-	/**
-	 * Convenience 'pass-thru' method  
-	 */
-	public Number3dBufferList normals()
-	{
-		return _vertices.normals();
-	}
-	
-	/**
-	 * Convenience 'pass-thru' method  
-	 */
-	public Color4BufferList colors()
-	{
-		return _vertices.colors();
-	}
-	
-	/**
-	 * Convenience 'pass-thru' method  
-	 */
-	public boolean hasUvs()
-	{
-		return _vertices.hasUvs();
-	}
-
-	/**
-	 * Convenience 'pass-thru' method  
-	 */
-	public boolean hasNormals()
-	{
-		return _vertices.hasNormals();
-	}
-	
-	/**
-	 * Convenience 'pass-thru' method  
-	 */
-	public boolean hasVertexColors()
-	{
-		return _vertices.hasColors();
-	}
-
-
-	/**
-	 * Clear object for garbage collection.
-	 */
-	public void clear()
-	{
-		if (this.vertices().points() != null) 	this.vertices().points().clear();
-		if (this.vertices().uvs() != null) 		this.vertices().uvs().clear();
-		if (this.vertices().normals() != null) 	this.vertices().normals().clear();
-		if (this.vertices().colors() != null) 	this.vertices().colors().clear();
-		if (_textures != null) 					_textures.clear();
-		
-		if (this.parent() != null) 				this.parent().removeChild(this);
-	}
-
-	//
-
-	/**
-	 * Color used to render object, but only when colorsEnabled is false.
-	 */
-	public Color4 defaultColor()
-	{
-		return _defaultColor;
-	}
-	
-	public void defaultColor(Color4 color) {
-		_defaultColor = color;
-	}
-
-	/**
-	 * X/Y/Z position of object. 
-	 */
-	public Number3d position()
-	{
-		return _position;
-	}
-	
-	/**
-	 * X/Y/Z euler rotation of object, using Euler angles.
-	 * Units should be in degrees, to match OpenGL usage. 
-	 */
-	public Number3d rotation()
-	{
-		return _rotation;
-	}
-
-	/**
-	 * X/Y/Z scale of object.
-	 */
-	public Number3d scale()
-	{
-		return _scale;
-	}
-	
-	/**
-	 * Point size (applicable when renderType is POINT)
-	 * Default is 3. 
-	 */
-	public float pointSize()
-	{
-		return _pointSize; 
-	}
-	public void pointSize(float $n)
-	{
-		_pointSize = $n;
-	}
-
-	/**
-	 * Point smoothing (anti-aliasing), applicable when renderType is POINT.
-	 * When true, points look like circles rather than squares.
-	 * Default is true.
-	 */
-	public boolean pointSmoothing()
-	{
-		return _pointSmoothing;
-	}
-	public void pointSmoothing(boolean $b)
-	{
-		_pointSmoothing = $b;
-	}
-
-	/**
-	 * Line width (applicable when renderType is LINE)
-	 * Default is 1. 
-	 * 
-	 * Remember that maximum line width is OpenGL-implementation specific, and varies depending 
-	 * on whether lineSmoothing is enabled or not. Eg, on Nexus One,  lineWidth can range from
-	 * 1 to 8 without smoothing, and can only be 1f with smoothing. 
-	 */
-	public float lineWidth()
-	{
-		return _lineWidth;
-	}
-	public void lineWidth(float $n)
-	{
-		_lineWidth = $n;
-	}
-	
-	/**
-	 * Line smoothing (anti-aliasing), applicable when renderType is LINE
-	 * Default is false.
-	 */
-	public boolean lineSmoothing()
-	{
-		return _lineSmoothing;
-	}
-	public void lineSmoothing(boolean $b)
-	{
-		_lineSmoothing = $b;
-	}
-	
-	/**
-	 * Convenience property 
-	 */
-	public String name()
-	{
-		return _name;
-	}
-	public void name(String $s)
-	{
-		_name = $s;
-	}
-	
-	public IObject3dContainer parent()
-	{
-		return _parent;
-	}
-	
-	//
-	
-	void parent(IObject3dContainer $container) /*package-private*/
-	{
-		_parent = $container;
-	}
-	
-	/**
-	 * Called by Scene
-	 */
-	void scene(Scene $scene) /*package-private*/
-	{
-		_scene = $scene;
-	}
-	/**
-	 * Called by DisplayObjectContainer
-	 */
-	Scene scene() /*package-private*/
-	{
-		return _scene;
-	}
-	
-	/**
-	 * Can be overridden to create custom draw routines on a per-object basis, 
-	 * rather than using Renderer's built-in draw routine. 
-	 * 
-	 * If overridden, return true instead of false.
-	 */
-	public Boolean customRenderer(GL10 gl)
-	{
-		return false;
-	}
-	
-	public Object3d clone()
-	{
-		Vertices v = _vertices.clone();
-		FacesBufferedList f = _faces.clone();
-			
-		Object3d clone = new Object3d(v, f, _textures);
-		
-		clone.position().x = position().x;
-		clone.position().y = position().y;
-		clone.position().z = position().z;
-		
-		clone.rotation().x = rotation().x;
-		clone.rotation().y = rotation().y;
-		clone.rotation().z = rotation().z;
-		
-		clone.scale().x = scale().x;
-		clone.scale().y = scale().y;
-		clone.scale().z = scale().z;
-		
-		return clone;
-	}
-}

+ 0 - 137
app/src/main/java/min3d/core/Object3dContainer.java

@@ -1,137 +0,0 @@
-package min3d.core;
-
-import java.util.ArrayList;
-
-import min3d.interfaces.IObject3dContainer;
-
-public class Object3dContainer extends Object3d implements IObject3dContainer
-{
-	protected ArrayList<Object3d> _children = new ArrayList<Object3d>();
-
-	public Object3dContainer()
-	{
-		super(0, 0, false, false, false);
-	}
-	/**
-	 * Adds container functionality to Object3d.
-	 * 
-	 * Subclass Object3dContainer instead of Object3d if you
-	 * believe you may want to add children to that object. 
-	 */
-	public Object3dContainer(int $maxVerts, int $maxFaces)
-	{
-		super($maxVerts, $maxFaces, true,true,true);
-	}
-
-	public Object3dContainer(int $maxVerts, int $maxFaces,  Boolean $useUvs, Boolean $useNormals, Boolean $useVertexColors)
-	{
-		super($maxVerts, $maxFaces, $useUvs,$useNormals,$useVertexColors);
-	}
-	
-	/**
-	 * This constructor is convenient for cloning purposes 
-	 */
-	public Object3dContainer(Vertices $vertices, FacesBufferedList $faces, TextureList $textures)
-	{
-		super($vertices, $faces, $textures);
-	}
-	
-	public void addChild(Object3d $o)
-	{
-		_children.add($o);
-		
-		$o.parent(this);
-		$o.scene(this.scene());
-	}
-	
-	public void addChildAt(Object3d $o, int $index) 
-	{
-		_children.add($index, $o);
-		
-		$o.parent(this);
-		$o.scene(this.scene());
-	}
-
-	public boolean removeChild(Object3d $o)
-	{
-		boolean b = _children.remove($o);
-		
-		if (b) {
-			$o.parent(null);
-			$o.scene(null);
-		}
-		return b;
-	}
-	
-	public Object3d removeChildAt(int $index) 
-	{
-		Object3d o = _children.remove($index);
-		if (o != null) {
-			o.parent(null);
-			o.scene(null);
-		}
-		return o;
-	}
-	
-	public Object3d getChildAt(int $index) 
-	{
-		return _children.get($index);
-	}
-
-	/**
-	 * TODO: Use better lookup 
-	 */
-	public Object3d getChildByName(String $name)
-	{
-		for (int i = 0; i < _children.size(); i++)
-		{
-			if (_children.get(i).name().equals($name)) return _children.get(i); 
-		}
-		return null;
-	}
-
-	public int getChildIndexOf(Object3d $o) 
-	{
-		return _children.indexOf($o);		
-	}
-
-
-	public int numChildren() 
-	{
-		return _children.size();
-	}
-	
-	/*package-private*/ 
-	ArrayList<Object3d> children()
-	{
-		return _children;
-	}
-	
-	public Object3dContainer clone()
-	{
-		Vertices v = _vertices.clone();
-		FacesBufferedList f = _faces.clone();
-
-		Object3dContainer clone = new Object3dContainer(v, f, _textures);
-		
-		clone.position().x = position().x;
-		clone.position().y = position().y;
-		clone.position().z = position().z;
-		
-		clone.rotation().x = rotation().x;
-		clone.rotation().y = rotation().y;
-		clone.rotation().z = rotation().z;
-		
-		clone.scale().x = scale().x;
-		clone.scale().y = scale().y;
-		clone.scale().z = scale().z;
-		
-		for(int i = 0; i< this.numChildren();i++)
-		{
-			 clone.addChild(this.getChildAt(i));
-		}
-		 
-		return clone;
-	}
-
-}

+ 0 - 153
app/src/main/java/min3d/core/RenderCaps.java

@@ -1,153 +0,0 @@
-package min3d.core;
-
-import java.nio.IntBuffer;
-
-import javax.microedition.khronos.opengles.GL10;
-import javax.microedition.khronos.opengles.GL11;
-
-import min3d.Min3d;
-
-import android.util.Log;
-
-/**
- * Simple static class holding values representing various capabilities of 
- * hardware's concrete OpenGL capabilities that are relevant to min3d's 
- * supported features. 
- */
-public class RenderCaps 
-{
-	private static float _openGlVersion;
-	private static boolean _isGl10Only;
-	private static int _maxTextureUnits;
-	private static int _maxTextureSize;
-	private static int _aliasedPointSizeMin;
-	private static int _aliasedPointSizeMax;
-	private static int _smoothPointSizeMin;
-	private static int _smoothPointSizeMax;
-	private static int _aliasedLineSizeMin;
-	private static int _aliasedLineSizeMax;
-	private static int _smoothLineSizeMin;
-	private static int _smoothLineSizeMax;
-	private static int _maxLights;
-	
-	
-	public static float openGlVersion()
-	{
-		return _openGlVersion;
-	}
-	
-	public static boolean isGl10Only()
-	{
-		return _isGl10Only;
-	}
-
-	public static int maxTextureUnits()
-	{
-		return _maxTextureUnits;
-	}
-	
-	public static int aliasedPointSizeMin()
-	{
-		return _aliasedPointSizeMin;
-	}
-	
-	public static int aliasedPointSizeMax()
-	{
-		return _aliasedPointSizeMax;
-	}
-	
-	public static int smoothPointSizeMin()
-	{
-		return _smoothPointSizeMin;
-	}
-	
-	public static int smoothPointSizeMax()
-	{
-		return _smoothPointSizeMax;
-	}
-	
-	public static int aliasedLineSizeMin()
-	{
-		return _aliasedLineSizeMin;
-	}
-	
-	public static int aliasedLineSizeMax()
-	{
-		return _aliasedLineSizeMax;
-	}
-	
-	public static int smoothLineSizeMin()
-	{
-		return _smoothLineSizeMin;
-	}
-	
-	public static int smoothLineSizeMax()
-	{
-		return _smoothLineSizeMax;
-	}
-	
-	public static int maxLights()
-	{
-		return _maxLights;
-	}
-	
-	/**
-	 * Called by Renderer.onSurfaceCreate() 
-	 */
-	static void setRenderCaps(GL10 $gl) /* package-private*/
-	{
-	    IntBuffer i;
-
-	    // OpenGL ES version
-		if ($gl instanceof GL11) {
-			_openGlVersion = 1.1f;
-		}
-		else {
-			_openGlVersion = 1.0f;
-		}
-		
-	    // Max texture units
-		i = IntBuffer.allocate(1);
-		$gl.glGetIntegerv(GL10.GL_MAX_TEXTURE_UNITS, i);
-		_maxTextureUnits = i.get(0);
-		
-	    // Max texture size
-		i = IntBuffer.allocate(1);
-		$gl.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, i);
-		_maxTextureSize = i.get(0);
-		
-		// Aliased point size range
-		i = IntBuffer.allocate(2);
-		$gl.glGetIntegerv(GL10.GL_ALIASED_POINT_SIZE_RANGE, i);
-		_aliasedPointSizeMin = i.get(0);
-		_aliasedPointSizeMax = i.get(1);
-
-		// Smooth point size range
-		i = IntBuffer.allocate(2);
-		$gl.glGetIntegerv(GL10.GL_SMOOTH_POINT_SIZE_RANGE, i);
-		_smoothPointSizeMin = i.get(0);
-		_smoothPointSizeMax = i.get(1);
-
-		// Aliased line width range
-		i = IntBuffer.allocate(2);
-		$gl.glGetIntegerv(GL10.GL_ALIASED_LINE_WIDTH_RANGE, i);
-		_aliasedLineSizeMin = i.get(0);
-		_aliasedLineSizeMax = i.get(1);
-
-		// Smooth line width range
-		i = IntBuffer.allocate(2);
-		$gl.glGetIntegerv(GL10.GL_SMOOTH_LINE_WIDTH_RANGE, i);
-		_smoothLineSizeMin = i.get(0);
-		_smoothLineSizeMax = i.get(1);
-		
-	    // Max lights
-		i = IntBuffer.allocate(1);
-		$gl.glGetIntegerv(GL10.GL_MAX_LIGHTS, i);
-		_maxLights = i.get(0);
-
-		Log.v(Min3d.TAG, "RenderCaps - openGLVersion: " + _openGlVersion);
-		Log.v(Min3d.TAG, "RenderCaps - maxTextureUnits: " + _maxTextureUnits);
-		Log.v(Min3d.TAG, "RenderCaps - maxTextureSize: " + _maxTextureSize);
-		Log.v(Min3d.TAG, "RenderCaps - maxLights: " + _maxLights);
-	}
-}

+ 0 - 684
app/src/main/java/min3d/core/Renderer.java

@@ -1,684 +0,0 @@
-package min3d.core;
-
-import java.nio.FloatBuffer;
-import java.nio.IntBuffer;
-
-import javax.microedition.khronos.egl.EGLConfig;
-import javax.microedition.khronos.opengles.GL10;
-import javax.microedition.khronos.opengles.GL11;
-
-import min3d.Min3d;
-import min3d.Shared;
-import min3d.animation.AnimationObject3d;
-import min3d.vos.FrustumManaged;
-import min3d.vos.Light;
-import min3d.vos.RenderType;
-import min3d.vos.TextureVo;
-import android.app.ActivityManager;
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.opengl.GLSurfaceView;
-import android.opengl.GLU;
-import android.opengl.GLUtils;
-import android.util.Log;
-
-
-public class Renderer implements GLSurfaceView.Renderer
-{
-	public static final int NUM_GLLIGHTS = 8;
-
-	private GL10 _gl;
-	private Scene _scene;
-	private TextureManager _textureManager;
-
-	private float _surfaceAspectRatio;
-	
-	private IntBuffer _scratchIntBuffer;
-	private FloatBuffer _scratchFloatBuffer;
-	private boolean _scratchB;
-	
-
-	// stats-related
-	public static final int FRAMERATE_SAMPLEINTERVAL_MS = 1000; 
-	private boolean _logFps = false;
-	private long _frameCount = 0;
-	private float _fps = 0;
-	private long _timeLastSample;
-	private ActivityManager _activityManager;
-	private ActivityManager.MemoryInfo _memoryInfo;
-
-
-	public Renderer(Scene $scene)
-	{
-		_scene = $scene;
-
-		_scratchIntBuffer = IntBuffer.allocate(4);
-		_scratchFloatBuffer = FloatBuffer.allocate(4);
-		
-		_textureManager = new TextureManager();
-		Shared.textureManager(_textureManager); 
-		
-		_activityManager = (ActivityManager) Shared.context().getSystemService( Context.ACTIVITY_SERVICE );
-		_memoryInfo = new ActivityManager.MemoryInfo();
-	}
-
-	public void onSurfaceCreated(GL10 $gl, EGLConfig eglConfig) 
-	{
-		Log.i(Min3d.TAG, "Renderer.onSurfaceCreated()");
-
-		RenderCaps.setRenderCaps($gl);
-
-		setGl($gl);
-
-		reset();
-		
-		_scene.init();
-	}
-
-	public void clearScene()
-	{
-		_scene.clear();
-	}
-
-	public void onSurfaceChanged(GL10 gl, int w, int h) 
-	{
-		Log.i(Min3d.TAG, "Renderer.onSurfaceChanged()");
-
-		Log.i("-----", "Renderer.onSurfaceChanged()");
-
-		setGl(_gl);
-		_surfaceAspectRatio = (float)w / (float)h;
-		
-		_gl.glViewport(0, 0, w, h);
-		_gl.glMatrixMode(GL10.GL_PROJECTION);
-		_gl.glLoadIdentity();
-		updateViewFrustrum();
-	}
-	
-	public void onDrawFrame(GL10 gl)
-	{
-		// Update 'model'
-		_scene.update();
-		
-		// Update 'view'
-		drawSetup();
-		drawScene();
-
-		if (_logFps) doFps();
-	}
-	
-	//
-	
-	/**
-	 *  Accessor to the GL object, in case anything outside this class wants to do 
-	 *  bad things with it :)
-	 */
-	public GL10 gl()
-	{
-		return _gl;
-	}
-
-	/**
-	 * Returns last sampled framerate (logFps must be set to true) 
-	 */
-	public float fps()
-	{
-		return _fps;
-	}
-	/**
-	 * Return available system memory in bytes
-	 */
-	public long availMem()
-	{
-		_activityManager.getMemoryInfo(_memoryInfo);
-		return _memoryInfo.availMem;
-	}
-	
-	protected void drawSetup()
-	{
-		// View frustrum
-		
-		if (_scene.camera().frustum.isDirty()) {
-			updateViewFrustrum();
-		}
-		 
-		// Camera 
-		
-		_gl.glMatrixMode(GL10.GL_MODELVIEW);
-		_gl.glLoadIdentity();
-
-		GLU.gluLookAt(_gl, 
-			_scene.camera().position.x,_scene.camera().position.y,_scene.camera().position.z,
-			_scene.camera().target.x,_scene.camera().target.y,_scene.camera().target.z,
-			_scene.camera().upAxis.x,_scene.camera().upAxis.y,_scene.camera().upAxis.z);
-		
-		// Background color
-		
-		if (_scene.backgroundColor().isDirty())
-		{
-			_gl.glClearColor( 
-				(float)_scene.backgroundColor().r() / 255f, 
-				(float)_scene.backgroundColor().g() / 255f, 
-				(float)_scene.backgroundColor().b() / 255f, 
-				(float)_scene.backgroundColor().a() / 255f);
-			_scene.backgroundColor().clearDirtyFlag();
-		}
-		
-		_gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
-		
-		drawSetupLights();
-		
-		// Always on:
-		_gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
-	}
-	
-	protected void drawSetupLights()
-	{
-		// GL_LIGHTS enabled/disabled based on enabledDirty list
-		for (int glIndex = 0; glIndex < NUM_GLLIGHTS; glIndex++)
-		{
-			if (_scene.lights().glIndexEnabledDirty()[glIndex] == true)
-			{
-				if (_scene.lights().glIndexEnabled()[glIndex] == true) 
-				{
-					_gl.glEnable(GL10.GL_LIGHT0 + glIndex);
-					
-					// make light's properties dirty to force update
-					_scene.lights().getLightByGlIndex(glIndex).setAllDirty();
-				} 
-				else 
-				{
-					_gl.glDisable(GL10.GL_LIGHT0 + glIndex);
-				}
-				
-				_scene.lights().glIndexEnabledDirty()[glIndex] = false; // clear dirtyflag
-			}
-		}
-		
-		// Lights' properties 
-
-		Light[] lights = _scene.lights().toArray();
-		for (int i = 0; i < lights.length; i++)
-		{
-			Light light = lights[i];
-			
-			if (light.isDirty()) // .. something has changed
-			{
-				// Check all of Light's properties for dirty 
-				
-				int glLightId = GL10.GL_LIGHT0 + _scene.lights().getGlIndexByLight(light);
-				
-				if (light.position.isDirty())
-				{
-					light.commitPositionAndTypeBuffer();
-					_gl.glLightfv(glLightId, GL10.GL_POSITION, light._positionAndTypeBuffer);
-					light.position.clearDirtyFlag();
-				}
-				if (light.ambient.isDirty()) 
-				{
-					light.ambient.commitToFloatBuffer();
-					_gl.glLightfv(glLightId, GL10.GL_AMBIENT, light.ambient.floatBuffer());
-					light.ambient.clearDirtyFlag();
-				}
-				if (light.diffuse.isDirty()) 
-				{
-					light.diffuse.commitToFloatBuffer();
-					_gl.glLightfv(glLightId, GL10.GL_DIFFUSE, light.diffuse.floatBuffer());
-					light.diffuse.clearDirtyFlag();
-				}
-				if (light.specular.isDirty())
-				{
-					light.specular.commitToFloatBuffer();
-					_gl.glLightfv(glLightId, GL10.GL_SPECULAR, light.specular.floatBuffer());
-					light.specular.clearDirtyFlag();
-				}
-				if (light.emissive.isDirty())
-				{
-					light.emissive.commitToFloatBuffer();
-					_gl.glLightfv(glLightId, GL10.GL_EMISSION, light.emissive.floatBuffer());
-					light.emissive.clearDirtyFlag();
-				}
-
-				if (light.direction.isDirty())
-				{
-					light.direction.commitToFloatBuffer();
-					_gl.glLightfv(glLightId, GL10.GL_SPOT_DIRECTION, light.direction.floatBuffer());
-					light.direction.clearDirtyFlag();
-				}
-				if (light._spotCutoffAngle.isDirty())
-				{
-					_gl.glLightf(glLightId, GL10.GL_SPOT_CUTOFF, light._spotCutoffAngle.get());
-				}
-				if (light._spotExponent.isDirty())
-				{
-					_gl.glLightf(glLightId, GL10.GL_SPOT_EXPONENT, light._spotExponent.get());
-				}
-
-				if (light._isVisible.isDirty()) 
-				{
-					if (light.isVisible()) {
-						_gl.glEnable(glLightId);
-					} else {
-						_gl.glDisable(glLightId);
-					}
-					light._isVisible.clearDirtyFlag();
-				}
-
-				if (light._attenuation.isDirty())
-				{
-					_gl.glLightf(glLightId, GL10.GL_CONSTANT_ATTENUATION, light._attenuation.getX());
-					_gl.glLightf(glLightId, GL10.GL_LINEAR_ATTENUATION, light._attenuation.getY());
-					_gl.glLightf(glLightId, GL10.GL_QUADRATIC_ATTENUATION, light._attenuation.getZ());
-				}
-				
-				light.clearDirtyFlag();
-			}
-		}
-	}
-
-	protected void drawScene()
-	{
-		if(_scene.fogEnabled() == true) {
-			_gl.glFogf(GL10.GL_FOG_MODE, _scene.fogType().glValue());
-			_gl.glFogf(GL10.GL_FOG_START, _scene.fogNear());
-			_gl.glFogf(GL10.GL_FOG_END, _scene.fogFar());
-			_gl.glFogfv(GL10.GL_FOG_COLOR, _scene.fogColor().toFloatBuffer() );
-			_gl.glEnable(GL10.GL_FOG);
-		} else {
-			_gl.glDisable(GL10.GL_FOG);
-		}
-
-		for (int i = 0; i < _scene.children().size(); i++)
-		{
-			Object3d o = _scene.children().get(i);
-			if(o.animationEnabled())
-			{
-				((AnimationObject3d)o).update();
-			}
-			drawObject(o);
-		}
-	}
-	
-	//boolean customResult = o.customRenderer(_gl); 
-	//if (customResult) return;
-
-
-	protected void drawObject(Object3d $o)
-	{
-		if ($o.isVisible() == false) return;		
-
-		// Various per-object settings:
-		
-		// Normals
-
-		if ($o.hasNormals() && $o.normalsEnabled()) {
-			$o.vertices().normals().buffer().position(0);
-			_gl.glNormalPointer(GL10.GL_FLOAT, 0, $o.vertices().normals().buffer());
-			_gl.glEnableClientState(GL10.GL_NORMAL_ARRAY);
-		}
-		else {
-			_gl.glDisableClientState(GL10.GL_NORMAL_ARRAY);
-		}
-		
-		// Is lighting enabled for object...
-		
-		/*
-		// *** this version not working properly on emulator - why not? ***
-		_scratchIntBuffer.position(0);
-		_gl.glGetIntegerv(GL10.GL_LIGHTING, _scratchIntBuffer);
-		if (useLighting != _scratchIntBuffer.get(0))
-		{
-			if (useLighting == 1) {
-				_gl.glEnable(GL10.GL_LIGHTING);
-			} else {
-				_gl.glDisable(GL10.GL_LIGHTING);
-			}
-		}
-		*/
-		
-		boolean useLighting = (_scene.lightingEnabled() && $o.hasNormals() && $o.normalsEnabled() && $o.lightingEnabled());
-		if (useLighting) {
-			_gl.glEnable(GL10.GL_LIGHTING);
-		} else {
-			_gl.glDisable(GL10.GL_LIGHTING);
-		}
-		
-		// Shademodel
-		
-		_gl.glGetIntegerv(GL11.GL_SHADE_MODEL, _scratchIntBuffer);
-		if ($o.shadeModel().glConstant() != _scratchIntBuffer.get(0)) {
-			_gl.glShadeModel($o.shadeModel().glConstant());
-		}
-		
-		// Colors: either per-vertex, or per-object
-
-		if ($o.hasVertexColors() && $o.vertexColorsEnabled()) {
-			$o.vertices().colors().buffer().position(0);
-			_gl.glColorPointer(4, GL10.GL_UNSIGNED_BYTE, 0, $o.vertices().colors().buffer());
-			_gl.glEnableClientState(GL10.GL_COLOR_ARRAY); 
-		}
-		else {
-			_gl.glColor4f(
-				(float)$o.defaultColor().r / 255f, 
-				(float)$o.defaultColor().g / 255f, 
-				(float)$o.defaultColor().b / 255f, 
-				(float)$o.defaultColor().a / 255f
-			);
-			_gl.glDisableClientState(GL10.GL_COLOR_ARRAY);
-		}
-		
-		// Colormaterial
-		
-		_gl.glGetIntegerv(GL10.GL_COLOR_MATERIAL, _scratchIntBuffer);
-		_scratchB = (_scratchIntBuffer.get(0) != 0);
-		if ($o.colorMaterialEnabled() != _scratchB) {
-			if ($o.colorMaterialEnabled())
-				_gl.glEnable(GL10.GL_COLOR_MATERIAL);
-			else
-				_gl.glDisable(GL10.GL_COLOR_MATERIAL);
-		}
-		
-		// Point size
-		
-		if ($o.renderType() == RenderType.POINTS) 
-		{
-			if ($o.pointSmoothing()) 
-				_gl.glEnable(GL10.GL_POINT_SMOOTH);
-			else
-				_gl.glDisable(GL10.GL_POINT_SMOOTH);
-			
-			_gl.glPointSize($o.pointSize());
-		}
-
-		// Line properties
-		
-		if ($o.renderType() == RenderType.LINES || $o.renderType() == RenderType.LINE_STRIP || $o.renderType() == RenderType.LINE_LOOP) 
-		{
-			if ( $o.lineSmoothing() == true) {
-				_gl.glEnable(GL10.GL_LINE_SMOOTH);
-			}
-			else {
-				_gl.glDisable(GL10.GL_LINE_SMOOTH);
-			}
-
-			_gl.glLineWidth($o.lineWidth());
-		}
-
-		// Backface culling 
-		
-		if ($o.doubleSidedEnabled()) {
-		    _gl.glDisable(GL10.GL_CULL_FACE);
-		} 
-		else {
-		    _gl.glEnable(GL10.GL_CULL_FACE);
-		}
-		
-
-		drawObject_textures($o);
-
-		
-		// Matrix operations in modelview
-
-		_gl.glPushMatrix();
-
-
-		_gl.glTranslatef($o.position().x, $o.position().y, $o.position().z);
-		_gl.glRotatef($o.rotation().x, 1,0,0);
-		_gl.glRotatef($o.rotation().y, 0,1,0);
-		_gl.glRotatef($o.rotation().z, 0,0,1);
-
-		_gl.glScalef($o.scale().x, $o.scale().y, $o.scale().z);
-		
-		// Draw
-
-		$o.vertices().points().buffer().position(0);
-		_gl.glVertexPointer(3, GL10.GL_FLOAT, 0, $o.vertices().points().buffer());
-
-		if (! $o.ignoreFaces())
-		{
-			int pos, len;
-			
-			if (! $o.faces().renderSubsetEnabled()) {
-				pos = 0;
-				len = $o.faces().size();
-			}
-			else {
-				pos = $o.faces().renderSubsetStartIndex() * FacesBufferedList.PROPERTIES_PER_ELEMENT;
-				len = $o.faces().renderSubsetLength();
-			}
-
-			$o.faces().buffer().position(pos);
-
-			_gl.glDrawElements(
-					$o.renderType().glValue(),
-					len * FacesBufferedList.PROPERTIES_PER_ELEMENT, 
-					GL10.GL_UNSIGNED_SHORT, 
-					$o.faces().buffer());
-		}
-		else
-		{
-			_gl.glDrawArrays($o.renderType().glValue(), 0, $o.vertices().size());
-		}
-		
-		//
-		// Recurse on children
-		//
-		
-		if ($o instanceof Object3dContainer)
-		{
-			Object3dContainer container = (Object3dContainer)$o;
-			
-			for (int i = 0; i < container.children().size(); i++)
-			{
-				Object3d o = container.children().get(i);
-				drawObject(o);
-			}
-		}
-		
-		// Restore matrix
-		
-		_gl.glPopMatrix();
-	}
-	
-	private void drawObject_textures(Object3d $o)
-	{
-		// iterate thru object's textures
-		
-		for (int i = 0; i < RenderCaps.maxTextureUnits(); i++)
-		{
-			_gl.glActiveTexture(GL10.GL_TEXTURE0 + i);
-			_gl.glClientActiveTexture(GL10.GL_TEXTURE0 + i); 
-
-			if ($o.hasUvs() && $o.texturesEnabled())
-			{
-				$o.vertices().uvs().buffer().position(0);
-				_gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, $o.vertices().uvs().buffer());
-
-				TextureVo textureVo = ((i < $o.textures().size())) ? textureVo = $o.textures().get(i) : null;
-
-				if (textureVo != null)
-				{
-					// activate texture
-					int glId = _textureManager.getGlTextureId(textureVo.textureId);
-					_gl.glBindTexture(GL10.GL_TEXTURE_2D, glId);
-				    _gl.glEnable(GL10.GL_TEXTURE_2D);
-					_gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
-
-					int minFilterType = _textureManager.hasMipMap(textureVo.textureId) ? GL10.GL_LINEAR_MIPMAP_NEAREST : GL10.GL_NEAREST; 
-					_gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, minFilterType);
-					_gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); // (OpenGL default)
-					
-					// do texture environment settings
-					for (int j = 0; j < textureVo.textureEnvs.size(); j++)
-					{
-						_gl.glTexEnvx(GL10.GL_TEXTURE_ENV, textureVo.textureEnvs.get(j).pname, textureVo.textureEnvs.get(j).param);
-					}
-					
-					// texture wrapping settings
-					_gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_S, (textureVo.repeatU ? GL10.GL_REPEAT : GL10.GL_CLAMP_TO_EDGE));
-					_gl.glTexParameterx(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_WRAP_T, (textureVo.repeatV ? GL10.GL_REPEAT : GL10.GL_CLAMP_TO_EDGE));		
-
-					// texture offset, if any
-					if (textureVo.offsetU != 0 || textureVo.offsetV != 0)
-					{
-						_gl.glMatrixMode(GL10.GL_TEXTURE);
-						_gl.glLoadIdentity();
-						_gl.glTranslatef(textureVo.offsetU, textureVo.offsetV, 0);
-						_gl.glMatrixMode(GL10.GL_MODELVIEW); // .. restore matrixmode
-					}
-				}
-				else
-				{
-					_gl.glBindTexture(GL10.GL_TEXTURE_2D, 0);
-				    _gl.glDisable(GL10.GL_TEXTURE_2D);
-					_gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
-				}
-			}
-			else
-			{
-				_gl.glBindTexture(GL10.GL_TEXTURE_2D, 0);
-			    _gl.glDisable(GL10.GL_TEXTURE_2D);
-				_gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
-			}
-		}
-	}
-	
-	/**
-	 * Used by TextureManager
-	 */
-	int uploadTextureAndReturnId(Bitmap $bitmap, boolean $generateMipMap) /*package-private*/
-	{
-		int glTextureId;
-		
-		int[] a = new int[1];
-		_gl.glGenTextures(1, a, 0); // create a 'texture name' and put it in array element 0
-		glTextureId = a[0];
-		_gl.glBindTexture(GL10.GL_TEXTURE_2D, glTextureId);
-		
-		if($generateMipMap && _gl instanceof GL11) {
-			_gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_GENERATE_MIPMAP, GL11.GL_TRUE);
-		} else {
-			_gl.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_GENERATE_MIPMAP, GL11.GL_FALSE);
-		}
-
-		// 'upload' to gpu
-		GLUtils.texImage2D(GL10.GL_TEXTURE_2D, 0, $bitmap, 0);
-		
-		return glTextureId;
-	}
-	
-
-	/**
-	 * Used by TextureManager
-	 */
-	void deleteTexture(int $glTextureId) /*package-private*/
-	{
-		int[] a = new int[1];
-		a[0] = $glTextureId;
-		_gl.glDeleteTextures(1, a, 0);
-	}
-	
-	protected void updateViewFrustrum()
-	{
-		FrustumManaged vf = _scene.camera().frustum;
-		float n = vf.shortSideLength() / 2f;
-
-		float lt, rt, btm, top;
-		
-		lt  = vf.horizontalCenter() - n*_surfaceAspectRatio;
-		rt  = vf.horizontalCenter() + n*_surfaceAspectRatio;
-		btm = vf.verticalCenter() - n*1; 
-		top = vf.verticalCenter() + n*1;
-
-		if (_surfaceAspectRatio > 1) {
-			lt *= 1f/_surfaceAspectRatio;
-			rt *= 1f/_surfaceAspectRatio;
-			btm *= 1f/_surfaceAspectRatio;
-			top *= 1f/_surfaceAspectRatio;
-		}
-		
-		_gl.glMatrixMode(GL10.GL_PROJECTION);
-		_gl.glLoadIdentity();
-		_gl.glFrustumf(lt,rt, btm,top, vf.zNear(), vf.zFar());
-		
-		vf.clearDirtyFlag();
-	}
-
-	/**
-	 * If true, framerate and memory is periodically calculated and Log'ed,
-	 * and gettable thru fps() 
-	 */
-	public void logFps(boolean $b)
-	{
-		_logFps = $b;
-		
-		if (_logFps) { // init
-			_timeLastSample = System.currentTimeMillis();
-			_frameCount = 0;
-		}
-	}
-	
-	private void setGl(GL10 $gl)
-	{
-		_gl = $gl;
-
-	}
-	
-	private void doFps()
-	{
-		_frameCount++;
-
-		long now = System.currentTimeMillis();
-		long delta = now - _timeLastSample;
-		if (delta >= FRAMERATE_SAMPLEINTERVAL_MS)
-		{
-			_fps = _frameCount / (delta/1000f); 
-
-			_activityManager.getMemoryInfo(_memoryInfo);
-			Log.v(Min3d.TAG, "FPS: " + Math.round(_fps) + ", availMem: " + Math.round(_memoryInfo.availMem/1048576) + "MB");
-
-			_timeLastSample = now;
-			_frameCount = 0;
-		}
-	}
-	
-	private void reset()
-	{
-		// Reset TextureManager
-		Shared.textureManager().reset();
-
-		// Do OpenGL settings which we are using as defaults, or which we will not be changing on-draw
-		
-	    // Explicit depth settings
-		_gl.glEnable(GL10.GL_DEPTH_TEST);									
-		_gl.glClearDepthf(1.0f);
-		_gl.glDepthFunc(GL10.GL_LESS);										
-		_gl.glDepthRangef(0,1f);											
-		_gl.glDepthMask(true);												
-
-		// Alpha enabled
-		_gl.glEnable(GL10.GL_BLEND);										
-		_gl.glBlendFunc(GL10.GL_SRC_ALPHA, GL10.GL_ONE_MINUS_SRC_ALPHA); 	
-		
-		// "Transparency is best implemented using glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) 
-		// with primitives sorted from farthest to nearest."
-
-		// Texture
-		_gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MIN_FILTER, GL10.GL_NEAREST); // (OpenGL default is GL_NEAREST_MIPMAP)
-		_gl.glTexParameterf(GL10.GL_TEXTURE_2D, GL10.GL_TEXTURE_MAG_FILTER, GL10.GL_LINEAR); // (is OpenGL default)
-		
-		// CCW frontfaces only, by default
-		_gl.glFrontFace(GL10.GL_CCW);
-	    _gl.glCullFace(GL10.GL_BACK);
-	    _gl.glEnable(GL10.GL_CULL_FACE);
-	    
-	    // Disable lights by default
-	    for (int i = GL10.GL_LIGHT0; i < GL10.GL_LIGHT0 + NUM_GLLIGHTS; i++) {
-	    	_gl.glDisable(i);
-	    }
-
-		//
-		// Scene object init only happens here, when we get GL for the first time
-		//
-	}
-}

+ 0 - 218
app/src/main/java/min3d/core/RendererActivity.java

@@ -1,218 +0,0 @@
-package min3d.core;
-
-import min3d.Shared;
-import min3d.interfaces.ISceneController;
-import android.app.Activity;
-import android.graphics.PixelFormat;
-import android.opengl.GLSurfaceView;
-import android.os.Bundle;
-import android.os.Handler;
-import android.util.Log;
-import android.view.MotionEvent;
-import android.view.View;
-
-/**
- * Extend this class when creating your min3d-based Activity. 
- * Then, override initScene() and updateScene() for your main
- * 3D logic.
- * 
- * Override onCreateSetContentView() to change layout, if desired.
- * 
- * To update 3d scene-related variables from within the the main UI thread,  
- * override onUpdateScene() and onUpdateScene() as needed.
- */
-public class RendererActivity extends Activity implements ISceneController, View.OnTouchListener
-{
-	public Scene scene;
-	public Renderer mRender;
-	protected GLSurfaceView _glSurfaceView;
-	
-	protected Handler _initSceneHander;
-	protected Handler _updateSceneHander;
-	
-    private boolean _renderContinuously;
-    protected float mPreviousX;
-	protected float mPreviousY;
-
-	final Runnable _initSceneRunnable = new Runnable() 
-	{
-        public void run() {
-            onInitScene();
-        }
-    };
-    
-	final Runnable _updateSceneRunnable = new Runnable() 
-    {
-        public void run() {
-            onUpdateScene();
-        }
-    };
-    
-
-	public void initStatic(Activity a)
-	{
-		Shared.context(a);
-		scene = new Scene(null);
-		mRender= new Renderer(scene);
-		Shared.renderer(mRender);
-	}
-
-    @Override
-	protected void onCreate(Bundle savedInstanceState) 
-	{
-		super.onCreate(savedInstanceState);
-
-		_initSceneHander = new Handler();
-		_updateSceneHander = new Handler();
-		
-		//
-		// These 4 lines are important.
-		//
-		_glSurfaceView = new GLSurfaceView(this);
-
-		_glSurfaceView.setZOrderOnTop(true);
-		_glSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 16, 0);
-		_glSurfaceView.getHolder().setFormat(PixelFormat.RGBA_8888);
-		_glSurfaceView.setOnTouchListener(this);
-
-		//ici
-		Shared.context(this);
-		//scene.sceneController(this);
-		scene = new Scene(this);
-		mRender= new Renderer(scene);
-		Shared.renderer(mRender);
-
-        glSurfaceViewConfig();
-		_glSurfaceView.setRenderer(mRender);
-		//_glSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
-		_glSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
-
-        onCreateSetContentView();
-	}
-    
-    /**
-     * Any GlSurfaceView settings that needs to be executed before 
-     * GLSurfaceView.setRenderer() can be done by overriding this method. 
-     * A couple examples are included in comments below.
-     */
-    protected void glSurfaceViewConfig()
-    {
-	    // Example which makes glSurfaceView transparent (along with setting scene.backgroundColor to 0x0)
-		_glSurfaceView.setZOrderOnTop(true);
-	     _glSurfaceView.setEGLConfigChooser(8,8,8,8, 16, 0);
-	     _glSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT); _glSurfaceView.getHolder().setFormat( PixelFormat.RGB_565 );
-
-
-		// Example of enabling logging of GL operations 
-		// _glSurfaceView.setDebugFlags(GLSurfaceView.DEBUG_CHECK_GL_ERROR | GLSurfaceView.DEBUG_LOG_GL_CALLS);
-    }
-	
-	protected GLSurfaceView glSurfaceView()
-	{
-		return _glSurfaceView;
-	}
-	
-	/**
-	 * Separated out for easier overriding...
-	 */
-	protected void onCreateSetContentView()
-	{
-		setContentView(_glSurfaceView);
-	}
-	
-	@Override
-	protected void onResume() 
-	{
-		super.onResume();
-		mRender.clearScene();
-		_glSurfaceView.onResume();
-	}
-	
-	@Override
-	protected void onPause() 
-	{
-		super.onPause();
-		mRender.clearScene();
-		_glSurfaceView.onPause();
-	}
-
-	/**
-	 * Instantiation of Object3D's, setting their properties, and adding Object3D's 
-	 * to the scene should be done here. Or any point thereafter.
-	 * 
-	 * Note that this method is always called after GLCanvas is created, which occurs
-	 * not only on Activity.onCreate(), but on Activity.onResume() as well.
-	 * It is the user's responsibility to build the logic to restore state on-resume.
-	 */
-	public void initScene()
-	{
-	}
-
-	/**
-	 * All manipulation of scene and Object3D instance properties should go here.
-	 * Gets called on every frame, right before rendering.   
-	 */
-	public void updateScene()
-	{
-	}
-	
-    /**
-     * Called _after_ scene init (ie, after initScene).
-     * Unlike initScene(), gets called from the UI thread.
-     */
-    public void onInitScene()
-    {
-    }
-    
-    /**
-     * Called _after_ updateScene()
-     * Unlike initScene(), gets called from the UI thread.
-     */
-    public void onUpdateScene()
-    {
-    }
-    
-    /**
-     * Setting this to false stops the render loop, and initScene() and onInitScene() will no longer fire.
-     * Setting this to true resumes it. 
-     */
-    public void renderContinuously(boolean $b)
-    {
-    	_renderContinuously = $b;
-    	if (_renderContinuously)
-    		_glSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_CONTINUOUSLY);
-    	
-    	else
-    		_glSurfaceView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
-    }
-    
-	public Handler getInitSceneHandler()
-	{
-		return _initSceneHander;
-	}
-	
-	public Handler getUpdateSceneHandler()
-	{
-		return _updateSceneHander;
-	}
-
-    public Runnable getInitSceneRunnable()
-    {
-    	return _initSceneRunnable;
-    }
-	
-    public Runnable getUpdateSceneRunnable()
-    {
-    	return _updateSceneRunnable;
-    }
-
-	@Override
-	public boolean onTouch(View view, MotionEvent motionEvent) {
-		return true;
-	}
-
-	public void setOnToucheListener(View.OnTouchListener d)
-	{
-		_glSurfaceView.setOnTouchListener(d);
-	}
-}

+ 0 - 297
app/src/main/java/min3d/core/Scene.java

@@ -1,297 +0,0 @@
-package min3d.core;
-
-import java.util.ArrayList;
-
-import min3d.Min3d;
-import min3d.interfaces.IDirtyParent;
-import min3d.interfaces.IObject3dContainer;
-import min3d.interfaces.ISceneController;
-import min3d.vos.CameraVo;
-import min3d.vos.Color4;
-import min3d.vos.Color4Managed;
-import min3d.vos.FogType;
-import android.util.Log;
-
-
-public class Scene implements IObject3dContainer, IDirtyParent
-{
-	private ArrayList<Object3d> _children = new ArrayList<Object3d>();
-
-	private ManagedLightList _lights;
-	private CameraVo _camera;
-	
-	private Color4Managed _backgroundColor;
-	private boolean _lightingEnabled;
-	
-	private Color4 _fogColor;
-	private float _fogFar;
-	private float _fogNear;
-	private FogType _fogType;
-	private boolean _fogEnabled;
-
-	private ISceneController _sceneController;
-	
-
-	public Scene(ISceneController $sceneController) 
-	{
-		_sceneController = $sceneController;
-		_lights = new ManagedLightList();
-		_fogColor = new Color4(255, 255, 255, 255);
-		_fogNear = 0;
-		_fogFar = 10;
-		_fogType = FogType.LINEAR;
-		_fogEnabled = false;
-	}
-
-	/**
-	 * Allows you to use any Class implementing ISceneController
-	 * to drive the Scene...
-	 * @return
-	 */
-	public ISceneController sceneController()
-	{
-		return _sceneController;
-	}
-	public void sceneController(ISceneController $sceneController)
-	{
-		_sceneController = $sceneController;
-	}
-	
-	//
-	
-	/**
-	 * Resets Scene to default settings.
-	 * Removes and clears any attached Object3ds.
-	 * Resets light list.
-	 */
-	public void reset()
-	{
-		clearChildren(this);
-
-		_children = new ArrayList<Object3d>();
-
-		_camera = new CameraVo();
-		
-		_backgroundColor = new Color4Managed(0,0,0,255, this);
-		
-		_lights = new ManagedLightList();
-		
-		lightingEnabled(true);
-	}
-	
-	/**
-	 * Adds Object3d to Scene. Object3d's must be added to Scene in order to be rendered
-	 * Returns always true. 
-	 */
-	public void addChild(Object3d $o)
-	{
-		if (_children.contains($o)) return;
-		
-		_children.add($o);
-		
-		$o.parent(this);
-		$o.scene(this);
-	}
-
-	public void clear()
-	{
-		_children.clear();
-	}
-	
-	public void addChildAt(Object3d $o, int $index)
-	{
-		if (_children.contains($o)) return;
-
-		_children.add($index, $o);
-	}
-	
-	/**
-	 * Removes Object3d from Scene.
-	 * Returns false if unsuccessful
-	 */
-	public boolean removeChild(Object3d $o)
-	{
-		$o.parent(null);
-		$o.scene(null);
-		return _children.remove($o);
-	}
-	
-	public Object3d removeChildAt(int $index)
-	{
-		Object3d o = _children.remove($index);
-		
-		if (o != null) {
-			o.parent(null);
-			o.scene(null);
-		}
-		return o;
-	}
-	
-	public Object3d getChildAt(int $index)
-	{
-		return _children.get($index);
-	}
-	
-	/**
-	 * TODO: Use better lookup 
-	 */
-	public Object3d getChildByName(String $name)
-	{
-		for (int i = 0; i < _children.size(); i++)
-		{
-			if (_children.get(0).name() == $name) return _children.get(0); 
-		}
-		return null;
-	}
-	
-	public int getChildIndexOf(Object3d $o)
-	{
-		return _children.indexOf($o);
-	}
-	
-	public int numChildren()
-	{
-		return _children.size();
-	}
-
-	/**
-	 * Scene's camera
-	 */
-	public CameraVo camera()
-	{
-		return _camera;
-	}
-	public void camera(CameraVo $camera)
-	{
-		_camera = $camera;
-	}
-	
-	/**
-	 * Scene instance's background color
-	 */
-	public Color4Managed backgroundColor()
-	{
-		return _backgroundColor;
-	}
-
-	/**
-	 * Lights used by the Scene 
-	 */
-	public ManagedLightList lights()
-	{
-		return _lights;
-	}
-
-	/**
-	 * Determines if lighting is enabled for Scene. 
-	 */
-	public boolean lightingEnabled()
-	{
-		return _lightingEnabled;
-	}
-	
-	public void lightingEnabled(boolean $b)
-	{
-		_lightingEnabled = $b;
-	}
-	
-	//
-
-	/*
-	public boolean backgroundTransparent() {
-		return _backgroundTransparent;
-	}
-
-	public void backgroundTransparent(boolean backgroundTransparent) {
-		this._backgroundTransparent = backgroundTransparent;
-	}
-	*/
-
-	public Color4 fogColor() {
-		return _fogColor;
-	}
-
-	public void fogColor(Color4 _fogColor) {
-		this._fogColor = _fogColor;
-	}
-
-	public float fogFar() {
-		return _fogFar;
-	}
-
-	public void fogFar(float _fogFar) {
-		this._fogFar = _fogFar;
-	}
-
-	public float fogNear() {
-		return _fogNear;
-	}
-
-	public void fogNear(float _fogNear) {
-		this._fogNear = _fogNear;
-	}
-
-	public FogType fogType() {
-		return _fogType;
-	}
-
-	public void fogType(FogType _fogType) {
-		this._fogType = _fogType;
-	}
-
-	public boolean fogEnabled() {
-		return _fogEnabled;
-	}
-
-	public void fogEnabled(boolean _fogEnabled) {
-		this._fogEnabled = _fogEnabled;
-	}
-
-	/**
-	 * Used by Renderer 
-	 */
-	void init() /*package-private*/ 
-	{
-		Log.i(Min3d.TAG, "Scene.init()");
-		
-		this.reset();
-		
-		_sceneController.initScene();
-		_sceneController.getInitSceneHandler().post(_sceneController.getInitSceneRunnable());
-	}
-	
-	void update()
-	{
-		_sceneController.updateScene();
-		_sceneController.getUpdateSceneHandler().post(_sceneController.getUpdateSceneRunnable());
-	}
-	
-	/**
-	 * Used by Renderer 
-	 */
-	ArrayList<Object3d> children() /*package-private*/ 
-	{
-		return _children;
-	}
-	
-	private void clearChildren(IObject3dContainer $c)
-	{
-		for (int i = $c.numChildren() - 1; i >= 0; i--)
-		{
-			Object3d o = $c.getChildAt(i);
-			o.clear();
-			
-			if (o instanceof Object3dContainer)
-			{
-				clearChildren((Object3dContainer)o);
-			}
-		}
-	}	
-	
-	public void onDirty()
-	{
-		//
-	}
-
-
-}

+ 0 - 155
app/src/main/java/min3d/core/TextureList.java

@@ -1,155 +0,0 @@
-package min3d.core;
-
-import java.util.ArrayList;
-
-import min3d.Shared;
-import min3d.vos.TextureVo;
-
-/**
- * Manages a list of TextureVo's used by Object3d's.
- * This allows an Object3d to use multiple textures. 
- * 
- * If more textures are added than what's supported by the hardware  
- * running the application, the extra items are ignored by Renderer
- * 
- * Uses a subset of ArrayList's methods. 
- */
-public class TextureList  
-{
-	private ArrayList<TextureVo> _t;
-	
-	
-	public TextureList()
-	{
-		_t = new ArrayList<TextureVo>();
-	}
-	
-	/**
-	 * Adds item to the list 
-	 */
-	public boolean add(TextureVo $texture)
-	{
-		if (! Shared.textureManager().contains($texture.textureId)) return false;
-		return _t.add($texture);
-	}
-	
-	/**
-	 * Adds item at the given position to the list 
-	 */
-	public void add(int $index, TextureVo $texture)
-	{
-		_t.add($index, $texture);
-	}
-	
-	/**
-	 * Adds a new TextureVo with the given textureId to the list, and returns that textureVo  
-	 */
-	public TextureVo addById(String $textureId)
-	{
-		if (! Shared.textureManager().contains($textureId)) {
-			throw new Error("Could not create TextureVo using textureId \"" + $textureId + "\". TextureManager does not contain that id.");
-		}
-		
-		TextureVo t = new TextureVo($textureId);
-		_t.add(t);
-		return t;
-	}
-	
-	/**
-	 * Adds texture as the sole item in the list, replacing any existing items  
-	 */
-	public boolean addReplace(TextureVo $texture)
-	{
-		_t.clear();
-		return _t.add($texture);
-	}
-	
-	/**
-	 * Removes item from the list 
-	 */
-	public boolean remove(TextureVo $texture)
-	{
-		return _t.remove($texture);
-	}
-	
-	/**
-	 * Removes item with the given textureId from the list 
-	 */
-	public boolean removeById(String $textureId)
-	{
-		TextureVo t = this.getById($textureId);
-		if (t == null) {
-			throw new Error("No match in TextureList for id \"" + $textureId + "\"");
-		}
-		return _t.remove(t);
-	}
-	
-	public void removeAll()
-	{
-		for (int i = 0; i < _t.size(); i++)
-			_t.remove(0);
-	}
-	
-	/**
-	 * Get item from the list which is at the given index position 
-	 */
-	public TextureVo get(int $index)
-	{
-		return _t.get($index);
-	}
-	
-	/**
-	 * Gets item from the list which has the given textureId
-	 */
-	public TextureVo getById(String $textureId)
-	{
-		for (int i = 0; i < _t.size(); i++) {
-			String s = _t.get(i).textureId;
-			if ($textureId == s) {
-				TextureVo t = _t.get(i);
-				return t;
-			}
-		}
-		return null;
-	}
-	
-	public int size()
-	{
-		return _t.size();
-	}
-	
-	public void clear()
-	{
-		_t.clear();
-	}
-	
-	/**
-	 * Return a TextureVo array of TextureList's items 
-	 */
-	public TextureVo[] toArray()
-	{
-		Object[] a = _t.toArray();
-		TextureVo[] ret = new TextureVo[a.length];
-		for (int i = 0; i < _t.size(); i++)
-		{
-			ret[i] = (TextureVo)_t.get(i);
-		}
-		return ret;
-	}
-	
-	/**
-	 * Returns a String Array of the textureIds of each of the items in the list 
-	 */
-	public String[] getIds()
-	{
-		// BTW this makes a casting error. Why?
-		// (TextureVo[])_t.toArray();
-
-		String[] a = new String[_t.size()];
-		for (int i = 0; i < _t.size(); i++)
-		{
-			a[i] = _t.get(i).textureId;
-		}
-		return a;
-	}
-}

+ 0 - 165
app/src/main/java/min3d/core/TextureManager.java

@@ -1,165 +0,0 @@
-package min3d.core;
-
-import java.util.HashMap;
-import java.util.Set;
-
-import min3d.Min3d;
-import min3d.Shared;
-import android.graphics.Bitmap;
-import android.util.Log;
-
-/**
- * TextureManager is responsible for managing textures for the whole environment. 
- * It maintains a list of id's that are mapped to the GL texture names (id's).
- * 
- * You add a Bitmap to the TextureManager, which adds a textureId to its list.
- * Then, you assign one or more TextureVo's to your Object3d's using id's that 
- * exist in the TextureManager.
- * 
- * Note that the _idToTextureName and _idToHasMipMap HashMaps used below
- * don't test for exceptions. 
- */
-public class TextureManager 
-{
-	private HashMap<String, Integer> _idToTextureName;
-	private HashMap<String, Boolean> _idToHasMipMap;
-	private static int _counter = 1000001;
-	private static int _atlasId = 0;
-	
-	
-	public TextureManager()
-	{
-		reset();
-	}
-
-	public void reset()
-	{
-		// Delete any extant textures
-
-		if (_idToTextureName != null) 
-		{
-			Set<String> s = _idToTextureName.keySet();
-			Object[] a = s.toArray(); 
-			for (int i = 0; i < a.length; i++) {
-				int glId = getGlTextureId((String)a[i]);
-				Shared.renderer().deleteTexture(glId);
-			}
-			// ...pain
-		}
-		
-		_idToTextureName = new HashMap<String, Integer>();
-		_idToHasMipMap = new HashMap<String, Boolean>();
-	}
-
-	/**
-	 * 'Uploads' a texture via OpenGL which is mapped to a textureId to the TextureManager, 
-	 * which can subsequently be used to assign textures to Object3d's. 
-	 * 
-	 * @return The textureId as added to TextureManager, which is identical to $id 
-	 */
-	public String addTextureId(Bitmap $b, String $id, boolean $generateMipMap)
-	{
-		if (_idToTextureName.containsKey($id)) throw new Error("Texture id \"" + $id + "\" already exists."); 
-
-		int glId = Shared.renderer().uploadTextureAndReturnId($b, $generateMipMap);
-
-		String s = $id;
-		_idToTextureName.put(s, glId);
-		_idToHasMipMap.put(s, $generateMipMap);
-	
-		_counter++;
-		
-		// For debugging purposes (potentially adds a lot of chatter)
-		// logContents();
-		
-		return s;
-	}
-
-	/**
-	 * Alternate signature for "addTextureId", with MIP mapping set to false by default.
-	 * Kept for API backward-compatibility. 
-	 */
-	public String addTextureId(Bitmap $b, String $id)
-	{
-		return this.addTextureId($b, $id, false);
-	}
-	
-	/**
-	 * 'Uploads' texture via OpenGL and returns an autoassigned textureId,
-	 * which can be used to assign textures to Object3d's. 
-	 */
-	public String createTextureId(Bitmap $b, boolean $generateMipMap)
-	{
-		return addTextureId($b, (_counter+""), $generateMipMap);
-	}
-	
-	/**
-	 * Deletes a textureId from the TextureManager,  
-	 * and deletes the corresponding texture from the GPU
-	 */
-	public void deleteTexture(String $textureId)
-	{
-		int glId = _idToTextureName.get($textureId);
-		Shared.renderer().deleteTexture(glId);
-		_idToTextureName.remove($textureId);
-		_idToHasMipMap.remove($textureId);
-		
-		// logContents();
-		
-		//xxx needs error check
-	}
-
-	/**
-	 * Returns a String Array of textureId's in the TextureManager 
-	 */
-	public String[] getTextureIds()
-	{
-		Set<String> set = _idToTextureName.keySet();
-		String[] a = new String[set.size()];
-		set.toArray(a);
-		return a;
-	}
-	
-	/**
-	 * Used by Renderer
-	 * 
-	 */
-	int getGlTextureId(String $textureId) /*package-private*/
-	{
-		return _idToTextureName.get($textureId);
-	}
-	
-	/**
-	 * Used by Renderer
-	 */
-	boolean hasMipMap(String $textureId) /*package-private*/
-	{
-		return _idToHasMipMap.get($textureId);
-	}
-	
-
-	public boolean contains(String $textureId)
-	{
-		return _idToTextureName.containsKey($textureId);
-	}
-	
-	
-	private String arrayToString(String[] $a)
-	{
-		String s = "";
-		for (int i = 0; i < $a.length; i++)
-		{
-			s += $a[i].toString() + " | ";
-		}
-		return s;
-	}
-	
-	private void logContents()
-	{
-		Log.v(Min3d.TAG, "TextureManager contents updated - " + arrayToString( getTextureIds() ) );		
-	}
-	
-	public String getNewAtlasId() {
-		return "atlas".concat(Integer.toString(_atlasId++));
-	}
-}

+ 0 - 137
app/src/main/java/min3d/core/UvBufferList.java

@@ -1,137 +0,0 @@
-package min3d.core;
-
-import java.nio.ByteBuffer;
-import java.nio.ByteOrder;
-import java.nio.FloatBuffer;
-
-import min3d.vos.Uv;
-
-
-public class UvBufferList 
-{
-	public static final int PROPERTIES_PER_ELEMENT = 2;
-	public static final int BYTES_PER_PROPERTY = 4;
-
-	private FloatBuffer _b;
-	private int _numElements = 0;
-	
-	public UvBufferList(FloatBuffer $b, int $size)
-	{
-		ByteBuffer bb = ByteBuffer.allocateDirect($b.limit() * BYTES_PER_PROPERTY); 
-		bb.order(ByteOrder.nativeOrder());
-		_b = bb.asFloatBuffer();
-		_b.put($b);
-		_numElements = $size;
-	}
-	
-	public UvBufferList(int $maxElements)
-	{
-		int numBytes = $maxElements * PROPERTIES_PER_ELEMENT * BYTES_PER_PROPERTY;
-		ByteBuffer bb = ByteBuffer.allocateDirect(numBytes); 
-		bb.order(ByteOrder.nativeOrder());
-		
-		_b  = bb.asFloatBuffer();
-	}
-	
-	/**
-	 * The number of items in the list. 
-	 */
-	public int size()
-	{
-		return _numElements;
-	}
-	
-	/**
-	 * The _maximum_ number of items that the list can hold, as defined on instantiation.
-	 * (Not to be confused with the Buffer's capacity)
-	 */
-	public int capacity()
-	{
-		return _b.capacity() / PROPERTIES_PER_ELEMENT;
-	}
-	
-	/**
-	 * Clear object in preparation for garbage collection
-	 */
-	public void clear()
-	{
-		_b.clear();
-	}
-	
-	public Uv getAsUv(int $index)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		return new Uv( _b.get(), _b.get() );
-	}
-	
-	public void putInUv(int $index, Uv $uv)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		$uv.u = _b.get();
-		$uv.v = _b.get();
-	}
-
-	public float getPropertyU(int $index)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		return _b.get();
-	}
-	public float getPropertyV(int $index)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT + 1);
-		return _b.get();
-	}
-	
-	//
-	
-	public void add(Uv $uv)
-	{
-		set( _numElements, $uv );
-		_numElements++;
-	}
-	
-	public void add(float $u, float $v)
-	{
-		set(_numElements, $u, $v);
-		_numElements++;
-	}
-	
-	public void set(int $index, Uv $uv)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		_b.put($uv.u);
-		_b.put($uv.v);
-	}
-
-	public void set(int $index, float $u, float $v)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		_b.put($u);
-		_b.put($v);
-	}
-	
-	public void setPropertyU(int $index, float $u)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT);
-		_b.put($u);
-	}
-	public void setPropertyV(int $index, float $v)
-	{
-		_b.position($index * PROPERTIES_PER_ELEMENT + 1);
-		_b.put($v);
-	}
-	
-	//
-	
-	public FloatBuffer buffer()
-	{
-		return _b;
-	}
-	
-	public UvBufferList clone()
-	{
-		_b.position(0);
-		UvBufferList c = new UvBufferList(_b, size());
-		return c;
-	}
-}

+ 0 - 183
app/src/main/java/min3d/core/Vertices.java

@@ -1,183 +0,0 @@
-package min3d.core;
-
-import min3d.vos.Color4;
-import min3d.vos.Number3d;
-import min3d.vos.Uv;
-
-
-public class Vertices
-{
-	private Number3dBufferList _points;
-	private UvBufferList _uvs;
-	private Number3dBufferList _normals;
-	private Color4BufferList _colors;
-	
-	private boolean _hasUvs;
-	private boolean _hasNormals;
-	private boolean _hasColors;
-	
-	
-	/**
-	 * Used by Object3d to hold the lists of vertex points, texture coordinates (UV), normals, and vertex colors. 
-	 * Use "addVertex()" to build the vertex data for the Object3d instance associated with this instance. 
-	 * 
-	 * Direct manipulation of position, UV, normal, or color data can be done directly through the associated 
-	 * 'buffer list' instances contained herein.
-	 */
-	public Vertices(int $maxElements)
-	{
-		_points = new Number3dBufferList($maxElements);
-		
-		_hasUvs = true;
-		_hasNormals = true;
-		_hasColors = true;
-		
-		if (_hasUvs) _uvs = new UvBufferList($maxElements);
-		if (_hasNormals) _normals = new Number3dBufferList($maxElements);
-		if (_hasColors) _colors = new Color4BufferList($maxElements);
-	}
-
-	/**
-	 * This version of the constructor adds 3 boolean arguments determine whether 
-	 * uv, normal, and color lists will be used by this instance.
-	 * Set to false when appropriate to save memory, increase performance. 
-	 */
-	public Vertices(int $maxElements, Boolean $useUvs, Boolean $useNormals, Boolean $useColors)
-	{
-		_points = new Number3dBufferList($maxElements);
-		
-		_hasUvs = $useUvs;
-		_hasNormals = $useNormals;
-		_hasColors = $useColors;
-		
-		if (_hasUvs) _uvs = new UvBufferList($maxElements);
-		if (_hasNormals) _normals = new Number3dBufferList($maxElements);
-		if (_hasColors) _colors = new Color4BufferList($maxElements);
-	}
-	
-	public Vertices(Number3dBufferList $points, UvBufferList $uvs, Number3dBufferList $normals,
-			Color4BufferList $colors)
-	{
-		_points = $points;
-		_uvs = $uvs;
-		_normals = $normals;
-		_colors = $colors;
-		
-		_hasUvs = _uvs != null && _uvs.size() > 0;
-		_hasNormals = _normals != null && _normals.size() > 0;
-		_hasColors = _colors != null && _colors.size() > 0;
-	}
-	
-	public int size()
-	{
-		return _points.size();
-	}
-	
-	public int capacity()
-	{
-		return _points.capacity();
-	}
-	
-	public boolean hasUvs()
-	{
-		return _hasUvs;
-	}
-
-	public boolean hasNormals()
-	{
-		return _hasNormals;
-	}
-	
-	public boolean hasColors()
-	{
-		return _hasColors;
-	}
-	
-	
-	/**
-	 * Use this to populate an Object3d's vertex data.
-	 * Return's newly added vertex's index 
-	 * 
-	 *  	If hasUvs, hasNormals, or hasColors was set to false, 
-	 * 		their corresponding arguments are just ignored.
-	 */
-	public short addVertex(
-		float $pointX, float $pointY, float $pointZ,  
-		float $textureU, float $textureV,  
-		float $normalX, float $normalY, float $normalZ,  
-		short $colorR, short $colorG, short $colorB, short $colorA)
-	{
-		_points.add($pointX, $pointY, $pointZ);
-		
-		if (_hasUvs) _uvs.add($textureU, $textureV);
-		if (_hasNormals) _normals.add($normalX, $normalY, $normalZ);
-		if (_hasColors) _colors.add($colorR, $colorG, $colorB, $colorA);
-		
-		return (short)(_points.size()-1);
-	}
-	
-	/**
-	 * More structured-looking way of adding a vertex (but potentially wasteful).
-	 * The VO's taken in as arguments are only used to read the values they hold
-	 * (no references are kept to them).  
-	 * Return's newly added vertex's index 
-	 * 
-	 * 		If hasUvs, hasNormals, or hasColors was set to false, 
-	 * 		their corresponding arguments are just ignored.
-	 */
-	public short addVertex(Number3d $point, Uv $textureUv, Number3d $normal, Color4 $color)
-	{
-		_points.add($point);
-		
-		if (_hasUvs) _uvs.add($textureUv);
-		if (_hasNormals) _normals.add($normal);
-		if (_hasColors) _colors.add($color);
-		
-		return (short)(_points.size()-1);
-	}
-	
-	public void overwriteVerts(float[] $newVerts)
-	{
-		_points.overwrite($newVerts);
-	}
-	
-	public void overwriteNormals(float[] $newNormals)
-	{
-		_normals.overwrite($newNormals);
-	}
-	
-	Number3dBufferList points() /*package-private*/
-	{
-		return _points;
-	}
-	
-	/**
-	 * List of texture coordinates
-	 */
-	UvBufferList uvs() /*package-private*/
-	{
-		return _uvs;
-	}
-	
-	/**
-	 * List of normal values 
-	 */
-	Number3dBufferList normals() /*package-private*/
-	{
-		return _normals;
-	}
-	
-	/**
-	 * List of color values
-	 */
-	Color4BufferList colors() /*package-private*/
-	{
-		return _colors;
-	}
-	
-	public Vertices clone()
-	{
-		Vertices v = new Vertices(_points.clone(), _uvs.clone(), _normals.clone(), _colors.clone());
-		return v;
-	}
-}

+ 0 - 8
app/src/main/java/min3d/interfaces/IDirtyManaged.java

@@ -1,8 +0,0 @@
-package min3d.interfaces;
-
-public interface IDirtyManaged 
-{
-	public boolean isDirty();
-	public void setDirtyFlag();
-	public void clearDirtyFlag();
-}

+ 0 - 6
app/src/main/java/min3d/interfaces/IDirtyParent.java

@@ -1,6 +0,0 @@
-package min3d.interfaces;
-
-public interface IDirtyParent 
-{
-	public void onDirty();
-}

+ 0 - 20
app/src/main/java/min3d/interfaces/IObject3dContainer.java

@@ -1,20 +0,0 @@
-package min3d.interfaces;
-
-import java.util.ArrayList;
-
-import min3d.core.Object3d;
-
-/**
- * Using Actionscript 3 nomenclature for what are essentially "pass-thru" methods to an underlying ArrayList  
- */
-public interface IObject3dContainer 
-{
-	public void addChild(Object3d $child);
-	public void addChildAt(Object3d $child, int $index);
-	public boolean removeChild(Object3d $child);
-	public Object3d removeChildAt(int $index);
-	public Object3d getChildAt(int $index);
-	public Object3d getChildByName(String $string);
-	public int getChildIndexOf(Object3d $o);	
-	public int numChildren();
-}

+ 0 - 39
app/src/main/java/min3d/interfaces/ISceneController.java

@@ -1,39 +0,0 @@
-package min3d.interfaces;
-
-import android.os.Handler;
-
-/**
- * Interface to handle the initialization of the Scene 
- * and the 'on-enter-frame' updates to the Scene (think 'model').
- * 
- * The RendererActivity class implements this interface.
- * 
- * But you could use any other class to implement this interface, 
- * not just the Activity class.
- *   
- */
-public interface ISceneController 
-{
-	/**
-	 * Initialization of scene objects happens here. 
-	 * 
-	 * It is called after the GL Surface is created, which means not only at startup, 
-	 * but also when the application resumes after losing focus.
-	 * 
-	 * It would be the end-user's responsibility to save and restore state if so desired...
-	 */
-	public void initScene();
-
-	/**
-	 * Updating properties of scene objects happens here.
-	 * This is called on every frame right before the render routine.
-	 */
-	public void updateScene();
-	
-	
-	public Handler getInitSceneHandler();
-	public Runnable getInitSceneRunnable();
-	
-	public Handler getUpdateSceneHandler();
-	public Runnable getUpdateSceneRunnable();
-}

+ 0 - 114
app/src/main/java/min3d/objectPrimitives/Box.java

@@ -1,114 +0,0 @@
-package min3d.objectPrimitives;
-
-import min3d.Utils;
-import min3d.core.Object3dContainer;
-import min3d.vos.Color4;
-
-
-/**
- * Note how each 'face' (quad) of the box uses its own set of 4 vertices each, 
- * rather than sharing with adjacent faces.  This allows for each face to be 
- * texture mapped, normal'ed, and colored independently of the others. 
- * 
- * Object origin is center of box. 
- */
-public class Box extends Object3dContainer
-{
-	private Color4[] _cols;
-	private float _width;
-	private float _height;
-	private float _depth;
-	
-
-	public Box(float $width, float $height, float $depth, Color4[] $sixColor4s, Boolean $useUvs, Boolean $useNormals, Boolean $useVertexColors)
-	{
-		super(4*6, 2*6, $useUvs,$useNormals,$useVertexColors);
-		
-		_width = $width;
-		_height = $height;
-		_depth = $depth;
-		
-		if ($sixColor4s != null)
-		{
-			_cols = $sixColor4s;
-		}
-		else
-		{
-			_cols = new Color4[6];
-			_cols[0] = new Color4(255,0,0,255);
-			_cols[1] = new Color4(0,255,0,255);
-			_cols[2] = new Color4(0,0,255,255);
-			_cols[3] = new Color4(255,255,0,255);
-			_cols[4] = new Color4(0,255,255,255);
-			_cols[5] = new Color4(255,0,255,255);
-		}
-		
-		make();
-	}
-	
-	public Box(float $width, float $height, float $depth, Color4[] $sixColor4s)
-	{
-		this($width,$height,$depth, $sixColor4s, true,true,true);
-	}
-	
-	public Box(float $width, float $height, float $depth, Color4 color)
-	{
-		this($width,$height,$depth, new Color4[] { color, color, color, color, color, color }, true,true,true);
-	}
-
-	public Box(float $width, float $height, float $depth)
-	{
-		this($width,$height,$depth, null,  true,true,true);
-	}
-
-	private void make()
-	{
-		float w = _width / 2f;
-		float h = _height / 2f;
-		float d = _depth / 2f;
-
-		short ul, ur, lr, ll;
-		
-		// front
-		ul = this.vertices().addVertex(-w,+h,+d,	0f,0f,	0,0,1,	_cols[0].r,_cols[0].g,_cols[0].b,_cols[0].a);
-		ur = this.vertices().addVertex(+w,+h,+d,	1f,0f,	0,0,1,	_cols[0].r,_cols[0].g,_cols[0].b,_cols[0].a);
-		lr = this.vertices().addVertex(+w,-h,+d,	1f,1f,	0,0,1,	_cols[0].r,_cols[0].g,_cols[0].b,_cols[0].a);
-		ll = this.vertices().addVertex(-w,-h,+d,	0f,1f,	0,0,1,	_cols[0].r,_cols[0].g,_cols[0].b,_cols[0].a);
-		Utils.addQuad(this, ul,ur,lr,ll);
-		
-		// right
-		ul = this.vertices().addVertex(+w,+h,+d,	0f,0f,	1,0,0,	_cols[1].r,_cols[1].g,_cols[1].b,_cols[1].a);
-		ur = this.vertices().addVertex(+w,+h,-d,	1f,0f,	1,0,0,	_cols[1].r,_cols[1].g,_cols[1].b,_cols[1].a);
-		lr = this.vertices().addVertex(+w,-h,-d,	1f,1f,	1,0,0,	_cols[1].r,_cols[1].g,_cols[1].b,_cols[1].a);
-		ll = this.vertices().addVertex(+w,-h,+d,	0f,1f,	1,0,0,	_cols[1].r,_cols[1].g,_cols[1].b,_cols[1].a);
-		Utils.addQuad(this, ul,ur,lr,ll);
-
-		// back
-		ul = this.vertices().addVertex(+w,+h,-d,	0f,0f,	0,0,-1,	_cols[2].r,_cols[2].g,_cols[2].b,_cols[2].a);
-		ur = this.vertices().addVertex(-w,+h,-d,	1f,0f,	0,0,-1,	_cols[2].r,_cols[2].g,_cols[2].b,_cols[2].a);
-		lr = this.vertices().addVertex(-w,-h,-d,	1f,1f,	0,0,-1,	_cols[2].r,_cols[2].g,_cols[2].b,_cols[2].a);
-		ll = this.vertices().addVertex(+w,-h,-d,	0f,1f,	0,0,-1,	_cols[2].r,_cols[2].g,_cols[2].b,_cols[2].a);
-		Utils.addQuad(this, ul,ur,lr,ll);
-	
-		// left
-		ul = this.vertices().addVertex(-w,+h,-d,	0f,0f,	-1,0,0,	_cols[3].r,_cols[3].g,_cols[3].b,_cols[3].a);
-		ur = this.vertices().addVertex(-w,+h,+d,	1f,0f,	-1,0,0,	_cols[3].r,_cols[3].g,_cols[3].b,_cols[3].a);
-		lr = this.vertices().addVertex(-w,-h,+d,	1f,1f,	-1,0,0,	_cols[3].r,_cols[3].g,_cols[3].b,_cols[3].a);
-		ll = this.vertices().addVertex(-w,-h,-d,	0f,1f,	-1,0,0,	_cols[3].r,_cols[3].g,_cols[3].b,_cols[3].a);
-		Utils.addQuad(this, ul,ur,lr,ll);
-		
-		// top
-		ul = this.vertices().addVertex(-w,+h,-d,	0f,0f,	0,1,0,	_cols[4].r,_cols[4].g,_cols[4].b,_cols[4].a);
-		ur = this.vertices().addVertex(+w,+h,-d,	1f,0f,	0,1,0,	_cols[4].r,_cols[4].g,_cols[4].b,_cols[4].a);
-		lr = this.vertices().addVertex(+w,+h,+d,	1f,1f,	0,1,0,	_cols[4].r,_cols[4].g,_cols[4].b,_cols[4].a);
-		ll = this.vertices().addVertex(-w,+h,+d,	0f,1f,	0,1,0,	_cols[4].r,_cols[4].g,_cols[4].b,_cols[4].a);
-		Utils.addQuad(this, ul,ur,lr,ll);
-
-		// bottom
-		ul = this.vertices().addVertex(-w,-h,+d,	0f,0f,	0,-1,0,	_cols[5].r,_cols[5].g,_cols[5].b,_cols[5].a);
-		ur = this.vertices().addVertex(+w,-h,+d,	1f,0f,	0,-1,0,	_cols[5].r,_cols[5].g,_cols[5].b,_cols[5].a);
-		lr = this.vertices().addVertex(+w,-h,-d,	1f,1f,	0,-1,0,	_cols[5].r,_cols[5].g,_cols[5].b,_cols[5].a);
-		ll = this.vertices().addVertex(-w,-h,-d,	0f,1f,	0,-1,0,	_cols[5].r,_cols[5].g,_cols[5].b,_cols[5].a);
-		Utils.addQuad(this, ul,ur,lr,ll);
-	}
-}

+ 0 - 142
app/src/main/java/min3d/objectPrimitives/HollowCylinder.java

@@ -1,142 +0,0 @@
-package min3d.objectPrimitives;
-
-import min3d.core.Object3dContainer;
-import min3d.vos.Color4;
-import min3d.vos.Face;
-import min3d.vos.Number3d;
-import min3d.vos.Uv;
-
-/**
- * Example of a more complex programmatically-drawn object.
- * 
- * Unfortunately, because the object's faces share as many vertices as possible,
- * shading is incorrect on the cylinder surfaces.
- *  
- * To fix would require duplicating vertices, adding new normals, 
- * and generally reworking algorithm. Yek.
- */
-public class HollowCylinder extends Object3dContainer 
-{
-	private double DEG = Math.PI / 180;
-	
-	private int _segs;
-	private float _radiusOuter;
-	private float _radiusInner;
-	private float _height;
-	
-
-	public HollowCylinder(float $radiusOuter, float $radiusInner, float $height, int $segs)
-	{
-		super($segs * 4, $segs * 8);
-		
-		_segs = $segs;
-		_height = $height;
-		_radiusOuter = $radiusOuter;
-		_radiusInner = $radiusInner;
-		
-		addHorizontalSurface(false, _height / +2);
-		addHorizontalSurface(true, _height / -2);
-		addVerticalSurface(true);
-		addVerticalSurface(false);
-	}
-	
-	private void addHorizontalSurface(boolean $isTopSide, float $zOffset)
-	{
-		int indexOffset = _vertices.size();
-		float step = (float)((360.0 / _segs) * DEG);
-
-		// verts
-		
-		Color4 col = $isTopSide ? new Color4(255,0,0,255) : new Color4(0,255,0,255);
-		
-		for (int i = 0; i < _segs; i++)
-		{
-			float angle = (float)i * step;
-
-			// outer 
-			float x1 		= (float) Math.sin(angle) * _radiusOuter;
-			float y1 		= (float) Math.cos(angle) * _radiusOuter;
-			float z1 		= $zOffset; 
-			Uv uv1 			= new Uv(x1,y1);
-			Number3d n1 	= new Number3d(0,0, $isTopSide ? -1 : +1);
-			this.vertices().addVertex(new Number3d(x1,y1,z1), uv1, n1, col);
-
-			// inner 
-			float x2 		= (float) Math.sin(angle) * _radiusInner;
-			float y2 		= (float) Math.cos(angle) * _radiusInner;
-			float z2 		= $zOffset; 
-			Uv uv2			= new Uv(x2,y2);
-			Number3d n2	= new Number3d(0,0, $isTopSide ? -1 : +1);
-			this.vertices().addVertex(new Number3d(x2,y2,z2), uv2, n2, col);
-		}
-		
-		// indicies
-		
-		for (int i = 2; i <= _segs; i++)
-		{
-			int a = indexOffset  +  i*2 - 3 - 1;
-			int b = indexOffset  +  i*2 - 2 - 1;
-			int c = indexOffset  +  i*2 - 1 - 1;
-			int d = indexOffset  +  i*2 - 0 - 1;
-			addQuad(a,b,c,d, $isTopSide);
-		}		
-	
-		int a = indexOffset  +  _segs*2 - 1 - 1; // ... connect last segment
-		int b = indexOffset  +  _segs*2 - 0 - 1;
-		int c = indexOffset  +  0;
-		int d = indexOffset  +  1;
-		addQuad(a,b,c,d, $isTopSide);
-	}
-	
-	// 
-	private void addVerticalSurface(boolean $isOuter)
-	{
-		int off = (int)(_vertices.size() / 2); 
-		
-		for (int i = 0; i < _segs - 1; i++)
-		{
-			int ul = i*2;
-			int bl = ul + off;
-			int ur = i*2 + 2;
-			int br = ur + off;
-			
-			if (!$isOuter) {
-				ul++;
-				bl++;
-				ur++;
-				br++;
-			}
-			addQuad(ul,bl,ur,br, $isOuter);
-		}
-		
-		int ul = (_segs-1)*2;
-		int bl = ul + off;
-		int ur = 0*2;
-		int br = ur + off;
-
-		if (!$isOuter) {
-			ul++;
-			bl++;
-			ur++;
-			br++;
-		}
-
-		addQuad(ul,bl,ur,br, $isOuter);
-	}
-	
-	private void addQuad(int ul, int bl, int ur, int br, boolean $flipped)
-	{
-		Face t;
-		
-		if (! $flipped)
-		{
-			_faces.add((short)ul,(short)bl,(short)ur);
-			_faces.add((short)bl,(short)br,(short)ur);
-		}
-		else
-		{
-			_faces.add((short)ur,(short)br,(short)ul);
-			_faces.add((short)br,(short)bl,(short)ul);
-		}
-	}
-}

+ 0 - 57
app/src/main/java/min3d/objectPrimitives/Rectangle.java

@@ -1,57 +0,0 @@
-package min3d.objectPrimitives;
-
-import min3d.Utils;
-import min3d.core.Object3dContainer;
-import min3d.vos.Color4;
-
-public class Rectangle extends Object3dContainer
-{
-	public Rectangle(float $width, float $height, int $segsW, int $segsH)
-	{
-		this($width, $height, $segsW, $segsH, new Color4(255, 0, 0, 255));
-	}
-	
-	public Rectangle(float $width, float $height, int $segsW, int $segsH, Color4 color)
-	{
-		super(4 * $segsW * $segsH, 2 * $segsW * $segsH);
-
-		int row, col;
-
-		float w = $width / $segsW;
-		float h = $height / $segsH;
-
-		float width5 = $width/2f;
-		float height5 = $height/2f;
-		
-		// Add vertices
-		
-		for (row = 0; row <= $segsH; row++)
-		{
-			for (col = 0; col <= $segsW; col++)
-			{
-				this.vertices().addVertex(
-					(float)col*w - width5, (float)row*h - height5,0f,	
-					(float)col/(float)$segsW, 1 - (float)row/(float)$segsH,	
-					0,0,1f,	
-					color.r, color.g, color.b, color.a
-				);
-			}
-		}
-		
-		// Add faces
-		
-		int colspan = $segsW + 1;
-		
-		for (row = 1; row <= $segsH; row++)
-		{
-			for (col = 1; col <= $segsW; col++)
-			{
-				int lr = row * colspan + col;
-				int ll = lr - 1;
-				int ur = lr - colspan;
-				int ul = ur - 1;
-				Utils.addQuad(this, ul,ur,lr,ll);
-			}
-		}
-	}
-}

+ 0 - 106
app/src/main/java/min3d/objectPrimitives/SkyBox.java

@@ -1,106 +0,0 @@
-package min3d.objectPrimitives;
-
-import android.graphics.Bitmap;
-import min3d.Shared;
-import min3d.Utils;
-import min3d.core.Object3dContainer;
-import min3d.vos.Color4;
-
-public class SkyBox extends Object3dContainer {
-	private float size;
-	private float halfSize;
-	private int quality;
-	private Color4 color;
-	private Rectangle[] faces;
-	
-	public enum Face {
-		North,
-		East,
-		South,
-		West,
-		Up,
-		Down,
-		All
-	}
-	
-	public SkyBox(float size, int quality) {
-		super(0, 0);
-		this.size = size;
-		this.halfSize = size *.5f;
-		this.quality = quality;
-		build();
-	}
-	
-	private void build() {
-		color = new Color4();
-		faces = new Rectangle[6];
-		Rectangle north = new Rectangle(size, size, quality, quality, color);
-		Rectangle east = new Rectangle(size, size, quality, quality, color);
-		Rectangle south = new Rectangle(size, size, quality, quality, color);
-		Rectangle west = new Rectangle(size, size, quality, quality, color);
-		Rectangle up = new Rectangle(size, size, quality, quality, color);
-		Rectangle down = new Rectangle(size, size, quality, quality, color);
-		
-		north.position().z = halfSize;
-		north.lightingEnabled(false);
-		
-		east.rotation().y = -90;
-		east.position().x = halfSize;
-		east.doubleSidedEnabled(true);
-		east.lightingEnabled(false);
-		
-		south.rotation().y = 180;
-		south.position().z = -halfSize;
-		south.lightingEnabled(false);
-		
-		west.rotation().y = 90;
-		west.position().x = -halfSize;
-		west.doubleSidedEnabled(true);
-		west.lightingEnabled(false);
-		
-		up.rotation().x = 90;
-		up.position().y = halfSize;
-		up.doubleSidedEnabled(true);
-		up.lightingEnabled(false);
-		
-		down.rotation().x = -90;
-		down.position().y = -halfSize;
-		down.doubleSidedEnabled(true);
-		down.lightingEnabled(false);
-		
-		faces[Face.North.ordinal()] = north;
-		faces[Face.East.ordinal()] = east;
-		faces[Face.South.ordinal()] = south;
-		faces[Face.West.ordinal()] = west;
-		faces[Face.Up.ordinal()] = up;
-		faces[Face.Down.ordinal()] = down;
-		
-		addChild(north);
-		addChild(east);
-		addChild(south);
-		addChild(west);
-		addChild(up);
-		addChild(down);
-	}
-	
-	public void addTexture(Face face, int resourceId, String id) {
-		Bitmap bitmap = Utils.makeBitmapFromResourceId(resourceId);
-		Shared.textureManager().addTextureId(bitmap, id, true);
-		bitmap.recycle();
-		addTexture(face, bitmap, id);
-	}
-	
-	public void addTexture(Face face, Bitmap bitmap, String id) {
-		if(face == Face.All)
-		{
-			for(int i=0; i<6; i++)
-			{
-				faces[i].textures().addById(id);
-			}
-		}
-		else
-		{
-			faces[face.ordinal()].textures().addById(id);
-		}
-	}
-}

+ 0 - 127
app/src/main/java/min3d/objectPrimitives/Sphere.java

@@ -1,127 +0,0 @@
-package min3d.objectPrimitives;
-
-import min3d.Utils;
-import min3d.core.Object3dContainer;
-import min3d.vos.Color4;
-import min3d.vos.Number3d;
-
-
-/**
- * Creates a sphere.
- * Vertex colors are assigned randomly across the 'latitudes' of the sphere,
- */
-public class Sphere extends Object3dContainer
-{
-	private float _radius;
-	private int _cols;
-	private int _rows;
-	
-	
-	public Sphere(float $radius, int $columns, int $rows, Boolean $useUvs, Boolean $useNormals, Boolean $useVertexColors)
-	{
-		super(
-			($columns+1) * ($rows+1),
-			$columns * $rows * 2,
-			$useUvs,
-			$useNormals,
-			$useVertexColors
-		);
-
-		_cols = $columns;
-		_rows = $rows;
-		_radius = $radius;
-
-		build();
-	}
-
-	public Sphere(float $radius, int $columns, int $rows)
-	{
-		super(
-				($columns+1) * ($rows+1),
-				$columns * $rows * 2,
-				true,
-				true,
-				true
-			);
-
-			_cols = $columns;
-			_rows = $rows;
-			_radius = $radius;
-			
-			build();
-	} 
-	
-	public Sphere(float $radius, int $columns, int $rows, Color4 color)
-	{
-		super(
-				($columns+1) * ($rows+1),
-				$columns * $rows * 2,
-				true,
-				true,
-				true
-		);
-		defaultColor(color);
-		_cols = $columns;
-		_rows = $rows;
-		_radius = $radius;
-		
-		build();
-	}
-	
-	private void build()
-	{
-		int r, c;
-		
-		Number3d n = new Number3d();
-		Number3d pos = new Number3d();
-		Number3d posFull = new Number3d();
-
-		if( defaultColor() == null ) defaultColor(new Color4());
-		// Build vertices
-				
-		for (r = 0; r <= _rows; r++)
-		{
-			float v = (float)r / (float)_rows; // [0,1]
-			float theta1 = v * (float)Math.PI; // [0,PI]
-
-			n.setAll(0,1,0);
-			n.rotateZ(theta1); 
-
-			// each 'row' assigned random color. for the hell of it.
-			
-			for (c = 0; c <= _cols; c++)
-			{
-				float u = (float)c / (float)_cols; // [0,1]
-				float theta2 = u * (float)(Math.PI * 2f); // [0,2PI]
-				pos.setAllFrom(n);
-				pos.rotateY(theta2);
-				
-				posFull.setAllFrom(pos);
-				posFull.multiply(_radius);
-				
-				
-				this.vertices().addVertex(posFull.x,posFull.y,posFull.z,  u,v,  pos.x,pos.y,pos.z,  defaultColor().r,defaultColor().g,defaultColor().b,defaultColor().a);
-			}
-		}
-
-
-		// Add faces
-
-		int colLength = _cols + 1;
-		
-		for (r = 0; r < _rows; r++)
-		{
-			int offset = r * colLength; 
-			
-			for (c = 0; c < _cols; c++)
-			{
-				int ul = offset  +  c;
-				int ur = offset  +  c+1;
-				int br = offset  +  (int)(c + 1 + colLength);
-				int bl = offset  +  (int)(c + 0 + colLength);
-				
-				Utils.addQuad(this, ul,ur,br,bl);
-			}
-		}
-	}
-}

+ 0 - 115
app/src/main/java/min3d/objectPrimitives/Torus.java

@@ -1,115 +0,0 @@
-package min3d.objectPrimitives;
-
-import min3d.core.Object3dContainer;
-import min3d.vos.Color4;
-import min3d.vos.Number3d;
-import min3d.vos.Uv;
-import min3d.vos.Vertex3d;
-
-/**
- * @author Dennis Ippel
- * @author Thomas Pfeiffer
- * @author Tim Knip
- *
- * Torus primitive.
- * This is an adaptation from Sandy's ActionScript 3 class which was adapted from Tim Knip's 
- * ActionScript 2 class. All credits go to Tim Knip.
- * Original sources available at: http://www.suite75.net/svn/papervision3d/tim/as2/org/papervision3d/objects/Torus.as
- * Sandy source available at: http://code.google.com/p/sandy/source/browse/trunk/sandy/as3/trunk/src/sandy/primitive/Torus.as
- *
- */
-
-public class Torus extends Object3dContainer {
-	private final int MIN_SEGMENTSW = 3;
-	private final int MIN_SEGMENTSH = 2;
-	
-	private float largeRadius;
-	private float smallRadius;
-	private int segmentsW;
-	private int segmentsH;
-	
-	public Torus() {
-		this(2, 1, 12, 8, new Color4());
-	}
-	
-	public Torus(Color4 color) {
-		this(2, 1, 12, 8, color);
-	}
-	
-	public Torus(float largeRadius, float smallRadius, int segmentsW, int segmentsH) {
-		this(largeRadius, smallRadius, segmentsW, segmentsH, new Color4());
-	}
-	
-	public Torus(float largeRadius, float smallRadius, int segmentsW, int segmentsH, Color4 color) {
-		super(segmentsW * segmentsH * 2 * 3, segmentsW * segmentsH * 2);
-		this.largeRadius = largeRadius;
-		this.smallRadius = smallRadius;
-		this.segmentsW = Math.max(MIN_SEGMENTSW, segmentsW);
-		this.segmentsH = Math.max(MIN_SEGMENTSH, segmentsH);
-		this.defaultColor(color);
-		build();
-	}
-	
-	private void build()
-	{
-		float r1 = largeRadius;
-		float r2 = smallRadius;
-		int steps1 = segmentsW;
-		int steps2 = segmentsH;
-		float step1r = (float) ((2.0 * Math.PI) / steps1);
-		float step2r = (float) ((2.0 * Math.PI) / steps2);
-		float a1a = 0;
-		float a1b = step1r;
-		int vcount = 0;
-		
-		for(float s=0; s<steps1; s++, a1a=a1b, a1b+=step1r) {
-			float a2a = 0;
-			float a2b = step2r;
-			
-			for(float s2=0; s2<steps2; s2++, a2a=a2b, a2b+=step2r) {
-				Vertex3d v0 = getVertex(a1a, r1, a2a, r2);
-				Vertex3d v1 = getVertex(a1b, r1, a2a, r2);
-				Vertex3d v2 = getVertex(a1b, r1, a2b, r2);
-				Vertex3d v3 = getVertex(a1a, r1, a2b, r2);
-				
-				float ux1 = s/steps1;
-				float ux0 = (s+1)/steps1;
-				float uy0 = s2/steps2;
-				float uy1 = (s2+1)/steps2;
-
-				vertices().addVertex(v0.position, new Uv(1-ux1, uy0), v0.normal, defaultColor());
-				vertices().addVertex(v1.position, new Uv(1-ux0, uy0), v1.normal, defaultColor());
-				vertices().addVertex(v2.position, new Uv(1-ux0, uy1), v2.normal, defaultColor());
-				vertices().addVertex(v3.position, new Uv(1-ux1, uy1), v3.normal, defaultColor());
-				
-				faces().add(vcount, vcount+1, vcount+2);
-				faces().add(vcount, vcount+2, vcount+3);
-				
-				vcount += 4;
-			}
-		}
-	}
-	
-	private Vertex3d getVertex(float a1, float r1, float a2, float r2) {
-		Vertex3d vertex = new Vertex3d();
-		vertex.normal = new Number3d();
-		
-		float ca1 = (float)Math.cos(a1);
-		float sa1 = (float)Math.sin(a1);
-		float ca2 = (float)Math.cos(a2);
-		float sa2 = (float)Math.sin(a2);
-		
-		float centerX = r1 * ca1;
-		float centerZ = -r1 * sa1;
-		
-		vertex.normal.x = ca2 * ca1;
-		vertex.normal.y = sa2;
-		vertex.normal.z = -ca2 * sa1;
-		
-		vertex.position.x = centerX + r2 * vertex.normal.x;
-		vertex.position.y = r2 * vertex.normal.y;
-		vertex.position.z = centerZ + r2 * vertex.normal.z;
-				
-		return vertex;
-	}
-}

+ 0 - 429
app/src/main/java/min3d/parser/AParser.java

@@ -1,429 +0,0 @@
-package min3d.parser;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-
-import app.mar.utils.files.FileManager;
-import min3d.Min3d;
-import min3d.Shared;
-import min3d.Utils;
-import min3d.animation.AnimationObject3d;
-import min3d.core.Object3dContainer;
-import min3d.vos.Color4;
-import min3d.vos.Number3d;
-import min3d.vos.Uv;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.Bitmap.Config;
-import android.util.Log;
-
-/**
- * Abstract parser class with basic parsing functionality.
- * 
- * @author dennis.ippel
- *
- */
-public abstract class AParser implements IParser {
-	protected Resources resources;
-	protected String resourceID;
-	protected String packageID;
-	protected String currentMaterialKey;
-	protected ArrayList<ParseObjectData> parseObjects;
-	protected ParseObjectData co;
-	protected boolean firstObject;
-	protected TextureAtlas textureAtlas;
-	protected ArrayList<Number3d> vertices;
-	protected ArrayList<Uv> texCoords;
-	protected ArrayList<Number3d> normals;
-	protected boolean generateMipMap;
-	protected HashMap<String, Material> materialMap;
-	protected InputStream mStream=null;
-	protected String 	  mPath;
-	protected Context mContext=null;
-
-	public AParser(Context a)
-	{
-		mContext=a;
-		vertices = new ArrayList<Number3d>();
-		texCoords = new ArrayList<Uv>();
-		normals = new ArrayList<Number3d>();
-		parseObjects = new ArrayList<ParseObjectData>();
-		textureAtlas = new TextureAtlas();
-		firstObject = true;
-		materialMap = new HashMap<String, Material>();
-	}
-
-	public AParser(Context a, Resources resources, String resourceID, Boolean generateMipMap)
-	{
-		this(a);
-		mContext=a;
-		this.resources = resources;
-		this.resourceID = resourceID;
-		if (resourceID.indexOf(":") > -1)
-			this.packageID = resourceID.split(":")[0];
-		this.generateMipMap = generateMipMap;
-	}
-
-	public AParser(Context a, String path, Boolean generateMipMap)
-	{
-		this(a);
-		mContext=a;
-		mPath=path;
-		try {
-			mStream= FileManager.openFile(a,path);
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		int d = mPath.lastIndexOf('/');
-		if(d>=0) packageID=mPath.substring(0,d);
-		else packageID="";
-		this.generateMipMap = generateMipMap;
-	}
-	
-	protected void cleanup()
-	{
-		parseObjects.clear();
-		textureAtlas.cleanup();
-		vertices.clear();
-		texCoords.clear();
-		normals.clear();
-	}
-	
-	/**
-	 * Override this in the concrete parser
-	 */
-	public Object3dContainer getParsedObject() {
-		return null;
-	}
-	
-	/**
-	 * Override this in the concrete parser if applicable 
-	 */
-	public AnimationObject3d getParsedAnimationObject() {
-		return null;
-	}
-
-	protected String readString(InputStream stream) throws IOException {
-		String result = new String();
-		byte inByte;
-		while ((inByte = (byte) stream.read()) != 0)
-			result += (char) inByte;
-		return result;
-	}
-	
-	protected int readInt(InputStream stream) throws IOException {
-		return stream.read() | (stream.read() << 8) | (stream.read() << 16)
-				| (stream.read() << 24);
-	}
-
-	protected int readShort(InputStream stream) throws IOException {
-		return (stream.read() | (stream.read() << 8));
-	}
-
-	protected float readFloat(InputStream stream) throws IOException {
-		return Float.intBitsToFloat(readInt(stream));
-	}
-
-	/**
-	 * Override this in the concrete parser
-	 */
-	public void parse() {
-	}
-	
-
-	/**
-	 * Contains texture information. UV offsets and scaling is stored here.
-	 * This is used with texture atlases.
-	 * 
-	 * @author dennis.ippel
-	 *
-	 */
-	protected class BitmapAsset
-	{
-		/**
-		 * The texture bitmap
-		 */
-		public Bitmap bitmap;
-		/**
-		 * The texture identifier
-		 */
-		public String key;
-		/**
-		 * Resource ID
-		 */
-		public String resourceID;
-		/**
-		 * U-coordinate offset
-		 */
-		public float uOffset;
-		/**
-		 * V-coordinate offset
-		 */
-		public float vOffset;
-		/**
-		 * U-coordinate scaling value
-		 */
-		public float uScale;
-		/**
-		 * V-coordinate scaling value
-		 */
-		public float vScale;
-		public boolean useForAtlasDimensions;
-		
-		/**
-		 * Creates a new BitmapAsset object
-		 * @param
-		 * @param key
-		 */
-		public BitmapAsset(String key, String resourceID)
-		{
-			this.key = key;
-			this.resourceID = resourceID;
-			useForAtlasDimensions = false;
-		}
-	}
-	
-	/**
-	 * When a model contains per-face textures a texture atlas is created. This
-	 * combines multiple textures into one and re-calculates the UV coordinates.
-	 * 
-	 * @author dennis.ippel
-	 * 
-	 */
-	protected class TextureAtlas {
-		/**
-		 * The texture bitmaps that should be combined into one.
-		 */
-		private ArrayList<BitmapAsset> bitmaps;
-		/**
-		 * The texture atlas bitmap
-		 */
-		private Bitmap atlas;
-
-		/**
-		 * Creates a new texture atlas instance.
-		 */
-		public TextureAtlas() {
-			bitmaps = new ArrayList<BitmapAsset>();
-		}
-		private String atlasId;
-
-		/**
-		 * Adds a bitmap to the atlas
-		 * 
-		 * @param
-		 */
-		public void addBitmapAsset(BitmapAsset ba) {
-			BitmapAsset existingBA = getBitmapAssetByResourceID(ba.resourceID);
-
-			if(existingBA == null)
-			{
-				Bitmap b=null;
-				if(mStream==null) {
-					int bmResourceID = resources.getIdentifier(ba.resourceID, null, null);
-					if (bmResourceID == 0) {
-						Log.d(Min3d.TAG, "Texture not found: " + ba.resourceID);
-						return;
-					}
-
-					Log.d(Min3d.TAG, "Adding texture " + ba.resourceID);
-
-					b = Utils.makeBitmapFromResourceId(bmResourceID);
-				}else
-				{
-					try {
-						b=FileManager.openImage(mContext, ba.resourceID);
-					} catch (Exception e) {
-						e.printStackTrace();
-					}
-				}
-				ba.useForAtlasDimensions = true;
-				ba.bitmap = b;
-			}
-			else
-			{
-				ba.bitmap = existingBA.bitmap;
-			}
-
-			bitmaps.add(ba);
-		}
-		
-		public BitmapAsset getBitmapAssetByResourceID(String resourceID)
-		{
-			int numBitmaps = bitmaps.size();
-			
-			for(int i=0; i<numBitmaps; i++)
-			{
-				if(bitmaps.get(i).resourceID.equals(resourceID))
-					return bitmaps.get(i);
-			}
-			
-			return null;
-		}
-
-		/**
-		 * Generates a new texture atlas
-		 */
-		public void generate() {
-			Collections.sort(bitmaps, new BitmapHeightComparer());
-
-			if(bitmaps.size() == 0) return;
-			
-			BitmapAsset largestBitmap = bitmaps.get(0);
-			int totalWidth = 0;
-			int numBitmaps = bitmaps.size();
-			int uOffset = 0;
-			int vOffset = 0;
-
-			for (int i = 0; i < numBitmaps; i++) {
-				if(bitmaps.get(i).useForAtlasDimensions)
-					totalWidth += bitmaps.get(i).bitmap.getWidth();
-			}
-
-			atlas = Bitmap.createBitmap(totalWidth, largestBitmap.bitmap
-					.getHeight(), Config.ARGB_8888);
-
-			for (int i = 0; i < numBitmaps; i++) {
-				BitmapAsset ba = bitmaps.get(i);
-				BitmapAsset existingBA = getBitmapAssetByResourceID(ba.resourceID);				
-				
-				if(ba.useForAtlasDimensions)
-				{
-					Bitmap b = ba.bitmap;
-					int w = b.getWidth();
-					int h = b.getHeight();
-					int[] pixels = new int[w * h];
-					
-					b.getPixels(pixels, 0, w, 0, 0, w, h);
-					atlas.setPixels(pixels, 0, w, uOffset, vOffset, w, h);
-					
-					ba.uOffset = (float) uOffset / totalWidth;
-					ba.vOffset = 0;
-					ba.uScale = (float) w / (float) totalWidth;
-					ba.vScale = (float) h / (float) largestBitmap.bitmap.getHeight();
-					
-					uOffset += w;
-					b.recycle();
-				}
-				else
-				{
-					ba.uOffset = existingBA.uOffset;
-					ba.vOffset = existingBA.vOffset;
-					ba.uScale = existingBA.uScale;
-					ba.vScale = existingBA.vScale;
-				}
-			}
-			/*
-			FileOutputStream fos;
-			try {
-				fos = new FileOutputStream("/data/screenshot.png");
-				atlas.compress(Bitmap.CompressFormat.PNG, 100, fos);
-				fos.flush();
-				fos.close();
-			} catch (FileNotFoundException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-			} catch (IOException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
-			}
-			*/
-			setId(Shared.textureManager().getNewAtlasId());
-		}
-
-		/**
-		 * Returns the generated texture atlas bitmap
-		 * 
-		 * @return
-		 */
-		public Bitmap getBitmap() {
-			return atlas;
-		}
-
-		/**
-		 * Indicates whether bitmaps have been added to the atlas.
-		 * 
-		 * @return
-		 */
-		public boolean hasBitmaps() {
-			return bitmaps.size() > 0;
-		}
-
-		/**
-		 * Compares the height of two BitmapAsset objects.
-		 * 
-		 * @author dennis.ippel
-		 * 
-		 */
-		private class BitmapHeightComparer implements Comparator<BitmapAsset> {
-			public int compare(BitmapAsset b1, BitmapAsset b2) {
-				int height1 = b1.bitmap.getHeight();
-				int height2 = b2.bitmap.getHeight();
-
-				if (height1 < height2) {
-					return 1;
-				} else if (height1 == height2) {
-					return 0;
-				} else {
-					return -1;
-				}
-			}
-		}
-		
-		/**
-		 * Returns a bitmap asset with a specified name.
-		 * 
-		 * @param materialKey
-		 * @return
-		 */
-		public BitmapAsset getBitmapAssetByName(String materialKey) {
-			int numBitmaps = bitmaps.size();
-
-			for (int i = 0; i < numBitmaps; i++) {
-				if (bitmaps.get(i).key.equals(materialKey))
-					return bitmaps.get(i);
-			}
-
-			return null;
-		}
-		
-		public void cleanup()
-		{
-			int numBitmaps = bitmaps.size();
-
-			for (int i = 0; i < numBitmaps; i++) {
-				bitmaps.get(i).bitmap.recycle();
-			}
-			
-			if(atlas != null) atlas.recycle();
-			bitmaps.clear();
-			vertices.clear();
-			texCoords.clear();
-			normals.clear();
-		}
-
-		public void setId(String newAtlasId) {
-			atlasId = newAtlasId;			
-		}
-
-		public String getId() {
-			return atlasId;
-		}
-	}
-	
-	protected class Material {
-		public String name;
-		public String diffuseTextureMap;
-		public Color4 diffuseColor;
-
-		public Material(String name) {
-			this.name = name;
-		}
-	}
-}

+ 0 - 27
app/src/main/java/min3d/parser/IParser.java

@@ -1,27 +0,0 @@
-package min3d.parser;
-
-import min3d.animation.AnimationObject3d;
-import min3d.core.Object3dContainer;
-
-/**
- * Interface for 3D object parsers
- * 
- * @author dennis.ippel
- *
- */
-public interface IParser {
-	/**
-	 * Start parsing the 3D object
-	 */
-	public void parse();
-	/**
-	 * Returns the parsed object
-	 * @return
-	 */
-	public Object3dContainer getParsedObject();
-	/**
-	 * Returns the parsed animation object
-	 * @return
-	 */
-	public AnimationObject3d getParsedAnimationObject();
-}

Some files were not shown because too many files changed in this diff