Log in or register to post comments

Multiple trackable handling question

December 19, 2012 - 9:22am #1

Using the Unity plugin, I'd like to do the following:

1. Have a database of, say, 10 trackables.

2. Each trackable "launches" a different animation (details unimportant).

Is this possible? Do I have to setup multiple ImageTargets in the same scene to be able to do this? And if so, how do I know which trackable was found in the cloud so I know which animation to launch on it?

Hope this is clear. It's really no different than having multiple ImageTargets in a non-cloud application... except in that paradigm you are specifying the trackables so it's easier to see what's going on.

Multiple trackable handling question

March 5, 2015 - 8:34pm #6

I'm using same way and the app is working fine in the below vuforia 4 but after upgrading vuforia 4 it's not augmenting properly...I combined vuforia cloud & video playback app.

 

newImageTarget = Instantiate (ImageTargetTemplate_AssetBundle.gameObject) as GameObject;
 
// enable the new result with the same ImageTargetBehaviour: ???
//ImageTracker tracker = TrackerManager.Instance.GetTracker<ImageTracker> ();
ObjectTracker tracker = TrackerManager.Instance.GetTracker<ObjectTracker>();
ImageTargetBehaviour imageTargetBehaviour = (ImageTargetBehaviour)tracker.TargetFinder.EnableTracking 
(targetSearchResult, newImageTarget);
Debug.Log (imageTargetBehaviour);
 
StartCoroutine(GetAssetBundle(imageTargetBehaviour));
 
IEnumerator GetAssetBundle(ImageTargetBehaviour itbModel ) {
 
using (WWW www = WWW .LoadFromCacheOrDownload(bundleURL, Version)) {
 
yield return www;
Debug.Log (Version);
 
if (www .error != null)
throw new UnityException("WWW Download had an error: " + www .error);
 
 
AssetBundle bundle = www .assetBundle;
 
 
if (AssetName == "") {
Debug.Log ("null");
 
if(audio.clip){
  mBundleInstance = Instantiate (bundle.mainAsset) as GameObject;
 
mBundleInstance.transform.parent = itbModel.gameObject.transform; 
mBundleInstance.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
mBundleInstance.transform.localPosition = new Vector3(0.0f, 0.0f, 0.0f);
mBundleInstance.transform.gameObject.SetActive(true);
 

 

Let's say that you have two

December 26, 2012 - 1:46pm #5

Let's say that you have two models named 'modelA' and 'modelB' in your project Hierarchy, and you want to augment your CR targets with these models based on the metadata associated with each target. A simple approach will be to create a text file for each target that contains the name of the associated model, and to upload these text files as the metadata for their respective targets. So one has a metadata file containing the text modelA and the other target's metadata file contains the text modelB.

Then you can use the following code to retrieve the metadata from your CR search result, find and clone the model, and assign this clone as the augmentation for the target. You want to clone the model because the parent target is going to be destroyed whenever a new search result is obtained.

In CloudRecoEventHandler.cs ..

    public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)
    {

  string modelName = "";
  GameObject model = null;
  
  Vector3 localPos = new Vector3( 0,0,0 ); // to center the model on the target
 
  
  if( targetSearchResult.MetaData != null ){
   
   modelName = targetSearchResult.MetaData; // the modelName is assigned the metadata text as a string.
   
   Debug.Log("Metadata = "+modelName );
   
   model = GameObject.Find( modelName ); // find the model by this name
   
   Debug.Log("Found model "+ model.name );
  }
        // duplicate the referenced image target
        GameObject newImageTarget = Instantiate(ImageTargetTemplate.gameObject) as GameObject;

        // enable the new result with the same ImageTargetBehaviour:
        ImageTargetBehaviour imageTargetBehaviour = mImageTracker.TargetFinder.EnableTracking(targetSearchResult, newImageTarget);
  
  if( model != null ){
   
   GameObject modelClone = Instantiate( model ) as GameObject;

  // this is how to parent an augmentation w/ an ImageTarget instance
   modelClone.transform.parent = imageTargetBehaviour.gameObject.transform;
   modelClone.transform.position = localPos;
 
   
   Debug.Log("Parented "+modelClone.name +" to "+ modelClone.transform.parent.name );
  }

        if (imageTargetBehaviour != null)
        {
            // stop the target finder
            mCloudRecoBehaviour.CloudRecoEnabled = true;
        }
    }

cloudreco show differ virtual object

December 25, 2012 - 9:04pm #4

Hi David,

your wrote the solution for cloudreco show differ virtual object for each marker target

DavidBeard wrote:

I'd recommend attaching a metadata file to each trackable that you create in your Cloud database which identifies its associated animation. This can simply be a text file containing the name of the animation. You can add the metadata file to the target instance through the Target Manager, or using the VWS API. 

The sample demonstrates one approach to changing the augmentation for a single target dynamically, by alternating the textures and text used in the augmentation. Another is to swap augmentations by dynamically assigning them to the target as a child of the ImageTarget instance. Basically you define an ImageTarget instance as the Image Target Template for the Cloud Reco Event Handler , as with the sample, and then swap these augmentation objects (e.g. animated models ) dynamically by de/activating their rendering and assigning the transform of the target as the transform.parent of the desired augmentation, this is known as 'parenting'. You'd also want to extend the event handler to execute the Play() method on your animations. 

You parent an object as such  ..

myAugmentationObj.transform.parent = ImageTargetTemplate.gameObject.transform;

what class must be added "myAugmentationObj.transform.parent = ImageTargetTemplate.gameObject.transform;"??

how to synchronize the target and virtual object on metadata that upload to cloudreco database?

any sample project of this case??

Please help....

 

I'd recommend attaching a

December 19, 2012 - 4:15pm #3

I'd recommend attaching a metadata file to each trackable that you create in your Cloud database which identifies its associated animation. This can simply be a text file containing the name of the animation. You can add the metadata file to the target instance through the Target Manager, or using the VWS API. 

The sample demonstrates one approach to changing the augmentation for a single target dynamically, by alternating the textures and text used in the augmentation. Another is to swap augmentations by dynamically assigning them to the target as a child of the ImageTarget instance. Basically you define an ImageTarget instance as the Image Target Template for the Cloud Reco Event Handler , as with the sample, and then swap these augmentation objects (e.g. animated models ) dynamically by de/activating their rendering and assigning the transform of the target as the transform.parent of the desired augmentation, this is known as 'parenting'. You'd also want to extend the event handler to execute the Play() method on your animations. 

You parent an object as such  ..

myAugmentationObj.transform.parent = ImageTargetTemplate.gameObject.transform;

Hi Jack, Basically you should

December 19, 2012 - 10:15am #2

Hi Jack,

Basically you should get a callback in Unity:

 

    public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)

 
If you look through the sample app (which is a bit complicated) then it shows how to get the metadata and query an external source to get JSON back then you can see this function.
 
Probably worth going through the documentation as well to explain the new classes.
 
HTH
 
N
Log in or register to post comments