Jelajahi Sumber

Envoi et fin OK

François Gautrais 8 tahun lalu
induk
melakukan
9abee2ff9b
31 mengubah file dengan 613 tambahan dan 74 penghapusan
  1. 8 5
      app/src/main/AndroidManifest.xml
  2. 42 0
      app/src/main/java/app/brest/app/brest/ui/RotateButton.java
  3. 27 2
      app/src/main/java/app/brest/testmin3d/ARActivity.java
  4. 2 1
      app/src/main/java/app/brest/testmin3d/EndActivity.java
  5. 15 0
      app/src/main/java/app/brest/testmin3d/MenuActivity.java
  6. 262 0
      app/src/main/java/app/brest/testmin3d/NewMenuActivity.java
  7. 2 3
      app/src/main/java/app/brest/testmin3d/ResourceListActivity.java
  8. 2 2
      app/src/main/java/app/brest/testmin3d/TransferActivity.java
  9. 1 1
      app/src/main/java/app/brest/utils/SensorsManager.java
  10. 71 1
      app/src/main/java/app/brest/utils/SlideBuffer.java
  11. 15 7
      app/src/main/java/app/brest/utils/app/brest/game/Game.java
  12. 29 0
      app/src/main/java/app/brest/utils/app/brest/game/LocatedResource.java
  13. 43 16
      app/src/main/java/app/brest/utils/app/brest/game/Place.java
  14. 15 0
      app/src/main/java/app/brest/utils/app/brest/game/Player.java
  15. 1 3
      app/src/main/java/app/brest/utils/app/brest/game/Resource.java
  16. 5 0
      app/src/main/java/app/brest/utils/geometry/GPSPoint.java
  17. 2 2
      app/src/main/java/min3d/core/Renderer.java
  18. 1 1
      app/src/main/java/min3d/vos/CameraVo.java
  19. TEMPAT SAMPAH
      app/src/main/res/drawable/background.png
  20. TEMPAT SAMPAH
      app/src/main/res/drawable/bscanner.png
  21. TEMPAT SAMPAH
      app/src/main/res/drawable/button.png
  22. TEMPAT SAMPAH
      app/src/main/res/drawable/buttonb.png
  23. 1 1
      app/src/main/res/layout/activity_end.xml
  24. 4 4
      app/src/main/res/layout/activity_main.xml
  25. 14 0
      app/src/main/res/layout/activity_new_menu.xml
  26. 1 1
      app/src/main/res/layout/activity_resource_list.xml
  27. 1 1
      app/src/main/res/layout/activity_settings.xml
  28. 2 3
      app/src/main/res/layout/activity_transfer.xml
  29. 3 3
      app/src/main/res/layout/activity_viewer.xml
  30. 30 17
      app/src/main/res/raw/game_medium
  31. 14 0
      app/src/main/res/values/colors.xml

+ 8 - 5
app/src/main/AndroidManifest.xml

@@ -32,17 +32,20 @@
         <activity
             android:name=".MenuActivity"
             android:label="@string/title_activity_menu">
-            <intent-filter>
-                <action android:name="android.intent.action.MAIN" />
 
-                <category android:name="android.intent.category.LAUNCHER" />
-            </intent-filter>
         </activity>
         <activity
             android:name=".SettingsActivity"
             android:label="@string/title_activity_settings" />
         <activity android:name=".TransferActivity" />
-        <activity android:name=".EndActivity"></activity>
+        <activity android:name=".EndActivity" />
+        <activity android:name=".NewMenuActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
     </application>
 
 </manifest>

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

@@ -0,0 +1,42 @@
+package app.brest.app.brest.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;
+    }
+}

+ 27 - 2
app/src/main/java/app/brest/testmin3d/ARActivity.java

@@ -11,6 +11,7 @@ import android.view.View;
 import android.view.WindowManager;
 import android.widget.Button;
 import android.widget.FrameLayout;
+import android.widget.ImageButton;
 import android.widget.MediaController;
 import android.widget.TextView;
 import android.widget.Toast;
@@ -27,6 +28,8 @@ import app.brest.utils.JSONLoader;
 import app.brest.utils.ResourceManager;
 import app.brest.utils.SensorsManager;
 import app.brest.utils.app.brest.game.Game;
+import app.brest.utils.app.brest.game.LocatedResource;
+import app.brest.utils.app.brest.game.Place;
 import app.brest.utils.app.brest.game.Resource;
 import app.brest.utils.app.brest.game.Stage;
 import app.brest.utils.geometry.GPSPoint;
