|
@@ -1,40 +1,36 @@
|
|
|
-package app.brest.testmin3d;
|
|
|
-import android.Manifest;
|
|
|
-import android.app.Activity;
|
|
|
+package app.ara.activities;
|
|
|
import android.content.Intent;
|
|
|
import android.content.pm.ActivityInfo;
|
|
|
-import android.content.pm.PackageManager;
|
|
|
import android.content.res.Resources;
|
|
|
import android.graphics.PixelFormat;
|
|
|
import android.hardware.Camera;
|
|
|
import android.os.Bundle;
|
|
|
import android.os.Handler;
|
|
|
-import android.support.v4.app.ActivityCompat;
|
|
|
-import android.support.v4.content.ContextCompat;
|
|
|
import android.util.Log;
|
|
|
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 java.util.List;
|
|
|
-
|
|
|
-import app.brest.app.brest.ui.CameraPreview;
|
|
|
-import app.brest.utils.app.brest.game.Area;
|
|
|
-import app.brest.utils.app.brest.game.Game;
|
|
|
-import app.brest.utils.app.brest.game.LocatedResources;
|
|
|
-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;
|
|
|
+
|
|
|
+import app.ara.ui.CameraPreview;
|
|
|
+import app.ara.utils.AndroidResources;
|
|
|
+import app.ara.utils.Settings;
|
|
|
+import app.ara.utils.app.brest.game.Area;
|
|
|
+import app.ara.utils.app.brest.game.Game;
|
|
|
+import app.ara.utils.app.brest.game.LocatedResources;
|
|
|
+import app.ara.utils.app.brest.game.Place;
|
|
|
+import app.ara.utils.app.brest.game.Resource;
|
|
|
+import app.ara.utils.app.brest.game.Stage;
|
|
|
+import app.ara.utils.geometry.GPSPoint;
|
|
|
import min3d.core.Object3d;
|
|
|
import min3d.core.Object3dContainer;
|
|
|
import min3d.core.RendererActivity;
|
|
@@ -42,7 +38,6 @@ 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
|
|
@@ -77,6 +72,8 @@ public class ARActivity extends RendererActivity
|
|
|
private Boolean mUpdate = true;
|
|
|
private Handler mCustomHandler = new Handler();
|
|
|
|
|
|
+ private boolean mIsResource = false;
|
|
|
+
|
|
|
public void init()
|
|
|
{
|
|
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
|
@@ -221,6 +218,9 @@ public class ARActivity extends RendererActivity
|
|
|
if(mGame.getmSettings().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);
|
|
@@ -230,13 +230,13 @@ public class ARActivity extends RendererActivity
|
|
|
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().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.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";
|
|
|
+ + ", " + dts(oo.position().z) + ")\nAngle Rel:"+dts(alpha)+" : "+dts(mGame.getPlayer().getAngleWith(p))+" - "+dts(mGame.getPlayer().getOrientationX())+"\n";
|
|
|
}
|
|
|
}else
|
|
|
{
|
|
@@ -251,90 +251,7 @@ public class ARActivity extends RendererActivity
|
|
|
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()
|
|
|
{
|
|
@@ -414,7 +331,10 @@ public class ARActivity extends RendererActivity
|
|
|
protected void onCreate(Bundle savedInstanceState)
|
|
|
{
|
|
|
super.onCreate(savedInstanceState);
|
|
|
- setContentView(R.layout.activity_main);
|
|
|
+
|
|
|
+ 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) getIntent().getSerializableExtra("game");
|
|
|
mGame = Game.game();
|
|
@@ -474,13 +394,12 @@ public class ARActivity extends RendererActivity
|
|
|
synchronized (mUpdate)
|
|
|
{
|
|
|
if(!mUpdate) return;
|
|
|
- boolean isResource = false;
|
|
|
|
|
|
//Precache du modèle 3D
|
|
|
synchronized (mLock) {
|
|
|
if (!isPausing) {
|
|
|
boolean b = mGame.precache3DResource(this);
|
|
|
- isResource = updateSceneResource();
|
|
|
+ mIsResource = updateSceneResource();
|
|
|
}else
|
|
|
{
|
|
|
scene.clear();
|
|
@@ -488,7 +407,7 @@ public class ARActivity extends RendererActivity
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(isResource) {
|
|
|
+ if(mIsResource) {
|
|
|
mOkButton.getHandler().post(new Runnable() {
|
|
|
public void run() {
|
|
|
mOkButton.setVisibility(View.VISIBLE);
|
|
@@ -623,10 +542,9 @@ public class ARActivity extends RendererActivity
|
|
|
startActivity(intent2);
|
|
|
}
|
|
|
System.out.println("Ressource: '"+s.getResourceName()+"' : "+!s.getResourceName().isEmpty());
|
|
|
- if(!s.getResourceName().isEmpty())
|
|
|
+ if(!s.getResourceName().isEmpty() && s.isTransition())
|
|
|
{
|
|
|
- Intent intent = new Intent(this, ViewerActivity.class);
|
|
|
- intent.putExtra("resource", stageRes);
|
|
|
+ Intent intent = AndroidResources.getViewerIntent(this, stageRes);
|
|
|
startActivity(intent);
|
|
|
}
|
|
|
|
|
@@ -639,8 +557,7 @@ public class ARActivity extends RendererActivity
|
|
|
}
|
|
|
for(int i=0; i<res.size(); i++)
|
|
|
{
|
|
|
- Intent intent = new Intent(this, ViewerActivity.class);
|
|
|
- intent.putExtra("resource", res.get(i) );
|
|
|
+ Intent intent = AndroidResources.getViewerIntent(this, res.get(i));
|
|
|
startActivity(intent);
|
|
|
}
|
|
|
finish();
|
|
@@ -664,9 +581,18 @@ public class ARActivity extends RendererActivity
|
|
|
return (int) (px / Resources.getSystem().getDisplayMetrics().density);
|
|
|
}
|
|
|
|
|
|
- public void onStub(View v)
|
|
|
+
|
|
|
+
|
|
|
+ public void onClickScreen(View v)
|
|
|
+
|
|
|
{
|
|
|
- mGame.getPlayer().nextStub();
|
|
|
+ if(mIsResource)
|
|
|
+ onClickPickUp(v);
|
|
|
+ else if(Settings.getSettings().isGPSDebug())
|
|
|
+ mGame.getPlayer().nextStub();
|
|
|
+ else {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|