By juanmb
on Wed, 06/20/2012 - 17:12
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]
Re: Trying to render 2 models on 1 image target
Re: Trying to render 2 models on 1 image target
Re: Trying to render 2 models on 1 image target
Trying to render 2 models on 1 image target
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..
Trying to render 2 models on 1 image target
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,
Trying to render 2 models on 1 image target
Hi all, i made 2 object showed in camera with this methode :
1. Draw object in _ImageTargetRenderer_RenderFrame
Trying to render 2 models on 1 image target
I fix the problem with a little patient, just the matter of OpenGL problem..
and 1 more help needed, on this link : https://developer.vuforia.com/forum/android/video-and-3d-model
Please