Log in or register to post comments

Load 3d model through cloud

April 22, 2013 - 11:47pm #1

I have seen that we can define our image target on cloud database. I want in the same way 3d model load through cloud.Is that any method for the same? My Image target right now is on my project and i want 3d model through cloud.

Load 3d model through cloud

November 8, 2017 - 6:21am #49

Hii..

I just started to do stuff in unity...I am newbie in this unity Gaming world..

I am doing dynamic 3d model using Cloud Reco...and I am able to get Metadata when Image is scanned ..Metadata as URL from where I can download 3d model..

But I am getting error..which I am not able to interpret it ....

could Anyone please help out it...

Error in this line --> 

AssetBundleRequest request = www.assetBundle.LoadAssetAsync("ImageTarget", typeof(GameObject));

Error -->

NullReferenceException: Object reference not set to an instance of an object

SimpleCloudHandler+<GetAssetBundle>c__Iterator0.MoveNext () (at Assets/SimpleCloudHandler.cs:150)

UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)

Load 3d model through cloud

February 15, 2014 - 7:43am #48

Hi,

Could you please share me the contact details of the programmer? I am having a project that requires the use of loading dynamic 3D models.

Thanks,

BP

Load 3d model through cloud

January 13, 2014 - 11:53pm #47

Hi,

Thanks for the reply. I am also working in the similar line to load 3D models dynamically from the server. I am using the 'monkey.obj model for testing. When using the Unity AssetBundle code, the response obtained is:

1. The cloud recognition meta url is obtained correctly (The last BundleURL is: http://www.domain.com/streaming/Model.obj)

2. I am getting the progressbar updated to 100%.

3. No model is displayed. I think there is something to be done with the script or model.

---

Also, I would like to know your feedback/suggestion on the following:

-> What all file types are currently supported?

-> How did you assign the texture to the model? Is the texture baked inside the model?

 

Thanks,

BP

Load 3d model through cloud

January 13, 2014 - 10:09am #46

Hi binspaul,

 

We've been able to correct the issue with some work in modilying the structure of the script.

With the help of an experience programmer, we've been able to create a solution that would support ios and android platform where we can stream our 3d content from any servers with the use our metadata file.

Since it been a while since we fixed the issue, i will look into the new sdk.

Thanks

Rick

Load 3d model through cloud

January 11, 2014 - 9:15pm #45

Hi Rickb,

Have you tried with the new Vuforia relase cloud recognition demo?

Thanks,

BP

Load 3d model through cloud

October 22, 2013 - 12:09am #44

Hi,

I have been able to load the 3d model with recognition cloud. The problem remaining is that it does no desappear when the target is off the camera or when pressing the scan button, it does not reset the scanner. I added a load level application script as a seperate file (with Gui Button) but it does not reset the scanner or application. The loaded model seems to remain in memory (wihout seeing it) not allowing to load new models or the same one.

I guest i would need to do something under OnNewSearchResult class to crreate a condtion when the target is or not in view. I have been looing at all the forums that would cover this issue over the last week. Beside the exemple that we can download from the site an using the ContentManager, there is nothing to tell us anything to solve this issue.

Here's the code so far when loading of asset bundle for IOS.

Can you help?

Rick

 

using System;

using UnityEngine;

using System.Collections;

 

 

public class Simple2CloudRecoEventHandler : MonoBehaviour, ICloudRecoEventHandler

{

    #region PRIVATE_MEMBER_VARIABLES

 

    // CloudRecoBehaviour reference to avoid lookups

    private CloudRecoBehaviour mCloudRecoBehaviour;

    // ImageTracker reference to avoid lookups

    private ImageTracker mImageTracker;

 

//private ContentManager mContentManager;

 

private WWW www;

private AssetBundleRequest gameObjectRequest;

private string BundleURL;

 

//For progress bar

private int progress = 0;

 

private GameObject TempObject;

 

    #endregion // PRIVATE_MEMBER_VARIABLES

 

 

 

    #region EXPOSED_PUBLIC_VARIABLES

 

public ImageTargetBehaviour ImageTargetTemplate;

 

//For progress bar

public int guiOffset = 20;

public GUIStyle CustomStyle;

 

    #endregion

 

 

void Start()

    {

        // register this event handler at the cloud reco behaviour

        CloudRecoBehaviour cloudRecoBehaviour = GetComponent<CloudRecoBehaviour>();

        if (cloudRecoBehaviour)

        {

            cloudRecoBehaviour.RegisterEventHandler(this);

        }

        // remember cloudRecoBehaviour for later

        mCloudRecoBehaviour = cloudRecoBehaviour;

    }

 

 

 

 

 

#region ICloudRecoEventHandler_IMPLEMENTATION

 

    public void OnInitialized()

    {

        // get a reference to the Image Tracker, remember it

        mImageTracker = (ImageTracker)TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER);

        //mContentManager = (ContentManager)FindObjectOfType(typeof(ContentManager));

    }

 

     #region UNTIY_MONOBEHAVIOUR_METHODS

 

 

    #endregion // UNTIY_MONOBEHAVIOUR_METHODS

 

    #region ICloudRecoEventHandler_IMPLEMENTATION

 

    public void OnInitError(TargetFinder.InitState initError)

    {

    }

 

    public void OnUpdateError(TargetFinder.UpdateState updateError)

    {

    }

 

    public void OnStateChanged(bool scanning)

    {

if (scanning)

        {

            // clear all known trackables

            mImageTracker.TargetFinder.ClearTrackables(false);

            // hide the ImageTargetTemplate

            //mContentManager.HideObject();

        }

    }

 

    public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)

    {

        // duplicate the referenced image target

        GameObject newImageTarget = Instantiate(ImageTargetTemplate.gameObject) as GameObject;

         

        GameObject augmentation = null;

 

        if( augmentation != null )

            augmentation.transform.parent = newImageTarget.transform;

 

        // enable the new result with the same ImageTargetBehaviour:

        ImageTargetBehaviour imageTargetBehaviour = mImageTracker.TargetFinder.EnableTracking(targetSearchResult, newImageTarget);

         

//StartCoroutine(GetAssetBundle());

 

        Debug.Log("Metadata value is " + BundleURL );

 

if (imageTargetBehaviour != null)

        {

            // stop the target finder

            mCloudRecoBehaviour.CloudRecoEnabled = false;

 

    if (targetSearchResult.MetaData != null)

{

BundleURL = targetSearchResult.MetaData;

StartCoroutine(GetAssetBundle());

    }

        }

 

}

 

 

 

    #endregion // ICloudRecoEventHandler_IMPLEMENTATION

 

 

