Log in or register to post comments

Is it possible to make touch work for Virtual buttons from screen?

April 11, 2013 - 7:33pm #1

Hi,

I have added few virtual buttons in my project and I can touch on them in Image target and it is working. But I am trying to interact with the virtual buttons from my device screen (need to touch the virtual buttons from my device screen). It is not working. Can someone suggest me how to do this?

Is it possible to make touch work for Virtual buttons from scree

December 6, 2013 - 7:09am #9

 thanks AlessandroB for your fast respont
maybe my statement earlier a bit confusing, I worked with a virtual button example,
and I want to add a touch event in my application. when the user presses the object on the screen then it will produce an event like the sound. is it possible?

I've seen domino.cpp, i try harder to understand the code in dominoes, but i cant.  and I've followed the instructions here

https://developer.vuforia.com/forum/faq/android-how-do-i-project-screen-touch-target
 

but fails to touch my event, what code / method i must export and edit form dominoes app into the app to touchthe  object beside projectScreenPointToPlane and linePlaneIntersection methods.i really have to finish my problem about touch the object completely  .. my thesis really depends on it .. please help me

Is it possible to make touch work for Virtual buttons from scree

December 6, 2013 - 6:36am #8

Hi, the Dominoes sample shows how to interact with a 3D object via touch screen; this has nothing to do with Virtual Buttons feature.

If you want to implement the touch screen functionality, it may help to have a look at the code in Domionoes.cp but also SampleMath.cpp and SampleUtil.cpp

 

Is it possible to make touch work for Virtual buttons from scree

December 6, 2013 - 4:50am #7

please help me, I'm develope virtualbutton app into my own app. and I want to try to put a virtual button on the screen device, can you tell me how to do a virtual button on a touch screen.
  I've seen examples of domino but I do not understand it. which parts of the dominoes should I use in my application, please help me

Is it possible to make touch work for Virtual buttons from scree

October 11, 2013 - 8:30am #6

hi all
I have a 3d object like in the picture, on the object I have 7 bar,,
and I tried to pass tap event at every bar,
Is it possible I could be doing a tap event for every bar is through a screen devise?

instances when I pass tap event at first bar through a screen device then it will give voice, and so are the others but in difference voice,,

Could you give me directions to do it?

I hope you will help me

thanks,,

AttachmentSize
Image icon Screenshot_2013-10-11-21-56-55.png638.55 KB

Is it possible to make touch work for Virtual buttons from scree

April 12, 2013 - 1:06am #5

I started my application by modifying Video Playback sample only :) . I will look into that part of the code. Thank you for guiding.

But can you suggest me why the below event handler code is not working for me..

 

 

using UnityEngine;
using System.Collections;
 
public class InputHandler : MonoBehaviour {
 
 private Ray m_Ray;
 private RaycastHit m_RayCastHit;
 private MovableObject m_CurrentMovableObject;
private float m_MovementMultipier = 10f;
 
 void Update () 
 {
Debug.Log("Sushh update input for button");
    if(Input.touches.Length == 1)
    {
    Touch touchedFinger = Input.touches[0];
 
    switch(touchedFinger.phase)
    {
 
    case TouchPhase.Began: 
Debug.Log("Sushh button began");
    m_Ray = Camera.mainCamera.ScreenPointToRay(touchedFinger.position);
    if(Physics.Raycast(m_Ray.origin, m_Ray.direction, out m_RayCastHit, Mathf.Infinity))
    {
       MovableObject movableObj = m_RayCastHit.collider.gameObject.GetComponent<MovableObject>();
       if(movableObj)
       {
          m_CurrentMovableObject = movableObj;
       }
    }
    break;
    case TouchPhase.Moved:
Debug.Log("Sushh button moved");
        if(m_CurrentMovableObject)
       {
          m_CurrentMovableObject.gameObject.transform.Translate(Time.deltaTime * m_MovementMultipier * new Vector3(touchedFinger.deltaPosition.x, 0, touchedFinger.deltaPosition.y));
       }
    break;
    case TouchPhase.Ended:
       m_CurrentMovableObject = null;
       break;
    default:
       break;
    }
   }
 }
}
 
I added this script to my virtual button

Is it possible to make touch work for Virtual buttons from scree

April 12, 2013 - 12:39am #4

Ok, if you are using Unity, then your best bet is to look at VideoPlayback sample in Unity, in particular, if you click on the ARCamera, you will see that there is a C# script attached to the ARCamera, which is called:

Video Playback Controller

If you look at the code in that script, you will see a method called HandleTap(), and a method called PickVideo(Vector3 screenPoint);

those methods should contain all the code that you need for your case.

 

 

Is it possible to make touch work for Virtual buttons from scree

April 12, 2013 - 12:32am #3

Thank you Alessandro for answering. I am using unity for my development, so it is possible to do it through unity. I tried writing an eventhandler C# script for the virtual button but it is not working for me. The same eventscript works for 3d models though. Can you please suggest me what should I do? Thanks again

 

 

Is it possible to make touch work for Virtual buttons from scree

April 12, 2013 - 12:21am #2

Hi, the Virtual Buttons feature is not meant to work via touch-screen.

If you need such functionality, you can refer to the sample code in the VideoPlayback sample; in particular, you will find some code which allows you to raycast a screen position (i.e. the position where you touch, in screen coordinates) to a 3D point located on the image target rectangle;

in particular, check the function isTapOnScreenInsideTarget, which is defined in VideoPlayback.cpp and is called from the Java code in VideoPlayback.java;

you should be able to reuse that code, the only difference is that you will need to use the bounding rectangle of your virtual button instead of the bounding rectangle of the whole image target.

 

 

Log in or register to post comments