public bool GetSourceAsset(SdfAssetPath sourceAsset, TfToken sourceType) { bool ret = UsdCsPINVOKE.UsdShadeShader_GetSourceAsset__SWIG_0(swigCPtr, SdfAssetPath.getCPtr(sourceAsset), TfToken.getCPtr(sourceType)); if (UsdCsPINVOKE.SWIGPendingException.Pending) { throw UsdCsPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public static bool Equals(SdfAssetPath lhs, SdfAssetPath rhs) { bool ret = UsdCsPINVOKE.SdfAssetPath_Equals(SdfAssetPath.getCPtr(lhs), SdfAssetPath.getCPtr(rhs)); if (UsdCsPINVOKE.SWIGPendingException.Pending) { throw UsdCsPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public bool SetSourceAsset(SdfAssetPath sourceAsset) { bool ret = UsdCsPINVOKE.UsdShadeShader_SetSourceAsset__SWIG_1(swigCPtr, SdfAssetPath.getCPtr(sourceAsset)); if (UsdCsPINVOKE.SWIGPendingException.Pending) { throw UsdCsPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public bool SetClipManifestAssetPath(SdfAssetPath manifestAssetPath) { bool ret = UsdCsPINVOKE.UsdClipsAPI_SetClipManifestAssetPath__SWIG_1(swigCPtr, SdfAssetPath.getCPtr(manifestAssetPath)); if (UsdCsPINVOKE.SWIGPendingException.Pending) { throw UsdCsPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public SdrShaderNode GetShaderNodeFromAsset(SdfAssetPath shaderAsset) { global::System.IntPtr cPtr = UsdCsPINVOKE.SdrRegistry_GetShaderNodeFromAsset__SWIG_3(swigCPtr, SdfAssetPath.getCPtr(shaderAsset)); SdrShaderNode ret = (cPtr == global::System.IntPtr.Zero) ? null : new SdrShaderNode(cPtr, false); if (UsdCsPINVOKE.SWIGPendingException.Pending) { throw UsdCsPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public SdrShaderNode GetShaderNodeFromAsset(SdfAssetPath shaderAsset, SWIGTYPE_p_std__unordered_mapT_TfToken_std__string_TfToken__HashFunctor_t metadata, TfToken subIdentifier) { global::System.IntPtr cPtr = UsdCsPINVOKE.SdrRegistry_GetShaderNodeFromAsset__SWIG_1(swigCPtr, SdfAssetPath.getCPtr(shaderAsset), SWIGTYPE_p_std__unordered_mapT_TfToken_std__string_TfToken__HashFunctor_t.getCPtr(metadata), TfToken.getCPtr(subIdentifier)); SdrShaderNode ret = (cPtr == global::System.IntPtr.Zero) ? null : new SdrShaderNode(cPtr, false); if (UsdCsPINVOKE.SWIGPendingException.Pending) { throw UsdCsPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
static public SdfAssetPathArray ToVtArray(SdfAssetPath[] input) { var output = new SdfAssetPathArray((uint)input.Length); // PERFORMANCE: this is super inefficient. for (int i = 0; i < input.Length; i++) { output[i] = new SdfAssetPath(input[i].GetAssetPath()); } return(output); }
public static bool operator==(SdfAssetPath lhs, SdfAssetPath rhs) { // The Swig binding glue will re-enter this operator comparing to null, so // that case must be handled explicitly to avoid an infinite loop. This is still // not great, since it crosses the C#/C++ barrier twice. A better approache might // be to return a simple value from C++ that can be compared in C#. bool lnull = lhs as object == null; bool rnull = rhs as object == null; return((lnull == rnull) && ((lnull && rnull) || SdfAssetPath.Equals(lhs, rhs))); }
public NdrNode GetNodeFromAsset(SdfAssetPath asset, SWIGTYPE_p_std__unordered_mapT_TfToken_std__string_TfToken__HashFunctor_t metadata) { global::System.IntPtr cPtr = UsdCsPINVOKE.NdrRegistry_GetNodeFromAsset(swigCPtr, SdfAssetPath.getCPtr(asset), SWIGTYPE_p_std__unordered_mapT_TfToken_std__string_TfToken__HashFunctor_t.getCPtr(metadata)); NdrNode ret = (cPtr == global::System.IntPtr.Zero) ? null : new NdrNode(cPtr, false); if (UsdCsPINVOKE.SWIGPendingException.Pending) { throw UsdCsPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public void StopRecording(double currentTime) { if (Clip.UsdScene == null) { // If an error occured, avoid spewing on every frame. return; } try { if (Clip.IsUSDZ && usdzTemporaryDir != null) { Directory.SetCurrentDirectory(usdzTemporaryDir.FullName); } Clip.Context = new ExportContext(); Clip.UsdScene.EndTime = currentTime * kExportFrameRate; // In a real exporter, additional error handling should be added here. if (!string.IsNullOrEmpty(Clip.m_usdFile)) { // We could use SaveAs here, which is fine for small scenes, though it will require // everything to fit in memory and another step where that memory is copied to disk. Clip.UsdScene.Save(); } // Release memory associated with the scene. Clip.UsdScene.Close(); Clip.UsdScene = null; if (Clip.IsUSDZ) { SdfAssetPath assetPath = new SdfAssetPath(usdcFileName); bool success = pxr.UsdCs.UsdUtilsCreateNewARKitUsdzPackage(assetPath, usdzFileName); if (!success) { Debug.LogError("Couldn't export " + _root.name + " to the usdz file: " + usdzFilePath); return; } // needed if we export into temp folder first File.Copy(usdzFileName, usdzFilePath, overwrite: true); } } finally { // Clean up temp files. Directory.SetCurrentDirectory(currentDir); if (Clip.IsUSDZ && usdzTemporaryDir != null && usdzTemporaryDir.Exists) { usdzTemporaryDir.Delete(recursive: true); } } }
public void ExportUsdz(string filePath, bool deleteUsdDirectory) { InitUsd.Initialize(); var currentDir = Directory.GetCurrentDirectory(); var usdFileName = Path.GetFileName(filePath); var usdzFileName = Path.GetFileNameWithoutExtension(usdFileName) + ".usdz"; string usdzDirectroy; if (string.IsNullOrEmpty(this.exportDirectory)) { usdzDirectroy = currentDir; } else { usdzDirectroy = Path.GetFullPath(this.exportDirectory); } var usdzFilePath = Path.Combine(usdzDirectroy, usdzFileName); try { // 画像の検索パスを合わせるためにカレントディレクトリを変更する // 後で戻し忘れるとUnityが壊れるので注意 Directory.SetCurrentDirectory(Path.GetDirectoryName(filePath)); var assetPath = new SdfAssetPath(usdFileName); var success = UsdCs.UsdUtilsCreateNewARKitUsdzPackage(assetPath, usdzFilePath); if (!success) { Debug.LogError("usdzファイルの出力に失敗しました"); return; } Debug.Log($"出力完了: '{usdzFilePath}'"); } finally { // 変更していたディレクトリを戻す Directory.SetCurrentDirectory(currentDir); if (deleteUsdDirectory) { var d = Path.GetDirectoryName(filePath); // 違うディレクトリを消してしまうとやばいのでチェック if (Path.GetFileName(d).StartsWith("temp-")) { var di = new DirectoryInfo(d); di.Delete(true); } } } }
protected override void EndRecording(RecordingSession session) { context.scene.EndTime = session.recorderTime * session.settings.FrameRate; context.scene.Save(); context.scene.Close(); if (Settings.ExportFormat == UsdRecorderSettings.Format.USDZ) { try { Directory.SetCurrentDirectory(usdzTemporaryDir.FullName); var assetPath = new SdfAssetPath(usdcFileName); var success = UsdCs.UsdUtilsCreateNewARKitUsdzPackage(assetPath, usdzFileName); if (!success) { Debug.LogError("Couldn't export to the usdz file: " + usdzFilePath); return; } // needed if we export into temp folder first File.Copy(usdzFileName, usdzFilePath, overwrite: true); } finally { // Clean up temp files. Directory.SetCurrentDirectory(currentDir); if (usdzTemporaryDir != null && usdzTemporaryDir.Exists) { usdzTemporaryDir.Delete(recursive: true); } } } context = null; Input.Context = null; base.EndRecording(session); }
protected SdfAssetPath GetValue(int index) { SdfAssetPath ret = new SdfAssetPath(UsdCsPINVOKE.SdfAssetPathArray_GetValue(swigCPtr, index), false); return(ret); }
public bool GetSourceAsset(SdfAssetPath sourceAsset) { bool ret = UsdCsPINVOKE.UsdShadeShader_GetSourceAsset__SWIG_1(swigCPtr, SdfAssetPath.getCPtr(sourceAsset)); return(ret); }
public bool GetAssetIdentifier(SdfAssetPath identifier) { bool ret = UsdCsPINVOKE.UsdModelAPI_GetAssetIdentifier(swigCPtr, SdfAssetPath.getCPtr(identifier)); return(ret); }
override public bool Equals(object rhs) { return(SdfAssetPath.Equals(this, rhs as SdfAssetPath)); }
public SdfAssetPathArray(Vt_ArrayForeignDataSource foreignSrc, SdfAssetPath data, uint size) : this(UsdCsPINVOKE.new_SdfAssetPathArray__SWIG_2(Vt_ArrayForeignDataSource.getCPtr(foreignSrc), SdfAssetPath.getCPtr(data), size), true) { }
public static void ExportUsdz(string usdzFilePath, GameObject root) { // Ensure USD is initialized before changing CWD. // This does not protect us against external changes to CWD, so we are actively looking for // a more robust solution with UPM devs. InitUsd.Initialize(); // Keep the current directory to restore it at the end. var currentDir = Directory.GetCurrentDirectory(); // Setup a temporary directory to export the wanted USD file and zip it. string tmpDirPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); DirectoryInfo tmpDir = Directory.CreateDirectory(tmpDirPath); // Get the usd file name to export and the usdz file name of the archive. string usdcFileName = Path.GetFileNameWithoutExtension(usdzFilePath) + ".usdc"; string usdzFileName = Path.GetFileName(usdzFilePath); try { // Set the current working directory to the tmp directory to export with relative paths. Directory.SetCurrentDirectory(tmpDirPath); // Create the tmp .usd scene, into which the data will be exported. Scene scene = ExportHelpers.InitForSave(Path.Combine(tmpDirPath, usdcFileName)); Vector3 localScale = root.transform.localScale; try { // USDZ is in centimeters. root.transform.localScale = localScale * 100; // Export the temp scene. SceneExporter.Export(root, scene, BasisTransformation.SlowAndSafe, // Required by ARKit exportUnvarying: true, zeroRootTransform: false, exportMaterials: true); } finally { // Undo temp scale. root.transform.localScale = localScale; // Flush any in-flight edits and release the scene so the file can be deleted. scene.Save(); scene.Close(); scene = null; } SdfAssetPath assetPath = new SdfAssetPath(usdcFileName); bool success = pxr.UsdCs.UsdUtilsCreateNewARKitUsdzPackage(assetPath, usdzFileName); if (!success) { Debug.LogError("Couldn't export " + root.name + " to the usdz file: " + usdzFilePath); return; } File.Copy(usdzFileName, usdzFilePath, overwrite: true); } finally { // Clean up temp files. Directory.SetCurrentDirectory(currentDir); tmpDir.Delete(recursive: true); } }
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(SdfAssetPath obj) { return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr); }
public bool GetClipManifestAssetPath(SdfAssetPath manifestAssetPath) { bool ret = UsdCsPINVOKE.UsdClipsAPI_GetClipManifestAssetPath__SWIG_1(swigCPtr, SdfAssetPath.getCPtr(manifestAssetPath)); return(ret); }
public SdfAssetPath GetColorConfiguration() { SdfAssetPath ret = new SdfAssetPath(UsdCsPINVOKE.UsdStageWeakPtr_GetColorConfiguration(swigCPtr), true); return(ret); }
public SdfAssetPathArray(uint n, SdfAssetPath value) : this(UsdCsPINVOKE.new_SdfAssetPathArray__SWIG_4(n, SdfAssetPath.getCPtr(value)), true) { if (UsdCsPINVOKE.SWIGPendingException.Pending) { throw UsdCsPINVOKE.SWIGPendingException.Retrieve(); } }