Log in or register to post comments

Draw multiple (custom) models

May 11, 2011 - 6:57am #1

We have two custom models, both as included header files and now we want to draw them both simultaneously in the scene. Which is the best to achieve this? Can you give us an example?

Note: We are already able to draw one of our models (we exported them with obj2opengl)

Which code blocks have to be repeated to draw an object twice?

Re: Draw multiple (custom) models

May 11, 2011 - 12:42pm #3
ksiva wrote:

Just be sure to start with a fresh copy of the modelview matrix before each render.

Ah OK, that's what wie didn't do. Now all is working fine. Thank you for your quick response!

Re: Draw multiple (custom) models

May 11, 2011 - 7:16am #2

If you're starting with the ImageTargets sample, I suggest picking OpenGL ES 1.1 or 2.0 and studying the relevant code in the ImageTargets.cpp renderFrame() method. OpenGL ES 2.0 is used by default, or you can switch to 1.1 with the USE_OPENGL_ES_1_1 flag in the Android.mk file.

There are a few steps to drawing your model:

1) Placing and sizing your model with transforms (translate, rotate, scale).
2) Binding the texture.
3) Binding the vertex, texcoord, and normal arrays.
4) Rendering with glDrawElements or glDrawArrays.

You should be able to copy and paste the relevant code and render your models one after the other. Just be sure to start with a fresh copy of the modelview matrix before each render.

QCAR::Matrix44F modelViewMatrix =
    QCAR::Tool::convertPose2GLMatrix(trackable->getPose());

- Kim

Log in or register to post comments