By shymaao
on Tue, 01/06/2015 - 15:35
Hello ,
I'm using Vuforia samples 3.0
And I need to render 2D object tracking target positions instead of TeaPot
I read this intersting guide :
Textured Plane on Target
https://developer.vuforia.com/resources/dev-guide/textured-plane-target
But I found difficulties in translating code from c++ to java because there are many changes in functions names and code architecture generally .
Please help changing this code to java compatible with vuforia samples 3.0
// assuming this is an image target QCAR::Matrix44F modelViewProjection; QCAR::Vec2F targetSize = ((QCAR::ImageTarget *) &trackable)->getSize(); SampleUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale, &modelViewMatrix.data[0]); //SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale, &modelViewMatrix.data[0]); SampleUtils::scalePoseMatrix(targetSize.data[0], targetSize.data[1], 1.0f, &modelViewMatrix.data[0]); SampleUtils::multiplyMatrix(&projectionMatrix.data[0], &modelViewMatrix.data[0], &modelViewProjection.data[0]); glUseProgram(shaderProgramID); //glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &teapotVertices[0]); //glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &teapotNormals[0]); //glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &teapotTexCoords[0]); glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &planeVertices[0]); glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &planeNormals[0]); glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &planeTexcoords[0]); glEnableVertexAttribArray(vertexHandle); glEnableVertexAttribArray(normalHandle); glEnableVertexAttribArray(textureCoordHandle); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID); glUniform1i(texSampler2DHandle, 0 /*GL_TEXTURE0*/); glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE, (GLfloat*) &modelViewProjection.data[0]); //glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT, (const GLvoid*) &teapotIndices[0]); glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, (const GLvoid*) &planeIndices[0]);
Rendering 2D object tracking Target in Java
You can probably do the Java conversion by looking at this article, which provides a more general guide to replacing the teapot model with a custom geometry using Java and C++:
https://developer.vuforia.com/resources/dev-guide/replacing-teapot
Rendering 2D object tracking Target in Java
Thanks It helps in a good way but
There is a problem in getting the corresponding java for plane block of code ..as the java functions require int type arrays not double
Rendering 2D object tracking Target in Java
That's because in Java with OpenGL you need to pass a Buffer (such as ByteBuffer for instance) ad argument to the
Rendering 2D object tracking Target in Java
Thanks for response .. but I need to make 2D object track marker not 3D !
How can I get bufffer arrays for 2D rectangular ?!!
The article you referred to just use a float arrays while function applicable for ONLY int !
Please Help !
Rendering 2D object tracking Target in Java