Log in or register to post comments

Issue with virtual buttons

August 18, 2011 - 2:34pm #1

I have developed an application with QCAR Unity 3d extension.
My application contains virtual buttons . the problem is that, when I move the camera toward the Image Target ( at run time ), virtual buttons are invoked automatically without touching.
I tried to follow “QCAR Virtual Buttons” sample and the instructions in AR developer guide to see if I made mistake , but I observed that the same problem occurs even with “QCAR Virtual Buttons” sample.

Any help please. :confused:

Re: Issue with virtual buttons

June 14, 2011 - 6:59pm #12

Have a look at the VirtualButtonEventHandler.cs script included with the Virtual Buttons sample. This Event Handler may give you some ideas as to why your second button is not registering. Also make sure you buttons are named differently. Are you using one event handler script for the buttons?

-Peter

Re: Issue with virtual buttons

June 14, 2011 - 8:20am #11

i'm using stones image target, so the details won't be the problem. i went through these steps (i made a first button work).
tracking on logcat, second button is never fired on press/release.
is there something i'm missing?

Re: Issue with virtual buttons

June 13, 2011 - 5:13pm #10

Make sure your target has features in the area of the second virtual button. Take a look at the Virtual Buttons section of the Dev Guide for a list of best practices. Let us know if you are still having trouble.

-Peter

Re: Issue with virtual buttons

June 12, 2011 - 2:10pm #9

hi all!

i have problems on adding virtual buttons. i my scene there is one virt. button which is working just fine. but when i add a new button, with other event handler script, new button is simply not working. old button does. what can be the problem?

thanks in advance!

Re: Issue with virtual buttons

May 27, 2011 - 11:39am #8

Has this been addressed in the current SDK? I'm not able to replicate the problem, using the VB sample, by clipping in the camera view. I've played with the button size and sensitivity, but can't get them to trigger without deliberately occluding the buttons. It would be helpful to know when to expect this, if it still occurs.

Re: Issue with virtual buttons

May 27, 2011 - 3:31am #7

Thanks Kim, works very well!

Re: Issue with virtual buttons

May 26, 2011 - 6:05am #6

Try something like this (just one approach):

public class VirtualButtonEventHandler : MonoBehaviour, IVirtualButtonEventHandler
{
    private float timer = 0.0f;
    private bool isTimerValid = false;
    
    void Start()
    {
        VirtualButtonBehaviour[] vbs = GetComponentsInChildren<VirtualButtonBehaviour>();
        for (int i = 0; i < vbs.Length; ++i)
        {
            vbs[i].RegisterEventHandler(this);
        }
    }
    
    public void Update()
    {
        if (isTimerValid)
        {
            timer -= Time.deltaTime;
            
            if (timer <= 0.0f)
            {
                TimeIsUp();
                InvalidateTimer();
            }
        }
    }
    
    public void OnButtonPressed(VirtualButtonBehaviour vb)
    {
    	print("button pressed, starting timer");
        StartTimer(2.0f);
    }
    
    public void OnButtonReleased(VirtualButtonBehaviour vb)
    {
    	print("button released, invalidating timer");
        InvalidateTimer();
    }
    
    private void StartTimer(float seconds)
    {
        timer = seconds;
        isTimerValid = true;
    }
    
    private void InvalidateTimer()
    {
        timer = 0.0f;
        isTimerValid = false;
    }
    
    private void TimeIsUp()
    {
        // do stuff here!
        print("doing stuff");
    }
}

- Kim

Re: Issue with virtual buttons

May 24, 2011 - 9:07pm #5

I'm experiencing the same issue here. When you said :

ksiva wrote:

You can determine how long a virtual button has been held by starting a timer on the initial OnVirtualButtonPress call. If after x seconds OnVirtualButtonRelease has not yet been called, you could trigger an action.

Can you give some code please? I don't really know where to begin with this...

Re: Issue with virtual buttons

January 12, 2011 - 6:26am #4

So you could do some tricky math on your own to figure out which virtual buttons are currently visible in the scene. You would need to take the projection matrix's view frustum and the modelview matrix into account. If you could determine the boundaries of the target plane that are visible, you could figure out which virtual buttons are completely contained inside the camera image.

You can determine how long a virtual button has been held by starting a timer on the initial OnVirtualButtonPress call. If after x seconds OnVirtualButtonRelease has not yet been called, you could trigger an action.

Finally, the base QCAR SDK does have some helpful button sensitivity settings. These will be exposed in a later version of the Unity extension.

- Kim

Re: Issue with virtual buttons

January 12, 2011 - 12:22am #3

Thank you Kim for your support
I have two suggestions to avoid this issue ,
1. By allowing virtual button to invoke only if all virtual buttons are visible , so we can disable buttons when the user move the camera closely toward to the image target.
2. By determine the occlusion period , for example enable the virtual button only if the user press and hold 2 sec. on the button, so we can minimize the effect of clipping of the camera view.

Please let me know if the above solutions work, and guide me on how to implement them within QCAR SDK framework

Regards,

Re: Issue with virtual buttons

January 11, 2011 - 8:08am #2

This is an unavoidable issue with Virtual Buttons, they cannot always tell the difference between occlusion caused by the user's hand or clipping of the camera view. Try to place the buttons in a position to minimize this problem. You might also try playing around with the size of the buttons.

- Kim

Log in or register to post comments