/*

public void Hide (GameObject obj)

{

 

Renderer[] rendererComponents = obj.GetComponentsInChildren<Renderer>();

 

//Disable rendering:

foreach (Renderer component in rendererComponents)

{

component.enabled = false;

}

 

}

 

*/

 

private void Hide( GameObject model ){

         

        Debug.Log( "Hiding "+ model.name );

         

        Renderer[] rendererComponents = model.GetComponentsInChildren<Renderer>();

        Collider[] colliderComponents = model.GetComponentsInChildren<Collider>();

 

        // Disable rendering:

        foreach (Renderer component in rendererComponents)

        {

            component.enabled = false;

        }

 

        // Disable colliders:

        foreach (Collider component in colliderComponents)

        {

            component.enabled = false;

        }

 

        //Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost");

    }

 

 

//}

 

#endregion ICloudRecoEventHandler_IMPLEMENTATION

 

 

IEnumerator GetAssetBundle ()

{

 

www = new WWW(BundleURL);

yield return www;

Debug.Log("The last BundleURL " + BundleURL );

 

AssetBundleRequest request = www.assetBundle.LoadAsync("modelipad", typeof(GameObject));

yield return request;

 

Instantiate(request.asset, new Vector3(0f, 0f, 0f), Quaternion.identity);

 

//Put the stream model under the image target

GameObject ImageTargetUsed = GameObject.Find("CloudRecoTarget");

        GameObject ModelIpadClone = GameObject.Find("modelipad(Clone)");

        ModelIpadClone.transform.parent = ImageTargetUsed.transform;

 

}

 

 

// Update is called once per frame

  void OnGUI(){

 

GUILayout.Space(guiOffset);

progress = (int)(www.progress * 100);

GUILayout.BeginArea(new Rect(Screen.width / 2, 20,200,50));

GUILayout.Label( progress + "%",CustomStyle);

GUILayout.EndArea();

}

 

}

 

Load 3d model through cloud

October 17, 2013 - 12:56pm #43

Thank for the reply. 

Ok. so if i understand well i would need to build under target image prefab and assign on the asset bundle CachingLoadExemple that will load the url based model. I will need to transfer the BundleURL value.I am still struggling with c# but how do i stranfer the url value to tell the other script wich model to load.

I would execute the the script line from the StartCoroutine of the current SimpleCloudRecoEventHandler script. Is that correct? How would i transfer the BundleURL value and what DoSomething function could be?

GameObject.Find("TargetChildObject").GetComponentInChildren<CachingLoadExemple>().DoSomething();

or 

public GameObject TargetChildObject;

TargetChildObject.GetComponentInChildren<CachingLoadExemple>().DoSomething();

 

Script to stream the asset bundle. Does this srcript load asset with .assetbundle extension. I seem to only work with .unity3D extension This is for IOS.

 

using System;
using UnityEngine;
using System.Collections;

