Log in or register to post comments

how to config trackables??

January 23, 2011 - 11:33pm #1

Hi everyone
I would like to map the model with the track but I don't know how to config. For example track A model is banana and track B is apple like this. I am not sure that use ID to refrence or not like in FrameMakers example but in this example not has .dat file.
Please give me a suggestion how to change model in diffrence trackable.

Thank you

Re: how to config trackables??

April 4, 2011 - 6:02am #10

You just need to branch the code according to the target. It could be as simple as this:

int textureIndex;
const float* thisVertices;
const float* thisTexCoords;
const float* thisNormals;
const unsigned short* thisIndices;

if (!strcmp(trackable->getName(), "stones"))
{
    textureIndex = 0;
    thisVertices = teapotVertices;
    thisTexCoords = teapotTexCoords;
    thisNormals = teapotNormals;
    thisIndices = teapotIndices;
}
else if (!strcmp(trackable->getName(), "chips"))
{
    textureIndex = 1;
    thisVertices = otherVertices;
    thisTexCoords = otherTexCoords;
    thisNormals = otherNormals;
    thisIndices = otherIndices;
}
else
{
    // default values just in case
}

const Texture* const thisTexture = textures[textureIndex];

And then just update the rendering code to use the new variables:

glVertexAttribPointer(vertexHandle, 3, GL_FLOAT, GL_FALSE, 0,
                      (const GLvoid*) &thisVertices[0]);
glVertexAttribPointer(normalHandle, 3, GL_FLOAT, GL_FALSE, 0,
                      (const GLvoid*) &thisNormals[0]);
glVertexAttribPointer(textureCoordHandle, 2, GL_FLOAT, GL_FALSE, 0,
                      (const GLvoid*) &thisTexCoords[0]);

glEnableVertexAttribArray(vertexHandle);
glEnableVertexAttribArray(normalHandle);
glEnableVertexAttribArray(textureCoordHandle);

glBindTexture(GL_TEXTURE_2D, thisTexture->mTextureID);
glUniformMatrix4fv(mvpMatrixHandle, 1, GL_FALSE,
                   (GLfloat*)&modelViewProjection.data[0] );
glDrawElements(GL_TRIANGLES, NUM_TEAPOT_OBJECT_INDEX, GL_UNSIGNED_SHORT,
               (const GLvoid*) &thisIndices[0]);

- Kim

Re: how to config trackables??

April 4, 2011 - 2:39am #9

Here i have a one questions. I also trying to render two different object on two marker(image). for that I enable following lines in imagetargets.cpp:

QCAR::setHint(QCAR::HINT_MAX_SIMULTANEOUS_IMAGE_TARGETS, 2);
QCAR::setHint(QCAR::HINT_IMAGE_TARGET_MULTI_FRAME_ENABLED, 1);

For two marker(stones and chips), i written following way(thoguh no sure its ok or not)

int textureIndex = (!strcmp(trackable->getName(), "stones")) ? 0 : 1;
const Texture* const thisTexture = textures[textureIndex];

int textureIndex1 = (!strcmp(trackable->getName(), "chips")) ? 0 : 1;
const Texture* const thisTexture1 = textures[textureIndex1];

But now how I call to glVertexAttribPointer and glDrawElements to change model in specific marker(stone and chips). That means what will be the coding/parameter here to call glVertexAttribPointer and glDrawElements to draw different model on different marker(chips and stones).

Thanks

Rassall

ksiva wrote:

Models are not switched automatically. Take a look at the ImageTargets.cpp file. You can figure out which target is currently visible using the trackable->getName() method. This will return the target name from the config.xml file (in your case "entrance", "bird", "logo", or "exit"). Now you can use this information to swap the rendering data.

You can swap the model by changing the calls to glVertexAttribPointer and glDrawElements. You may also want to bind a different texture by changing the call to glBindTexture. In the ImageTargets sample, the texture is picked based on the currently visible target, see this line:

int textureIndex = (!strcmp(trackable->getName(), "stones")) ? 0 : 1;

- Kim

Re: how to config trackables??

February 10, 2011 - 8:14am #8

Take a look at this thread: http://ar.qualcomm.at/node/2000032

The sample code there passes the name of the trackable to Java, using JNI calls. The Java code then presents a message with this name, but you could use the name to switch which song to play instead. You could also simply pass an integer up to Java, in which case the method signature would look something like this:

jmethodID method = env->GetMethodID(javaClass, "playSong", "(I)V");

- Kim

Re: how to config trackables??

February 10, 2011 - 6:18am #7

I have modified domino with my audio I need to play and select music with trackable but domino recognizes only a single trackable
I need to have 3 trackables

I need to know How to return value in JNI. my idea like this below
// JNI code
if(trackable =="stone")
{
return 1;
}
if(trackable=="bird")
{
return 2;
}
if(trackable=="chip")
{
return 3;
}

/// java code

if(1) play loving song
if(2)play rock song
if(3)play

I would like to know How to return value in JNI and Pass value to JAVA
from my idea I need to return int and check value in android(java code)

Re: how to config trackables??

February 9, 2011 - 7:36am #6

The Dominoes sample only recognizes a single trackable, the "stones" target. It never checks to see which trackable is visible, since it assumes that if any trackable is visible it is the stones target.

The ImageTargets sample recognizes two different trackables, the "stones" and "chips" targets. It figures out which target is currently visible using the trackable->getName() method.

- Kim

Re: how to config trackables??

February 9, 2011 - 7:17am #5

To everyone
I have some question about tracker in Domino sample. In file domino.cpp which part that check the name of trackable.

is it in this part ? if yes how can I put the name of trackable to match model.

        // Cast to an image target
        assert(trackable->getType() == QCAR::Trackable::IMAGE_TARGET);
        const QCAR::ImageTarget* target = static_cast<const QCAR::ImageTarget*> (trackable);

Thank you

Re: how to config trackables??

January 24, 2011 - 6:35am #4

Models are not switched automatically. Take a look at the ImageTargets.cpp file. You can figure out which target is currently visible using the trackable->getName() method. This will return the target name from the config.xml file (in your case "entrance", "bird", "logo", or "exit"). Now you can use this information to swap the rendering data.

You can swap the model by changing the calls to glVertexAttribPointer and glDrawElements. You may also want to bind a different texture by changing the call to glBindTexture. In the ImageTargets sample, the texture is picked based on the currently visible target, see this line:

int textureIndex = (!strcmp(trackable->getName(), "stones")) ? 0 : 1;

- Kim

Re: how to config trackables??

January 24, 2011 - 6:16am #3

To rasarahul
I already create config.xml and .dat file from web already but I confuse that which part of code is switch the model.

In file config has code like this

<?xml version="1.0" encoding="UTF-8"?>
<QCARConfig xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="qcar_config.xsd">
  <Tracking>
    <ImageTarget size="320 192" name="entrance" />
    <ImageTarget size="320 304" name="bird" />
    <ImageTarget size="320 304" name="logo" />
    <ImageTarget size="320 304" name="exit" />
  </Tracking>
</QCARConfig>

I am not sure which part that match name of track match with the model.

Re: how to config trackables??

January 24, 2011 - 12:48am #2

Hello,
Have you created trackables in qualcomm website,u will receive config.xml and .dat file,create two image targets and place different models for each target.

Log in or register to post comments