Oh, but it is... :)
You made two mistakes.
Firstly you need to make this call exactly where I stated, right after InitTracker:
Secondly, in order to see two bowls and spoons you need to amend the code in (void)renderFrameQCAR(), because as it stands the code will only ever draw one. You need to ensure that the code that draws the bowl and spoon is inside a loop that iterates through the number of trackables
You could have spotted this by understanding the code a bit better and showing a log as follows:
// Did we find any trackables this frame?
if (state.getNumTrackableResults())
{
// Get the trackable:
const QCAR::TrackableResult* result=NULL;
int numResults=state.getNumTrackableResults();
NSLog(@"NumTrackableResults = %i",numResults);
// Browse results searching for the MultiTargets
for (int j=0;j<numResults;j++)
{
result = state.getTrackableResult(j);
if (result->isOfType(QCAR::MultiTargetResult::getClassType()))
{
QCAR::Matrix44F modelViewMatrix =
QCAR::Tool::convertPose2GLMatrix(result->getPose());
QCAR::Matrix44F modelViewProjection;
SampleApplicationUtils::scalePoseMatrix(kCubeScaleX, kCubeScaleY, kCubeScaleZ,
&modelViewMatrix.data[0]);
SampleApplicationUtils::multiplyMatrix(&vapp.projectionMatrix.data[0],
&modelViewMatrix.data[0],
&modelViewProjection.data[0]);
glUseProgram(shaderProgramID);
// Draw the cube:
// We must detect if background reflection is active and adjust the culling direction.
// If the reflection is active, this means the pose matrix has been reflected as well,
// therefore standard counter clockwise face culling will result in "inside out" models.
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
if(QCAR::Renderer::getInstance().getVideoBackgroundConfig().mReflection == QCAR::VIDEO_BACKGROUND_REFLECTION_ON)
glFrontFace(GL_CW); //Front camera
else
glFrontFace(GL_CCW); //Back camera
glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &cubeVertices[0]);
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &cubeNormals[0]);
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &cubeTexCoords[0]);
glEnableVertexAttribArray(vertexHandle);
glEnableVertexAttribArray(normalHandle);
glEnableVertexAttribArray(textureCoordHandle);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, [augmentationTexture[0] textureID]);
glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,
(GLfloat*)&modelViewProjection.data[0] );
glUniform1i(texSampler2DHandle, 0 /*GL_TEXTURE0*/);
glDrawElements(GL_TRIANGLES, NUM_CUBE_INDEX, GL_UNSIGNED_SHORT,
(const GLvoid*) &cubeIndices[0]);
glDisable(GL_CULL_FACE);
// Draw the bowl:
modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(result->getPose());
// Remove the following line to make the bowl stop spinning:
[self animateBowl: &modelViewMatrix];
SampleApplicationUtils::translatePoseMatrix(0.0f, -0.50f*120.0f, 1.35f*120.0f,
&modelViewMatrix.data[0]);
SampleApplicationUtils::rotatePoseMatrix(-90.0f, 1.0f, 0, 0,
&modelViewMatrix.data[0]);
SampleApplicationUtils::scalePoseMatrix(kBowlScaleX, kBowlScaleY, kBowlScaleZ,
&modelViewMatrix.data[0]);
SampleApplicationUtils::multiplyMatrix(&vapp.projectionMatrix.data[0],
&modelViewMatrix.data[0],
&modelViewProjection.data[0]);
glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &objectVertices[0]);
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &objectNormals[0]);
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &objectTexCoords[0]);
glBindTexture(GL_TEXTURE_2D, [augmentationTexture[1] textureID]);
glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,
(GLfloat*)&modelViewProjection.data[0] );
glDrawElements(GL_TRIANGLES, NUM_OBJECT_INDEX, GL_UNSIGNED_SHORT,
(const GLvoid*) &objectIndices[0]);
SampleApplicationUtils::checkGlError("MultiTargetss renderFrameQCAR");
}
}
// If it was not found exit
if (result==NULL)
{
// Clean up and leave
glDisable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
QCAR::Renderer::getInstance().end();
return;
}
}
glDisable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
glDisableVertexAttribArray(vertexHandle);
glDisableVertexAttribArray(normalHandle);
glDisableVertexAttribArray(textureCoordHandle);
QCAR::Renderer::getInstance().end();
[self presentFramebuffer];
Lol thanks Nalin, will try once I get hold of a machine.
Thanks again,
W
------ UPDATE ------
It worked perfectly!