//This method is importing the poly assest
    void generatingAsset(PolyAsset asset, PolyStatusOr <PolyImportResult> result)
    {
        if (!result.Ok)
        {
            Debug.LogError("Failed to import asset. :( Reason: " + result.Status);
            return;
        }
        assetAppeared = true;
        assetGenerate = true;
        assetName     = "Creating: " + asset.displayName;
        result.Value.gameObject.gameObject.transform.position = Camera.main.transform.position + Camera.main.transform.forward;
        result.Value.gameObject.gameObject.transform.rotation = Camera.main.transform.rotation;
        result.Value.gameObject.AddComponent <BoxCollider>();
        result.Value.gameObject.AddComponent <Rigidbody>();
        boxCol      = result.Value.gameObject.GetComponent <BoxCollider>();
        boxCol.size = new Vector3(0.5f, 0.5f, 0.5f);
        var rb = result.Value.gameObject.GetComponent <Rigidbody>();

        rb.useGravity = false;
        result.Value.gameObject.AddComponent <MiraPhysicsGrabExample>();
        result.Value.gameObject.AddComponent <MiraPhysicsRaycast>();
        var MiraGrab = result.Value.gameObject.GetComponent <MiraPhysicsRaycast>();

        MiraGrab.raycastStyle = MiraBaseRaycaster.RaycastStyle.World;
    }
Esempio n. 2
0
        /// <summary>
        /// Callback invoked when we get request results.
        /// </summary>
        private void OnRequestResult(PolyStatusOr <PolyListAssetsResult> result)
        {
            if (result.Ok)
            {
                PtDebug.LogFormat("ABM: request results received ({0} assets).", result.Value.assets.Count);
                this.listAssetsResult = result;
                resultHasMorePages    = result.Value.nextPageToken != null;
            }
            else
            {
                Debug.LogError("Asset request failed. Try again later: " + result.Status);
                this.listAssetsResult = result;
            }
            querying = false;
            if (null != refreshCallback)
            {
                refreshCallback();
            }

            if (result.Ok)
            {
                assetsInUse = GetAssetsInUse();
                FinishFetchingThumbnails(result);
            }
        }
Esempio n. 3
0
 private void ListAssetsCallback(PolyStatusOr <PolyListAssetsResult> result)
 {
     if (!result.Ok)
     {
         return;
     }
 }
Esempio n. 4
0
    private void ImportResults(PolyStatusOr <PolyListAssetsResult> result)
    {
        // Set options for import so the assets aren't crazy sizes
        PolyImportOptions options = PolyImportOptions.Default();

        options.rescalingMode = PolyImportOptions.RescalingMode.FIT;
        options.desiredSize   = 5.0f;
        options.recenter      = true;

        // List our assets
        List <PolyAsset> assetsInUse = new List <PolyAsset>();

        // Loop through the list and display the first 3
        for (int i = 0; i < Mathf.Min(5, result.Value.assets.Count); i++)
        {
            // Import our assets into the scene with the ImportAsset function
            PolyApi.Import(result.Value.assets[i], options, ImportAsset);
            PolyAsset asset = result.Value.assets[i];
            assetsInUse.Add(asset);

            //attributionsText.text = PolyApi.GenerateAttributions(includeStatic: false, runtimeAssets: assetsInUse);
        }

        string attribution = PolyApi.GenerateAttributions(includeStatic: false, runtimeAssets: assetsInUse);

        InterfaceManager.GetInstance().AddMessageToBox(attribution);
    }
Esempio n. 5
0
        // Callback invoked when the featured assets results are returned.
        private static void GetAssetCallback(PolyStatusOr <PolyToolkit.PolyAsset> result, Action <GameObject> onImport)
        {
            if (!result.Ok)
            {
                Debug.LogError("Failed to get assets. Reason: " + result.Status);
                //statusText.text = "ERROR: " + result.Status;
                return;
            }
            Debug.Log("Successfully got asset!");

            // Set the import options.
            PolyImportOptions options = PolyImportOptions.Default();

            // We want to rescale the imported mesh to a specific size.
            options.rescalingMode = PolyImportOptions.RescalingMode.CONVERT;
            // The specific size we want assets rescaled to (fit in a 5x5x5 box):
            options.desiredSize = 5.0f;
            // We want the imported assets to be recentered such that their centroid coincides with the origin:
            options.recenter = true;

            //statusText.text = "Importing...";
            PolyApi.Import(result.Value, options, (asset, importResult) =>
            {
                if (result.Ok)
                {
                    onImport(importResult.Value.gameObject);
                }
            });
        }
