public void Reset() { ResetSettings(); AssignMeshesFromPairs(); GameObject obj = GameObject.Find("onion"); if (obj) { targetObject.SetActive(false); } else { obj = GameObject.Find("Meat"); if (obj) { targetObject.SetActive(false); } } targetObject = barabarianRef; preserveFace.interactable = true; preservationStrength.interactable = preserveFace.isOn; targetObject.SetActive(true); objectMeshPairs = PolyfewRuntime.GetObjectMeshPairs(targetObject, true); trianglesCount.text = PolyfewRuntime.CountTriangles(true, targetObject) + ""; exportButton.interactable = false; importFromWeb.interactable = true; importFromFileSystem.interactable = true; }
public void ImportOBJFromNetwork() { // This function downloads and imports an obj file named onion.obj from the url below // This also loads the associated textures and materials given by the absolute URLs GameObject importedObject; isImportingFromNetwork = true; OBJImportOptions importOptions = new OBJImportOptions(); importOptions.zUp = false; importOptions.localPosition = new Vector3(0.87815f, 1.4417f, -4.4708f); importOptions.localScale = new Vector3(0.0042f, 0.0042f, 0.0042f); string objURL = "https://dl.dropbox.com/s/v09bh0hiivja10e/onion.obj?dl=1"; string objName = "onion"; string diffuseTexURL = "https://dl.dropbox.com/s/0u4ij6sddi7a3gc/onion.jpg?dl=1"; string bumpTexURL = ""; string specularTexURL = ""; string opacityTexURL = ""; string materialURL = "https://dl.dropbox.com/s/fuzryqigs4gxwvv/onion.mtl?dl=1"; progressSlider.value = 0; uninteractivePanel.SetActive(true); downloadProgress = new ReferencedNumeric <float>(0); StartCoroutine(UpdateProgress()); PolyfewRuntime.ImportOBJFromNetwork(objURL, objName, diffuseTexURL, bumpTexURL, specularTexURL, opacityTexURL, materialURL, downloadProgress, (GameObject imp) => { AssignMeshesFromPairs(); isImportingFromNetwork = false; importedObject = imp; barabarianRef.SetActive(false); targetObject = importedObject; ResetSettings(); objectMeshPairs = PolyfewRuntime.GetObjectMeshPairs(targetObject, true); trianglesCount.text = PolyfewRuntime.CountTriangles(true, targetObject) + ""; exportButton.interactable = true; uninteractivePanel.SetActive(false); importFromWeb.interactable = false; importFromFileSystem.interactable = false; preserveFace.interactable = false; preservationStrength.interactable = false; disableTemporary = true; preservationSphere.gameObject.SetActive(false); disableTemporary = false; }, (Exception ex) => { uninteractivePanel.SetActive(false); isImportingFromNetwork = false; Debug.LogError("Failed to download and import OBJ file. " + ex.Message); }, importOptions); }
// Start is called before the first frame update void Start() { if (Application.platform == RuntimePlatform.WebGLPlayer) { isWebGL = true; } uninteractivePanel.SetActive(false); exportButton.interactable = false; barabarianRef = targetObject; objectMeshPairs = PolyfewRuntime.GetObjectMeshPairs(targetObject, true); trianglesCount.text = PolyfewRuntime.CountTriangles(true, targetObject) + ""; }
public void Destruct() { if (objectMeshPairs == null || objectMeshPairs.Count == 0) { return; } foreach (var item in objectMeshPairs) { item.Value.Destruct(); } objectMeshPairs = null; }
public void ImportOBJ() { // This function loads an abj file named Meat.obj from the project's asset directory // This also loads the associated textures and materials GameObject importedObject; OBJImportOptions importOptions = new OBJImportOptions(); importOptions.zUp = false; importOptions.localPosition = new Vector3(-2.199f, -1, -1.7349f); importOptions.localScale = new Vector3(0.045f, 0.045f, 0.045f); string objPath = Application.dataPath + "/PolyFew/demo/TestModels/Meat.obj"; string texturesFolderPath = Application.dataPath + "/PolyFew/demo/TestModels/textures"; string materialsFolderPath = Application.dataPath + "/PolyFew/demo/TestModels/materials"; PolyfewRuntime.ImportOBJFromFileSystem(objPath, texturesFolderPath, materialsFolderPath, (GameObject imp) => { importedObject = imp; Debug.Log("Successfully imported GameObject: " + importedObject.name); barabarianRef.SetActive(false); targetObject = importedObject; ResetSettings(); objectMeshPairs = PolyfewRuntime.GetObjectMeshPairs(targetObject, true); trianglesCount.text = PolyfewRuntime.CountTriangles(true, targetObject) + ""; exportButton.interactable = true; importFromWeb.interactable = false; importFromFileSystem.interactable = false; preserveFace.interactable = false; preservationStrength.interactable = false; disableTemporary = true; preservationSphere.gameObject.SetActive(false); disableTemporary = false; }, (Exception ex) => { Debug.LogError("Failed to load OBJ file. " + ex.ToString()); }, importOptions); }
public ObjectHistory(bool isReduceDeep, ObjectMeshPairs objectMeshPairs) { this.isReduceDeep = isReduceDeep; this.objectMeshPairs = objectMeshPairs; }