François Gautrais 8 年 前
コミット
0ff1980a38

+ 1 - 0
app/src/main/java/app/brest/app/brest/ui/RotateButton.java

@@ -12,6 +12,7 @@ public class RotateButton extends Button {
     private float mAngle = 45;
     public RotateButton(Context context) {
         super(context);
+
     }
 
 

+ 149 - 39
app/src/main/java/app/brest/testmin3d/ARActivity.java

@@ -40,16 +40,21 @@ import min3d.core.Object3dContainer;
 import min3d.core.RendererActivity;
 import min3d.vos.CameraVo;
 import min3d.vos.Light;
+import min3d.vos.LightType;
 import min3d.vos.Number3d;
+import min3d.vos.Number3dManaged;
 
 
 public class ARActivity extends RendererActivity
 {
 
+
+
     private CameraPreview mImageSurfaceView;
     private Camera camera;
     private FrameLayout cameraPreviewLayout;
 
+
     private Object3dContainer faceObject3D;
     private Button mOkButton;
     private final Object mLock = new Object();
@@ -131,8 +136,9 @@ public class ARActivity extends RendererActivity
         //scene.lights().add(new Light());
 
         Light myLight = new Light();
-        myLight.position.setZ(150);
-        myLight.position.setY(150);
+        myLight.position.setZ(0);
+        myLight.position.setY(100);
+        myLight.type(LightType.POSITIONAL);
         scene.lights().add(myLight);
 
 
@@ -207,17 +213,140 @@ public class ARActivity extends RendererActivity
             mInArea=mDetect=false;
         }
     }