@@ -35,6 +38,7 @@ import min3d.core.Object3dContainer;
 import min3d.core.RendererActivity;
 import min3d.parser.IParser;
 import min3d.parser.Parser;
+import min3d.vos.CameraVo;
 import min3d.vos.Light;
 import min3d.vos.Number3d;
 
@@ -139,18 +143,34 @@ public class ARActivity extends RendererActivity
     protected boolean updateSceneResource()
     {
 
-        ArrayList<Resource> res = mGame.getResourcesNextToPlayer();
+        ArrayList<LocatedResource> res = mGame.getResourcesNextToPlayer();
         final TextView tv = (TextView) findViewById(R.id.text_detected);
         final TextView tv2 = (TextView)findViewById(R.id.text_place);
         String toDisplay ="Detetected \n";
        // String dete = "Detected:\n";
         scene.clear();
         for (int i = 0; i < res.size(); i++) {
-            Resource rr = res.get(i);
+            Resource rr = res.get(i).getResource();
+            Place p = res.get(i).getPlace();
             if(rr!=null) {
                 toDisplay += "\t" + rr.getName() + " \n";
                 //dete += "\t" + rr.getName() + "\n";
                 Object3d oo = rr.get3DModel(this);
+                CameraVo v = new CameraVo();
+
+                v.target.y=mGame.getPlayer().getOrientationY()-315;
+
+                //si utilisation de field et angle
+                if(p.isUseAngle())
+                    v.target.x=(float)(mGame.getPlayer().getOrientationX()-p.getAngle())+mGame.getPlayer().getOrientationZ()-270f;
+                //si utilisation GPS pour l'angle
+                else
+                    v.target.x=(float)(mGame.getPlayer().getOrientationX()-mGame.getPlayer().getAngleWith(p))
+                            +mGame.getPlayer().getOrientationZ()-270f;
+
+                toDisplay += "    "+(float)(mGame.getPlayer().getAngleWith(p)) +"("+mGame.getPlayer().getXWith(p)+", "+mGame.getPlayer().getYWith(p) +")\n";
+                //v.target.z=mGame.getPlayer().getOrientationZ()-270;
+                scene.camera(v);
                 scene.addChild(oo);
             }
         }
@@ -298,6 +318,7 @@ public class ARActivity extends RendererActivity
         }
     }
 
+
     public void onSaveInstanceState(Bundle savedInstanceState) {
         // Save the user's current game state
         savedInstanceState.putSerializable("game", mGame);
@@ -317,6 +338,7 @@ public class ARActivity extends RendererActivity
         if(stageFinished)
         {
            finished = mGame.nextStage();
+            Log.e("--____", "Finished="+finished);
         }
 
         if(finished)
@@ -331,6 +353,7 @@ public class ARActivity extends RendererActivity
 
             if(finished)
             {
+                Log.e("--____", "Here");
                 Intent intent2 = new Intent(this, EndActivity.class);
                 startActivity(intent2);
             }
@@ -356,4 +379,6 @@ public class ARActivity extends RendererActivity
         mLocationUpdated=true;
     }
 
+
+
 }

+ 2 - 1
app/src/main/java/app/brest/testmin3d/EndActivity.java

@@ -1,9 +1,10 @@
 package app.brest.testmin3d;
 
+import android.app.Activity;
 import android.support.v7.app.AppCompatActivity;
 import android.os.Bundle;
 