public class CachingLoadExample : MonoBehaviour {
	public string BundleURL;
	public string AssetName;
	public int version;

	void Start() {
		StartCoroutine (DownloadAndCache());
	}

	IEnumerator DownloadAndCache (){
		// Wait for the Caching system to be ready
		while (!Caching.ready)
			yield return null;

		// Load the AssetBundle file from Cache if it exists with the same version or download and store it in the cache
		using(WWW www = WWW.LoadFromCacheOrDownload (BundleURL, version)){
			yield return www;
			if (www.error != null)
				throw new Exception("WWW download had an error:" + www.error);
			AssetBundle bundle = www.assetBundle;
			if (AssetName == "")
				Instantiate(bundle.mainAsset);
			else
				Instantiate(bundle.Load(AssetName));
                	// Unload the AssetBundles compressed contents to conserve memory
                	bundle.Unload(false);

		} // memory is freed from the web stream (www.Dispose() gets called implicitly)
	}
}

Load 3d model through cloud

October 17, 2013 - 11:56am #42

What I recommend is to implement a separate script in a language you're familiar w/ (e.g. Javascript ) and to call that from the C# event handler using GetComponent<your_script>().DownloadMethod(), rather than attempt to load from within the event handler.

There is a sample script here that shows how to implement error handling for downloaded asset bundles - http://docs.unity3d.com/Documentation/Manual/DownloadingAssetBundles.html

Load 3d model through cloud

October 17, 2013 - 11:23am #41

 

Hi,

Yes i have been able to see the content of the metadata using Debug.Log (BundleURL) but it gives me the following error:

 

You are trying to load data from a www stream which had the following error when downloading.
Could not resolve host: BundleURL (Domain name not found)

The Metadata value is http://www.server.com/URLAssetBundlesCloud_Ver_4_0/file_name.assetbundle

I am using a StartCoroutine fonction from the OnNewSearchResult class and load the 3d model from server in the IEnumerator GetAssetBundle section of the script. Set the script section below with the script in the attachement.

 

It gives me the following error

 
 
Thanks
Rick

 

 

...

...

 

if(targetSearchResult.MetaData != null ){

 

Debug.Log (BundleURL);

 

 

StartCoroutine(GetAssetBundle());

 

....

....

 

 

IEnumerator GetAssetBundle ()

{

 

www = new WWW("BundleURL");

yield return www;

 

request = www.assetBundle.LoadAsync("BundleURL", typeof(GameObject));

yield return request;

 

GameObject qcarObjParent = Instantiate(request.asset, new Vector3(0f, 0f, 0f), Quaternion.identity) as GameObject;

GameObject gObject = qcarObjParent.GetComponentInChildren<QCARBehaviour>().gameObject;

StopCoroutine("GetAssetBundle");

 

}

 

}

 

Load 3d model through cloud

October 15, 2013 - 7:42am #40

Hi,

I have been able to see the content of the metadata using Debug.Log (BundleURL);

Metadata value is http://www.server.com/URLAssetBundlesCloud_Ver_4_0/file_name.assetbundle

It gives me the following error

 

You are trying to load data from a www stream which had the following error when downloading.
Could not resolve host: BundleURL (Domain name not found)
 
Thanks
Rick

Here's an update of my script called Simple2CloudRecoEventHandler:

 

 

using System;

using UnityEngine;

using System.Collections;

 

/// <summary>

/// This MonoBehaviour implements the Cloud Reco Event handling for this sample.

/// It registers itself at the CloudRecoBehaviour and is notified of new search results.

/// </summary>

public class Simple2CloudRecoEventHandler : MonoBehaviour, ICloudRecoEventHandler

{

    #region PRIVATE_MEMBER_VARIABLES

 

    // CloudRecoBehaviour reference to avoid lookups

    private CloudRecoBehaviour mCloudRecoBehaviour;

    // ImageTracker reference to avoid lookups

    private ImageTracker mImageTracker;

 

//private ContentManager 

//mContentManager;

 

public WWW www;

 

//private GameObject cube, sphere;

 

    #endregion // PRIVATE_MEMBER_VARIABLES

 

 

 

    #region EXPOSED_PUBLIC_VARIABLES

 

    /// <summary>

    /// can be set in the Unity inspector to reference a ImageTargetBehaviour that is used for augmentations of new cloud reco results.

    /// </summary>

    //public ImageTargetBehaviour ImageTargetTemplate;

public ImageTargetBehaviour ImageTargetTemplate;

//private string BundleURL;

//private static string DipslayBundleURL;

 

public GUIStyle CustomStyle;

    #endregion

 

#region ICloudRecoEventHandler_IMPLEMENTATION

 

    /// <summary>

    /// called when TargetFinder has been initialized successfully

    /// </summary>

    public void OnInitialized()

