Hi all Unity, Vuforia, VR, and AR experts,
I have asked the same question on the Vuforia developer forum and would love some advice: https://developer.vuforia.com/forum/object-recognition/combine-two-or-more-image-targets-create-third-3d-object
Currently with Vuforia you can easily detect multiple image target simultaneously to display objects, but it’s a one to one association. Meaning 1 image target will display 1 object upon detection, and the system can simultaneously detect multiple image targets, say 2 images, and display 2 separate objects.
What I would like to accomplish is when 2 images are display at the same time, display a different object than that of object 1 (from image 1) or object 2 (from image 2) like in the following:
if Image 1 is detected, then show 3D Object 1
if Image 2 is detected, then show Object 2
if Image 1 + 2 are both detected (at the same time), then show Object 3
It seems currently the way it works is if an object is found, display its child, which is the actual object. I thought I can make a list to capture when objects are found, and then look through the list for if all the image target names exist in the list then display the model (Object 3 in this case); however as I am doing it it doesn’t make as much sense.
Wondering if anyone know of a more elegant solution or any suggestions. Is this even the right idea? I am not much a developer, so any help is much appreciated!
private void OnTrackingFound()
{
Renderer[] rendererComponents = GetComponentsInChildren<Renderer>(true);
Collider[] colliderComponents = GetComponentsInChildren<Collider>(true);
// My addition: Declaring a list of strings
List<string> foundComponents = new List<string>();
// Enable rendering:
foreach (Renderer component in rendererComponents)
{
//My addition: Captured the names of the image targets that are found
foundComponents.Add(mTrackableBehaviour.TrackableName);
component.enabled = true;
}
// Enable colliders:
foreach (Collider component in colliderComponents)
{
component.enabled = true;
}
Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
foreach( string component in foundComponents )
{
Debug.Log( component );
}
}