Skip to content

Commit f504e65

Browse files
committed
more refactoring
1 parent f33e026 commit f504e65

File tree

12 files changed

+56
-49
lines changed

12 files changed

+56
-49
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ allprojects {
4444

4545
Properties arProperties = new Properties()
4646
arProperties.load(project.rootProject.file("mode/libraries/ar/library.properties").newDataInputStream())
47-
ext.arLibVersion = vrProperties.getProperty("prettyVersion")
47+
ext.arLibVersion = arProperties.getProperty("prettyVersion")
4848

4949

5050
def fn = project.rootProject.file("local.properties")

mode/libraries/ar/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ dependencies {
6060
compileOnly "org.p5android:processing-core:${modeVersion}"
6161

6262
aar "com.google.ar:core:${garVersion}"
63-
aar "de.javagl:obj:0.2.1"
6463
}
6564

6665
/**

mode/libraries/ar/src/processing/ar/render/PBackground.java renamed to mode/libraries/ar/src/processing/ar/ARBackground.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package processing.ar.render;
1+
package processing.ar;
22

33
import android.content.Context;
44
import android.opengl.GLES11Ext;
@@ -10,7 +10,7 @@
1010
import java.nio.ByteOrder;
1111
import java.nio.FloatBuffer;
1212

13-
public class PBackground {
13+
public class ARBackground {
1414

1515
private static final int COORDS_PER_VERTEX = 3;
1616
private static final int TEXCOORDS_PER_VERTEX = 2;
@@ -27,17 +27,17 @@ public class PBackground {
2727
private int textureId = -1;
2828

2929
static private URL screenquad_vertex =
30-
PBackground.class.getResource("/assets/shaders/screenquad_vertex.glsl");
30+
ARBackground.class.getResource("/assets/shaders/screenquad_vertex.glsl");
3131
static private URL screenquad_fragment =
32-
PBackground.class.getResource("/assets/shaders/screenquad_fragment.glsl");
32+
ARBackground.class.getResource("/assets/shaders/screenquad_fragment.glsl");
3333

3434
private String VERTICES_ERROR = "Unexpected number of vertices in BackgroundRenderer";
3535
private String ERROR_TAG = "Error";
3636
private String CREATION_ERROR = "Program creation";
3737
private String PARAMETERS_ERROR = "Program parameters";
3838
private String DRAW_ERROR = "Draw";
3939

40-
public PBackground() {}
40+
public ARBackground() {}
4141

4242
public int getTextureId() {
4343
return textureId;

mode/libraries/ar/src/processing/ar/render/PPlane.java renamed to mode/libraries/ar/src/processing/ar/ARPlane.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package processing.ar.render;
1+
package processing.ar;
22

33
import android.content.Context;
44
import android.graphics.Bitmap;
@@ -19,13 +19,13 @@
1919
import java.nio.ShortBuffer;
2020
import java.util.*;
2121

22-
public class PPlane {
22+
public class ARPlane {
2323
private static String PLANE_TEXTURE = "grid.png";
2424

2525
static private URL plane_vertex =
26-
PPlane.class.getResource("/assets/shaders/plane_vertex.glsl");
26+
ARPlane.class.getResource("/assets/shaders/plane_vertex.glsl");
2727
static private URL plane_fragment =
28-
PPlane.class.getResource("/assets/shaders/plane_fragment.glsl");
28+
ARPlane.class.getResource("/assets/shaders/plane_fragment.glsl");
2929

3030
private String ERROR_TAG = "Error";
3131
private String CREATION_ERROR = "Program creation";
@@ -90,7 +90,7 @@ public class PPlane {
9090

9191
private final Map<Plane, Integer> planeIndexMap = new HashMap<>();
9292

93-
public PPlane() {
93+
public ARPlane() {
9494
}
9595

9696
public void createOnGlThread(Context context) throws IOException {

mode/libraries/ar/src/processing/ar/render/PPointCloud.java renamed to mode/libraries/ar/src/processing/ar/ARPointCloud.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package processing.ar.render;
1+
package processing.ar;
22

33
import android.content.Context;
44
import android.opengl.GLES20;
@@ -7,12 +7,12 @@
77

88
import java.net.URL;
99

10-
public class PPointCloud {
10+
public class ARPointCloud {
1111

1212
static private URL pointcloud_vertex =
13-
PPointCloud.class.getResource("/assets/shaders/pointcloud_vertex.glsl");
13+
ARPointCloud.class.getResource("/assets/shaders/pointcloud_vertex.glsl");
1414
static private URL pointcloud_fragment =
15-
PPointCloud.class.getResource("/assets/shaders/pointcloud_fragment.glsl");
15+
ARPointCloud.class.getResource("/assets/shaders/pointcloud_fragment.glsl");
1616

1717
private String ERROR_TAG = "Error";
1818
private String BEF_CREATE = "before create";
@@ -43,7 +43,7 @@ public class PPointCloud {
4343

4444
private PointCloud lastPointCloud = null;
4545

46-
public PPointCloud() {}
46+
public ARPointCloud() {}
4747

4848
public void createOnGlThread(Context context) {
4949
Utils.checkGLError(ERROR_TAG, BEF_CREATE);

mode/libraries/ar/src/processing/ar/PSurfaceAR.java

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import com.google.ar.core.exceptions.*;
4040

4141
import processing.android.AppComponent;
42-
import processing.ar.render.*;
4342
import processing.core.PGraphics;
4443
import processing.opengl.PGLES;
4544
import processing.opengl.PGraphicsOpenGL;
@@ -81,9 +80,9 @@ public class PSurfaceAR extends PSurfaceGLES {
8180
protected float[] viewmtx = new float[16];
8281
protected RotationHandler displayRotationHelper;
8382

84-
protected PBackground backgroundRenderer = new PBackground();
85-
protected PPlane planeRenderer = new PPlane();
86-
protected PPointCloud pointCloud = new PPointCloud();
83+
protected ARBackground backgroundRenderer = new ARBackground();
84+
protected ARPlane planeRenderer = new ARPlane();
85+
// protected ARPointCloud pointCloud = new ARPointCloud();
8786

8887
protected ProgressDialog progressdialog = new ProgressDialog(activity);
8988

@@ -99,8 +98,8 @@ public PSurfaceAR(PGraphics graphics, AppComponent appComponent, SurfaceHolder s
9998
displayRotationHelper = new RotationHandler(activity);
10099
surfaceView = new SurfaceViewAR(activity);
101100

102-
progressdialog.setMessage("Searching for Surfaces");
103-
progressdialog.show();
101+
// progressdialog.setMessage("Searching for Surfaces");
102+
// progressdialog.show();
104103
}
105104

106105
@Override
@@ -233,7 +232,7 @@ public void onSurfaceCreated(GL10 gl, EGLConfig config) {
233232
} catch (IOException e) {
234233
PGraphics.showWarning("Failed to read plane texture");
235234
}
236-
pointCloud.createOnGlThread(activity);
235+
// pointCloud.createOnGlThread(activity);
237236
}
238237

239238
@Override
@@ -252,15 +251,15 @@ public void onSurfaceChanged(GL10 gl, int width, int height) {
252251
public void onDrawFrame(GL10 gl) {
253252
if (session == null) return;
254253

255-
if (progressdialog != null) {
256-
for (Plane plane : session.getAllTrackables(Plane.class)) {
257-
if (plane.getType() == com.google.ar.core.Plane.Type.HORIZONTAL_UPWARD_FACING
258-
&& plane.getTrackingState() == TrackingState.TRACKING) {
259-
progressdialog.dismiss();
260-
break;
261-
}
262-
}
263-
}
254+
// if (progressdialog != null) {
255+
// for (Plane plane : session.getAllTrackables(Plane.class)) {
256+
// if (plane.getType() == com.google.ar.core.Plane.Type.HORIZONTAL_UPWARD_FACING
257+
// && plane.getTrackingState() == TrackingState.TRACKING) {
258+
// progressdialog.dismiss();
259+
// break;
260+
// }
261+
// }
262+
// }
264263

265264
displayRotationHelper.updateSessionIfNeeded(session);
266265
try {
@@ -280,8 +279,8 @@ public void onDrawFrame(GL10 gl) {
280279
sketch.calculate();
281280
sketch.handleDraw();
282281

283-
} catch (CameraNotAvailableException ex) {
284-
PGraphics.showWarning("Camera is not available");
282+
} catch (Throwable tr) {
283+
PGraphics.showWarning("An error occurred in ARCORE: " + tr.getMessage());
285284
}
286285
}
287286
}
@@ -316,11 +315,13 @@ protected void updateMatrices() {
316315
}
317316

318317
protected void renderHelpers() {
319-
PointCloud foundPointCloud = frame.acquirePointCloud();
320-
pointCloud.update(foundPointCloud);
321-
pointCloud.draw(viewmtx, projmtx);
322-
foundPointCloud.release();
318+
// This should be enabled/disabled with a parameter...
319+
// PointCloud foundPointCloud = frame.acquirePointCloud();
320+
// pointCloud.update(foundPointCloud);
321+
// pointCloud.draw(viewmtx, projmtx);
322+
// foundPointCloud.release();
323323

324+
// Same with the planes...
324325
planeRenderer.drawPlanes(
325326
session.getAllTrackables(Plane.class), camera.getDisplayOrientedPose(), projmtx);
326327
for (Anchor anchor : anchors) {

mode/libraries/ar/src/processing/ar/render/RotationHandler.java renamed to mode/libraries/ar/src/processing/ar/RotationHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package processing.ar.render;
1+
package processing.ar;
22

33

44
import android.content.Context;

mode/libraries/ar/src/processing/ar/render/Utils.java renamed to mode/libraries/ar/src/processing/ar/Utils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package processing.ar.render;
1+
package processing.ar;
22

33
import android.content.Context;
44
import android.opengl.GLES20;
-480 Bytes
Binary file not shown.
-36.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)