    {

        // get a reference to the Image Tracker, remember it

        mImageTracker = (ImageTracker)TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER);

        //mContentManager = (ContentManager)FindObjectOfType(typeof(ContentManager));

    }

 

     #region UNTIY_MONOBEHAVIOUR_METHODS

 

    /// <summary>

    /// register for events at the CloudRecoBehaviour

    /// </summary>

    

void Start()

    {

        // register this event handler at the cloud reco behaviour

        CloudRecoBehaviour cloudRecoBehaviour = GetComponent<CloudRecoBehaviour>();

        if (cloudRecoBehaviour)

        {

            cloudRecoBehaviour.RegisterEventHandler(this);

        }

 

        // remember cloudRecoBehaviour for later

        mCloudRecoBehaviour = cloudRecoBehaviour;

    }

 

    #endregion // UNTIY_MONOBEHAVIOUR_METHODS

 

 

 

    #region ICloudRecoEventHandler_IMPLEMENTATION

 

    /// <summary>

    /// called when TargetFinder has been initialized successfully

    /// </summary>

    //public void OnInitialized()

    //{

        // get a reference to the Image Tracker, remember it

    //    mImageTracker = (ImageTracker)TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER);

// //mContentManager = (ContentManager)FindObjectOfType(typeof(ContentManager));

    //}

 

    /// <summary>

    /// visualize initialization errors

    /// </summary>

    public void OnInitError(TargetFinder.InitState initError)

    {

    }

 

    /// <summary>

    /// visualize update errors

    /// </summary>

    public void OnUpdateError(TargetFinder.UpdateState updateError)

    {

    }

 

    /// <summary>

    /// when we start scanning, unregister Trackable from the ImageTargetTemplate, then delete all trackables

    /// </summary>

    public void OnStateChanged(bool scanning)

    {

    }

 

    /// <summary>

    /// Handles new search results

    /// </summary>

    /// <param name="targetSearchResult"></param>

    public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)

    {

        // 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);

 

GameObject augmentation = null;

         

        string BundleURL = targetSearchResult.MetaData;

 

        if (imageTargetBehaviour != null)

        {

            // stop the target finder

            mCloudRecoBehaviour.CloudRecoEnabled = true;

 

//Instantiate(gObject);

 

// Calls the TargetCreated Method of the SceneManager object to start loading

            // the GameObject

 

            //mContentManager.TargetCreated(targetSearchResult.MetaData);

 

if(targetSearchResult.MetaData != null ){

 

//string BundleURL = targetSearchResult.MetaData;

 

Debug.Log (BundleURL);

 

 

StartCoroutine(GetAssetBundle());

 

    }

        }

 

}

 

 

 

    #endregion // ICloudRecoEventHandler_IMPLEMENTATION

 

public void Hide (GameObject obj)

{

 

Renderer[] rendererComponents = obj.GetComponentsInChildren<Renderer>();

 

//Disable rendering:

foreach (Renderer component in rendererComponents)

{

component.enabled = false;

}

 

}

 

#endregion ICloudRecoEventHandler_IMPLEMENTATION

 

 

IEnumerator GetAssetBundle ()

{

 

www = new WWW("BundleURL");

 

yield return www;

 

     AssetBundle bundle = www.assetBundle;

  GameObject gObject=Instantiate(bundle.mainAsset,new Vector3(0,0,0),Quaternion.identity) as GameObject;

  gObject.transform.localScale=new Vector3(50f,50f,50f);

 

 

/*

//For Android?

//www = new WWW(BundleURL);

BundleURL = "http://www.server.com/......./file_name.unity3d";

using (WWW www = new WWW(BundleURL)) {

    yield return www;

    Instantiate(www.assetBundle.mainAsset);

}

*/

}

 

}

 
 

Load 3d model through cloud

October 14, 2013 - 2:19pm #39

Thanks for the reply

Indeed i am trying to retreive this information. I am not to confirtable with c#.

I added a GUI.Label at the end of the file but i am not getting anything.

I'll try to confirm shortly.

Thanks

 

 

....

....

 

 

public void Hide (GameObject obj)

{

 

Renderer[] rendererComponents = obj.GetComponentsInChildren<Renderer>();

 

//Disable rendering:

foreach (Renderer component in rendererComponents)

{

component.enabled = false;

}

 

}

 

#endregion ICloudRecoEventHandler_IMPLEMENTATION

 

 

IEnumerator GetAssetBundle ()

{

 

//www = new WWW("http://www.simfusion.com/URLAssetBundlesCloud_Ver_4_0/modelipadcloud_300.assetbundle");

www = new WWW(BundleURL);

 

yield return www;

 

     AssetBundle bundle = www.assetBundle;

  GameObject gObject=Instantiate(bundle.mainAsset,new Vector3(0,0,0),Quaternion.identity) as GameObject;

  gObject.transform.localScale=new Vector3(50f,50f,50f);

}

 

 