Esempio n. 6
0
        // Callback invoked when an asset has just been imported.
        private void ImportAssetCallback(PolyAsset asset, PolyStatusOr <PolyImportResult> result)
        {
            if (!result.Ok)
            {
                Debug.LogError("Failed to import asset. :( Reason: " + result.Status);
                _statusText.text = "ERROR: Import failed: " + result.Status;
                return;
            }
            Debug.Log("Successfully imported asset!");

            // need to make sure that the scene hasn't been destroyed by the time this callback comes in, so we just check
            // the validity of the status text object and if it's null, drop out
            if (_statusText == null)
            {
                Debug.Log("PolyImageManager>Dropping out because scene appears to have been unloaded!!");
                return;
            }

            _statusText.text = "";

            // Show attribution (asset title and author).
            _attributionsText.text = asset.displayName + "\nby " + asset.authorName;

            // Here, you would place your object where you want it in your scene, and add any
            // behaviors to it as needed by your app. As an example, let's just make it
            // slowly rotate:
            result.Value.gameObject.AddComponent <Rotate>();

            // make the new object a child of this gameobject
            result.Value.gameObject.transform.parent        = transform;
            result.Value.gameObject.transform.localScale    = new Vector3(0.05f, 0.05f, 0.05f);
            result.Value.gameObject.transform.localRotation = FPCAMERA.transform.localRotation;
            result.Value.gameObject.transform.Translate(result.Value.gameObject.transform.forward * 10000f);
        }
Esempio n. 7
0
 void InitialiseUIContent(PolyStatusOr <PolyListAssetsResult> result)
 {
     foreach (PolyAsset asset in result.Value.assets)
     {
         PolyApi.FetchThumbnail(asset, callback);
     }
 }
    // Callback invoked when the featured assets results are returned.
    private void GetAssetCallback(PolyStatusOr <PolyListAssetsResult> result)
    {
        if (!result.Ok)
        {
            Debug.LogError("Failed to get assets. Reason: " + result.Status);

            statusText.text = "ERROR: " + result.Status;

            return;
        }
        Debug.Log("Successfully got asset!");

        foreach (PolyAsset asset in result.Value.assets)
        {
            // Set the import options.
            PolyImportOptions options = PolyImportOptions.Default();
            // We want to rescale the imported mesh to a specific size.
            options.rescalingMode = PolyImportOptions.RescalingMode.FIT;
            // The specific size we want assets rescaled to (fit in a 5x5x5 box):
            options.desiredSize = 0.4f;
            // We want the imported assets to be recentered such that their centroid coincides with the origin:
            options.recenter = true;

            statusText.text = "Importing...";
            PolyApi.Import(asset, options, ImportAssetCallback);
        }
    }
Esempio n. 9
0
 void handleGetAssetCallback(PolyStatusOr <PolyAsset> result)
 {
     if (result.Ok)
     {
         Debug.Log("handleGetAssetCallBack handled");
     }
 }
Esempio n. 10
0
    private void ImportAssetCallback(PolyAsset asset, PolyStatusOr <PolyImportResult> result)
    {
        if (!result.Ok)
        {
            Debug.LogError("Failed to import asset. :( Reason: " + result.Status);
            currCount++;
            return;
        }
        Debug.Log("Successfully imported asset: " + asset.name);

        // Here, you would place your object where you want it in your scene, and add any
        // behaviors to it as needed by your app. As an example, let's just make it
        // slowly rotate:
        result.Value.gameObject.AddComponent <Rotate>();
        result.Value.gameObject.SetActive(false);
        result.Value.gameObject.transform.parent = this.transform;
        currentGameObjects.Add(result.Value.gameObject);

        if (currItemTotalCount == currCount + 1)
        {
            for (int i = 0; i < currentGameObjects.Count; i++)
            {
                currentGameObjects[i].transform.localPosition = GetPositionInCircle(i, currentGameObjects.Count, 0.1f);
                currentGameObjects[i].SetActive(true);
            }
            loadingSphere.SetActive(false);
        }
        else
        {
            currCount++;
        }
    }
