Adding 3D objects to the world

Forums:

Hi, Firstly I would like to thank you for really amazing AR engine. It is really good framework.

However I would like to know if its possible to add 3D objects to the world instead of the 2D objects. 

Beyondar's picture

It is possible but you need to code some lines there...

You would need to implement the Renderable interface and create your own 3D stuff and then set your custom Renderable in the GeoObject that you need

I Have actually done that.. But am not able to see any 3D stuff..

For the Started I had replaced the SquareRenderable with my Custom Colored square but am not able to see any objects. Here is my code : 

public static final float TEMPLATE_VERTICES[] = {

//

-1.0f, 0.0f, -1.0f, // V1 - bottom left

-1.0f, 0.0f, 1.0f, // V2 - top left

1.0f, 0.0f, -1.0f, // V3 - bottom right

1.0f, 0.0f, 1.0f // V4 - top right

};

public final static float TEMPLATE_TEXTURE[] = {

// Mapping coordinates for the vertices

0.0f, 1.0f, // top left (V2)

0.0f, 0.0f, // bottom left (V1)

1.0f, 1.0f, // top right (V4)

1.0f, 0.0f // bottom right (V3)

};

public final static float TEMPLATE_COLORS[]=

{

1.0f,0.0f,0.0f,1.0f,

0.0f,1.0f,0.0f,1.0f,

0.0f,0.0f,1.0f,1.0f,

1.0f,0.0f,1.0f,1.0f

};

After setting up the appropriate buffer the Draw method is as follows :

gl.glTranslatef(mPosition.x, mPosition.y, mPosition.z);

error = gl.glGetError();

// ROTATE According to the angles

 

gl.glRotatef((float) mAngle.x, 1, 0, 0);

               gl.glRotatef((float) mAngle.y, 0, 1, 0);

              gl.glRotatef((float) mAngle.z, 0, 0, 1);

              gl.glVertexPointer(3, GL10.GL_FLOAT, 0, mVertexBuffer);

gl.glColorPointer(4, GL10.GL_FLOAT, 0, mColorBuffer);

gl.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, mVertices.length/3);

               gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);

error = gl.glGetError();

gl.glDisableClientState(GL10.GL_COLOR_ARRAY)

THe weird thing is that the above code works if I enable the texutures but when i diasble and enable the Color array, I cannot see anything, only one of the objects(Object8) appears randomly.

Please help me with this.

 

Beyondar's picture

That could be because of the GL configuration. I really don't know what it could be but you can try to tune some values in the ARRenderer in the onSurfaceCreated

Thank you very much for the immediate response.. It was really helpful..Yes as you suggested, it was because of the Alpha test and the Blending enabled in the surfaceCreated method.. I disabled them and it works now. thank you very much  :)

Beyondar's picture

You are welcome! :) 

Would you like to share your findings when you will finish it? you can put it on github