Log in or register to post comments

Implementing different objects in virtual buttons..

May 23, 2011 - 12:08am #1

Dear All,

I am trying to implement/draw different object using virtual button. that means four button will draw four different object once its press. not like only color change of sample example. So I already written four different object(square) using four texture. so i want to integrate this four square objects in four different button.

At this moment, its difficult to understand where I should have start to implement this over virtual button sample.

I observed from following line each button activity(change the teapot color) has started after press.

// Iterate through this targets virtual buttons:
for (int i = 0; i getNumVirtualButtons(); ++i)
{
const QCAR::VirtualButton* button = target->getVirtualButton(i);

// If the button is pressed, than use this texture:
if (button->isPressed())
{
// Run through button name array to find texture index
for (int j = 0; j {
if (strcmp(button->getName(), virtualButtonColors[j]) == 0)
{
textureIndex = j+1;
break;
}
}
}

So can anyone help me to implement this four object in four button concept here.

Thanks

Rassall

Re: Implementing different objects in virtual buttons..

May 23, 2011 - 6:08am #2

I suggest taking a look at the FrameMarkers sample. It includes a switch statement for swapping models based on the currently active frame marker, you can do something similar depending on which button is pressed. For switching on the button press, use something like this:

for (int i = 0; i < target->getNumVirtualButtons(); ++i)
{
    const QCAR::VirtualButton* button = target->getVirtualButton(i);
    
    if (button->isPressed())
    {
        if (strcmp(button->getName(), "myButton1") == 0)
        {
            // render object 1
            break;
        }
        else if (strcmp(button->getName(), "myButton2") == 0)
        {
            // render object 2
            break;
        }
        else if (strcmp(button->getName(), "myButton3") == 0)
        {
            // render object 3
            break;
        }
        else if (strcmp(button->getName(), "myButton4") == 0)
        {
            // render object 4
            break;
        }
    }
}

- Kim

Log in or register to post comments