-public class EndActivity extends AppCompatActivity {
+public class EndActivity extends Activity {
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {

+ 15 - 0
app/src/main/java/app/brest/testmin3d/MenuActivity.java

@@ -1,11 +1,13 @@
 package app.brest.testmin3d;
 
 import android.app.Activity;
+import android.content.DialogInterface;
 import android.content.Intent;
 import android.graphics.Point;
 import android.os.Bundle;
 import android.support.design.widget.FloatingActionButton;
 import android.support.design.widget.Snackbar;
+import android.support.v7.app.AlertDialog;
 import android.support.v7.app.AppCompatActivity;
 import android.support.v7.widget.Toolbar;
 import android.util.Log;
@@ -71,6 +73,9 @@ public class MenuActivity extends Activity {
             mGame.pickResource("e");
             */
         }
+
+        Intent intent = new Intent(this, NewMenuActivity.class);
+        startActivity(intent);
     }
 
     public void onResume()
@@ -141,6 +146,13 @@ public class MenuActivity extends Activity {
         Stage s = mGame.getCurrentStageObj();
         Resource stageRes = s.getResource();
 
+        if(finished)
+        {
+            Log.e("--____", "Here");
+            Intent intent2 = new Intent(this, EndActivity.class);
+            startActivity(intent2);
+        }
+
         Intent intent = new Intent(this, ViewerActivity.class);
         intent.putExtra("resource", stageRes );
         startActivity(intent);
@@ -149,4 +161,7 @@ public class MenuActivity extends Activity {
         Intent intent2 = new Intent(this, TransferActivity.class);
         startActivity(intent2);
     }
+
+
+
 }

+ 262 - 0
app/src/main/java/app/brest/testmin3d/NewMenuActivity.java

@@ -0,0 +1,262 @@
+package app.brest.testmin3d;
+
+import android.animation.ObjectAnimator;
+import android.app.Activity;
+import android.content.Intent;
+import android.graphics.Point;
+import android.graphics.Typeface;
+import android.graphics.drawable.Drawable;
+import android.os.Handler;
+import android.support.v7.app.AppCompatActivity;
+import android.os.Bundle;
+import android.text.Layout;
+import android.util.Log;
+import android.view.Display;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.RelativeLayout;
+import android.widget.Toast;
+
+import app.brest.app.brest.ui.RotateButton;
+import app.brest.utils.app.brest.game.Game;
+import app.brest.utils.app.brest.game.Resource;
+import app.brest.utils.app.brest.game.Stage;
+
+public class NewMenuActivity extends Activity implements View.OnClickListener{
+
+    private int mWidth;
+    private int mHeight;
+    protected Game mGame;
+
+    private RelativeLayout mRootLayout;
+    private Handler mCustomHandler = new Handler();
+    //private final int COLOR_BACKGROUND = ;
+    private final int COLOR_SHAPE = R.color.dull_2;
+    private final int COLOR_BACKGROUND_SECOND = R.color.dull_3;
+    private final int COLOR_OTHER = R.color.dull_4;
+    private final int COLOR_TEXT = R.color.dull_5;
+
+    private Button mIbScanner;
+    private Button mBBriefing;
+    private Button mBInvotory;
+    private Button mBMap;
+    private Button mBOptions;
+    private Button mBMenu;
+    private Button mBSend;
+
+
+    private void setUpStyle()
+    {
+        mRootLayout.setBackgroundResource(R.drawable.background);
+        int h4 = mHeight/3;
+        int w4 = mWidth/3;
+        int w = (int)(w4*1.25);
+        int h = 80;
+        moveView(mBBriefing, w4-2*w/3, h4-h,w,h);
+        moveView(mBInvotory, 2*w4-w/3, h4-h,w,h);
+        moveView(mBMap, w4-2*w/3, 2*h4,w,h);
+        moveView(mBOptions, 2*w4-w/3, 2*h4,w,h);
+        moveView(mBSend, 0, mHeight-100, mWidth, 100);
+        mBMenu.setTextSize(28);
+        mBMenu.setTypeface(null,Typeface.BOLD);
+        sendVisibility();
+
+    }
+
+    private void updateSize()
+    {
+        Display display = getWindowManager().getDefaultDisplay();
+        Point size = new Point();
+        display.getSize(size);
+        mWidth = size.x;
+        mHeight = size.y;
+    }
+
+    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.button);
+        b.setTextColor(getResources().getColor(R.color.dull_4));
+        b.setTextSize(22);
+        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);
+
+        Game g = null;//Game.load(this);
+
+        if (g!= null && mGame==null) {
+            mGame = g;
+            Game.setGame(mGame);
+            mGame.newSensorManager(this);
+            Toast.makeText(this, "Chargement", Toast.LENGTH_LONG).show();
+        }
+        else if( mGame==null)
+        {
+            mGame = new Game("game_medium", this);
+            Game.setGame(mGame);
+            Toast.makeText(this, "Nouveau Jeu", Toast.LENGTH_LONG).show();
+        }else if( mGame==null)
+        {
+            Toast.makeText(this, "Erreur", Toast.LENGTH_LONG).show();
+            throw new Error("Le jeu n'est pas sauvegardé");
+        }
+        updateSize();
+
+        mIbScanner = new Button(this);
+        //mIbScanner.setImageResource(R.drawable.scanner);
+        //mIbScanner.setScaleType(ImageView.ScaleType.FIT_CENTER);
+        mRootLayout.addView(mIbScanner);
+        mIbScanner.setBackgroundResource(R.drawable.bscanner);
+        mIbScanner.setText("Scanner");
+        mIbScanner.setTextColor(getResources().getColor(R.color.dull_4));
+        mIbScanner.setTextSize(22);
+        mIbScanner.setOnClickListener(this);
+
+        moveView(mIbScanner, mWidth/2-mHeight/8, mHeight/2-mHeight/8, mHeight/4, mHeight/4);
+
+        mBBriefing = newButton("Briefing");
+        mBInvotory = newButton("Inventaire");
+        mBMap = newButton("Carte");
+        mBOptions = newButton("Options");
+        mBMenu = newButton("Menu Principal");
+
+        mBSend = newButton("Envoyer les données");
+        moveView(mBMenu, 0, 0, mWidth, mHeight/8);
+        //mBSend = newButton("Envoyer");
+
+
+        setUpStyle();
+        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 = new Intent(this, ViewerActivity.class);
+        intent.putExtra("map", mGame.getName()+"_map");
+        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 onInfoClick(View v) {
+        Intent intent = new Intent(this, ViewerActivity.class);
+        Stage s = mGame.getCurrentStageObj();
+        Resource r = (s!=null)?s.getResource(): null;
+        intent.putExtra("resource", r );
+        startActivity(intent);
+    }
+
+
+    public void onSendClick(View v)
+    {
+        //TODO : Transmssion des donnes
+        boolean finished = mGame.nextStage();
+
+        Stage s = mGame.getCurrentStageObj();
+        Resource stageRes = s.getResource();
+
+        if(finished)
+        {
+            Log.e("--____", "Here");
+            Intent intent2 = new Intent(this, EndActivity.class);
+            startActivity(intent2);
+        }
+
+        Intent intent = new Intent(this, ViewerActivity.class);
+        intent.putExtra("resource", stageRes );
+        startActivity(intent);
+
+
+        Intent intent2 = new Intent(this, TransferActivity.class);
+        startActivity(intent2);
+    }
+
+    @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 == mBSend) onSendClick(view);
+        else if(view == mBInvotory) onInventaireClick(view);
+        else if(view == mBOptions) onOptionsClick(view);
+    }
+
+    public void onResume()
+    {
+        super.onResume();
+        setUpStyle();
+    }
+
+    private void sendVisibility()
+    {
+        if(mGame.canSendData()) mBSend.setVisibility(View.VISIBLE);
+        else mBSend.setVisibility(View.INVISIBLE);
+    }
+
+    private Runnable updateTimerThread = new Runnable() {
+
+        public void run() {
+
+            mCustomHandler.postDelayed(this, 10);
+        }
+
+    };
+}

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