Esempio n. 11
0
    void FeaturedAssetListCallback(PolyStatusOr <PolyListAssetsResult> result)
    {
        if (!result.Ok)
        {
            // Handle error.
            Debug.LogError("Failed to import featured list. :( Reason: " + result.Status);
            return;
        }
        // Success. result.Value is a PolyListAssetsResult and
        // result.Value.assets is a list of PolyAssets.
        foreach (PolyAsset asset in result.Value.assets)
        {
            if (asset_id_name_list.Count < resultCount)
            {
                // Do something with the asset here.
                //Debug.Log(asset);
                Debug.Log(asset.displayName);
                // add name and ID KeyValuePair to List
                asset_id_name_list.Add(new KeyValuePair <string, string>(asset.name, asset.displayName));
                // request thumbnail of each asset
                PolyApi.FetchThumbnail(asset, GetThumbnailCallback);
            }
        }

        asset_id_name_list.Sort((x, y) => string.Compare(x.Key, y.Key, StringComparison.Ordinal));
        //      uI.InstatiatePolyAssetMenu(asset_id_name_list);
        //uI.SetPolyMenuInfo(assetNames, assetID);
        //uI.enabled = true;
        if (onPolyAssetsLoaded != null)
        {
            onPolyAssetsLoaded.Invoke();
        }
    }
Esempio n. 12
0
    void handleListAssetsCallback(PolyStatusOr <PolyListAssetsResult> result)
    {
        if (!result.Ok)
        {
            Debug.Log("Error occured while getting asset list");
        }
        Debug.Log("Displaying thumbnails of assets retrieved");

        for (int i = 0; i < 1; i++)
        {
            PolyAsset res = result.Value.assets[0];
            PolyApi.FetchThumbnail(res, CallFetchThumbnailEvent);
        }

        //foreach (PolyAsset asset in result.Value.assets) {
        //	Debug.Log (asset.thumbnail); //png
        //          Debug.Log(asset.thumbnailTexture);
        //          // t = asset.thumbnailTexture;
        //          // thumbnail.GetComponent<RawImage>().texture = t;
        //          Debug.Log(asset.description);
        //          Debug.Log(asset.authorName);
        //          Debug.Log(asset.displayName);
        //          Debug.Log(asset.formats);
        //          Debug.Log(asset.name); // asset ID
        //          Debug.Log(asset.license);
        //          Debug.Log(asset.visibility);

        //          PolyApi.FetchThumbnail(asset, CallFetchThumbnailEvent);
        //      }
    }
