François Gautrais 8 anos atrás
pai
commit
80c5eafcfe

+ 6 - 4
app/src/main/java/app/brest/testmin3d/ARActivity.java

@@ -139,10 +139,12 @@ public class ARActivity extends RendererActivity
         scene.clear();
         for (int i = 0; i < res.size(); i++) {
             Resource rr = res.get(i);
-            toDisplay+="\t"+rr.getName()+" \n";
-            //dete += "\t" + rr.getName() + "\n";
-            Object3d oo = rr.get3DModel(this);
-            scene.addChild(oo);
+            if(rr!=null) {
+                toDisplay += "\t" + rr.getName() + " \n";
+                //dete += "\t" + rr.getName() + "\n";
+                Object3d oo = rr.get3DModel(this);
+                scene.addChild(oo);
+            }
         }
         final String td = toDisplay;
         mAngle.getHandler().post(new Runnable() {

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

@@ -45,12 +45,13 @@ public class MenuActivity extends AppCompatActivity {
         mIOptions.setLayoutParams(new LinearLayout.LayoutParams(buttonHieght, buttonHieght));
         mIScanner.setLayoutParams(new LinearLayout.LayoutParams(buttonHieght, buttonHieght));
 
-        Game g = Game.load(this);
+        Game g = null;//Game.load(this);
+
         if (g!= null && mGame==null) {
             mGame = g;
             mGame.newSensorManager(this);
         }
-        else if(getIntent().hasExtra("game_name") && mGame==null)
+        else if( mGame==null)
         {
             mGame = new Game("game_medium", this);
 

+ 13 - 12
app/src/main/java/app/brest/utils/app/brest/game/Area.java

@@ -20,13 +20,12 @@ import app.brest.utils.geometry.Shape;
 public class Area  implements Serializable {
 
     protected String            mName;
-    protected String            mResource;
-    protected int               mStage;
+    protected String            mResourceName;
     protected Shape             mShape = new Shape();
     protected ArrayList<Place>  mPlaces = new ArrayList<Place>();
+    protected Resource          mResource;
 
-
-    public Area(JSONObject root)
+    public Area(JSONObject root, Activity act)
     {
         try {
             JSONArray ja = root.getJSONArray("coordinates");
@@ -35,12 +34,12 @@ public class Area  implements Serializable {
                 mShape.add(new GPSPoint(jaa.getDouble(0), jaa.getDouble(1)));
             }
             mName = root.getString("name");
-            mResource = root.getString("resource");
-            mStage = Integer.parseInt(root.getString("stage"));
+            mResourceName = root.getString("resource");
             ja = root.getJSONArray("points");
             for(int i=0; i<ja.length(); i++) {
                 mPlaces.add(new Place(ja.getJSONObject(i)));
             }
+            mResource =  new Resource(mResourceName, act);;
         } catch (JSONException e) {
             e.printStackTrace();
         }
@@ -51,15 +50,18 @@ public class Area  implements Serializable {
     }
 
     public String getResourceName() {
-        return mResource;
+        return mResourceName;
     }
 
     public Resource getResource(Activity act) {
-        return new Resource(mResource, mStage, act);
+        return mResource;
     }
 
-    public int getStage() {
-        return mStage;
+
+    public int getStage()
+    {
+        if(mResource==null) return -1;
+        return mResource.getStage();
     }
 
     public Shape getShape() {
@@ -91,8 +93,7 @@ public class Area  implements Serializable {
             jo.put("points", ja);
             jo.put("coordinates", mShape.getJson());
             jo.put("name", mName);
-            jo.put("resource", mResource);
-            jo.put("stage", ""+mStage);
+            jo.put("resource", mResourceName);
         }catch( Exception e)
         {
             e.printStackTrace();

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

@@ -45,7 +45,7 @@ public class Game  implements Serializable {
         try {
             JSONArray areas = root.getJSONArray("areas");
             for(int i=0; i<areas.length(); i++)
-                mAreas.add(new Area(areas.getJSONObject(i)));
+                mAreas.add(new Area(areas.getJSONObject(i), act));
             mResources = new ResourceManager(this, act);
             findMaxStage();
             nextStage();

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

@@ -20,9 +20,9 @@ public class Place  implements Serializable {
         try {
             JSONArray arr = root.getJSONArray("coordinates");
             mLocation = new GPSPoint(arr.getDouble(0), arr.getDouble(1));
-            mRadius = Double.parseDouble(root.getString("radius"));
-            mField = Double.parseDouble(root.getString("field"));
-            mAngle = Double.parseDouble(root.getString("angle"));
+            mRadius = root.getDouble("radius");
+            mField = root.getDouble("field");
+            mAngle = root.getDouble("angle");
         } catch (JSONException e) {
             e.printStackTrace();
         }

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

@@ -20,14 +20,13 @@ import min3d.vos.Number3d;
 public class Resource implements Serializable {
 
     protected String mName;
-    protected int    mStage;
     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 String mModelPath = "";
     protected boolean isLoaded = false;
+    protected int   mStage;
     protected String mType = ""; //3D Image Audio Video
     protected String mTitle= ""; //3D Image Audio Video
 
@@ -51,19 +50,18 @@ public class Resource implements Serializable {
             mScale.z =(float) obj.getJSONArray("scale").getDouble(2);
 
 
-            mModelPath = obj.getString("model");
             mType = obj.getString("type");
             mTitle = obj.getString("title");
+            mStage = obj.getInt("stage");
             isLoaded=true;
         } catch (JSONException e) {
             e.printStackTrace();
         }
     }
 
-    public Resource(String name, int stage, Activity act)
+    public Resource(String name, Activity act)
     {
         mName=name;
-        mStage=stage;
         loadResourceData(act);
     }
 
@@ -71,7 +69,6 @@ public class Resource implements Serializable {
     {
         try {
             mName=obj.getString("name");
-            mStage=obj.getInt("stage");
             loadResourceData(act);
         } catch (JSONException e) {
             e.printStackTrace();
@@ -104,7 +101,6 @@ public class Resource implements Serializable {
         JSONObject jo = new JSONObject();
         try {
             jo.put("name", mName);
-            jo.put("stage", mStage);
         } catch (JSONException e) {
             e.printStackTrace();
         }

+ 1 - 1
app/src/main/java/app/brest/utils/geometry/Shape.java

@@ -47,7 +47,6 @@ public class Shape  implements Serializable {
     {
         int nok=0;
         int nerr=0;
-
         for(int i=0; i<mPoints.size(); i++)
         {
             boolean ok=false;
@@ -61,6 +60,7 @@ public class Shape  implements Serializable {
             if(ok) nok++;
             else nerr++;
         }
+
         return (nok>0);
     }
 

+ 5 - 35
app/src/main/res/raw/face_mtl

@@ -1,35 +1,5 @@
-newmtl Texture0
-Ns 20
-d 1
-illum 2
-Kd 0.7 0.7 0.7
-Ks 0 0 0
-Ka 0 0 0
-map_Kd face_eyel_hi.jpg
-
-newmtl Texture1
-Ns 20
-d 1
-illum 2
-Kd 0.7 0.7 0.7
-Ks 0 0 0
-Ka 0 0 0
-map_Kd face_eyer_hi.jpg
-
-newmtl Texture2
-Ns 20
-d 1
-illum 2
-Kd 0.7 0.7 0.7
-Ks 0 0 0
-Ka 0 0 0
-map_Kd face_skin_hi.jpg
-
-newmtl Texture3
-Ns 20
-d 1
-illum 2
-Kd 0.7 0.7 0.7
-Ks 0 0 0
-Ka 0 0 0
-map_Kd face_sock.jpg
+newmtl Texture0
Ns 20
d 1
illum 2
Kd 0.7 0.7 0.7
Ks 0 0 0
Ka 0 0 0
map_Kd face_eyel_hi.jpg
+
newmtl Texture1
Ns 20
d 1
illum 2
Kd 0.7 0.7 0.7
Ks 0 0 0
Ka 0 0 0
map_Kd face_eyer_hi.jpg
+
newmtl Texture2
Ns 20
d 1
illum 2
Kd 0.7 0.7 0.7
Ks 0 0 0
Ka 0 0 0
map_Kd face_skin_hi.jpg
+
newmtl Texture3
Ns 20
d 1
illum 2
Kd 0.7 0.7 0.7
Ks 0 0 0
Ka 0 0 0
map_Kd face_sock.jpg
+

Diferenças do arquivo suprimidas por serem muito extensas
+ 1 - 18736
app/src/main/res/raw/face_obj


+ 24 - 8
app/src/main/res/raw/face_res

@@ -1,9 +1,25 @@
 {
-    "model" : "face_obj",
-    "position" : [0,0,0],
-    "scale" : [0.01,0.01,0.01],
-    "rotation" : [0,0,0],
-    "comment" : "A un tres beau visgae",
-    "type" : "3D",
-    "title" : "Un visage"
-}
+	"comment" : "",
+	"name" : "A",
+	"position" : 
+	[
+		0,
+		0,
+		0
+	],
+	"rotation" : 
+	[
+		0,
+		0,
+		0
+	],
+	"scale" : 
+	[
+		0.01,
+		0.01,
+		0.01
+	],
+	"stage" : 1,
+	"title" : "B",
+	"type" : "3D"
+}

+ 4 - 5
app/src/main/res/raw/game_medium

@@ -29,18 +29,17 @@
 			"points" :
 			[
 				{
-					"angle" : "90",
+					"angle" : 90,
 					"coordinates" :
 					[
 						-4.4792696325700003,
 						48.399854638950004
 					],
-					"field" : "90",
-					"radius" : "50"
+					"field" : 90,
+					"radius" : 50
 				}
 			],
-			"resource" : "camaro",
-			"stage" : "1"
+			"resource" : "face"
 		}
 	]
 }

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff