it's very simple (depending on your model):
I used a model generated from a "special" software; the problem was, that this model used more than one mesh and therefore more than one texture.
I imported the model in 3DSMAX (use "Merge to one mesh") and exported the model again (without any further modifications) as "*.obj". Bute there were again more than one texture. I used then DAZ Studio 3D to import the model.
There is a plugin "Texture Atlas" (29 $), which merges the textures to one.
Exported again as Wavefront .obj.
These steps are only necessary if the model has more than one mesh and/or more than one texture.
Now the part for QCAR: (assuming jour model has the name "model.obj" and the texture has the name "texture.png" - OK ?)
use the script "obj2opengl.pl" (I'm using a Mac w. Snow Leo):
Invoke "perl obj2opengl.pl model.obj".
This will generate a file "model.h". Save this to your "ImageTargets/jni" Folder.
Now edit "ImageTargets.cpp":
include this line
Now replace the lines from
glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &teapotVertices);
glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT, (const GLvoid*) &teapotIndices);
glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &modelVerts);
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &modelNormals);
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
(const GLvoid*) &modelTexCoords);
glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,
glDrawArrays(GL_TRIANGLES, 0, modelNumVerts);
Save it and invoke "ndk-build" in the folder "ImageTargets". If everything is fine the you should "Clean" your project in Eclipse and then "Build Project" and run it on your device.
If your model looks too small, you should set the scaling like this (factor 3.0):
SampleUtils::scalePoseMatrix(3.0f, 3.0f, 3.0f, &modelViewMatrix.data);
If you want to replace the texture (assuming your target is "stones") the you should copy the file "texture.png" (by draggin' into the "assets" folder).
Now include this line
BEFORE the line
in "ImageTargets.java" in the procedure "private void loadTextures()"
This will load the texture "model.png" as Texture with the index 0;
I hope this helps you (and others).