By dorankseo
on Mon, 04/01/2013 - 16:11
I've adapted this code Link on which code I adapted as follows:
for(int tIdx = 0; tIdx < state.getNumActiveTrackables(); tIdx++) { // Get the trackable: const QCAR::Trackable* trackable = state.getActiveTrackable(tIdx); QCAR::Matrix44F modelViewMatrix = QCAR::Tool::convertPose2GLMatrix(trackable->getPose()); QCAR::Matrix44F modelViewProjection; SampleUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale, &modelViewMatrix.data[0]); SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale, &modelViewMatrix.data[0]); SampleUtils::multiplyMatrix(&projectionMatrix.data[0], &modelViewMatrix.data[0] , &modelViewProjection.data[0]); glUseProgram(shaderProgramID); if (strcmp(trackable->getName(), "custom") == 0) {// if target is "chips" then we use nyancat mesh //// Banana glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, bananaVerts); glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, bananaNormals); glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, bananaTexCoords); glEnableVertexAttribArray(vertexHandle); glEnableVertexAttribArray(normalHandle); glEnableVertexAttribArray(textureCoordHandle); LOG("enabled arrays!"); glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (GLfloat*)&modelViewProjection.data[0] ); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID); glDrawArrays(GL_TRIANGLES, 0, bananaNumVerts); ////////////// } // etc ... }
When I put code to compile this Error occurred.
Compile++ arm : ImageTargets <= ImageTargets.cpp jni/ImageTargets.cpp: In function 'void Java_com_qualcomm_QCARSamples_ImageTargets_ImageTargetsRenderer_renderFrame(JNIEnv*, jobject)': jni/ImageTargets.cpp:330:33: error: 'class QCAR::State' has no member named 'getNumActiveTrackables' jni/ImageTargets.cpp:333:51: error: 'class QCAR::State' has no member named 'getActiveTrackable' jni/ImageTargets.cpp:334:89: error: 'const class QCAR::Trackable' has no member named 'getPose' jni/ImageTargets.cpp:360:42: error: 'thisTexture' was not declared in this scope /cygdrive/c/Development/Android/android-ndk-r8e-windows-x86/android-ndk-r8e/build/core/build-binary.mk:272: recipe for target `obj/local/armeabi/objs/ImageTargets/ImageTargets.o' failed make: *** [obj/local/armeabi/objs/ImageTargets/ImageTargets.o] Error 1
Advice, please? Don't know if I'm wrong code section adapted.Thank you very much
See the Code a bit, I adapted to display the model 2.
Hi,
that code still refers to the 1.5 API, so you need to adjust the first part of your code as follows:
See the Code a bit, I adapted to display the model 2.
[quote=AlessandroB]
Hi,
that code still refers to the 1.5 API, so you need to adjust the first part of your code as follows:
See the Code a bit, I adapted to display the model 2.
When you say "I want to make it show 2 model at the same time", what do you mean exactly ?
See the Code a bit, I adapted to display the model 2.
[quote=AlessandroB]
When you say "I want to make it show 2 model at the same time", what do you mean exactly ?
See the Code a bit, I adapted to display the model 2.
[quote=dorankseo]
[quote=AlessandroB]
When you say "I want to make it show 2 model at the same time", what do you mean exactly ?
See the Code a bit, I adapted to display the model 2.
Hi, you simply need to duplicate the OpenGL code inside the "for loop", i.e. for each target, you first render one mesh (using the related vertices, normals and textrue coordinates) and then the other mesh.
See the Code a bit, I adapted to display the model 2.
Reading your code:
the problem is that you are rendering both models using the same modelview matrix, but you actually need to change the modelview for each model because the scaling is different;