Log in or register to post comments

Receiving IOS touch and press the image target to control the object!

July 31, 2012 - 9:08pm #1

Hi,guys,I am a AR Lover.

Sincerely i am new to vuforia,I develop my IOS AR APPS with Unity,and there's got some problems.

When the camera got the imagetarget,it will show a button on the right top of it!

We press the button and it will start the animation that was hidden at the beginning.

Or we point at the IOS screen and choose the imagetarget,and it will show a object on it,just like the Dominoes Sample!

For i am not good at Unity,and those are the codes for me to find which imagetarget i have pressed!

As follows:

 

private ImageTargetBehaviour PickImageTarget(Vector3 screenPoint)

{

ImageTargetBehaviour[] imagetargets = (ImageTargetBehaviour[])FindObjectsOfType(typeof(ImageTargetBehaviour));

Ray ray = Camera.main.ScreenPointToRay(screenPoint);

RaycastHit hit = new RaycastHit();

foreach(ImageTargetBehaviour imagetarget in imagetargets)

{

str = imagetarget.transform.name.ToString(); 

if(imagetarget.collider.Raycast(ray,out hit,10000))

{

Touch3DPoint = hit.transform.worldToLocalMatrix.MultiplyPoint( hit.point );

Touch3DRotation = hit.transform.rotation;

str = hit.transform.name.ToString();

return imagetarget;

}

}

return null;

}

 
And if I find out which image target i have touched,and how should i get the right position of the new object!
Where to put it!!
 
Looking forward to your answers,and my
If you want to communicate with me about it,glad to...
 

 

 

Receiving IOS touch

August 1, 2012 - 8:05pm #2

If I understand your question correctly, you should be able to do this by transforming the world position to screen space - http://docs.unity3d.com/Documentation/ScriptReference/Camera.WorldToScreenPoint.html

Log in or register to post comments