public void PostProcessHierarchy(PrimMap primMap, SceneImportOptions sceneImportOptions) { InitRegex(); foreach (KeyValuePair <SdfPath, GameObject> kvp in primMap) { if (!IsMatch(kvp.Key)) { continue; } GameObject go = kvp.Value; switch (operation) { case Operation.LogicalAND: go.hideFlags &= hideFlagsSettings; continue; case Operation.LogicalOR: go.hideFlags |= hideFlagsSettings; continue; case Operation.LogicalXOR: go.hideFlags ^= hideFlagsSettings; continue; default: go.hideFlags = hideFlagsSettings; continue; } } }
public void PostProcessComponents(PrimMap primMap, SceneImportOptions sceneImportOptions) { InitRegex(); foreach (KeyValuePair <SdfPath, GameObject> kvp in primMap) { if (!IsMatch(kvp.Key)) { continue; } DoCombineMeshes(kvp.Value.transform); } }
public void PostProcessHierarchy(PrimMap primMap, SceneImportOptions sceneImportOptions) { InitRegex(); foreach (KeyValuePair <SdfPath, GameObject> kvp in primMap) { if (!IsMatch(kvp.Key)) { continue; } GameObject go = kvp.Value; go.hideFlags = hideFlagsSettings; } }
void Update() { m_usdFile = m_usdFile.Replace("\"", ""); if (!System.IO.Path.IsPathRooted(m_usdFile)) { m_usdFile = Application.dataPath + "/" + m_usdFile; } if (string.IsNullOrEmpty(m_usdFile)) { if (m_scene == null) { return; } m_scene.Close(); m_scene = null; UnloadGameObjects(); return; } // Is the stage already loaded? if (m_scene != null && m_scene.FilePath == m_usdFile && m_lastTime == m_usdTime) { return; } try { // Does the path exist? if (!System.IO.File.Exists(m_usdFile)) { throw new System.IO.FileNotFoundException(m_usdFile); } m_lastTime = m_usdTime; // Clear out the old scene. UnloadGameObjects(); // Import the new scene. m_scene = Scene.Open(m_usdFile); if (m_scene == null) { throw new Exception("Failed to import"); } // Set the time at which to read samples from USD. m_scene.Time = m_usdTime; // When converting right handed (USD) to left handed (Unity), there are two options: // // 1) Add an inversion at the root of the scene, leaving the points right-handed. // 2) Convert all transforms and points to left-handed (deep change of basis). // // Option (2) is more computationally expensive, but results in fewer down stream // surprises. var importOptions = new SceneImportOptions(); importOptions.changeHandedness = m_changeHandedness; importOptions.materialMap.DisplayColorMaterial = m_material; importOptions.enableGpuInstancing = m_enableGpuInstancing; // The root object at which the USD scene will be reconstructed. // It may need a Z-up to Y-up conversion and a right- to left-handed change of basis. var rootXf = new GameObject("root"); rootXf.transform.SetParent(this.transform, worldPositionStays: false); m_primMap = SceneImporter.BuildScene(m_scene, rootXf, importOptions, new PrimMap(), composingSubtree: false); // Ensure the file and the identifier match. m_usdFile = m_scene.FilePath; } catch { enabled = false; throw; } }