void EndScene() { RScript.resources[RScript.curPoint].tasks[RScript.curTask].isDone = true; tobj.Stop(); tobj.DestroyAllDataSets(true); SceneManager.LoadScene("QuestScene", LoadSceneMode.Single); }
public GameObject augmentationObject = null; // you can use teapot or other object public void DeactivateDataSets() { ObjectTracker objectTracker = TrackerManager.Instance.GetTracker<ObjectTracker>(); if (objectTracker.IsActive) { objectTracker.Stop(); objectTracker.DestroyAllDataSets(false); } }
public void destroyAllDataSets() { Debug.Log("DestroyAllDatasets 1"); countDatasets(); ObjectTracker objectTracker = TrackerManager.Instance.GetTracker <ObjectTracker>(); if (objectTracker.IsActive) { objectTracker.Stop(); // TODO qué onda este bool? objectTracker.DestroyAllDataSets(true); Debug.Log("<color=green>DestroyAllDataSets</color>"); } countDatasets(); Debug.Log("DestroyAllDatasets 2"); }
private void App_Reloading(object sender, EventArgs e) { // Reset all loaded databases m_loadedDatabases.Clear(); m_toLoad.Clear(); if (IsInitialized) { ObjectTracker objectTracker = TrackerManager.Instance.GetTracker <ObjectTracker>(); foreach (var ds in objectTracker.GetActiveDataSets()) { ds.DestroyAllTrackables(true); } objectTracker.DestroyAllDataSets(true); } }
void MakeTrackable(Texture2D trackableTexture, Texture2D overlayTexture) { ObjectTracker objectTracker = TrackerManager.Instance.GetTracker <ObjectTracker>(); objectTracker.DestroyAllDataSets(true); DataSet dataSet = objectTracker.CreateDataSet(); objectTracker.RuntimeImageSource.SetImage(trackableTexture, 0.16f, "newTargetImage"); DataSetTrackableBehaviour tbh = dataSet.CreateTrackable(objectTracker.RuntimeImageSource, "NewTrackableObject"); tbh.gameObject.AddComponent <DefaultTrackableEventHandler>(); tbh.gameObject.AddComponent <TurnOffBehaviour>(); tbh.RegisterOnTrackableStatusChanged(statusChange => { if (statusChange.NewStatus.Equals(TrackableBehaviour.Status.NO_POSE)) { mServerFoundTrackable = false; StartCoroutine(PutCameraImage()); } else if (statusChange.NewStatus.Equals(TrackableBehaviour.Status.TRACKED)) { mServerFoundTrackable = true; } }); // Create quad to display image GameObject childQuad = GameObject.CreatePrimitive(PrimitiveType.Quad); MeshRenderer meshRenderer = childQuad.GetComponent <MeshRenderer>(); meshRenderer.sharedMaterial = new Material(Shader.Find("Standard")); meshRenderer.sharedMaterial.SetTexture("_MainTex", overlayTexture); childQuad.transform.parent = tbh.gameObject.transform; childQuad.transform.localScale = new Vector3(overlayTexture.width / (float)overlayTexture.height, 1f, 1f); childQuad.transform.Rotate(new Vector3(90f, 0f, 0f)); // End quad objectTracker.ActivateDataSet(dataSet); }
protected void ClearAndLoadDataSet() { ObjectTracker objectTracker = Vuforia.TrackerManager.Instance.GetTracker <ObjectTracker> (); objectTracker.DestroyAllDataSets(false); objectTracker.Stop(); // stop tracker so that we can add new dataset var tNodes = data.Element("trackings").Nodes(); foreach (XElement node in tNodes) { string dataSetName = Xml.Attribute(node, "src"); DataSet dataSet = objectTracker.CreateDataSet(); if (dataSet.Load(GetAssetsPath(dataSetName), VuforiaUnity.StorageType.STORAGE_ABSOLUTE)) { if (!objectTracker.ActivateDataSet(dataSet)) { // Note: ImageTracker cannot have more than 100 total targets activated Debug.Log("<color=yellow>Failed to Activate DataSet: " + dataSetName + "</color>"); } } } }
void LoadDataSet() { ObjectTracker objectTracker = TrackerManager.Instance.GetTracker<ObjectTracker>(); if (objectTracker.IsActive) { objectTracker.Stop(); objectTracker.DestroyAllDataSets(false); } DataSet dataSet = objectTracker.CreateDataSet(); if (dataSet.Load(dataSetName)) { objectTracker.Stop(); // stop tracker so that we can add new dataset if (!objectTracker.ActivateDataSet(dataSet)) { // Note: ImageTracker cannot have more than 100 total targets activated Debug.Log("<color=yellow>Failed to Activate DataSet: " + dataSetName + "</color>"); } else { Debug.Log("<color=blue>DataSet Activated : " + dataSetName + "</color>"); } if (!objectTracker.Start()) { Debug.Log("<color=yellow>Tracker Failed to Start.</color>"); } int counter = 0; IEnumerable<TrackableBehaviour> tbs = TrackerManager.Instance.GetStateManager().GetTrackableBehaviours(); foreach (TrackableBehaviour tb in tbs) { if (tb.name == "New Game Object") { // change generic name to include trackable name tb.gameObject.name = ++counter + ":DynamicImageTarget-" + tb.TrackableName; // add additional script components for trackable tb.gameObject.AddComponent<DefaultTrackableEventHandler>(); tb.gameObject.AddComponent<TurnOffBehaviour>(); if (augmentationObject != null) { // instantiate augmentation object and parent to trackable GameObject augmentation = (GameObject)GameObject.Instantiate(augmentationObject); augmentation.transform.parent = tb.gameObject.transform; augmentation.transform.localPosition = new Vector3(0f, 0f, 0f); augmentation.transform.localRotation = Quaternion.identity; augmentation.transform.localScale = new Vector3(0.005f, 0.005f, 0.005f); augmentation.gameObject.SetActive(true); } else { Debug.Log("<color=yellow>Warning: No augmentation object specified for: " + tb.TrackableName + "</color>"); } } } } else { Debug.LogError("<color=yellow>Failed to load dataset: '" + dataSetName + "'</color>"); } }
IEnumerator LoadDataSet() { ObjectTracker objectTracker = TrackerManager.Instance.GetTracker <ObjectTracker> (); objectTracker.DestroyAllDataSets(false); objectTracker.Stop(); // stop tracker so that we can add new dataset var tNodes = data.Element("trackings").Nodes(); foreach (XElement node in tNodes) { string dataSetName = Xml.Attribute(node, "src"); DataSet dataSet = objectTracker.CreateDataSet(); if (dataSet.Load(GetAssetsPath(dataSetName), VuforiaUnity.StorageType.STORAGE_ABSOLUTE)) { if (!objectTracker.ActivateDataSet(dataSet)) { // Note: ImageTracker cannot have more than 100 total targets activated Debug.Log("<color=yellow>Failed to Activate DataSet: " + dataSetName + "</color>"); } } } //int counter = 0; IEnumerable <TrackableBehaviour> tbs = TrackerManager.Instance.GetStateManager().GetTrackableBehaviours(); foreach (TrackableBehaviour tb in tbs) { Logger.Log(tb.TrackableName, "purple"); tb.gameObject.name = "AR-" + tb.TrackableName; XElement info = Xml.GetChildByAttribute(itemInfos, "id", tb.TrackableName); if (info == null) { continue; } string objType = Xml.Attribute(info, "type"); tb.gameObject.AddComponent <DefaultTrackableEventHandler> (); tb.gameObject.AddComponent <CustomTrackableEventHandler> (); tb.gameObject.AddComponent <TurnOffBehaviour> (); CustomTrackableEventHandler cte = tb.gameObject.GetComponent <CustomTrackableEventHandler> (); cte.type = objType; cte.subtitlePath = GetAssetsPath(Xml.Attribute(info, "subtitle"), true); UnityEngine.Object asset = null; if (objType == "object") { asset = loadedAssets.ContainsKey(tb.TrackableName) ? loadedAssets [tb.TrackableName] : new GameObject(); } else if (objType == "video") { asset = planePrefab; //Renderer render = (planePrefab).GetComponent<Renderer> (); //render.material = videoMaterial; cte.videoPath = GetAssetsPath(Xml.Attribute(info, "videosrc"), true); //cte.mediaPlayer = mediaPlayer; } else if (objType == "menu4") { //asset = planePrefab; //Renderer render = (planePrefab).GetComponent<Renderer> (); //render.material = videoMaterial; //CustomTrackableEventHandler cte = tb.gameObject.GetComponent<CustomTrackableEventHandler> (); //cte.videoPath = GetAssetsPath (tb.TrackableName + ".mp4"); //cte.mediaPlayer = mediaPlayer; tb.gameObject.AddComponent <PopMenu> (); PopMenu popmenu = tb.gameObject.GetComponent <PopMenu> (); popmenu.menuItems = new List <PopMenuItem> (); //popmenu.playerMateral = videoMaterial; var menuNodes = info.Elements(); //XElement res = null; int index = 0; foreach (XElement n in menuNodes) { GameObject planeItem = GameObject.Instantiate(Resources.Load("Prefabs/PlaneItem4")) as GameObject; PopMenuItem pmi = planeItem.GetComponent <PopMenuItem> (); popmenu.menuItems.Add(pmi); pmi.floatSpeed = 5f; pmi.floatAmplitude = 0.03f; pmi.index = index; pmi.menu = popmenu; pmi.trackableHandler = cte; planeItem.transform.SetParent(tb.gameObject.transform, false); Vector3 position = planeItem.transform.localPosition; if (index == 1) { planeItem.transform.localPosition = position.SetX(-position.x); } else if (index == 2) { planeItem.transform.localPosition = position.SetZ(-position.z); } else if (index == 3) { planeItem.transform.localPosition = new Vector3(-position.x, position.y, -position.z); } pmi.Initiate(); string itemSrc = Xml.Attribute(n, "src"); string videoPath = Xml.Attribute(n, "videosrc"); pmi.subtitlePath = GetAssetsPath(Xml.Attribute(n, "subtitle"), true); if (!string.IsNullOrEmpty(videoPath)) { pmi.videoPath = GetAssetsPath(videoPath); } else { GameObject prefab = loadedAssets [Xml.Attribute(n, "prefab")] as GameObject; pmi.threeDObject = GameObject.Instantiate(prefab, prefab.transform.position, prefab.transform.rotation) as GameObject; pmi.threeDObject.transform.SetParent(tb.gameObject.transform, false); ApplyItemInfo(pmi.threeDObject, n); } WWW www = new WWW(GetAssetsPath(itemSrc, true)); yield return(www); Logger.Log(GetAssetsPath(itemSrc, true) + " " + www.texture.ToString()); pmi.material.mainTexture = www.texture; //Logger.Log (planeItem.transform.localPosition.x.ToString() + " " +planeItem.transform.localPosition.y+ " " + planeItem.transform.localPosition.z, "blue"); index++; } popmenu.Hide(); } //GameObject obj = (GameObject)GameObject.Instantiate (asset); if (asset != null) { GameObject prefab = asset as GameObject; GameObject obj = (GameObject)GameObject.Instantiate(prefab, prefab.transform.position, prefab.transform.rotation); obj.transform.SetParent(tb.gameObject.transform, false); ApplyItemInfo(obj, Xml.GetChildByAttribute(itemInfos, "id", tb.TrackableName)); } //obj.gameObject.SetActive (true); } if (!objectTracker.Start()) { Debug.Log("<color=yellow>Tracker Failed to Start.</color>"); } }