The pose is a 3D orientation matrix, analogous to the modelview matrix in OpenGL. It is used alongside the projection matrix to bring 3D world coordinates to screen coordinates. For a full look at the set of transformations involved, see the OpenGL FAQ (section 9.011): http://www.opengl.org/resources/faq/technical/transformations.htm
The pose is a 3D transformation, which means you won't easily get a set of 2D transformations out of it for manipulating 2D images on the screen (you're missing a dimension to rotate in). Instead, I would suggest rendering your image on a 3D plane using OpenGL. It's pretty easy, here are the steps:
1) Start with the ImageTargets sample project. Open ImageTargets.cpp, located in the jni folder.
2) Add the following just after the includes at the top:
#include <QCAR/ImageTarget.h>
static const float planeVertices[] =
{
-0.5, -0.5, 0.0, 0.5, -0.5, 0.0, 0.5, 0.5, 0.0, -0.5, 0.5, 0.0,
};
static const float planeTexcoords[] =
{
0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0
};
static const float planeNormals[] =
{
0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0
};
static const unsigned short planeIndices[] =
{
0, 1, 2, 0, 2, 3
};
3) Now replace the OpenGL ES 2.0 rendering code in the renderFrame method with the following:
// assuming this is an image target
QCAR::Vec2F targetSize = ((QCAR::ImageTarget *) trackable)->getSize();
QCAR::Matrix44F modelViewProjection;
SampleUtils::translatePoseMatrix(0.0f, 0.0f, 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*) &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);
glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,
(GLfloat*)&modelViewProjection.data[0] );
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT,
(const GLvoid*) &planeIndices[0]);
4) Build the native code using ndk-build, then refresh the Eclipse project and run the app. You should see the teapot texture stretched over the image target.
5) You can swap the texture by adding your image to the project's assets folder (png or jpg format). Then open ImageTargets.java and replace the teapot texture filenames with your own.
Let me know if you have any questions!
- Kim
Also make sure that you're loading the new texture. Which SDK are you using?