Log in or register to post comments

Show a 3D object with my own Trackable

July 18, 2012 - 8:23am #1

Hi,

I asked this before in another thread but I could't fix. Firstly, I'm able to show a Toast with the name of each trackable that appear on the screen, so I manage to recognise my own trackable loading the dataSet...etc. Secondly with the help of the other thread, where I asked before this issue, I could show another 3d object show it seem that I manage to do this too. But I could do that 2 thing at the same time, the object don't appear with my trackable, although the toast and other Android UI yes they do; and at the same time with te stone/chip sample the new 3d object worked.

Here I load the dataSet:

Quote:

    dataSetMeninas = imageTracker->createDataSet();
    if (dataSetMeninas == 0)
    {
        LOG("Failed to create a new tracking data.");
        return 0;
    }
   
    if (!dataSetMeninas->load("Meninas.xml", QCAR::DataSet::STORAGE_APPRESOURCE))
    {
        LOG("Failed to load data set.");
        return 0;
    }

    // Activate the data set:
    if (!imageTracker->activateDataSet(dataSetMeninas))
    {
        LOG("Failed to activate data set.");
        return 0;
    }

    LOG("Successfully loaded and activated data set.");
    return 1;

And here I load the 3d object after the Android UI components:

Quote:

       // Draw object:
        glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID);
        glVertexPointer(3, GL_FLOAT, 0, pruebaVerts);
        glNormalPointer(GL_FLOAT, 0, pruebaNormals);
        glTexCoordPointer(2, GL_FLOAT, 0, pruebaTexCoords);
        glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT,
                       (const GLvoid*) &teapotIndices[0]);
#else

        QCAR::Matrix44F modelViewProjection;

        SampleUtils::translatePoseMatrix(0.0f, 0.0f, kObjectScale,
                                         &modelViewMatrix.data[0]);
        SampleUtils::scalePoseMatrix(kObjectScale, kObjectScale, kObjectScale,
                                     &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*) &pruebaVerts[0]);
        glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &pruebaNormals[0]);
        glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0, (const GLvoid*) &pruebaTexCoords[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] );
        glDrawArrays(GL_TRIANGLES, 0, pruebaNumVerts);

Could anyone help me? If not, told me to look for another way to do what I want.

Thanks.

Show a 3D object with my own Trackable

July 20, 2012 - 9:32am #5

Ok, it's fixed. The problem was that the 3D model was too big to the screen, I had that value in 100.f

thanks

 

Show a 3D object with my own Trackable

July 19, 2012 - 10:39am #4

I recommend that you test w/ the sample dataset in this same context, and if the model appears, try increasing your scale factor, which is defined on line 81 in ImageTargets.cpp. The target's size defines the scene's unit scale and the model will be scaled and positioned proportional to this. It may be that your model is rendering, but that you can't see it.

 

Look for..

static const float kObjectScale = 3.f;

Show a 3D object with my own Trackable

July 19, 2012 - 3:12am #3

DavidBeard wrote:

So the Trackable is being detected (e.g. you are seeing the Toast ) but  the associated model is not being rendered on the target? - and this model does render correctly when using the stones and chips dataset?

Can you post your XML file from the dataset? What is the defined size of your ImageTarget?

Yes, the toast just so the trackable name (stones/chips/meninas) and it work in everyone, but the teapot or the sphere (the object I made) only appear in the samples trackable. At first time I just change the tarmac load process to load my xml but the teapot don't appear.

Here the Meninas.xml which is my trackable:

Quote:

<?xml version="1.0"?>
<QCARConfig xsi:noNamespaceSchemaLocation="qcar_config.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Tracking>
        <ImageTarget name="meninas" size="1400 1611"/>
    </Tracking>
</QCARConfig>

 

Thanks.

Show a 3D object with my own Trackable

July 18, 2012 - 10:13am #2

So the Trackable is being detected (e.g. you are seeing the Toast ) but  the associated model is not being rendered on the target? - and this model does render correctly when using the stones and chips dataset?

Can you post your XML file from the dataset? What is the defined size of your ImageTarget?

Log in or register to post comments