Esempio n. 13
0
    void HandleRequest(PolyStatusOr <PolyListAssetsResult> result)
    {
        if (!result.Ok)
        {
            // Handle error.
            Debug.LogError("Failed to get assets. Reason: " + result.Status);
            currCount++;
            return;
        }
        // Success. result.Value is a PolyListAssetsResult and
        // result.Value.assets is a list of PolyAssets.
        if (result.Value.assets.Count == 0)
        {
            Debug.Log("No asset found");
            currCount++;
            return;
        }

        foreach (PolyAsset asset in result.Value.assets)
        {
            // Set the import options.
            PolyImportOptions options = PolyImportOptions.Default();
            // We want to rescale the imported mesh to a specific size.
            options.rescalingMode = PolyImportOptions.RescalingMode.FIT;
            // The specific size we want assets rescaled to:
            options.desiredSize = 0.05f;
            // We want the imported assets to be recentered such that their centroid coincides with the origin:
            options.recenter = true;

            PolyApi.Import(asset, options, ImportAssetCallback);
        }
    }
    void FeaturedAssetListCallback(PolyStatusOr <PolyListAssetsResult> result)
    {
        if (!result.Ok)
        {
            // Handle error.
            Debug.LogError("Failed to import featured list. :( Reason: " + result.Status);
            return;
        }
        // Success. result.Value is a PolyListAssetsResult and
        // result.Value.assets is a list of PolyAssets.
        // asset_id_name_list
        asset_id_name_list.AddRange(
            result.Value.assets.Take(resultCount).Select((asset) =>
        {
            Debug.Log(asset.displayName);
            PolyApi.FetchThumbnail(asset, GetThumbnailCallback);
            return(new KeyValuePair <string, string>(asset.name, asset.displayName));
        }).AsParallel()
            );

        asset_id_name_list.Sort((x, y) => string.Compare(x.Key, y.Key, StringComparison.Ordinal));

        if (onPolyAssetsLoaded != null)
        {
            onPolyAssetsLoaded.Invoke();
        }
    }
    void OnAssetListReturned(PolyStatusOr <PolyListAssetsResult> result)
    {
        if (!result.Ok)
        {
            // Handle error.
            return;
        }

        PolyAsset bestResult = null;

        // Success. result.Value is a PolyListAssetsResult and
        // result.Value.assets is a list of PolyAssets.
        foreach (PolyAsset asset in result.Value.assets)
        {
            if (bestResult == null)
            {
                bestResult = asset;
            }
            // Do something with the asset here.
            if (!findBestMatchRequested || asset.displayName == lastRequestedAsset)
            {
                bestResult = asset;
            }
        }

        Debug.Log("Loading asset " + bestResult.displayName + " ...");
        PolyApi.GetAsset(bestResult.name, GetAssetCallback);
    }
Esempio n. 16
0
    // Callback invoked when an asset has just been imported.
    private void ImportAssetCallback(PolyAsset asset, PolyStatusOr <PolyImportResult> result)
    {
        if (!result.Ok)
        {
            Debug.LogError("Failed to import asset. :( Reason: " + result.Status);
            statusText.text = "ERROR: Import failed: " + result.Status;
            return;
        }
        Debug.Log("Successfully imported asset!");

        // Show attribution (asset title and author).
        statusText.text = asset.displayName + "\nby " + asset.authorName;
        // Here, you would place your object where you want it in your scene, and add any
        // behaviors to it as needed by your app. As an example, let's just make it
        // slowly rotate:
        // result.Value.gameObject.AddComponent<Rotate>();
        var object1 = result.Value.gameObject.transform.GetChild(0).gameObject.AddComponent <BoxCollider>();

        if (curr != null)
        {
            Destroy(curr);
        }
        var pz = Instantiate(PrefabZone, result.Value.gameObject.transform);

        curr = pz;
        object1.transform.parent = pz.transform;
        BoxCollider colli = pz.GetComponent <BoxCollider>();

        newbound     = object1.GetComponent <BoxCollider>().bounds;
        colli.size   = new Vector3((newbound.size.x / object1.transform.localScale.x) + 0.1f, (newbound.size.y / object1.transform.localScale.y) + 0.1f, (newbound.size.z / object1.transform.localScale.z) + 0.1f);
        colli.center = pz.transform.localPosition;

        /// var transl=result.Value.gameObject.AddComponent<Lean.Touch.LeanDragTranslate>();
        // var selec = result.Value.gameObject.AddComponent<Lean.Touch.LeanSelectable>();
    }
