Hi, I tried to make multi image targets. For example: image target "stones" can show oject "A" and image target "chips" can show object "B".
I did it. but then I realize there is something happened, which is the second object is looks like a strange shape . . .
here is the screen shoot image targets "chips":
http://foxcun.com/img/obj1.png
the second object "stones" screen shoot:
http://foxcun.com/img/obj2.png
then i try to make it simultaneously:
http://foxcun.com/img/obj3.png
it still the same, the second object in "stones" looks wired ...
When I use single object , the shape looks normaly, but when I used 2 different object, the second object will looks wired.
here is my code:
// Did we find any trackables this frame?
for(int tIdx = 0; tIdx < state.getNumTrackableResults(); tIdx++)
{
// Get the trackable:
const QCAR::TrackableResult* result = state.getTrackableResult(tIdx);
const QCAR::Trackable& trackable = result->getTrackable();
QCAR::Matrix44F modelViewMatrix =
QCAR::Tool::convertPose2GLMatrix(result->getPose());
// Choose the texture based on the target name:
int textureIndex;
if (strcmp(trackable.getName(), "chips") == 0)
{
//first object
textureIndex = 0;
glVertexAttribPointer(vertexHandle,3, GL_FLOAT, GL_FALSE, 0, foxboxOBJVerts);
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, foxboxOBJTexCoords);
}
else if (strcmp(trackable.getName(), "stones") == 0)
{
//second object
textureIndex = 1;
glVertexAttribPointer(vertexHandle,3, GL_FLOAT, GL_FALSE, 0, foxtriVerts);
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, foxtriTexCoords);
}
else
{
textureIndex = 2;
}
const Texture* const thisTexture = textures[textureIndex];
..........................
..........................
here is the full code:
http://foxcun.com/zipfile/ImageTargets.zip
Hoping anyone could help ..
Hi,
your OpenGL code is incorrect;
the main problem is this:
glDrawArrays(GL_TRIANGLES, 0, foxboxOBJNumVerts);