Exemplo n.º 1
0
    public bool loadFile(string filePath, bool editor, UnityEngine.Object prefab)
    {
        if (editor)
        {
            loadedObject.Clear();
        }

        m_PartsCount = 0;
        m_PolyCount  = 0;

        progressStatus = "Initializing PiXYZ";
        progress       = 0.0f;

        try
        {
            errorMsg = "";
            PiXYZ4UnityWrapper.setResourcesFolder(Application.dataPath + "\\PiXYZ\\Resources\\");
            PiXYZ4UnityWrapper.initialize();

            progressStatus = "Importing file in PiXYZ";
            progress      += 0.05f;
            int assembly = -1;
            m_PartsToLoadCount = PiXYZ4UnityWrapper.importFile(filePath, out assembly);

            progress = 0.5f;

            materials = new Dictionary <int, Material>();

            PiXYZ4UnityWrapper.ScenePath root = null;
            if (assembly > 0)
            {
                int[] path = new int[2];
                path[0] = PiXYZ4UnityWrapper.getSceneRoot();
                path[1] = assembly;
                root    = new PiXYZ4UnityWrapper.ScenePath(path);
            }
            else
            {
                root = new PiXYZ4UnityWrapper.ScenePath(PiXYZ4UnityWrapper.getSceneRoot());
            }
            progressStatus = "Importing into Unity";

            //PiXYZ4UnityWrapper.removeSymmetryMatrices(root.node());  //used to fix odd negative scale
            Dictionary <int, List <Renderer> > renderers      = new Dictionary <int, List <Renderer> >();
            Dictionary <int, double>           lodToThreshold = new Dictionary <int, double>();
            loadSubTree(null, root, 0, editor, prefab, false, -1, ref renderers, ref lodToThreshold);

            progress       = 1.0f;
            progressStatus = "Finalizing";
        }
        catch (Exception e)
        {
            PiXYZ4UnityWrapper.clear();
            Debug.LogException(e);
            return(false);
        }

        PiXYZ4UnityWrapper.clear();
        return(true);
    }
Exemplo n.º 2
0
    public IEnumerator loadFileRuntime(GameObject rootObject, string filePath, bool editor, UnityEngine.Object prefab)
    {
        if (editor)
        {
            loadedObject.Clear();
        }

        int assembly = -1;

        PiXYZ4UnityWrapper.setResourcesFolder(Application.dataPath + "/PiXYZ/Resources/");
        Thread _thread = new Thread(() => importThread(filePath, out assembly));

        m_PartsCount = 0;
        m_PolyCount  = 0;

        _thread.Start();

        while (_thread.IsAlive)
        {
            progress       = progress >= 0.05f ? 0.05f + (float)(PiXYZ4UnityWrapper.getProgress() * 0.45f) : progress;
            progressStatus = PiXYZ4UnityWrapper.getProgressStatus();
            yield return(null);
        }

        if (getErrorMessage() != "")
        {
            yield break;
        }

        materials = new Dictionary <int, Material>();

        PiXYZ4UnityWrapper.ScenePath root = null;
        if (assembly > 0)
        {
            int[] path = new int[2];
            path[0] = PiXYZ4UnityWrapper.getSceneRoot();
            path[1] = assembly;
            root    = new PiXYZ4UnityWrapper.ScenePath(path);
        }
        else
        {
            root = new PiXYZ4UnityWrapper.ScenePath(PiXYZ4UnityWrapper.getSceneRoot());
        }

        //PiXYZ4UnityWrapper.removeSymmetryMatrices(root.node());  //used to fix odd negative scale
        Dictionary <int, List <Renderer> > renderers      = new Dictionary <int, List <Renderer> >();
        Dictionary <int, double>           lodToThreshold = new Dictionary <int, double>();

        loadSubTree(null, root, 0, editor, prefab, false, -1, ref renderers, ref lodToThreshold);

        foreach (KeyValuePair <int, Material> kvpair in PiXYZ4UnityWrapper.getCreatedMaterials())
        {
            if (!materials.ContainsKey(kvpair.Key))
            {
                materials.Add(kvpair.Key, kvpair.Value);
            }
        }
        PiXYZ4UnityWrapper.clear();
    }
 void OnDestroy()
 {
     try
     {
         PiXYZ4UnityWrapper.clear();
     }
     catch (Exception) { }
 }
Exemplo n.º 4
0
    public bool CheckLicense()
    {
        try
        {
            PiXYZ4UnityWrapper.initialize();
        }
        catch (Exception)
        {
            Debug.Log("License not found");
            return(false);
        }

        PiXYZ4UnityWrapper.clear();
        return(true);
    }