@@ -1,6 +1,7 @@
 package app.brest.testmin3d;
 
 import android.annotation.SuppressLint;
+import android.app.Activity;
 import android.content.Intent;
 import android.graphics.Color;
 import android.graphics.Typeface;
@@ -29,7 +30,7 @@ import app.brest.utils.app.brest.game.Resource;
  * An example full-screen activity that shows and hides the system UI (i.e.
  * status bar and navigation/system bar) with user interaction.
  */
-public class ResourceListActivity extends AppCompatActivity {
+public class ResourceListActivity extends Activity {
 
     protected Game mGame;
     protected LinearLayout mLayout;
@@ -45,13 +46,11 @@ public class ResourceListActivity extends AppCompatActivity {
         b.setTextColor(Color.rgb(0x33, 0xb5, 0xe5));
         b.setTextSize(30);
         b.setTypeface(null, Typeface.BOLD);
-        b.setBackgroundColor(Color.rgb(0,0,0));
 
         aa = new ResourceArrayAdapter(this, android.R.layout.simple_list_item_1, ar);
         lv.setOnItemClickListener(aa);
 
         lv.setAdapter(aa);
-        lv.setBackgroundColor(Color.rgb(0,0,0));
 
         nl.setOrientation(LinearLayout.VERTICAL);
         nl.addView(b);

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

@@ -14,13 +14,13 @@ import android.widget.Toast;
 
 import app.brest.utils.app.brest.game.Game;
 
-public class TransferActivity extends AppCompatActivity {
+public class TransferActivity extends Activity {
 
     private Handler mCustomHandler = new Handler();
     private ProgressBar mBar;
     private ImageButton mImage;
     private int mCurrentPos = 0;
-    private final int MAX_POS=70;
+    private final int MAX_POS=210;
     private final int PERIODE_SEND=35;
     private Activity mSelf;
 

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

@@ -82,7 +82,7 @@ public class SensorsManager implements SensorEventListener, LocationListener {
         mSensorManager = (SensorManager) parent.getSystemService(parent.SENSOR_SERVICE);
         mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
         mMagnetometer = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD);
-        mBufferX = new SlideBuffer(16);
+        mBufferX = new SlideBuffer(64);
         mBufferY = new SlideBuffer(8);
         mBufferZ = new SlideBuffer(8);
 

+ 71 - 1
app/src/main/java/app/brest/utils/SlideBuffer.java

@@ -4,7 +4,7 @@ import java.util.ArrayList;
 
 import app.brest.utils.geometry.Point;
 
-
+/*
 public class SlideBuffer {
     private float mData;
     private int mSize;
@@ -27,8 +27,78 @@ public class SlideBuffer {
         return mData;
     }
 
+}*/
+
+public class SlideBuffer {
+    private float mDataSin;
+    private float mDataCos;
+    private final float COEF = 0.1f;
+    private int mSize;
+    private int mHead;
+
+    public SlideBuffer(int size)
+    {
+        mDataSin = 0;
+        mDataCos = 0;
+        mSize = 0;
+        mHead =0;
+    }
+
+    public void enqueue(float val)
+    {
+        mDataSin= mDataSin + COEF*((float)Math.sin(val*Math.PI/180)-mDataSin);
+        mDataCos= mDataCos + COEF*((float)Math.cos(val*Math.PI/180)-mDataCos);
+    }
+
+    public float average()
+    {
+        return (float)((Math.atan2(mDataCos, mDataSin))*180/Math.PI)+180f;
+    }
+
 }
 
+/*
+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;
 

+ 15 - 7
app/src/main/java/app/brest/utils/app/brest/game/Game.java

@@ -22,6 +22,7 @@ import app.brest.utils.JSONLoader;
 import app.brest.utils.ResourceManager;
 import app.brest.utils.SensorsManager;
 import app.brest.utils.Settings;
+import app.brest.utils.geometry.Point;
 
 /**
  * Created by ptitcois on 19/08/16.
@@ -99,6 +100,7 @@ public class Game  implements Serializable {
     public boolean nextStage()
     {
         mCurrentStage++;
+        Log.e("--_______", "Current="+mCurrentStage+" > total="+mNStages);
         if(mCurrentStage>mNStages) return true;
 
         loadStageAreasResources();
@@ -141,16 +143,16 @@ public class Game  implements Serializable {
 
     public boolean pickResource()
     {
-        ArrayList<Resource> r = getResourcesNextToPlayer();
+        ArrayList<LocatedResource> r = getResourcesNextToPlayer();
         for(int i=0; i<r.size(); i++) {
             for (int j = 0; j < mCurrentStageAreas.size(); j++) {
 
-                if (r.get(i).getName().compareTo(mCurrentStageAreas.get(j).getName()) == 0 &&
-                        r.get(i).getStage() == mCurrentStage) {
+                if (r.get(i).getResource().getName().compareTo(mCurrentStageAreas.get(j).getName()) == 0 &&
+                        r.get(i).getResource().getStage() == mCurrentStage) {
                     removeArea(j);
                 }
             }
-            pickResource(r.get(i).getName());
+            pickResource(r.get(i).getResource().getName());
         }
         return mCurrentStageAreas.size()==0;
     }
@@ -298,9 +300,9 @@ public class Game  implements Serializable {
      * Fonction principale de positionnnemnt et orientation
      *
      */
-    public ArrayList<Resource> getResourcesNextToPlayer()
+    public ArrayList<LocatedResource> getResourcesNextToPlayer()
     {
-        ArrayList<Resource> r = new ArrayList<Resource>();
+        ArrayList<LocatedResource> r = new ArrayList<LocatedResource>();
         for(int i=0; i<mCurrentStageAreas.size(); i++)
         {
             //probleme de GPS..
@@ -311,12 +313,17 @@ public class Game  implements Serializable {
 
                 if(i<mCurrentStageAreas.size() && mCurrentStageAreas.get(i).isOnDirection(mPlayer))
                 {
-                    r.add(mResources.getResourceLeftByName(mCurrentStageAreas.get(i).getResourceName()));
+                    r.add(new LocatedResource(
+                            mResources.getResourceLeftByName(mCurrentStageAreas.get(i).getResourceName()),
+                            mCurrentStageAreas.get(i).getPlace(0)
+                            ));
                 }
             }
         }
         return r;
     }
+
+
     public String getResourcesNextToPlayer2()
     {
         String str = "Detected\n";
@@ -392,4 +399,5 @@ public class Game  implements Serializable {
     public boolean isFinished() { return mFinished; }
 
     public void finish() { mFinished=true; }
+
 }

+ 29 - 0
app/src/main/java/app/brest/utils/app/brest/game/LocatedResource.java

@@ -0,0 +1,29 @@
+package app.brest.utils.app.brest.game;
+
+/**
+ * Created by ptitcois on 21/10/16.
+ */
+public class LocatedResource {
+    private Place mPlace = null;
+    private Resource mResource = null;
+    public LocatedResource(Resource r, Place p) { mPlace=p; mResource=r;}
+    public LocatedResource(Resource r) {mResource=r;}
+    public LocatedResource(Place p) { mPlace=p;}
+    public LocatedResource() {}
+
+    public Place getPlace() {
+        return mPlace;
+    }
+
+    public void setPlace(Place mPlace) {
+        this.mPlace = mPlace;
+    }
+
+    public Resource getResource() {
+        return mResource;
+    }
+
+    public void setResource(Resource mResource) {
+        this.mResource = mResource;
+    }
+}

+ 43 - 16
app/src/main/java/app/brest/utils/app/brest/game/Place.java

@@ -23,6 +23,7 @@ public class Place  implements Serializable {
             mRadius = root.getDouble("radius");
             mField = root.getDouble("field");
             mAngle = root.getDouble("angle");
+            mUseAngle = root.getBoolean("useAngle");
         } catch (JSONException e) {
             e.printStackTrace();
         }
@@ -33,7 +34,7 @@ public class Place  implements Serializable {
     protected double    mRadius;
     protected double    mField;
     protected double    mAngle;
-
+    protected boolean   mUseAngle;
     public GPSPoint getLocation() {
         return mLocation;
     }
@@ -61,6 +62,7 @@ public class Place  implements Serializable {
             js.put("radius", ""+mRadius);
             js.put("field", ""+mField);
             js.put("angle", ""+mAngle);
+            js.put("useAngle", ""+mUseAngle);
         } catch (JSONException e) {
             e.printStackTrace();
         }
@@ -78,30 +80,55 @@ public class Place  implements Serializable {
     public boolean isOnDirection(Player p)
     {
         boolean ret;
-        float angle = p.getOrientation()%360;
-        while(angle<0) angle+=360;
-        double min = mAngle-mField/2;
-        double max = mAngle+mField/2;
-
-
-        if(min<0)
+        //si utilisation de angle et field
+        if(mUseAngle)
         {
-            min+=360;
-            ret=angle>=min  || angle <=max;
+            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 if(max>=360)
-        {
-            max-=360;
-            ret=angle<=max || (angle>=min);
-        }else
+        else
+        //si par rapport au coordonnées gps
         {
-            ret=(angle<=max && angle>=min);
+            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)
     {
         return mLocation.getDistanceWith(p.getPosition());
     }
+
 }

+ 15 - 0
app/src/main/java/app/brest/utils/app/brest/game/Player.java

@@ -66,6 +66,21 @@ public class Player implements Serializable{
         return mSensors.getAngleZ();
     }
 
+    public double getAngleWith(Place p)
+    {
+        return mSensors.getPosition().getAngleWith(p.getLocation());
+    }
+
+    public double getXWith(Place p)
+    {
+        return mSensors.getPosition().getDistanceXWith(p.getLocation());
+    }
+
+    public double getYWith(Place p)
+    {
+        return mSensors.getPosition().getDistanceYWith(p.getLocation());
+    }
+
     public void newSensorManager(Activity act)
     {
         mSensors = new SensorsManager(act);

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

@@ -63,7 +63,6 @@ public class Resource implements Serializable {
     {
         mName=name;
         loadResourceData(act);
-        Log.e("_____", "Stage = "+ mStage);
     }
 
     public Resource(JSONObject obj, Activity act)
@@ -71,7 +70,6 @@ public class Resource implements Serializable {
         try {
             mName=obj.getString("name");
             loadResourceData(act);
-            Log.e("_____", "Stage == "+ mStage);
         } catch (JSONException e) {
             e.printStackTrace();
         }
@@ -121,7 +119,7 @@ public class Resource implements Serializable {
             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.scale().x = mScale.x; m3DModel.scale().y = mScale.y; m3DModel.scale().z = mScale.z;
+            m3DModel.scale().x = mScale.x*3; m3DModel.scale().y = mScale.y*3; m3DModel.scale().z = mScale.z*3;
             Log.e("MODEL", mName+" ("+m3DModel.scale().x+", "+m3DModel.scale().y+", "+m3DModel.scale().z+")");
         }
         return m3DModel;

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

@@ -82,4 +82,9 @@ public class GPSPoint extends app.brest.utils.geometry.Point  implements Seriali
         return getDistanceWith(b);
     }
 
+    public double getAngleWith(GPSPoint p)
+    {
+        return Math.atan2(getDistanceXWith(p), getDistanceXWith(p))*180/Math.PI;
+    }
+
 }

+ 2 - 2
app/src/main/java/min3d/core/Renderer.java

@@ -92,7 +92,6 @@ public class Renderer implements GLSurfaceView.Renderer
 		_gl.glViewport(0, 0, w, h);
 		_gl.glMatrixMode(GL10.GL_PROJECTION);
 		_gl.glLoadIdentity();
-
 		updateViewFrustrum();
 	}
 	
@@ -600,7 +599,7 @@ public class Renderer implements GLSurfaceView.Renderer
 		
 		_gl.glMatrixMode(GL10.GL_PROJECTION);
 		_gl.glLoadIdentity();
-		_gl.glFrustumf(lt,rt, btm,top, vf.zNear(), vf.zFar());
+		_gl.glFrustumf(lt,rt, btm,top, vf.zNear()*200, vf.zFar()*2000);
 		
 		vf.clearDirtyFlag();
 	}
@@ -622,6 +621,7 @@ public class Renderer implements GLSurfaceView.Renderer
 	private void setGl(GL10 $gl)
 	{
 		_gl = $gl;
+
 	}
 	
 	private void doFps()

+ 1 - 1
app/src/main/java/min3d/vos/CameraVo.java

@@ -5,7 +5,7 @@ package min3d.vos;
  */
 public class CameraVo
 {
-	public Number3d position = new Number3d(0,0, 15); // ... note, not 'managed'
+	public Number3d position = new Number3d(0,1000, 10000); // ... note, not 'managed'
 	public Number3d target = new Number3d(0,0,0);
 	public Number3d upAxis = new Number3d(0,1,0);
 	

TEMPAT SAMPAH
app/src/main/res/drawable/background.png


TEMPAT SAMPAH
app/src/main/res/drawable/bscanner.png


TEMPAT SAMPAH
app/src/main/res/drawable/button.png


TEMPAT SAMPAH
app/src/main/res/drawable/buttonb.png


+ 1 - 1
app/src/main/res/layout/activity_end.xml

@@ -8,7 +8,7 @@
     android:paddingRight="@dimen/activity_horizontal_margin"
     android:paddingTop="@dimen/activity_vertical_margin"
     tools:context="app.brest.testmin3d.EndActivity"
-    android:background="#000000">
+    android:background="@drawable/background">
 
     <TextView
         android:layout_width="wrap_content"

+ 4 - 4
app/src/main/res/layout/activity_main.xml

@@ -6,11 +6,11 @@
     tools:context=".ARActivity"
     android:baselineAligned="false"
     android:weightSum="1"
-    android:background="#000000">
+    android:background="@drawable/background">
 
     <Button
         android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
+        android:layout_height="60dp"
         android:text="Récupérer"
         android:id="@+id/button_catch"
         android:visibility="visible"
@@ -21,9 +21,9 @@
         android:layout_alignParentEnd="true"
         android:onClick="onClickPickUp"
         android:longClickable="false"
-        android:background="#000000"
         android:textColor="#33b5e5"
-        android:textSize="25dp" />
+        android:textSize="25dp"
+        android:background="@drawable/button" />
 
     <FrameLayout
         android:layout_width="match_parent"

+ 14 - 0
app/src/main/res/layout/activity_new_menu.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:paddingBottom="0dp"
+    android:paddingLeft="0dp"
+    android:paddingRight="0dp"
+    android:paddingTop="0dp"
+    tools:context="app.brest.testmin3d.NewMenuActivity"
+    android:id="@+id/menu_root"
+    android:background="#000000">
+
+</RelativeLayout>

+ 1 - 1
app/src/main/res/layout/activity_resource_list.xml

@@ -2,7 +2,7 @@
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:background="#000000"
+    android:background="@drawable/background"
     android:orientation="vertical"
     tools:context="app.brest.testmin3d.ResourceListActivity">
 

+ 1 - 1
app/src/main/res/layout/activity_settings.xml

@@ -2,7 +2,7 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical" android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:background="#FFFFFF"
+    android:background="@drawable/background"
     android:weightSum="1">
 
     <RelativeLayout

+ 2 - 3
app/src/main/res/layout/activity_transfer.xml

@@ -8,7 +8,7 @@
     android:paddingRight="@dimen/activity_horizontal_margin"
     android:paddingTop="@dimen/activity_vertical_margin"
     tools:context="app.brest.testmin3d.TransferActivity"
-    android:background="#000000">
+    android:background="@drawable/background">
 
     <ProgressBar
         style="?android:attr/progressBarStyleHorizontal"
@@ -31,7 +31,6 @@
         android:layout_centerHorizontal="true"
         android:layout_marginBottom="73dp"
         android:textColor="#33b5e5"
-        android:background="#000000"
         android:textSize="25dp"
         android:textStyle="bold"
         android:singleLine="false"
@@ -47,6 +46,6 @@
         android:src="@drawable/send"
         android:scaleType="fitCenter"
         android:clickable="false"
-        android:background="#000000" />
+        android:background="@null"/>
 
 </RelativeLayout>

+ 3 - 3
app/src/main/res/layout/activity_viewer.xml

@@ -2,7 +2,7 @@
     xmlns:tools="http://schemas.android.com/tools"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
-    android:background="#000000"
+    android:background="@drawable/background"
     tools:context="app.brest.testmin3d.ViewerActivity">
 
     <!-- The primary full-screen view. This can be replaced with whatever view
@@ -14,12 +14,12 @@
 
     <Button
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
+        android:layout_height="70dp"
         android:text="Informations"
         android:id="@+id/button_info"
         android:layout_alignParentBottom="true"
         android:layout_centerHorizontal="true"
-        android:background="#000000"
+        android:background="@drawable/button"
         android:textColor="#33b5e5"
         android:textStyle="bold"
         android:textSize="25dp"

+ 30 - 17
app/src/main/res/raw/game_medium

@@ -32,7 +32,8 @@
 						48.095527648925781
 					],
 					"field" : 90,
-					"radius" : 10
+					"radius" : 10,
+					"useAngle" : false
 				}
 			],
 			"resource" : "aaa"
@@ -68,7 +69,8 @@
 						48.095546722412109
 					],
 					"field" : 90,
-					"radius" : 10
+					"radius" : 10,
+					"useAngle" : false
 				}
 			],
 			"resource" : "bbb"
@@ -100,7 +102,8 @@
 						48.095508575439453
 					],
 					"field" : 90,
-					"radius" : 10
+					"radius" : 10,
+					"useAngle" : true
 				}
 			],
 			"resource" : "ccc"