Esempio n. 17
0
            // Callback invoked when the featured assets results are returned.
            void ListAssetsCallback(PolyStatusOr <PolyListAssetsResult> result)
            {
                if (!result.Ok)
                {
                    Debug.LogError("Failed to get featured assets. :( Reason: " + result.Status);
                    return;
                }

                if (m_ListCallback != null)
                {
                    m_ListCallback(result.Value.nextPageToken);
                }

                foreach (var asset in result.Value.assets)
                {
                    PolyGridAsset polyGridAsset;
                    var           name = asset.name;
                    if (!k_AssetCache.TryGetValue(name, out polyGridAsset))
                    {
                        polyGridAsset = new PolyGridAsset(asset, m_Container);
                        m_PolyModule.InjectFunctionalitySingle(polyGridAsset);
                        k_AssetCache[name] = polyGridAsset;
                    }

                    m_Assets.Add(polyGridAsset);
                }
            }
    // Callback invoked when the featured assets results are returned.
    private void ListAssetsCallback(PolyStatusOr <PolyListAssetsResult> result)
    {
        if (!result.Ok)
        {
            Debug.LogError("Failed to get featured assets. :( Reason: " + result.Status);
            statusText.text = "ERROR: " + result.Status;
            return;
        }
        Debug.Log("Successfully got featured assets!");
        statusText.text = "Importing...";

        // Set the import options.
        PolyImportOptions options = PolyImportOptions.Default();

        // We want to rescale the imported meshes to a specific size.
        options.rescalingMode = PolyImportOptions.RescalingMode.FIT;
        // The specific size we want assets rescaled to (fit in a 1x1x1 box):
        options.desiredSize = 1.0f;
        // We want the imported assets to be recentered such that their centroid coincides with the origin:
        options.recenter = true;

        // Now let's get the first 5 featured assets and put them on the scene.
        List <PolyAsset> assetsInUse = new List <PolyAsset>();

        for (int i = 0; i < Mathf.Min(5, result.Value.assets.Count); i++)
        {
            // Import this asset.
            PolyApi.Import(result.Value.assets[i], options, ImportAssetCallback);
            assetsInUse.Add(result.Value.assets[i]);
        }

        // Show attributions for the assets we display.
        attributionsText.text = PolyApi.GenerateAttributions(includeStatic: true, runtimeAssets: assetsInUse);
    }
Esempio n. 19
0
 private void CallImportCallbackEvent(PolyStatusOr <PolyImportResult> result)
 {
     if (result.Ok)
     {
         //event
         importCallback(result);
     }
 }
Esempio n. 20
0
 void handleImportCallback(PolyStatusOr <PolyImportResult> result)
 {
     if (result.Ok)
     {
         Debug.Log("Importing the asset as Unity GameObject.");
         Debug.Log(result.Value.gameObject);
     }
 }
Esempio n. 21
0
    private void CallListAssetsCallbackEvent(PolyStatusOr<PolyListAssetsResult> result)
    {
        foreach (PolyAsset asset in result.Value.assets)
        {
            PolyApi.FetchThumbnail(asset, callback);

        }
    }
Esempio n. 22
0
 private void CallAssetCallbackEvent(PolyStatusOr <PolyAsset> result)
 {
     if (result.Ok)
     {
         //event
         getAssetCallbackEvent(result);
     }
 }
Esempio n. 23
0
    private void ImportAsset(PolyAsset asset, PolyStatusOr <PolyImportResult> result)
    {
        // Line the assets up so they don't overlap
        GameObject go = result.Value.gameObject;

        go.transform.position = new Vector3(Random.Range(-10.0f, 10.0f), 2f, Random.Range(-10.0f, 10.0f));
        go.AddComponent <MouseDrag>();
        assetCount++;
    }
Esempio n. 24
0
 void PolyAssetCallback(PolyStatusOr <PolyAsset> result, OnActorableSearchResult resultCallback)
 {
     if (!result.Ok)
     {
         Debug.LogError("There is a problem with poly poly stuff" + result.Status.errorMessage);
         return;
     }
     PolyApi.FetchThumbnail(result.Value, (newasset, status) => PolyThumbnailCallback(newasset, status, resultCallback));
 }
Esempio n. 25
0
 void ImportCallback(PolyAsset asset, PolyStatusOr <PolyImportResult> result)
 {
     if (!result.Ok)
     {
         return;
     }
     result.Value.gameObject.transform.position = new Vector3(1, 0, 0);
     thumbTex         = asset.thumbnailTexture;
     thumbnail.sprite = Sprite.Create(thumbTex, new Rect(0.0f, 0.0f, thumbTex.width, thumbTex.height), new Vector2(0.5f, 0.5f), 100.0f);
 }
