diff --git a/app/src/main/java/com/google/ar/core/examples/java/common/framework/RWT/RWTRenderer.java b/app/src/main/java/com/google/ar/core/examples/java/common/framework/RWT/RWTRenderer.java index da0bad2..24a4558 100644 --- a/app/src/main/java/com/google/ar/core/examples/java/common/framework/RWT/RWTRenderer.java +++ b/app/src/main/java/com/google/ar/core/examples/java/common/framework/RWT/RWTRenderer.java @@ -2,10 +2,13 @@ import android.opengl.GLSurfaceView.Renderer; +import com.google.ar.core.Session; +import com.google.ar.core.examples.java.common.framework.model3D.Universe; import com.google.ar.core.examples.java.common.framework.view3D.Camera3D; import com.google.ar.core.examples.java.common.framework.view3D.Viewer3D; import com.google.ar.core.examples.java.common.java3d.GraphicsContext3D; import com.google.ar.core.examples.java.common.java3d.Light; +import com.google.ar.core.examples.java.helloar.HelloArActivity; import java.util.ArrayList; @@ -14,54 +17,64 @@ public class RWTRenderer implements Renderer { protected Viewer3D viewer; - protected Camera3D camera; + protected Session session; + protected HelloArActivity helloArActivity; + protected Universe universe; protected GraphicsContext3D gc3D = null; - public RWTRenderer() { + public RWTRenderer(Session session, HelloArActivity helloArActivity) { super(); + this.session = session; + this.helloArActivity = helloArActivity; } - public void attachCamera(Camera3D camera) { - // onSurfaceCreated()より先に呼ばれる - this.camera = camera; - viewer = new Viewer3D(camera); - } +// public void attachCamera(Camera3D camera) { +// // onSurfaceCreated()より先に呼ばれる +// this.camera = camera; +// viewer = new Viewer3D(camera); +// } @Override public void onSurfaceCreated(GL10 gl, EGLConfig config) { - gc3D = new GraphicsContext3D(gl); - ArrayList lights = camera.getUniverse().getLights(); - for (int i = 0; i < lights.size(); i++){ - Light l = lights.get(i); - gc3D.setLight(l,i); - } - viewer.setGraphicsContext3D(gc3D); +// gc3D = new GraphicsContext3D(gl); +// ArrayList lights = camera.getUniverse().getLights(); +// for (int i = 0; i < lights.size(); i++){ +// Light l = lights.get(i); +// gc3D.setLight(l,i); +// } +// viewer.setGraphicsContext3D(gc3D); + + helloArActivity.onSurfaceCreated(gl, config); } @Override public void onSurfaceChanged(GL10 gl, int width, int height) { - if (gc3D == null) { - gc3D = new GraphicsContext3D(gl); - viewer.setGraphicsContext3D(gc3D); - } else { - viewer.setGraphicsContext3D(gc3D.setGL10(gl)); - } - viewer.surfaceChanged(width, height); +// if (gc3D == null) { +// gc3D = new GraphicsContext3D(gl); +// viewer.setGraphicsContext3D(gc3D); +// } else { +// viewer.setGraphicsContext3D(gc3D.setGL10(gl)); +// } +// viewer.surfaceChanged(width, height); + + helloArActivity.onSurfaceChanged(gl, width, height); } @Override public void onDrawFrame(GL10 gl) { - if (gc3D == null) { - gc3D = new GraphicsContext3D(gl); - viewer.setGraphicsContext3D(gc3D); - } else { - viewer.setGraphicsContext3D(gc3D.setGL10(gl)); - } - viewer.onDrawFrame(); +// if (gc3D == null) { +// gc3D = new GraphicsContext3D(gl); +// viewer.setGraphicsContext3D(gc3D); +// } else { +// viewer.setGraphicsContext3D(gc3D.setGL10(gl)); +// } +// viewer.onDrawFrame(); +// +// // 3Dモデルのレンダリング +// gc3D.pushMatrix(); +// universe.render(viewer); +// gc3D.popMatrix(); - // 3Dモデルのレンダリング - gc3D.pushMatrix(); - camera.getUniverse().render(viewer); - gc3D.popMatrix(); + helloArActivity.onDrawFrame(gl); } }