Log in or register to post comments

changing the position of virtual buttons

September 21, 2011 - 1:41am #1

I'm using the virtual button sample application.
I want to put buttons on different positions from the sample. What should I do?

Looking at the code in the jni folder (VirtualButtons.cpp), I found "VirtualButton_UpdateCallback" class. there are lines as follows.

......
if (buttonMask & BUTTON_1)
{
LOG("Toggle Button 1");

toggleVirtualButton(imageTarget, virtualButtonColors[0],
-108.68f, -53.52f, -75.75f, -65.87f);

}
if (buttonMask & BUTTON_2)
{
LOG("Toggle Button 2");

toggleVirtualButton(imageTarget, virtualButtonColors[1],
-45.28f, -53.52f, -12.35f, -65.87f);
}
......

Do I have to modify the four numbers (left, top, right, bottom)? and what I have to do then?

Thanks in advance.

Re: changing the position of virtual buttons

October 18, 2011 - 11:38am #9
Quote:

Is it possible to define other button shapes than a rectangle, such as a circle or curved shape (set of points?) or some other primative?

No, virtual buttons are always rectangular. You could probably make it appear to be a circular button with the right design on your image target, and just make the rect fit inside (or encompass) the button on the sheet.

Quote:

How does one make the 3d object (like the teap pot ) or some other object handle interaction? Like when your hand enters the area underneath the shape?

In the VirtualButtons sample the relevant code is in the EAGLView renderFrameQCAR method. That method is called every frame, and button->isPressed() will return true for each frame the button is pressed. You may want to capture the point at which a button changes from not pressed to pressed, and perform an action at that time.

- Kim

Re: changing the position of virtual buttons

October 16, 2011 - 3:50pm #8

1> Is it possible to define other button shapes than a rectangle, such as a circle or curved shape (set of points?) or some other primative?

2> How does one make the 3d object (like the teap pot ) or some other object handle interaction? Like when your hand enters the area underneath the shape?

3> Where in the IOS code do trap the virtual button events, so I want to push a new view controller in, and pass the button name or id to the VC, so I have a reference to which button was pushed.

Some examples would be great. It's really cool, a bit confusing.

Re: changing the position of virtual buttons

September 25, 2011 - 8:32pm #7
ksiva wrote:

This seems to work as expected for me. It is possible to occasionally get false positives, set the button sensitivity to LOW to minimize this:

<VirtualButton name="red" enabled="true" rectangle="-108.68 -53.52 -75.75 -65.87" sensitivity="low"/> 
<VirtualButton name="blue" enabled="true" rectangle="-108.68 53.52 -75.75 65.87" sensitivity="low"/> 
<VirtualButton name="yellow" enabled="true" rectangle="76.57 -53.52 109.50 -65.87" sensitivity="low"/> 
<VirtualButton name="green" enabled="true" rectangle="76.57 53.52 109.50 65.87" sensitivity="low"/> 

Be careful to arrange your buttons so you don't accidentally occluded one while touching another.

- Kim

Thanks, Kim.

The problem was, I guess, because there was not enough feature points on the changed button position. When I tried another position for the button which caused frequent incorrect actions, it worked almost perfectly.

Re: changing the position of virtual buttons

September 25, 2011 - 8:17am #6

This seems to work as expected for me. It is possible to occasionally get false positives, set the button sensitivity to LOW to minimize this:

<VirtualButton name="red" enabled="true" rectangle="-108.68 -53.52 -75.75 -65.87" sensitivity="low"/> 
<VirtualButton name="blue" enabled="true" rectangle="-108.68 53.52 -75.75 65.87" sensitivity="low"/> 
<VirtualButton name="yellow" enabled="true" rectangle="76.57 -53.52 109.50 -65.87" sensitivity="low"/> 
<VirtualButton name="green" enabled="true" rectangle="76.57 53.52 109.50 65.87" sensitivity="low"/> 

Be careful to arrange your buttons so you don't accidentally occluded one while touching another.

- Kim

Re: changing the position of virtual buttons

September 22, 2011 - 8:20pm #5

I changed the config file only.











Re: changing the position of virtual buttons

September 22, 2011 - 8:06pm #4

The SDK just needs a good set of feature points under the button, you should be able to move the buttons in that sample. Can you share the contents of your config.xml file? Are you changing any code, or just the config file?

- Kim

Re: changing the position of virtual buttons

September 21, 2011 - 8:41pm #3

Thanks Kim.

I changed the position of buttons (i.e., rectangles with white lines) following your comment. But sometimes it works incorrectly, for example, the color is changed even when I don't press the button. the color is changed to green when I press the red button.

How does the QCAR sdk recognize the button pressed? Should I modify the image so that the green button is located in the position I have changed in the config.xml file?

Re: changing the position of virtual buttons

September 21, 2011 - 10:20am #2

The code there is used for runtime updates to the virtual buttons. That code is triggered from the options menu.

If you want to change the position of the buttons on initialization you can edit the config.xml file in the assets folder. The initial bounds of each button is defined there.

- Kim

Log in or register to post comments