public void Update(){

 

if (BundleURL != null)

        {

GUI.Label(new Rect(10, 10, 300, 70), "Path: " + BundleURL.ToString());

}

    }

}

 

Load 3d model through cloud

October 14, 2013 - 2:00pm #38

Have you confirmed whether you metadata is being retrieved and read properly?

LOADING 3D MODEL FROM CLOUD

October 14, 2013 - 11:14am #37

Hi,

I have read many forums on how to load 3d models using metadata flie created on cloud database on Target Manager section and i just cannot get anywhere on how to view a model from a server location.

I have everything setup with model in .assetbundle format (for IOS device) created and URL model path define in the metadata file.

I can see the application detecting the taget information (from the console) coming from the DefaultTrackableEventHandler script  assigned to the ImageTarge. 

I think the last step is to modify the CloudRecoEventHandler or the SimpleCloudRecoEventHandler which will assign the path coming from the targetSearchResult.MetaData (under OnNewSearchResult class) and link the target to the corresponding 3d model.

Here's the script that i have modify from the SimpleCloudRecoEventHandler sample script.

Can someone help.

Tks,

Rick

 

 

using System;

using UnityEngine;

using System.Collections;

 

/// <summary>

/// This MonoBehaviour implements the Cloud Reco Event handling for this sample.

/// It registers itself at the CloudRecoBehaviour and is notified of new search results.

/// </summary>

public class Simple2CloudRecoEventHandler : MonoBehaviour, ICloudRecoEventHandler

{

    #region PRIVATE_MEMBER_VARIABLES

 

    // CloudRecoBehaviour reference to avoid lookups

    private CloudRecoBehaviour mCloudRecoBehaviour;

    // ImageTracker reference to avoid lookups

    private ImageTracker mImageTracker;

 

private ContentManager mContentManager;

 

public WWW www;

 

//private GameObject cube, sphere;

 

    #endregion // PRIVATE_MEMBER_VARIABLES

 

 

 

    #region EXPOSED_PUBLIC_VARIABLES

 

    /// <summary>

    /// can be set in the Unity inspector to reference a ImageTargetBehaviour that is used for augmentations of new cloud reco results.

    /// </summary>

    //public ImageTargetBehaviour ImageTargetTemplate;

public ImageTargetBehaviour ImageTargetTemplate;

private string BundleURL;

private string str;

 

public GUIStyle CustomStyle;

    #endregion

 

#region ICloudRecoEventHandler_IMPLEMENTATION

 

    /// <summary>

    /// called when TargetFinder has been initialized successfully

    /// </summary>

    public void OnInitialized()

    {

        // get a reference to the Image Tracker, remember it

        mImageTracker = (ImageTracker)TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER);

        mContentManager = (ContentManager)FindObjectOfType(typeof(ContentManager));

    }

 

     #region UNTIY_MONOBEHAVIOUR_METHODS

 

    /// <summary>

    /// register for events at the CloudRecoBehaviour

    /// </summary>

    

void Start()

    {

        // register this event handler at the cloud reco behaviour

        CloudRecoBehaviour cloudRecoBehaviour = GetComponent<CloudRecoBehaviour>();

        if (cloudRecoBehaviour)

        {

            cloudRecoBehaviour.RegisterEventHandler(this);

        }

 

        // remember cloudRecoBehaviour for later

        mCloudRecoBehaviour = cloudRecoBehaviour;

    }

 

    #endregion // UNTIY_MONOBEHAVIOUR_METHODS

 

 

 

    #region ICloudRecoEventHandler_IMPLEMENTATION

 

    /// <summary>

    /// called when TargetFinder has been initialized successfully

    /// </summary>

    //public void OnInitialized()

    //{

        // get a reference to the Image Tracker, remember it

    //    mImageTracker = (ImageTracker)TrackerManager.Instance.GetTracker(Tracker.Type.IMAGE_TRACKER);