Esempio n. 26
0
    private void ParseToGameObject(PolyAsset asset, PolyStatusOr <PolyImportResult> result)
    {
        // Line the assets up so they don't overlap
        ui.AddMessageToBox("- Selection assets fetched");
        GameObject newSelectedObject = result.Value.gameObject;

        newSelectedObject.name = asset.displayName;
        scene.SetObjectToBePlaced(newSelectedObject);
        scene.SetTool("place");
    }
Esempio n. 27
0
 /// <summary>
 /// Clears the current request. Also cancels any pending request.
 /// </summary>
 public void ClearRequest()
 {
     PtDebug.Log("ABM: clearing request...");
     querying = false;
     // Increasing the ID will cause us to ignore the results of any pending requests
     // (we will know they are obsolete by their query ID).
     queryId++;
     listAssetsResult   = null;
     resultHasMorePages = false;
 }
Esempio n. 28
0
    // Callback invoked when an asset has just been imported.
    private void ImportAssetCallback(PolyAsset asset, PolyStatusOr <PolyImportResult> result)
    {
        if (!result.Ok)
        {
            Debug.LogError("Failed to import asset. :( Reason: " + result.Status);
            //statusText.text = "ERROR: Import failed: " + result.Status;
            loadingCircle.SetActive(false);
            return;
        }
        Debug.Log("Successfully imported asset!");
        loadingCircle.SetActive(false);

        // Show attribution (asset title and author).
        //statusText.text = asset.displayName + "\nby " + asset.authorName;

        // Here, you would place your object where you want it in your scene, and add any
        // behaviors to it as needed by your app. As an example, let's just make it
        // slowly rotate:
        float h = result.Value.gameObject.transform.GetChild(0).GetComponent <MeshRenderer>().bounds.extents.y;

        for (int i = 0; i < result.Value.gameObject.transform.childCount; i++)
        {
            if (result.Value.gameObject.transform.GetChild(i).GetComponent <MeshRenderer>() != null)
            {
                if (result.Value.gameObject.transform.GetChild(i).GetComponent <MeshRenderer>().bounds.extents.y > h)
                {
                    h = result.Value.gameObject.transform.GetChild(i).GetComponent <MeshRenderer>().bounds.extents.y;
                }
            }
        }

        float fov   = Camera.main.fieldOfView;
        float angle = Mathf.Deg2Rad * (fov / 2);
        float dist  = h / Mathf.Atan(angle);

        Debug.Log("Distance " + dist);

        Vector3 objPosition = m_cameraTransform.position + (m_cameraTransform.forward.normalized * dist * distMultiplier);         //place sphere 10cm in front of device

        result.Value.gameObject.transform.position = objPosition;

        importedObject      = result.Value.gameObject;
        importedObject.name = asset.displayName;

        importedObject.transform.LookAt(Camera.main.transform);
        importedObject.transform.eulerAngles = new Vector3(0, importedObject.transform.eulerAngles.y + 180f, 0);

        featured_artist_name = asset.authorName;
        artist_names.Add(featured_artist_name);

        if (onAssetImported != null)
        {
            onAssetImported.Invoke();
        }
    }
Esempio n. 29
0
 // Callback invoked when an asset has just been imported.
 private void ImportAssetCallback(PolyAsset asset, PolyStatusOr <PolyImportResult> result)
 {
     if (!result.Ok)
     {
         Debug.LogError("Failed to import asset. :( Reason: " + result.Status);
         return;
     }
     Debug.Log("Successfully imported asset!");
     result.Value.gameObject.gameObject.transform.position = Camera.main.transform.position + Camera.main.transform.forward * 1;
     result.Value.gameObject.AddComponent <Rotate>();
 }
Esempio n. 30
0
    private void CallListAssetsCallbackEvent(PolyStatusOr <PolyListAssetsResult> result)
    {
        foreach (PolyAsset asset in result.Value.assets)
        {
            PolyApi.FetchThumbnail(asset, callback);
        }

        currentpanel.SetActive(false);
        panel.SetActive(true);
        // SceneManager.LoadScene("2");
    }