Log in or register to post comments

Multiple Teapots on One Image Target

June 19, 2011 - 9:07pm #1

Hi,

I am very new to OpenGL. I am trying to render multiple teapots in the Image Target sample on one image target, but it doesn't work for me. I tried adding the projection/model transformation function calls at the end of the renderFrame() function and also added the glDrawElements() function call again expecting the scene to render and translate the second object on the scene in accordance to my parameters in the transformation function calls, but it doesn't work. Here is what I added at the end of the Image Target sample:

SampleUtils::rotatePoseMatrix(5.0f, 0.0f, 0.0f, 1.0f, &modelViewMatrix.data[0]);
SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale,
&modelViewMatrix.data[0]);
SampleUtils::multiplyMatrix(&projectionMatrix.data[0],
&modelViewMatrix.data[0] ,
&modelViewProjection.data[0]);

SampleUtils::checkGlError("ImageTargets renderFrame");
glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT,
(const GLvoid*) &teapotIndices[0]);

Can you please advise me as to what I need to do to render two or more teapots on one image target?

Thank you,

P.

Re: Multiple Teapots on One Image Target

June 19, 2011 - 9:53pm #2

First, grab a fresh copy of the modelview matrix before transforming it. Second, bind your modelViewProjectionMatrix before using it.

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

SampleUtils::rotatePoseMatrix(5.0f, 0.0f, 0.0f, 1.0f, &modelViewMatrix.data[0]);
SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale,
                             &modelViewMatrix.data[0]);
SampleUtils::multiplyMatrix(&projectionMatrix.data[0],
                            &modelViewMatrix.data[0] ,
                            &modelViewProjection.data[0]);

glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,
                   (GLfloat*)&modelViewProjection.data[0] );

SampleUtils::checkGlError("ImageTargets renderFrame");
glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT,
               (const GLvoid*) &teapotIndices[0]);

- Kim

Log in or register to post comments