-    float x = 0;
+    protected String updateArSceneResource(Resource rr, Place p, String toDisplay)
+    {
+        Object3d oo = rr.get3DModel(this);
+        CameraVo v = new CameraVo();
+
+        if(mGame.getmSettings().isARMode()) {
+            double distCoef = (p.getDistance(mGame.getPlayer()) / 50) * 0.8;
+            distCoef += 0.2;
+            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 = -20;//(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.getmSettings().isAreaDebug()) {
+
+                toDisplay += "Azimuth: " + dts(alpha) + "°\nAngle:"+mGame.getPlayer().getAngleWith(p) +"\nPosition (" + dts(oo.position().x) + ", " + dts(oo.position().y)
+                        + ", " + dts(oo.position().z) + ")\n\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 void updateArSceneResource(Resource rr, Place p, String toDisplay)
+    {
+        Object3d oo = rr.get3DModel(this);
+        CameraVo v = new CameraVo();
+
+        if(mGame.getmSettings().isARMode()) {
+            double distCoef = (p.getDistance(mGame.getPlayer()) / 50) * 0.8;
+            distCoef += 0.2;
+            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 = -20;//(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.getmSettings().isAreaDebug()) {
+
+                toDisplay += "Azimuth: " + dts(alpha) + "°\nPosition (" + dts(oo.position().x) + ", " + dts(oo.position().y)
+                        + ", " + dts(oo.position().z) + ")\n\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);
+    }*/
+
+
+    /*protected String updateArSceneResource(Resource rr, Place p, String toDisplay)
+    {
+        Object3d oo = rr.get3DModel(this);
+        CameraVo v = new CameraVo();
+        v.position.z=0;
+        v.position.y=0;
+        v.position.x=0;
+        //l.type(LightType.POSITIONAL);
+
+
+        double distCoef = (p.getDistance(mGame.getPlayer()) / 50) * 0.8;
+        distCoef += 0.2;
+        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 = -20;//(float)(90*distCoef*Math.cos(alpha*Math.PI/180.0));
+        oo.position().x = -(float) (90 * distCoef * Math.sin(alpha * Math.PI / 180.0));
+
+        oo.position().x=(float)(150 * distCoef * Math.sin(mGame.getPlayer().getAngleWith(p) * Math.PI / 180.0));
+        oo.position().y=-20;
+        oo.position().z=(float)(150 * distCoef * Math.cos(mGame.getPlayer().getAngleWith(p) * Math.PI / 180.0));
+
+        v.target.x=(float) (45 * distCoef * Math.sin(mGame.getPlayer().getOrientationX() * Math.PI / 180.0));
+        v.target.z=(float) (45 * distCoef * Math.cos(mGame.getPlayer().getOrientationX() * Math.PI / 180.0));
+        v.target.y=-(float) (20  * Math.cos(mGame.getPlayer().getOrientationY() * Math.PI / 180.0));
+        oo.rotation().x=90-mGame.getPlayer().getOrientationY();
+
+
+        if (mGame.getmSettings().isAreaDebug()) {
+
+            toDisplay += "Azimuth: " + dts(alpha) + "°\nPosition (" + dts(oo.position().x) + ", " + dts(oo.position().y)
+                    + ", " + dts(oo.position().z) + ")\n\n";
+            toDisplay+="Target ("+v.target.x+", "+v.target.y+", "+v.target.z+")\n";
+        }
+
+        //vX = (float) (mGame.getPlayer().getAngleWith(p));
+        scene.camera(v);
+        scene.addChild(oo);
+        return toDisplay;
+    }*/
+
     protected boolean updateSceneResource()
     {
 
         ArrayList<LocatedResources> res = mGame.getResourcesNextToPlayer();
         String toDisplay ="";
-        float vX =0;
         boolean detected = false;
+        boolean isAR = mGame.getmSettings().isARMode();
        // String dete = "Detected:\n";
         scene.clear();
 
+
         if(mGame.getmSettings().isAreaDebug())
         {
             ArrayList<Area> ar = mGame.getAreaNextToPlayer();
@@ -230,40 +359,17 @@ public class ARActivity extends RendererActivity
 
         if(mGame.getmSettings().isAreaDebug()) toDisplay+="Resources détectées: \n";
 
-        if(mGame.getmSettings().isARMode()) {
-            for (int i = 0; i < res.size(); i++) {
-                Resource rr = res.get(i).getResource(0);
-                Place p = res.get(i).getPlace();
-                if (rr != null) {
-                    detected = true;
-                    Object3d oo = rr.get3DModel(this);
-                    CameraVo v = new CameraVo();
-                    double distCoef = (p.getDistance(mGame.getPlayer()) / 50) * 0.8;
-                    distCoef += 0.2;
-                    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 = -20;//(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.getmSettings().isAreaDebug()) {
-
-                        toDisplay += "Azimuth: " + dts(alpha) + "°\nPosition (" + dts(oo.position().x) + ", " + dts(oo.position().y)
-                                + ", " + dts(oo.position().z) + ")\n\n";
-                    }
-
-                    vX = (float) (mGame.getPlayer().getAngleWith(p));
-                    scene.camera(v);
-                    scene.addChild(oo);
-                }
+        for (int i = 0; i < res.size(); i++) {
+            Resource rr = res.get(i).getResource(0);
+            Place p = res.get(i).getPlace();
+            if (rr != null) {
+                detected = true;
+                if(isAR) mGame.getPlayer().freezePosition(p.getLocation());
+                toDisplay=updateArSceneResource(rr, p, toDisplay);
             }
         }
+        if(isAR && res.size()==0) mGame.getPlayer().releasePosition();
+
         updateLed(detected, mGame.getResourcesNextToPlayerDistDouble());
 
 
@@ -282,8 +388,10 @@ public class ARActivity extends RendererActivity
             }
         });
 
-
-        return scene.numChildren()>0;
+        if(mGame.getmSettings().isARMode())
+            return scene.numChildren()>0;
+        else
+            return res.size()>0;
     }
 
     protected void onList()
@@ -330,7 +438,7 @@ public class ARActivity extends RendererActivity
                 int w =mViewWidth  = mRlRoot.getMeasuredWidth();
                 int h =mViewHeight = mRlRoot.getMeasuredHeight();
 
-                mTvGPS.setTextSize(pxToDp((int)(h*0.121f/3.5)));
+                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)));
@@ -367,6 +475,8 @@ public class ARActivity extends RendererActivity
         {
             if(!mUpdate) return;
             boolean isResource = false;
+
+            //Precache du modèle 3D
             synchronized (mLock) {
                 if (!isPausing) {
                     boolean b = mGame.precache3DResource(this);

+ 3 - 0
app/src/main/java/app/brest/testmin3d/EndActivity.java

@@ -4,11 +4,14 @@ import android.app.Activity;
 import android.support.v7.app.AppCompatActivity;
 import android.os.Bundle;
 
+import app.brest.utils.FontChangeCrawler;
+
 public class EndActivity extends Activity {
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_end);
+        FontChangeCrawler.setFont(this);
     }
 }

+ 7 - 2
app/src/main/java/app/brest/testmin3d/NewMenuActivity.java

@@ -24,6 +24,7 @@ import android.widget.RelativeLayout;
 import android.widget.Toast;
 
 import app.brest.app.brest.ui.RotateButton;
+import app.brest.utils.FontChangeCrawler;
 import app.brest.utils.Settings;
 import app.brest.utils.app.brest.game.Game;
 import app.brest.utils.app.brest.game.Resource;
@@ -66,7 +67,7 @@ public class NewMenuActivity extends Activity implements View.OnClickListener{
         moveView(mBOptions, 2*w4-w/3, mHOffset+2*h4,w,h);
         moveView(mBSend, mWidth/2-w, mHOffset+2*h4+4*h/3, 2*w, h);
         mBMenu.setTextSize(25);
-        mBMenu.setTypeface(null,Typeface.BOLD);
+        //mBMenu.setTypeface(null,Typeface.BOLD);
         sendVisibility();
 
     }
@@ -120,7 +121,6 @@ public class NewMenuActivity extends Activity implements View.OnClickListener{
     @Override
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-            System.out.println( " == " + (mGame == null) );
 
             setContentView(R.layout.activity_new_menu);
             mRootLayout = (RelativeLayout) findViewById(R.id.menu_root);
@@ -199,7 +199,9 @@ public class NewMenuActivity extends Activity implements View.OnClickListener{
         mGame.pickResource("ce");
         mGame.pickResource("cf");
         mGame.pickResource("cg");
+            FontChangeCrawler.setFont(this);
 */
+        FontChangeCrawler.setFont(this);
     }
 
     public void onOptionsClick(View v)
@@ -238,6 +240,9 @@ public class NewMenuActivity extends Activity implements View.OnClickListener{
         Intent intent = new Intent(this, ViewerActivity.class);
         Stage s = mGame.getCurrentStageObj();
         Resource r = (s!=null)?s.getResource(): null;
+        Log.e("_______", "Briefing\n"+s.toString());
+        Log.e("________", "Resource "+r);
+        Log.e("________", r+ "  ");
         intent.putExtra("resource", r );
         startActivity(intent);
     }

+ 2 - 0
app/src/main/java/app/brest/testmin3d/PermissionActivity.java

@@ -15,6 +15,7 @@ import android.widget.ImageView;
 import android.widget.TextView;
 import android.widget.Toast;
 
+import app.brest.utils.FontChangeCrawler;
 import app.brest.utils.files.FileManager;
 
 public class PermissionActivity extends AppCompatActivity {
@@ -38,6 +39,7 @@ public class PermissionActivity extends AppCompatActivity {
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_permission);
+        FontChangeCrawler.setFont(this);
 
         FileManager.init(this);
         mText = (TextView) findViewById(R.id.disclamer);

+ 2 - 0
app/src/main/java/app/brest/testmin3d/ResourceListActivity.java

@@ -26,6 +26,7 @@ import java.util.List;
 
 import app.brest.app.brest.ui.CustomListView;
 import app.brest.app.brest.ui.ResourceArrayAdapter;
+import app.brest.utils.FontChangeCrawler;
 import app.brest.utils.app.brest.game.Game;
 import app.brest.utils.app.brest.game.Resource;
 
@@ -99,6 +100,7 @@ public class ResourceListActivity extends Activity {
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_resource_list);
+        FontChangeCrawler.setFont(this);
         mGame = (Game)getIntent().getSerializableExtra("game");
 
         mList = (ListView) findViewById(R.id.list_layout);

+ 2 - 0
app/src/main/java/app/brest/testmin3d/SettingsActivity.java

@@ -35,6 +35,7 @@ import app.brest.app.brest.ui.CustomToggleButton;
 import app.brest.app.brest.ui.OnToggleListener;
 import app.brest.app.brest.ui.RotateButton;
 import app.brest.app.brest.ui.SelectButton;
+import app.brest.utils.FontChangeCrawler;
 import app.brest.utils.Settings;
 import app.brest.utils.app.brest.game.Game;
 
@@ -70,6 +71,7 @@ public class SettingsActivity extends Activity implements app.brest.app.brest.ui
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_settings);
+        FontChangeCrawler.setFont(this);
 
         mGame = Game.game();
         mRootDev=new LinearLayout(this);

+ 2 - 0
app/src/main/java/app/brest/testmin3d/TransferActivity.java

@@ -12,6 +12,7 @@ import android.widget.ImageButton;
 import android.widget.ProgressBar;
 import android.widget.Toast;
 
+import app.brest.utils.FontChangeCrawler;
 import app.brest.utils.app.brest.game.Game;
 
 public class TransferActivity extends Activity {
@@ -28,6 +29,7 @@ public class TransferActivity extends Activity {
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_transfer);
+        FontChangeCrawler.setFont(this);
         mBar = (ProgressBar) findViewById(R.id.pb_bar);
         mImage = (ImageButton) findViewById(R.id.ib_logo);
         mBar.setMax(MAX_POS);

+ 6 - 2
app/src/main/java/app/brest/testmin3d/ViewerActivity.java

@@ -26,6 +26,7 @@ import java.io.InputStream;
 import java.util.ArrayList;
 
 import app.brest.app.brest.ui.MediaView;
+import app.brest.utils.FontChangeCrawler;
 import app.brest.utils.app.brest.game.Resource;
 import app.brest.utils.files.FileManager;
 import app.brest.utils.geometry.Point;
@@ -65,6 +66,9 @@ public class ViewerActivity extends RendererActivity implements View.OnTouchList
     protected void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_viewer);
+        FontChangeCrawler.setFont(this);
+
+
         getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
         mFrameLayout = (FrameLayout) findViewById(R.id.frame_viewer);
         mImageView = (ImageView) findViewById(R.id.imageView);
@@ -186,8 +190,8 @@ public class ViewerActivity extends RendererActivity implements View.OnTouchList
         scene.backgroundColor().setAll(0x00000000);
 
         Light myLight = new Light();
-        myLight.position.setZ(150);
-        myLight.position.setY(150);
+        myLight.position.setZ(0);
+        myLight.position.setY(0);
         scene.lights().add(myLight);
         Object3d oo = mResource.get3DModel(this);
         oo.position().z=mResource.getPosition().z;

+ 58 - 0
app/src/main/java/app/brest/utils/FontChangeCrawler.java

@@ -0,0 +1,58 @@
+package app.brest.utils;
+
+import android.app.Activity;
+import android.content.res.AssetManager;
+import android.graphics.Typeface;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+/**
+ * Created by ptitcois on 06/06/17.
+ */
+public class FontChangeCrawler
+{
+    private Typeface typeface;
+
+    public FontChangeCrawler(Typeface typeface)
+    {
+        this.typeface = typeface;
+    }
+
+    public FontChangeCrawler(AssetManager assets, String assetsFontFileName)
+    {
+        typeface = Typeface.createFromAsset(assets, assetsFontFileName);
+    }
+
+    public void replaceFonts(ViewGroup viewTree)
+    {
+        View child;
+        for(int i = 0; i < viewTree.getChildCount(); ++i)
+        {
+            child = viewTree.getChildAt(i);
+            if(child instanceof ViewGroup)
+            {
+                // recursive call
+                replaceFonts((ViewGroup)child);
+            }
+            else if(child instanceof TextView)
+            {
+                // base case
+                ((TextView) child).setTypeface(typeface);
+            }
+        }
+    }
+
+    public static void setFont(Activity app, String font)
+    {
+        FontChangeCrawler fontChanger = new FontChangeCrawler(app.getAssets(), font);
+        fontChanger.replaceFonts((ViewGroup)app.findViewById(android.R.id.content));
+    }
+
+    public static void setFont(Activity app)
+    {
+        FontChangeCrawler fontChanger = new FontChangeCrawler(app.getAssets(), "font.ttf");
+        fontChanger.replaceFonts((ViewGroup)app.findViewById(android.R.id.content));
+    }
+
+}

+ 5 - 5
app/src/main/java/app/brest/utils/SensorsManager.java

@@ -72,7 +72,7 @@ public class SensorsManager implements SensorEventListener, LocationListener {
         return getAzimuth();
     }
 
-    private boolean useGpsStub()
+    public boolean useGpsStub()
     {
         return app.brest.utils.Settings.getSettings().isGPSDebug();
     }
@@ -173,8 +173,8 @@ public class SensorsManager implements SensorEventListener, LocationListener {
 
     public void restartSensors()
     {
-        mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME);
-        mSensorManager.registerListener(this, mMagnetometer, SensorManager.SENSOR_DELAY_GAME);
+        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) {
@@ -206,8 +206,8 @@ public class SensorsManager implements SensorEventListener, LocationListener {
     }
 
     public void onSensorChanged(SensorEvent event) {
-
-        if (event.sensor == mAccelerometer) {
+        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) {

+ 12 - 2
app/src/main/java/app/brest/utils/app/brest/game/Game.java

@@ -33,6 +33,7 @@ public class Game  implements Serializable {
     protected ArrayList<Area>  mAreas = new ArrayList<Area>();
     protected ArrayList<Area>  mCurrentStageAreas = new ArrayList<Area>();
     protected ArrayList<Stage> mStages = new ArrayList<Stage>();
+    protected ArrayList<Resource> m_otherResources = new ArrayList<Resource>();
     protected int              mNStages;
     protected int              mCurrentStage=0;
     protected Player           mPlayer;
@@ -52,12 +53,18 @@ public class Game  implements Serializable {
         try {
             JSONArray areas = root.getJSONArray("areas");
             JSONArray stages = root.getJSONArray("stages_list");
+            JSONArray others = root.getJSONArray("others");
+
+            for(int i=0; i<others.length(); i++)
+                m_otherResources.add(new Resource(others.getString(i), act));
 
             for(int i=0; i<areas.length(); i++)
                 mAreas.add(new Area(areas.getJSONObject(i), act));
+
             for(int i=0; i<stages.length(); i++) {
                 Stage s = new Stage(stages.getJSONObject(i));
                 Resource r = findResource(s.getResourceName());
+                Log.e("_______", "Res = "+r+" "+s.getResourceName());
                 s.setResource(r);
                 mStages.add(s);
             }
@@ -165,7 +172,7 @@ public class Game  implements Serializable {
         for(int i=0; i<r.size(); i++) {
             for (int j = 0; j < mCurrentStageAreas.size(); j++) {
 
-                if (r.get(i).getResource(0).getName().compareTo(mCurrentStageAreas.get(j).getName()) == 0 &&
+                if (r.get(i).getResource(0).getName().compareTo(mCurrentStageAreas.get(j).getResourceNames().get(0)) == 0 &&
                         r.get(i).getResource(0).getStage() == mCurrentStage) {
                     removeArea(j);
                 }
@@ -308,6 +315,9 @@ public class Game  implements Serializable {
             for(int j=0; j<mAreas.get(i).countResource(); j++)
                 if(mAreas.get(i).getResourceNames().get(j).compareTo(name)==0)
                  return mAreas.get(i).getResource(j);
+        for(int i=0; i<m_otherResources.size(); i++)
+            if(m_otherResources.get(i).getName().compareTo(name)==0)
+                return m_otherResources.get(i);
         return null;
     }
 
@@ -372,7 +382,7 @@ public class Game  implements Serializable {
             if(b)
             {
 
-                if(i<mCurrentStageAreas.size() && mCurrentStageAreas.get(i).isOnDirection(mPlayer) &&
+                if(i<mCurrentStageAreas.size() /*&& mCurrentStageAreas.get(i).isOnDirection(mPlayer)*/ &&
                         mCurrentStageAreas.get(i).isOnPlace(mPlayer))
                 {
                     ArrayList<Resource> rs = mResources.getResourceLeftByName(mCurrentStageAreas.get(i).getResourceNames());

+ 39 - 9
app/src/main/java/app/brest/utils/app/brest/game/Player.java

@@ -7,6 +7,7 @@ import java.io.Serializable;
 import app.brest.testmin3d.ARActivity;
 import app.brest.utils.SensorsManager;
 import app.brest.utils.geometry.GPSPoint;
+import min3d.vos.Number3d;
 
 /**
  * Created by ptitcois on 20/08/16.
@@ -14,6 +15,11 @@ import app.brest.utils.geometry.GPSPoint;
 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);
@@ -40,10 +46,6 @@ public class Player implements Serializable{
         mSensors.onResume();
     }
 
-    public GPSPoint getPosition()
-    {
-        return mSensors.getPosition();
-    }
 
     public float getOrientation()
     {
@@ -68,29 +70,29 @@ public class Player implements Serializable{
 
     public double getAngleWith(Place p)
     {
-        double d=mSensors.getPosition().getAngleWith(p.getLocation());;
+        double d=getPosition().getAngleWith(p.getLocation());;
         while(d<0) d+=360;
         return d;
     }
 
     public double getXWith(Place p)
     {
-        return mSensors.getPosition().getDistanceXWith(p.getLocation());
+        return getPosition().getDistanceXWith(p.getLocation());
     }
 
     public double getYWith(Place p)
     {
-        return mSensors.getPosition().getDistanceYWith(p.getLocation());
+        return getPosition().getDistanceYWith(p.getLocation());
     }
 
     public double getRelXWith(Place p)
     {
-        return mSensors.getPosition().getRelXWith(p.getLocation());
+        return getPosition().getRelXWith(p.getLocation());
     }
 
     public double getRelYWith(Place p)
     {
-        return mSensors.getPosition().getRelYWith(p.getLocation());
+        return getPosition().getRelYWith(p.getLocation());
     }
 
     public void newSensorManager(Activity act)
@@ -102,4 +104,32 @@ public class Player implements Serializable{
     {
         mSensors.nextStub();
     }
+
+    public GPSPoint getPosition()
+    {
+        if(mState==STATE_SEARCHING || mSensors.useGpsStub())
+            return mSensors.getPosition();
+        else
+            return mFreezedPosition;
+    }
+
+    public void freezePosition()
+    {
+        mState=STATE_FOUND;
+        mFreezedPosition=mSensors.getPosition().copy();
+    }
+
+    public void freezePosition(GPSPoint target)
+    {
+        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;
+    }
 }

+ 1 - 1
app/src/main/java/app/brest/utils/app/brest/game/Resource.java

@@ -139,7 +139,7 @@ public class Resource implements Serializable {
             //m3DModel.rotation().y+=-180;
 
             //m3DModel.rotation().y=90;
-            m3DModel.scale().x = mScale.x; m3DModel.scale().y = mScale.y; m3DModel.scale().z = mScale.z;
+            m3DModel.scale().x = mScale.x*2; m3DModel.scale().y = mScale.y*2; m3DModel.scale().z = mScale.z*2;
             Log.e("MODEL", mName+" ("+m3DModel.scale().x+", "+m3DModel.scale().y+", "+m3DModel.scale().z+")");
         }
         return m3DModel;

+ 9 - 0
app/src/main/java/app/brest/utils/app/brest/game/Stage.java

@@ -27,6 +27,15 @@ public class Stage implements Serializable {
         }
     }
 
+    public  String toString()
+    {
+        String s = "";
+        s+="Stage="+mStage+"\n";
+        s+="Resource="+mResourceName+"\n";
+        s+="Step="+mNResourceStep+"\n";
+        s+="Transition="+mIsTransition+"\n";
+        return s;
+    }
 
     protected int mStage;
     protected Resource mResource;

+ 5 - 0
app/src/main/java/app/brest/utils/geometry/GPSPoint.java

@@ -36,6 +36,11 @@ public class GPSPoint extends app.brest.utils.geometry.Point  implements Seriali
         mAccuracy=acc;
     }
 
+    public GPSPoint copy()
+    {
+        return new GPSPoint(mX, mY, mAccuracy);
+    }
+
     public float getAccuracy()
     {
         return mAccuracy;

+ 2 - 1
app/src/main/res/values/strings.xml

@@ -72,8 +72,9 @@
     <string name="pref_title_vibrate">Vibrate</string>
     <string name="gps_stub_bis">-1.6636940 48.0955401 ; </string>
     <string name="gps_stub__">-1.67609 48.10663;-1.67918 48.10971;-1.67929 48.11128;-1.68026 48.11461;</string>
-    <string name="gps_stub">-4.4931557 48.3852982;-4.4907396 48.3822208;-4.4913189 48.3821055;-4.5009306 48.3812175;-4.4994088 48.3816246;-4.5001176 48.3829454;-4.4998877 48.3861891;-4.4993333 48.3843879;-4.4981522 48.3837466;-4.4940766 48.3855502;-4.4934548 48.3850800;-4.4920585 48.3832195;-4.4925920 48.3818895;-4.4974687 48.3831305;-4.4977893 48.3839475;-4.4936559 48.3832834;-4.4947957 48.3844682;-4.4944665 48.3851339;-4.4940462 48.3842496;-4.4926676 48.3835729;-4.4927382 48.3826774;-4.4972925 48.3835206;-4.4956640 48.3843096;-4.4980210 48.3844962;      </string>
+    <string name="gps_stub_brest">-4.4931557 48.3852982;-4.4907396 48.3822208;-4.4913189 48.3821055;-4.5009306 48.3812175;-4.4994088 48.3816246;-4.5001176 48.3829454;-4.4998877 48.3861891;-4.4993333 48.3843879;-4.4981522 48.3837466;-4.4940766 48.3855502;-4.4934548 48.3850800;-4.4920585 48.3832195;-4.4925920 48.3818895;-4.4974687 48.3831305;-4.4977893 48.3839475;-4.4936559 48.3832834;-4.4947957 48.3844682;-4.4944665 48.3851339;-4.4940462 48.3842496;-4.4926676 48.3835729;-4.4927382 48.3826774;-4.4972925 48.3835206;-4.4956640 48.3843096;-4.4980210 48.3844962;      </string>
     <string name="gps_stub_">-1.6636940 48.0955401 ;-1.6648474 48.0958025;-1.6649627 48.0958487;-1.6652739 48.0958718;-1.6658446 48.0954599;-1.6658503 48.0947939;-1.6649685 48.0953636;-1.6635852 48.0952597;-1.6637062 48.0954137;-1.6637927 48.0955215;-1.6639079 48.0956793;-1.6641270 48.0957178;-1.6642653 48.0956139;-1.6644785 48.0957216;</string>
+    <string name="gps_stub">-1.654773 48.020967;-1.655274 48.021321;-1.655843 48.020494;</string>
 
     <string name="title_activity_puzzle">PuzzleActivity</string>
 </resources>