@@ -136,7 +139,8 @@
 						48.095550537109375
 					],
 					"field" : 90,
-					"radius" : 10
+					"radius" : 10,
+					"useAngle" : true
 				}
 			],
 			"resource" : "aa"
@@ -172,7 +176,8 @@
 						48.095550537109375
 					],
 					"field" : 90,
-					"radius" : 10
+					"radius" : 10,
+					"useAngle" : true
 				}
 			],
 			"resource" : "bb"
@@ -208,7 +213,8 @@
 						48.095546722412109
 					],
 					"field" : 90,
-					"radius" : 10
+					"radius" : 10,
+					"useAngle" : false
 				}
 			],
 			"resource" : "cc"
@@ -217,16 +223,20 @@
 			"coordinates" : 
 			[
 				[
-					-1.6708660125732422,
-					48.097171783447266
+					-1.6641926765441895,
+					48.095829010009766
 				],
 				[
-					-1.6697072982788086,
-					48.096942901611328
+					-1.663779616355896,
+					48.095699310302734
+				],
+				[
+					-1.6639620065689087,
+					48.095500946044922
 				],
 				[
-					-1.6707158088684082,
-					48.096267700195312
+					-1.6644018888473511,
+					48.095573425292969
 				]
 			],
 			"name" : "a",