// mContentManager = (ContentManager)FindObjectOfType(typeof(ContentManager));

    //}

 

    /// <summary>

    /// visualize initialization errors

    /// </summary>

    public void OnInitError(TargetFinder.InitState initError)

    {

    }

 

    /// <summary>

    /// visualize update errors

    /// </summary>

    public void OnUpdateError(TargetFinder.UpdateState updateError)

    {

    }

 

    /// <summary>

    /// when we start scanning, unregister Trackable from the ImageTargetTemplate, then delete all trackables

    /// </summary>

    public void OnStateChanged(bool scanning)

    {

    }

 

    /// <summary>

    /// Handles new search results

    /// </summary>

    /// <param name="targetSearchResult"></param>

    public void OnNewSearchResult(TargetFinder.TargetSearchResult targetSearchResult)

    {

        // 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 (imageTargetBehaviour != null)

        {

            // stop the target finder

            mCloudRecoBehaviour.CloudRecoEnabled = false;

 

//Instantiate(gObject);

 

// Calls the TargetCreated Method of the SceneManager object to start loading

            // the GameObject

 

            mContentManager.TargetCreated(targetSearchResult.MetaData);

 

         }

 

if(targetSearchResult.MetaData != null ){

 

BundleURL = targetSearchResult.MetaData;

 

StartCoroutine(GetAssetBundle());

     }

}

 

 

 

    #endregion // ICloudRecoEventHandler_IMPLEMENTATION

 

public void Hide (GameObject obj)

{

 

Renderer[] rendererComponents = obj.GetComponentsInChildren<Renderer>();

 

//Disable rendering:

foreach (Renderer component in rendererComponents)

{

component.enabled = false;

}

 

}

 

#endregion ICloudRecoEventHandler_IMPLEMENTATION

 

 

IEnumerator GetAssetBundle ()

{

 

//www = new WWW("http://Some Path If Dont Use targetSearchResult.MetaData");

www = new WWW(BundleURL);

 

yield return www;

 

      AssetBundle bundle = www.assetBundle;

   GameObject gObject=Instantiate(bundle.mainAsset,new    Vector3(0,0,0),Quaternion.identity) as GameObject;

   gObject.transform.localScale=new Vector3(1f,1f,1f);

 

}

}

Load 3d model through cloud

September 19, 2013 - 12:44am #36

i have load the 3d model through cloud. I want to destroy it when tracking image is lost. I have write destroy game object code on tracking lost method of defaulttrackableeventhandler code but not succeded. What can i do?

Load 3d model through cloud

August 14, 2013 - 7:48am #35

This is defined in the CloudRecoSampleMenu script (see OnGUI() method)

 

Load 3d model through cloud

August 14, 2013 - 5:13am #34

Close button on device is not shown in my cloud reco project. How to enable it?

Load 3d model through cloud

July 26, 2013 - 1:55am #33

Ya I have check it after attaching it to cloud target but on tracking lost method is not call.

Load 3d model through cloud

July 26, 2013 - 1:34am #32

Have you attached the DefaultTrackableEventHandler script to your Cloud Target ? you can find it in the ImageTargets sample.

Load 3d model through cloud

July 25, 2013 - 11:58pm #31

I have also tried in cloud reco event handler script's On tracking lost event start cloud reco  but On tracking lost event is also not call

Load 3d model through cloud

July 19, 2013 - 3:10am #30

I have call startCloudreco of cloud reco behaviour after  oNTrackingLost of Default Trackable Behaviour but tracking is not started after image target change From any other method i should call startcloudreco method?

Load 3d model through cloud

July 19, 2013 - 1:01am #29

You can use the DefaultTrackableEventHandler script (which is attached to each target), to get notified of when a target gets detected or lost;

this allows you to know "when" there is a change;

then you can use the StateManager class to retrieve the list of the currently active trackables, see:

https://developer.vuforia.com/resources/api/unity/class_state_manager

So, you can compare the curent list with a previous one and see what targets are in, and what targets are out.

Load 3d model through cloud

July 18, 2013 - 11:10pm #28

Can we restart scan on image target change? Is there any method that identify image target is change?

 

 

Load 3d model through cloud

July 18, 2013 - 11:06pm #27

This is happening because you stop the cloud scanning when you detect the first target; 

you need to restart the scan, as shown in the Cloud Reco sample (in the sample this is achieved by touching the "close" button)

 

Load 3d model through cloud

July 18, 2013 - 10:16pm #26

Hi 

I am successful to load 3d model. Now i want to recognize more than one image from cloud database. Actually I have 2 image target right now. It can be more letter. I have 3d model url attach to it. If first image tracked and model load then if I change image target change  then scaning is not start . What can i do?

 

Thanks in advance.

Load 3d model through cloud

May 30, 2013 - 4:46am #25

Have you been able to load and display an AssetBundle on mobile latform, without integrating it with Vuforia ?

That would be the first thing to try, to isolate the issue... I seem to understand tha something goes wrong when instantiating the assetBundle... I doubt this is caused or related to Vuforia itself...

 

Load 3d model through cloud

May 29, 2013 - 11:54pm #24

url is right. i haved double ckeck it.

Load 3d model through cloud

May 29, 2013 - 11:45pm #23

Perhaps you are pointing to a wrong URL ?

 

Load 3d model through cloud

May 29, 2013 - 10:50pm #22

Transform g=GameObject.Instantiate(bundle.Load(str))as Transform;

