Log in or register to post comments

2 different Image Targets and 2 Objects

May 24, 2013 - 5:53am #1

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];

..........................
..........................

 

        QCAR::Matrix44F modelViewProjection;
 
        SampleUtils::translatePoseMatrix(0.0f, 0.0f, 0.0f,&modelViewMatrix.data[0]);
        SampleUtils::rotatePoseMatrix(180, 0.0f, 90, kObjectScale, &modelViewMatrix.data[0]);
        SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale, &modelViewMatrix.data[0]);
        SampleUtils::multiplyMatrix(&projectionMatrix.data[0],&modelViewMatrix.data[0],&modelViewProjection.data[0]);
.......................

 

        glDrawArrays(GL_TRIANGLES, 0, foxtriNumVerts);

 

        glDrawArrays(GL_TRIANGLES, 0, foxboxOBJNumVerts);
 
        SampleUtils::checkGlError("ImageTargets renderFrame");

here is the full code:
http://foxcun.com/zipfile/ImageTargets.zip
Hoping anyone could help  .. 
 

2 different Image Targets and 2 Objects

February 12, 2014 - 1:26am #18

Hi,

I've found the error, thank you so much AlessandroB

It's about the dimensions of my texture ..

But i've question, i've try to resize my object like this : (left scale 100.0f and right scale 200.0f)