/// <summary>
        /// Moves the specified anchored object.
        /// </summary>
        /// <param name="objectToMove">The anchored object to move.</param>
        /// <param name="worldPos">The world position.</param>
        /// <param name="worldRot">The world rotation.</param>
        /// <param name="cloudSpatialAnchor">The cloud spatial anchor.</param>
        protected virtual void MoveAnchoredObject(GameObject objectToMove, Vector3 worldPos, Quaternion worldRot, CloudSpatialAnchor cloudSpatialAnchor = null)
        {
            // Get the cloud-native anchor behavior
            CloudNativeAnchor cna = objectToMove.GetComponent <CloudNativeAnchor>();

            // Warn and exit if the behavior is missing
            if (cna == null)
            {
                Debug.LogWarning($"The object {objectToMove.name} is missing the {nameof(CloudNativeAnchor)} behavior.");
                return;
            }

            // Is there a cloud anchor to apply
            if (cloudSpatialAnchor != null)
            {
                // Yes. Apply the cloud anchor, which also sets the pose.
                Debug.Log("!!!!!! MoveAnchoredObject (1)");
                cna.CloudToNative(cloudSpatialAnchor);
            }
            else
            {
                // No. Just set the pose.
                Debug.Log("!!!!!! MoveAnchoredObject (2)");
                cna.SetPose(worldPos, worldRot);
            }
        }
Exemple #2
0
        private void Construct(CloudSpatialAnchor cloudSpatialAnchor)
        {
            _cloudNativeAnchor = gameObject.AddComponent <CloudNativeAnchor>();

            // restore existing anchor if cloudSpatialAnchor is not null
            // otherwise it is new one
            if (cloudSpatialAnchor == null)
            {
                return;
            }

            _cloudNativeAnchor.CloudToNative(cloudSpatialAnchor);
        }
Exemple #3
0
    private GameObject SpawnNewAnchoredObject(Vector3 position, Quaternion rotation)
    {
        GameObject newGameObject = GameObject.Instantiate(generalConfiguration.spatialAnchorGroupPrefab, position, rotation);

        newGameObject.AddComponent <CloudNativeAnchor>();

        if (currentCloudSpatialAnchor != null)
        {
            CloudNativeAnchor cloudNativeAnchor = newGameObject.GetComponent <CloudNativeAnchor>();
            cloudNativeAnchor.CloudToNative(currentCloudSpatialAnchor);
        }

        return(newGameObject);
    }
        /// <summary>
        /// Spawns a new object.
        /// </summary>
        /// <param name="worldPos">The world position.</param>
        /// <param name="worldRot">The world rotation.</param>
        /// <param name="cloudSpatialAnchor">The cloud spatial anchor.</param>
        /// <returns><see cref="GameObject"/>.</returns>
        protected virtual GameObject SpawnNewAnchoredObject(Vector3 worldPos, Quaternion worldRot, CloudSpatialAnchor cloudSpatialAnchor)
        {
            // Create the object like usual
            GameObject newGameObject = SpawnNewAnchoredObject(worldPos, worldRot);

            // If a cloud anchor is passed, apply it to the native anchor
            if (cloudSpatialAnchor != null)
            {
                CloudNativeAnchor cloudNativeAnchor = newGameObject.GetComponent <CloudNativeAnchor>();
                cloudNativeAnchor.CloudToNative(cloudSpatialAnchor);
            }

            // Return newly created object
            return(newGameObject);
        }
        /// <summary>
        /// Spawns a new object.
        /// </summary>
        /// <param name="worldPos">The world position.</param>
        /// <param name="worldRot">The world rotation.</param>
        /// <param name="cloudSpatialAnchor">The cloud spatial anchor.</param>
        /// <returns><see cref="GameObject"/>.</returns>
        protected virtual GameObject SpawnNewAnchoredObject(Vector3 worldPos, Quaternion worldRot, CloudSpatialAnchor cloudSpatialAnchor)
        {
            //Debug.Log("#### Base SpawnNewAnchoredObject Start cloudSpatialAnchor=" + cloudSpatialAnchor);
            // Create the object like usual
            GameObject newGameObject = SpawnNewAnchoredObject(worldPos, worldRot);

            // If a cloud anchor is passed, apply it to the native anchor
            if (cloudSpatialAnchor != null)
            {
                CloudNativeAnchor cloudNativeAnchor = newGameObject.GetComponent <CloudNativeAnchor>();
                cloudNativeAnchor.CloudToNative(cloudSpatialAnchor);
                //Debug.Log("#### koko??? Base SpawnNewAnchoredObject OK ###");
            }

            // Set color
//            newGameObject.GetComponent<MeshRenderer>().material.color = GetStepColor();

            // Return newly created object
            return(newGameObject);
        }