Demo 2
Demo 1
Presentation and video link:
https://drive.google.com/open?id=1ePr1sKLeLbHFvW54...
Demo please click the link:
https://drive.google.com/open?id=1SEiBwMjRYmKhQncD...


| using System.Collections; | |
| using System.Collections.Generic; | |
| using UnityEngine; | |
| public class RotateEarth : MonoBehaviour { | |
| // Use this for initialization | |
| void Start () { | |
| } | |
| // Update is called once per frame | |
| void Update () { | |
| transform.Rotate(0,1,0); | |
| } | |
| } |
| /*============================================================================== | |
| Copyright (c) 2017 PTC Inc. All Rights Reserved. | |
| Copyright (c) 2010-2014 Qualcomm Connected Experiences, Inc. | |
| All Rights Reserved. | |
| Confidential and Proprietary - Protected under copyright and other laws. | |
| ==============================================================================*/ | |
| using UnityEngine; | |
| using Vuforia; | |
| using System.Collections; | |
| using System.Collections.Generic; | |
| /// <summary> | |
| /// A custom handler that implements the ITrackableEventHandler interface. | |
| /// </summary> | |
| public class DefaultTrackableEventHandler : MonoBehaviour, ITrackableEventHandler | |
| { | |
| //------------Begin Sound---------- | |
| public AudioSource soundTarget; | |
| public AudioClip clipTarget; | |
| private AudioSource[] allAudioSources; | |
| //function to stop all sounds | |
| void StopAllAudio() | |
| { | |
| allAudioSources = FindObjectsOfType(typeof(AudioSource)) as AudioSource[]; | |
| foreach (AudioSource audioS in allAudioSources) | |
| { | |
| audioS.Stop(); | |
| } | |
| } | |
| //function to play sound | |
| void playSound(string ss) | |
| { | |
| clipTarget = (AudioClip)Resources.Load(ss); | |
| soundTarget.clip = clipTarget; | |
| soundTarget.loop = false; | |
| soundTarget.playOnAwake = false; | |
| soundTarget.Play(); | |
| } | |
| //-----------End Sound------------ | |
| #region PRIVATE_MEMBER_VARIABLES | |
| protected TrackableBehaviour mTrackableBehaviour; | |
| #endregion // PRIVATE_MEMBER_VARIABLES | |
| #region UNTIY_MONOBEHAVIOUR_METHODS | |
| protected virtual void Start() | |
| { | |
| mTrackableBehaviour = GetComponent<TrackableBehaviour>(); | |
| if (mTrackableBehaviour) | |
| mTrackableBehaviour.RegisterTrackableEventHandler(this); | |
| //Register / add the AudioSource as object | |
| soundTarget = (AudioSource)gameObject.AddComponent<AudioSource>(); | |
| } | |
| #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 || | |
| newStatus == TrackableBehaviour.Status.EXTENDED_TRACKED) | |
| { | |
| Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " found"); | |
| OnTrackingFound(); | |
| } | |
| else if (previousStatus == TrackableBehaviour.Status.TRACKED && | |
| newStatus == TrackableBehaviour.Status.NOT_FOUND) | |
| { | |
| Debug.Log("Trackable " + mTrackableBehaviour.TrackableName + " lost"); | |
| OnTrackingLost(); | |
| } | |
| else | |
| { | |
| // For combo of previousStatus=UNKNOWN + newStatus=UNKNOWN|NOT_FOUND | |
| // Vuforia is starting, but tracking has not been lost or found yet | |
| // Call OnTrackingLost() to hide the augmentations | |
| OnTrackingLost(); | |
| } | |
| } | |
| #endregion // PUBLIC_METHODS | |
| #region PRIVATE_METHODS | |
| protected virtual void OnTrackingFound() | |
| { | |
| var rendererComponents = GetComponentsInChildren<Renderer>(true); | |
| var colliderComponents = GetComponentsInChildren<Collider>(true); | |
| var canvasComponents = GetComponentsInChildren<Canvas>(true); | |
| // Enable rendering: | |
| foreach (var component in rendererComponents) | |
| component.enabled = true; | |
| // Enable colliders: | |
| foreach (var component in colliderComponents) | |
| component.enabled = true; | |
| // Enable canvas': | |
| foreach (var component in canvasComponents) | |
| component.enabled = true; | |
| //Play Sound, IF detect an target | |
| if (mTrackableBehaviour.TrackableName == "moon") | |
| { | |
| playSound("sounds/moon-sound"); | |
| } | |
| if (mTrackableBehaviour.TrackableName == "mars") | |
| { | |
| playSound("sounds/mars-sound"); | |
| } | |
| } | |
| protected virtual void OnTrackingLost() | |
| { | |
| var rendererComponents = GetComponentsInChildren<Renderer>(true); | |
| var colliderComponents = GetComponentsInChildren<Collider>(true); | |
| var canvasComponents = GetComponentsInChildren<Canvas>(true); | |
| // Disable rendering: | |
| foreach (var component in rendererComponents) | |
| component.enabled = false; | |
| // Disable colliders: | |
| foreach (var component in colliderComponents) | |
| component.enabled = false; | |
| // Disable canvas': | |
| foreach (var component in canvasComponents) | |
| component.enabled = false; | |
| //Stop All Sounds if Target Lost | |
| StopAllAudio(); | |
| } | |
| #endregion // PRIVATE_METHODS | |
| } |
Please install the app to take a tour between moons.
SpaceApps is a NASA incubator innovation program.