AR-Camera
Posted: 24 Nov 2017, 21:24
				
				Basically a regular Camera, with a transparent sky and the ability to place the map anyhwere in 3d space, using two coordinates.
			
Ares wrote:if you could watch RTS in 3D Spring would be first of its kind to do and it could attract lots of new people, really good
pm me ur skype ill message you there. It wont let me send messages thro here for some reasonAres wrote:Are you sure my account name was in the field and you gave the message a subject, send screenshot. I never got any pm's so maybe its broken thanks for telling me.

Code: Select all
dependencies {
    // ARCore library
    implementation 'com.google.ar:core:1.1.0'
    // Obj - a simple Wavefront OBJ file loader
    // https://github.com/javagl/Obj
    implementation 'de.javagl:obj:0.2.1'
    implementation 'com.android.support:appcompat-v7:27.0.2'
    implementation 'com.android.support:design:27.0.2'
}Code: Select all
[Codebox=txt file=Logcat] 06-20 21:02:42.995 17769-17791/com.google.ar.core.examples.java.helloar.debug D/SpringOverlayRenderer: Spring OverlayRender Update called
    Spring OverlayRender drawOverlay called
06-20 21:02:42.995 17769-17791/com.google.ar.core.examples.java.helloar.debug E/emuglGLESv2_enc: device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glEnableVertexAttribArray:875 GL error 0x501
    Info: Invalid vertex attribute index. Wanted index: 4294967295. Max index: 16
    device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glVertexAttribPointer:598 GL error 0x501
    Info: Invalid vertex attribute index. Wanted index: 4294967295. Max index: 16
    device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glVertexAttribPointer:598 GL error 0x501
    Info: Invalid vertex attribute index. Wanted index: 4294967295. Max index: 16
    device/generic/goldfish-opengl/system/GLESv2_enc/GL2Encoder.cpp:s_glEnableVertexAttribArray:875 GL error 0x501
    Info: Invalid vertex attribute index. Wanted index: 4294967295. Max index: 16
06-20 21:02:42.996 17769-17791/com.google.ar.core.examples.java.helloar.debug E/SpringARActivity: Exception on the OpenGL thread
    java.lang.ArrayIndexOutOfBoundsException: remaining() < count < needed
        at android.opengl.GLES20.glDrawElements(Native Method)
        at com.google.ar.core.examples.app.common.rendering.SpringOverlayRenderer.drawOverlay(SpringOverlayRenderer.java:226)
        at com.google.ar.core.examples.app.springar.SpringARActivity.onDrawFrame(SpringARActivity.java:378)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1571)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1270)
06-20 21:02:42.998 1744-16525/? I/ActivityManager: Force stopping com.google.ar.core.examples.java.helloar.debug appid=10092 user=0: from pid 17834
    Killing 17769:com.google.ar.core.examples.java.helloar.debug/u0a92 (adj 0): stop com.google.ar.core.examples.java.helloar.debug
06-20 21:02:42.998 1744-1762/? W/libprocessgroup: kill(-17769, 9) failed: No such processCode: Select all
public void drawOverlay(float[] cameraView, float[] cameraPerspective) {
        Log.d(TAG, "Spring OverlayRender drawOverlay called");
        GLES20.glUseProgram(overlayProgram);
        mPositionHandle = GLES20.glGetAttribLocation(overlayProgram, "vPosition");
        GLES20.glEnableVertexAttribArray(mPositionHandle);
        int vsTextureCoord = GLES20.glGetAttribLocation(overlayProgram, "TexCoordIn");
        GLES20.glVertexAttribPointer(mPositionHandle,
                COORDS_PER_VERTEX,
                GLES20.GL_FLOAT,
                false,
                vertexStride,
                vertexBuffer);
        GLES20.glVertexAttribPointer(vsTextureCoord,
                COORDS_PER_TEXTURE,
                GLES20.GL_FLOAT,
                false,
                textureStride,
                textureBuffer);
        GLES20.glEnableVertexAttribArray(vsTextureCoord);
        GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]);
        int fsTexture = GLES20.glGetUniformLocation(overlayProgram, "TexCoordOut");
        GLES20.glUniform1i(fsTexture, 0);
        mMVPMatrixHandle = GLES20.glGetUniformLocation(overlayProgram, "uMVPMatrix");
        GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, cameraPerspective, 0);
        GLES20.glDrawElements(GLES20.GL_TRIANGLES,
                indices.length,
                GLES20.GL_UNSIGNED_SHORT,
                drawListBuffer);
        GLES20.glDisableVertexAttribArray(mPositionHandle);
        ShaderUtil.checkGLError(TAG, "Cleaning up after drawing planes");
    }Code: Select all
public void createOnGlThread(Context context) throws IOException {
        Log.d(TAG, "Spring OverlayRender createOnGlThread called");
        this.context = context;
        this.tcpConnection = new Server(this);
        ByteBuffer byteBuf = ByteBuffer.allocateDirect(vertices.length * 4);
        byteBuf.order(ByteOrder.nativeOrder());
        vertexBuffer = byteBuf.asFloatBuffer();
        vertexBuffer.put(vertices);
        vertexBuffer.position(0);
        byteBuf = ByteBuffer.allocateDirect(texture.length * 4);
        byteBuf.order(ByteOrder.nativeOrder());
        textureBuffer = byteBuf.asFloatBuffer();
        textureBuffer.put(texture);
        textureBuffer.position(0);
        ByteBuffer indexBuffer = ByteBuffer.allocateDirect(indices.length);
        indexBuffer.put(indices);
        indexBuffer.order(ByteOrder.nativeOrder());
        drawListBuffer = indexBuffer.asShortBuffer();
        drawListBuffer.position(0);
        try {
            vertexShader =
                    ShaderUtil.loadGLShader(TAG, context, GLES20.GL_VERTEX_SHADER, VERTEX_SHADER_NAME);
            fragmentShader =
                    ShaderUtil.loadGLShader(TAG, context, GLES20.GL_FRAGMENT_SHADER, FRAGMENT_SHADER_NAME);
        } catch (IOException i) {
            Log.e(TAG, "GLES20::Error" + i.toString());
            ShaderUtil.checkGLError(TAG, "GLES20::Error: Program parameters");
        }
        GLES20.glCompileShader(vertexShader);
        GLES20.glCompileShader(fragmentShader);
        overlayProgram = GLES20.glCreateProgram();
        GLES20.glAttachShader(overlayProgram, vertexShader);
        GLES20.glAttachShader(overlayProgram, fragmentShader);
        GLES20.glLinkProgram(overlayProgram);
        GLES20.glUseProgram(overlayProgram);
        //LOad the texture
        tcpConnection.Buffer.loadTexture(context,
                0,
                "models/springoverlayraw.png"
        );
        tcpConnection.Buffer.loadTexture(context,
                1,
                "models/springoverlayraw.png"
        );
        ShaderUtil.checkGLError(TAG, "Program parameters");
        /* */
    }