here str is my url. byentering message i come to know that game object is not instantiated. i can't understand the reason,

Load 3d model through cloud

May 7, 2013 - 11:56pm #21

Hi, have you checked this article:

https://developer.vuforia.com/forum/faq/unity-how-can-i-dynamically-attach-my-3d-model-image-target

This explains how you can dynamically attach a 3D model under a target at runtime  (in your case this will be the model instantiated from the assetBundle);

one important thing, you need to re-parent the model, similarly to what is done in this code (see the article above for full details):

 

Transform myModelTrf = GameObject.Instantiate(myModelPrefab) as Transform;
 
             myModelTrf.parent = mTrackableBehaviour.transform;            
             myModelTrf.localPosition = new Vector3(0f, 0f, 0f);
             myModelTrf.localRotation = Quaternion.identity;
             myModelTrf.localScale = new Vector3(0.0005f, 0.0005f, 0.0005f);
 
             myModelTrf.gameObject.active = true;
 

Load 3d model through cloud

May 7, 2013 - 11:18pm #20

hi all

my 3/4 th of the work is completed I can found now  data from my metadata file,i which i have store url on which i have store my 3d model. From that URL I want to load my 3d model. I have make code for that but not succeded . Can you please help me. I have attach my code for same.

 

 if(targetSearchResult.MetaData != null ){
 
  modelName = targetSearchResult.MetaData; // the modelName is assigned the metadata text as a string.
   str=modelName;
 
 /* code for loading 3d model*/
using (WWW www = new WWW(str)) {
  
     AssetBundle bundle = www.assetBundle;
 g=Instantiate(bundle.mainAsset,new Vector3(0,0,0),Quaternion.identity) as GameObject;
  g.transform.localScale=new Vector3(0.136500f,0.136500f,0.136500f);
}
I have write aboce code OnNewSearchResult function.
 
Thanks in advance

Load 3d model through cloud

May 6, 2013 - 11:19pm #19

Hi, I would recommend youn read this article about using metadata:

https://developer.vuforia.com/forum/cloud-recognition/cloud-reco-using-target-metadata

It also contains reference to the relevant API

 

Load 3d model through cloud

May 6, 2013 - 10:46pm #18

I can load my image through bundle url but i want to load it through metadata file. Can any one give me code for read metadata file associated with target image thanksin advance

Load 3d model through cloud

May 6, 2013 - 2:38am #17

Hi 

Scanning is done but image is not loaded through url. for it i have tio make my metadata package .can any one tell me about metadata package?

Load 3d model through cloud

May 5, 2013 - 11:17pm #16

Hi 

i found that my problem can be solve though metadatapackage. but can anyone tell me how can I make my own metadata package.

Load 3d model through cloud

May 4, 2013 - 6:22am #15

Hi friends ,

I have loaded 3d model through cloud . Now I want different thing. I want that my target resource is on cloud db and3d model is on url . when on cloud i detect the image then 3d model should load through URL. For that I have use example provided by vudforia and make changes in code but detection is not perform I have post here my script please help me. Thanks in advance.

 

using UnityEngine;
using System.Collections;
using System;
public class TrackMap : MonoBehaviour,ITrackableEventHandler {
 
#region PRIVATE_MEMBER_VARIABLES
 
    private TrackableBehaviour mTrackableBehaviour;
    
    #endregion // PRIVATE_MEMBER_VARIABLES
 
public string BundleURL;
   public string AssetName;
public GameObject g;
public string msg;
 
    #region UNTIY_MONOBEHAVIOUR_METHODS
    
   IEnumerator Start()
    {
     
Debug.Log("Go in start");
 
BundleURL="<myURL>";
  using (WWW www = new WWW(BundleURL)) {
     yield return www;
  
     AssetBundle bundle = www.assetBundle;
 g=Instantiate(bundle.mainAsset,new Vector3(0,0,0),Quaternion.identity) as GameObject;
  
}
 
    }
 
    #endregion // UNTIY_MONOBEHAVIOUR_METHODS
 
 
 
    #region PUBLIC_METHODS
 
    /// <summary>
    /// Implementation of the ITrackableEventHandler function called when the
    /// tracking state changes.
    /// </summary>
    public void OnTrackableStateChanged( TrackableBehaviour.Status previousStatus,
                                    TrackableBehaviour.Status newStatus)
    {
        if (newStatus == TrackableBehaviour.Status.DETECTED ||
            newStatus == TrackableBehaviour.Status.TRACKED)
        {
            OnTrackingFound();
        }
        else
        {
            OnTrackingLost();
        }
    }
 
    #endregion // PUBLIC_METHODS
 
 
 
    #region PRIVATE_METHODS
 
 
    private void OnTrackingFound()
    {
        Renderer[] rendererComponents = GetComponentsInChildren<Renderer>();
        Collider[] colliderComponents = GetComponentsInChildren<Collider>();
 
        // Enable rendering:
        foreach (Renderer component in rendererComponents)
        {
            component.enabled = true;
        }
 
        // Enable colliders:
        foreach (Collider component in colliderComponents)
        {
            component.enabled = true;
        }
 
        Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found");
 
/*---------------------------------*/
 
g.transform.parent=GameObject.Find("WorldMap").transform;
g=GameObject.Find("Dolphin(Clone)");
 
transform.localScale=new Vector3(0.136500f,0.136500f,0.136500f);
 
g.transform.localPosition=new Vector3(0.0f,0.0f,0.0f);
 
}
 
 
 
    private void OnTrackingLost()
    {
        Renderer[] rendererComponents = GetComponentsInChildren<Renderer>();
        Collider[] colliderComponents = GetComponentsInChildren<Collider>();
 
        // Disable rendering:
        foreach (Renderer component in rendererComponents)
        {
            component.enabled = false;
        }
 
        // Disable colliders:
        foreach (Collider component in colliderComponents)
        {
            component.enabled = false;
        }
 
 
    }
 
    #endregion // PRIVATE_METHODS
}
 

In target behaviour also I have chosen type cloudreco .In cloudrecobehaviour script given Accss Key and Secret Key. model is loaded on unity engine but not in device 

actually detection of image is not occur like it occur in  cloud reco example

Load 3d model through cloud

April 29, 2013 - 10:05pm #14

Great!

Load 3d model through cloud

April 29, 2013 - 9:48pm #13

ok finally i have done it. Actually my 3d model is made for ios. So i have made special 3d model for android put it on url. Instantiate it in game object and set position of it. Thanks to all for guiding me.

Load 3d model through cloud

April 26, 2013 - 6:50am #12

So, the same URL works in Play Mode (on PC) but not on device ?

If you are sure that the asset bundle has been generated with the BuildTarget.Android option, then it could be that the model is too large or too heavy to be rendered on mobile.

Maybe try creating a simple Cube and exporting it to Asset Bundle for Android; I did the same test in the past and it did work

(note: I just followed the Unity tutorial to achieev that, so nothing more than the code that you find in the Unity website).

 

Load 3d model through cloud

April 26, 2013 - 2:09am #11

It is an asset bundle which I have uploaded on web and that url I  am using.

Load 3d model through cloud

April 26, 2013 - 12:18am #10

What is the URL you're using ?

 

Load 3d model through cloud

April 26, 2013 - 12:10am #9

hi alessandrob

I have change in exportassetbundle file and give build target.android option but still not work. Is it possible that there is a problem in url? Is it url for asset bundle is different for ios and android?

Load 3d model through cloud

April 26, 2013 - 12:06am #8

Hi janantikey,

if you have created your own asset bundle (out of a 3D model) using the BuildPipeline API of Unity, you need to make sure to add this option:

BuildTarget.Android

otherwise your asset bundle will not be compatible with Android (and that might explain why it does not show up in your test)

See here:

http://docs.unity3d.com/Documentation/ScriptReference/BuildPipeline.BuildAssetBundle.html?from=BuildAssetBundleOptions

Load 3d model through cloud

April 25, 2013 - 9:51pm #7

hi all 

I have done it through load asset bundle script and changng in export asset bundle. It works on unity environment but model is not loaded on  android mobile. Any one have idea? Thanks in advance.

 

Load 3d model through cloud

April 24, 2013 - 2:29am #6

I cannot give you exact instructions to achieve this.

Firstly you need experience with Asset Bundles and loading the models into Unity.

Once you have done this you need to find a way of adding the model to the Image Target as a child.

Most of this is covered by the basic Unity documentation and tutorials as well as the scripting guide. 

The best thing to do is to break down the problem in to smaller components, solve each problem and then build up.

 

N

Load 3d model through cloud

April 24, 2013 - 2:21am #5

I am new for the vuforia. So if I cannot use exact technical word then sorry for that. In vuforia example we can see that dynasoreis loaded at run time. It is a child of image target. I want that if my dynasore is store at somewhere on cloud(web) and from their load my model

Load 3d model through cloud

April 24, 2013 - 2:07am #4

Please could you make your question clearer?

If you have the model via the asset bundle in Unity I am not sure what the problem is?

To show an augmentation it must be the child of the Image Target, so you will have to make that association at runtime using some code.

 

HTH

N

Load 3d model through cloud

April 24, 2013 - 1:38am #3

I have done it through asset bundle but how to do it in vuforia 3d model.

Load 3d model through cloud

April 23, 2013 - 2:55am #2

Search the forums for "asset bundles" and also read the docs over at Unity to see how this works.

Note this is a pro only feature.

 

N

Log in or register to post comments