Hello everyone,
I want to use the sdk for an augmented reality project so I want to know how some things are done maybe someone can help me trough.
For the models I want to render I use a Java library to parse from a certain file format. This file will be somewhere on the internet just like the trackables will be. Since I'm not very familiar to cpp I want to use Java to render the models.
Later I want to use the virtual buttons to trigger some animations from the model. But for now I like to know how to get started with rendering a simple cube on a trackable.
For my project I use some code from a good tutorial written by Per-Erik Bergman http://blog.uncle.se/.
private Mesh root;
private AssetManager assetMgr;
public OpenGLRenderer(MainActivity mainActivity) {
Group group = new Group();
Mesh mesh = new Mesh();
short[] indices = {0, 4, 5,
0, 5, 1,
1, 5, 6,
1, 6, 2,
2, 6, 7,
2, 7, 3,
3, 7, 4,
3, 4, 0,
4, 7, 6,
4, 6, 5,
3, 0, 1,
3, 1, 2,};
float[] vertices = {-1, -1, -1, // 0
1, -1, -1, // 1
1, 1, -1, // 2
-1, 1, -1, // 3
-1, -1, 1, // 4
1, -1, 1, // 5
1, 1, 1, // 6
-1, 1, 1, // 7};
mesh.setVertices(vertices);
mesh.setIndices(indices);
group.add(mesh);
root = group;
}
publicvoid onSurfaceCreated(GL10 gl, EGLConfig config) {
gl.glClearColor(0.224f, 0.224f, 0.224f, 0.0f);
gl.glShadeModel(GL10.GL_SMOOTH);
gl.glClearDepthf(1.0f);
gl.glEnable(GL10.GL_DEPTH_TEST);
gl.glDepthFunc(GL10.GL_LEQUAL);
gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
}
publicvoid onDrawFrame(GL10 gl) {
gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
gl.glTranslatef(0, 0, -4);
root.draw(gl);
}
publicvoid onSurfaceChanged(GL10 gl, int width, int height) {
gl.glViewport(0, 0, width, height);
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
GLU.gluPerspective(gl, 45.0f, (float) width / (float) height, 0.1f, 100.0f);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
}
}
How do I get this cude rendered on the trackable? What cpp files and methods do I need to use to get this done if whe take the basic ImageTargets example? Can some one explain this to me? I think that I am not the only one who wants to know this.
Thanks in advance.
Using Java to render objects
I'm sorry for the dubble post my content is not shown.
Content problem is resolved as shown below