"We offer new support options and therefor the forums are now in read-only mode! Please check out our Support Center for more information." - Vuforia Engine Team

Trying to render 2 models on 1 image target

I'm trying to render two chess pieces using as base source code, the one from the ImageTragets sample. I've managed to render a single piece but when I try to render the second one, it doesn't show. I don't use a fresh modelViewMatrix with the second piece, cause I never overwrite the contents of the original. As you can see, for the transformations, I begin with and identityMatrix to which I apply rotations, translations... etc then I multiply the transformation matrix and the modelViewMatrix and store the results in another matrix called objectMatrix and continue from there to obtain a modelViewProjectionMatrix which I send to the shader. This process is repeted for the second piece but with different translation with no results. what am I missing? Thanks in advance I think the piece of code that's important is this: [CODE] static const float kObjectScale = 30.f; // set shader glUseProgram(shaderProgramID); // enable attributes glEnableVertexAttribArray(vertexHandle); glEnableVertexAttribArray(normalHandle); glEnableVertexAttribArray(textureCoordHandle); // set texture glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID); // PAWN 1 // specify piece data unsigned int chosenPiece = PAWN; unsigned int firstVertex = vertex_offset_table[chosenPiece]; unsigned int firstIndex = indices_offset_table[chosenPiece]; // set attributes glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, sizeof(vertex_struct), (const GLfloat*) &vertices[firstVertex].x); glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, sizeof(vertex_struct), (const GLfloat*) &vertices[firstVertex].nx); glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, sizeof(vertex_struct), (const GLfloat*) &vertices[firstVertex].u); // transformations QCAR::Matrix44F transformMatrix = SampleMath::Matrix44FIdentity(); SampleUtils::rotatePoseMatrix(90.0f, 1.0f, 0.0f, 0.0f, &transformMatrix.data[0]); // rotation SampleUtils::translatePoseMatrix(0.0f, 0.0f, 0.0f, &transformMatrix.data[0]); // translation SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale, &transformMatrix.data[0]); // scale // apply transformations to object QCAR::Matrix44F modelViewProjection, objectMatrix; SampleUtils::multiplyMatrix(&modelViewMatrix.data[0], &transformMatrix.data[0], &objectMatrix.data[0]); SampleUtils::multiplyMatrix(&projectionMatrix.data[0], &objectMatrix.data[0], &modelViewProjection.data[0]); // draw piece glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (GLfloat*)&modelViewProjection.data[0] ); glDrawElements(GL_TRIANGLES, (faces_count [chosenPiece] * 3), GL_UNSIGNED_SHORT,(const GLvoid*) &indexes[firstIndex]); // PAWN 2 // transformations transformMatrix = SampleMath::Matrix44FIdentity(); SampleUtils::rotatePoseMatrix(90.0f, 1.0f, 0.0f, 0.0f, &transformMatrix.data[0]); // rotation SampleUtils::translatePoseMatrix(100.0f, 0.0f, 0.0f, &transformMatrix.data[0]); // translation SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale, &transformMatrix.data[0]); // scale // apply transformations to object // QCAR::Matrix44F modelViewProjection, objectMatrix; SampleUtils::multiplyMatrix(&modelViewMatrix.data[0], &transformMatrix.data[0], &objectMatrix.data[0]); SampleUtils::multiplyMatrix(&projectionMatrix.data[0], &objectMatrix.data[0], &modelViewProjection.data[0]); SampleUtils::multiplyMatrix(&projectionMatrix.data[0], &modelViewMatrix.data[0] , &modelViewProjection.data[0]); // draw piece glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (GLfloat*)&modelViewProjection.data[0] ); glDrawElements(GL_TRIANGLES, (faces_count [chosenPiece] * 3), GL_UNSIGNED_SHORT,(const GLvoid*) &indexes[firstIndex]); [/CODE]

Hi juanmb I just tried this on the ImageTargets sample and was able to get two teapots overlapping. Your code looks a little different, but after looking through one suggestion I might have is this line: SampleUtils::translatePoseMatrix(100.0f, 0.0f, 0.0f, &transformMatrix.data[0]); // translatio

Yes, that was my first thought but when I render the first pawn using that value, It shows somewhere near the border, Keep in mind that I have to scale by 30 the models in order to see them with a decent size. I'll double check though. Thanks!

dear admin and all member..

i'm still trying to show SIMULTANEOUS objek on 1 target image, could you please explain me more which part of code should i replace or modify ?

i need to show 1 3d object and 3 2d object

thanks..

finally i can show two object on 1 marker, but another issue is , the object is use the  same texture and right on top of the first object,

could you help me on this ?? I need to show different object with different texture and show 2d object.

 

thanks,