@@ -236,11 +246,12 @@
 					"angle" : 180,
 					"coordinates" : 
 					[
-						-1.670372486114502,
-						48.096755981445312
+						-1.6640585660934448,
+						48.095653533935547
 					],
 					"field" : 90,
-					"radius" : 10
+					"radius" : 10,
+					"useAngle" : true
 				}
 			],
 			"resource" : "a"
@@ -276,7 +287,8 @@
 						48.095550537109375
 					],
 					"field" : 90,
-					"radius" : 10
+					"radius" : 10,
+					"useAngle" : true
 				}
 			],
 			"resource" : "b"
@@ -312,7 +324,8 @@
 						48.095550537109375
 					],
 					"field" : 90,
-					"radius" : 10
+					"radius" : 10,
+					"useAngle" : true
 				}
 			],
 			"resource" : "c"

+ 14 - 0
app/src/main/res/values/colors.xml

@@ -5,4 +5,18 @@
     <color name="colorAccent">#FF4081</color>
 
     <color name="black_overlay">#66000000</color>
+
+
+    <color name="dull_1">#001111</color>
+    <color name="dull_2">#005566</color>
+    <color name="dull_3">#113344</color>
+    <color name="dull_4">#117788</color>
+    <color name="dull_5">#1199cc</color>
+
+    <color name="vibrant_1">#000000</color>
+    <color name="vibrant_2">#006699</color>
+    <color name="vibrant_3">#004466</color>
+    <color name="vibrant_4">#0099cc</color>
+    <color name="vibrant_5">#00ccff</color>
+
 </resources>