public static extern Error iplLoadScene(IntPtr globalContext, SimulationSettings simulationSettings, byte[] data, int size, IntPtr computeDevice, LoadSceneProgressCallback progressCallback, [In, Out] ref IntPtr scene);
public static extern Error iplCreateEnvironment(IntPtr globalContext, IntPtr computeDevice, SimulationSettings simulationSettings, IntPtr scene, IntPtr probeManager, [In, Out] ref IntPtr environment);
public Error Export(ComputeDevice computeDevice, SimulationSettings simulationSettings, MaterialValue defaultMaterial, IntPtr globalContext, bool exportOBJ = false) { var error = Error.None; simulationSettings.sceneType = SceneType.Phonon; // Scene type should always be Phonon when exporting. var objects = SceneExporter.GetStaticGameObjectsForExport(SceneManager.GetActiveScene()); Vector3[] vertices = null; Triangle[] triangles = null; int[] materialIndices = null; Material[] materials = null; SceneExporter.GetGeometryAndMaterialBuffers(objects, ref vertices, ref triangles, ref materialIndices, ref materials, false, exportOBJ); if (vertices.Length == 0 || triangles.Length == 0 || materialIndices.Length == 0 || materials.Length == 0) { throw new Exception( "No Steam Audio Geometry tagged. Attach Steam Audio Geometry to one or more GameObjects that " + "contain Mesh or Terrain geometry."); } error = PhononCore.iplCreateScene(globalContext, computeDevice.GetDevice(), simulationSettings, materials.Length, materials, null, null, null, null, IntPtr.Zero, ref scene); if (error != Error.None) { throw new Exception("Unable to create scene for export (" + materials.Length.ToString() + " materials): [" + error.ToString() + "]"); } var staticMesh = IntPtr.Zero; error = PhononCore.iplCreateStaticMesh(scene, vertices.Length, triangles.Length, vertices, triangles, materialIndices, ref staticMesh); if (error != Error.None) { throw new Exception("Unable to create static mesh for export (" + vertices.Length.ToString() + " vertices, " + triangles.Length.ToString() + " triangles): [" + error.ToString() + "]"); } #if UNITY_EDITOR if (!Directory.Exists(Application.streamingAssetsPath)) { UnityEditor.AssetDatabase.CreateFolder("Assets", "StreamingAssets"); } #endif if (exportOBJ) { PhononCore.iplSaveSceneAsObj(scene, Common.ConvertString(ObjFileName())); Debug.Log("Scene exported to " + ObjFileName() + "."); } else { var dataSize = PhononCore.iplSaveScene(scene, null); var data = new byte[dataSize]; PhononCore.iplSaveScene(scene, data); var fileName = SceneFileName(); File.WriteAllBytes(fileName, data); Debug.Log("Scene exported to " + fileName + "."); } PhononCore.iplDestroyStaticMesh(ref staticMesh); PhononCore.iplDestroyScene(ref scene); return(error); }
public void Export(string assetFileName, bool exportOBJ) { if (!ValidateGeometry()) { return; } assetFileName = Application.streamingAssetsPath + "/" + assetFileName; var objects = SceneExporter.GetDynamicGameObjectsForExport(this); Vector3[] vertices = null; Triangle[] triangles = null; int[] materialIndices = null; Material[] materials = null; SceneExporter.GetGeometryAndMaterialBuffers(objects, ref vertices, ref triangles, ref materialIndices, ref materials, true, exportOBJ); // TODO: Make the log callback function accessible from any class. var context = IntPtr.Zero; var status = PhononCore.iplCreateContext(null, IntPtr.Zero, IntPtr.Zero, ref context); if (status != Error.None) { throw new Exception(); } var computeDevice = IntPtr.Zero; var simulationSettings = new SimulationSettings { sceneType = SceneType.Phonon }; var scene = IntPtr.Zero; status = PhononCore.iplCreateScene(context, computeDevice, simulationSettings, materials.Length, materials, null, null, null, null, IntPtr.Zero, ref scene); if (status != Error.None) { throw new Exception(); } var staticMesh = IntPtr.Zero; status = PhononCore.iplCreateStaticMesh(scene, vertices.Length, triangles.Length, vertices, triangles, materialIndices, ref staticMesh); if (status != Error.None) { throw new Exception(); } if (exportOBJ) { PhononCore.iplSaveSceneAsObj(scene, Common.ConvertString(assetFileName + ".obj")); } else { var size = PhononCore.iplSaveScene(scene, null); var data = new byte[size]; PhononCore.iplSaveScene(scene, data); File.WriteAllBytes(assetFileName, data); } PhononCore.iplDestroyStaticMesh(ref staticMesh); PhononCore.iplDestroyScene(ref scene); PhononCore.iplDestroyContext(ref context); var exportedFileName = (exportOBJ) ? assetFileName + ".obj" : assetFileName; Debug.Log(string.Format("Steam Audio Dynamic Object [{0}]: Exported to {1}.", name, exportedFileName)); }
public static extern void iplUnitySetSimulationSettings(SimulationSettings simulationSettings);
public static extern Error iplCreateScene(IntPtr globalContext, IntPtr computeDevice, SimulationSettings simulationSettings, int numMaterials, [In, Out] ref IntPtr scene);
public void Initialize(SimulationSettingsValue settings, ComponentCache componentCache, GameEngineStateInitReason reason) { PhononCore.iplCreateContext(LogMessage, IntPtr.Zero, IntPtr.Zero, ref context); if (reason != GameEngineStateInitReason.EditingProbes) { var customSettings = componentCache.SteamAudioCustomSettings(); var useOpenCL = false; var computeDeviceType = ComputeDeviceType.Any; var requiresTan = false; var minReservableCUs = 0; var maxCUsToReserve = 0; if (customSettings) { convolutionType = customSettings.convolutionOption; if (customSettings.convolutionOption == ConvolutionOption.TrueAudioNext) { useOpenCL = true; requiresTan = true; computeDeviceType = ComputeDeviceType.GPU; minReservableCUs = customSettings.minComputeUnitsToReserve; maxCUsToReserve = customSettings.maxComputeUnitsToReserve; } else if (customSettings.rayTracerOption == SceneType.RadeonRays) { useOpenCL = true; } } try { var deviceFilter = new ComputeDeviceFilter { type = computeDeviceType, requiresTrueAudioNext = (requiresTan) ? Bool.True : Bool.False, minReservableCUs = minReservableCUs, maxCUsToReserve = maxCUsToReserve }; computeDevice.Create(context, useOpenCL, deviceFilter); } catch (Exception e) { Debug.LogWarning(String.Format("Unable to initialize TrueAudio Next: {0}. Using Phonon convolution.", e.Message)); customSettings.convolutionOption = ConvolutionOption.Phonon; } var inEditor = !SteamAudioManager.IsAudioEngineInitializing(); simulationSettings = new SimulationSettings { sceneType = (customSettings) ? customSettings.rayTracerOption : SceneType.Phonon, rays = (inEditor) ? settings.BakeRays : settings.RealtimeRays, secondaryRays = (inEditor) ? settings.BakeSecondaryRays : settings.RealtimeSecondaryRays, bounces = (inEditor) ? settings.BakeBounces : settings.RealtimeBounces, irDuration = (customSettings && customSettings.convolutionOption == ConvolutionOption.TrueAudioNext) ? customSettings.Duration : settings.Duration, ambisonicsOrder = (customSettings && customSettings.convolutionOption == ConvolutionOption.TrueAudioNext) ? customSettings.AmbisonicsOrder : settings.AmbisonicsOrder, maxConvolutionSources = (customSettings && customSettings.convolutionOption == ConvolutionOption.TrueAudioNext) ? customSettings.MaxSources : settings.MaxSources }; if (reason != GameEngineStateInitReason.ExportingScene) scene.Create(computeDevice, simulationSettings, context); if (reason == GameEngineStateInitReason.Playing) probeManager.Create(context); if (reason != GameEngineStateInitReason.ExportingScene && reason != GameEngineStateInitReason.GeneratingProbes) { try { environment.Create(computeDevice, simulationSettings, scene, probeManager, context); } catch (Exception e) { throw e; } } } }
public void Initialize(SimulationSettingsValue settings, ComponentCache componentCache, GameEngineStateInitReason reason) { PhononCore.iplCreateContext(LogMessage, IntPtr.Zero, IntPtr.Zero, ref context); var customSettings = componentCache.SteamAudioCustomSettings(); var useOpenCL = false; var computeDeviceType = ComputeDeviceType.Any; var numComputeUnits = 0; if (customSettings) { convolutionType = customSettings.convolutionOption; if (customSettings.convolutionOption == ConvolutionOption.TrueAudioNext) { useOpenCL = true; computeDeviceType = ComputeDeviceType.GPU; numComputeUnits = customSettings.numComputeUnits; } else if (customSettings.rayTracerOption == SceneType.RadeonRays) { useOpenCL = true; } } try { computeDevice.Create(context, useOpenCL, computeDeviceType, numComputeUnits); } catch (Exception e) { throw e; } var inEditor = !SteamAudioManager.IsAudioEngineInitializing(); simulationSettings = new SimulationSettings { sceneType = (customSettings) ? customSettings.rayTracerOption : SceneType.Phonon, rays = (inEditor) ? settings.BakeRays : settings.RealtimeRays, secondaryRays = (inEditor) ? settings.BakeSecondaryRays : settings.RealtimeSecondaryRays, bounces = (inEditor) ? settings.BakeBounces : settings.RealtimeBounces, irDuration = settings.Duration, ambisonicsOrder = settings.AmbisonicsOrder, maxConvolutionSources = settings.MaxSources }; if (reason != GameEngineStateInitReason.ExportingScene) { scene.Create(computeDevice, simulationSettings, context); } if (reason == GameEngineStateInitReason.Playing) { probeManager.Create(context); } if (reason != GameEngineStateInitReason.ExportingScene && reason != GameEngineStateInitReason.GeneratingProbes) { try { environment.Create(computeDevice, simulationSettings, scene, probeManager, context); } catch (Exception e) { throw e; } } }
public override void Initialize(IntPtr context, IntPtr defaultHRTF, SimulationSettings simulationSettings) { API.iplUnityInitialize(context); API.iplUnitySetHRTF(defaultHRTF); API.iplUnitySetSimulationSettings(simulationSettings); }
public static extern void iplUnitySetEnvironment(SimulationSettings simulationSettings, IntPtr environment, ConvolutionOption convolutionType);
public virtual void Initialize(IntPtr context, IntPtr defaultHRTF, SimulationSettings simulationSettings) { }
public void Initialize(SimulationSettingsValue settings, ComponentCache componentCache, GameEngineStateInitReason reason) { PhononCore.iplCreateContext(LogMessage, IntPtr.Zero, IntPtr.Zero, ref context); if (reason != GameEngineStateInitReason.EditingProbes) { var customSettings = componentCache.SteamAudioCustomSettings(); var useOpenCL = false; var computeDeviceType = ComputeDeviceType.Any; var maxCUsToReserve = 0; var fractionCUsForIRUpdate = .0f; convolutionType = ConvolutionOption.Phonon; var rayTracer = SceneType.Phonon; // TAN is enabled for realtime. if (customSettings && customSettings.ConvolutionType() == ConvolutionOption.TrueAudioNext && reason == GameEngineStateInitReason.Playing) { convolutionType = customSettings.ConvolutionType(); useOpenCL = true; computeDeviceType = ComputeDeviceType.GPU; maxCUsToReserve = customSettings.maxComputeUnitsToReserve; fractionCUsForIRUpdate = customSettings.fractionComputeUnitsForIRUpdate; } // Enable some settings which are commong whether Radeon Rays is enabled for baking or realtime. if (customSettings && (reason == GameEngineStateInitReason.Baking || reason == GameEngineStateInitReason.GeneratingProbes || reason == GameEngineStateInitReason.Playing)) { if (customSettings.RayTracerType() != SceneType.RadeonRays) { rayTracer = customSettings.RayTracerType(); } else { useOpenCL = true; rayTracer = SceneType.RadeonRays; computeDeviceType = ComputeDeviceType.GPU; } } // Enable additional settings when Radeon Rays is enabled for realtime but TAN is not. if (customSettings && customSettings.RayTracerType() == SceneType.RadeonRays && customSettings.ConvolutionType() != ConvolutionOption.TrueAudioNext && reason == GameEngineStateInitReason.Playing) { maxCUsToReserve = customSettings.maxComputeUnitsToReserve; fractionCUsForIRUpdate = 1.0f; } try { var deviceFilter = new ComputeDeviceFilter { type = computeDeviceType, maxCUsToReserve = maxCUsToReserve, fractionCUsForIRUpdate = fractionCUsForIRUpdate }; computeDevice.Create(context, useOpenCL, deviceFilter); } catch (Exception e) { if (customSettings && convolutionType == ConvolutionOption.TrueAudioNext) { var eInEditor = !SteamAudioManager.IsAudioEngineInitializing(); if (eInEditor && (!File.Exists(Directory.GetCurrentDirectory() + "/Assets/Plugins/x86_64/tanrt64.dll"))) { throw new Exception( "Steam Audio configured to use TrueAudio Next, but TrueAudio Next support package " + "not installed. Please import SteamAudio_TrueAudioNext.unitypackage in order to use " + "TrueAudio Next support for Steam Audio."); } else { Debug.LogWarning(String.Format("Unable to create compute device: {0}. Using Phonon convolution and raytracer.", e.Message)); } } else { Debug.LogWarning(String.Format("Unable to create compute device: {0}. Using Phonon convolution and raytracer.", e.Message)); } convolutionType = ConvolutionOption.Phonon; rayTracer = SceneType.Phonon; } var inEditor = !SteamAudioManager.IsAudioEngineInitializing(); var maxSources = settings.MaxSources; if (customSettings && convolutionType == ConvolutionOption.TrueAudioNext) { maxSources = customSettings.MaxSources; } if (rayTracer == SceneType.RadeonRays && reason == GameEngineStateInitReason.Baking) { maxSources = customSettings.BakingBatchSize; } simulationSettings = new SimulationSettings { sceneType = rayTracer, maxOcclusionSamples = settings.MaxOcclusionSamples, rays = (inEditor) ? settings.BakeRays : settings.RealtimeRays, secondaryRays = (inEditor) ? settings.BakeSecondaryRays : settings.RealtimeSecondaryRays, bounces = (inEditor) ? settings.BakeBounces : settings.RealtimeBounces, threads = (inEditor) ? (int)Mathf.Max(1, (settings.BakeThreadsPercentage * SystemInfo.processorCount) / 100.0f) : (int)Mathf.Max(1, (settings.RealtimeThreadsPercentage * SystemInfo.processorCount) / 100.0f), irDuration = (customSettings && convolutionType == ConvolutionOption.TrueAudioNext) ? customSettings.Duration : settings.Duration, ambisonicsOrder = (customSettings && convolutionType == ConvolutionOption.TrueAudioNext) ? customSettings.AmbisonicsOrder : settings.AmbisonicsOrder, maxConvolutionSources = maxSources, bakingBatchSize = (rayTracer == SceneType.RadeonRays) ? customSettings.BakingBatchSize : 1, irradianceMinDistance = settings.IrradianceMinDistance }; #if UNITY_EDITOR if (customSettings) { if (rayTracer == SceneType.RadeonRays) { if (!File.Exists(Directory.GetCurrentDirectory() + "/Assets/Plugins/x86_64/RadeonRays.dll")) { throw new Exception( "Steam Audio configured to use Radeon Rays, but Radeon Rays support package not " + "installed. Please import SteamAudio_RadeonRays.unitypackage in order to use Radeon " + "Rays support for Steam Audio."); } } if (convolutionType == ConvolutionOption.TrueAudioNext) { if (!File.Exists(Directory.GetCurrentDirectory() + "/Assets/Plugins/x86_64/tanrt64.dll")) { throw new Exception( "Editor: Steam Audio configured to use TrueAudio Next, but TrueAudio Next support package " + "not installed. Please import SteamAudio_TrueAudioNext.unitypackage in order to use " + "TrueAudio Next support for Steam Audio."); } } } #endif if (reason != GameEngineStateInitReason.ExportingScene) { scene.Create(computeDevice, simulationSettings, context); } // Add other scenes in the hierarchy if (scene.GetScene() != IntPtr.Zero && (reason == GameEngineStateInitReason.GeneratingProbes || reason == GameEngineStateInitReason.Baking)) { for (int i = 0; i < SceneManager.sceneCount; ++i) { var unityScene = SceneManager.GetSceneAt(i); if (!unityScene.isLoaded) { continue; } if (unityScene == SceneManager.GetActiveScene()) { continue; } IntPtr additiveScene, additiveMesh; var error = scene.AddAdditiveScene(unityScene, scene.GetScene(), computeDevice, simulationSettings, context, out additiveScene, out additiveMesh); if (error != Error.None) { continue; } if (additiveScenes == null) { editorAdditiveScenes = new List <IntPtr>(); } editorAdditiveScenes.Add(additiveScene); if (editorAdditiveSceneMeshes == null) { editorAdditiveSceneMeshes = new List <IntPtr>(); } editorAdditiveSceneMeshes.Add(additiveMesh); } PhononCore.iplCommitScene(scene.GetScene()); } if (reason == GameEngineStateInitReason.Playing) { probeManager.Create(context); } if (reason != GameEngineStateInitReason.ExportingScene && reason != GameEngineStateInitReason.GeneratingProbes) { try { environment.Create(computeDevice, simulationSettings, scene, probeManager, context); } catch (Exception e) { throw e; } } } }
public static extern void iplFMODSetSimulationSettings(SimulationSettings simulationSettings);
public static extern Error iplCreateScene(IntPtr context, IntPtr computeDevice, SimulationSettings simulationSettings, int numMaterials, Material[] materials, ClosestHitCallback closestHitCallback, AnyHitCallback anyHitCallback, BatchedClosestHitCallback batchedClosestHitCallback, BatchedAnyHitCallback batchedAnyHitCallback, IntPtr userData, [In, Out] ref IntPtr scene);
public static extern void iplUnitySetEnvironment(SimulationSettings simulationSettings, IntPtr environment);
public void Initialize(SimulationSettingsValue settings, ComponentCache componentCache, GameEngineStateInitReason reason) { PhononCore.iplCreateContext(LogMessage, IntPtr.Zero, IntPtr.Zero, ref context); if (reason != GameEngineStateInitReason.EditingProbes) { var customSettings = componentCache.SteamAudioCustomSettings(); var useOpenCL = false; var computeDeviceType = ComputeDeviceType.Any; var requiresTan = false; var minReservableCUs = 0; var maxCUsToReserve = 0; if (customSettings) { convolutionType = customSettings.ConvolutionType(); if (convolutionType == ConvolutionOption.TrueAudioNext) { useOpenCL = true; requiresTan = true; computeDeviceType = ComputeDeviceType.GPU; minReservableCUs = customSettings.minComputeUnitsToReserve; maxCUsToReserve = customSettings.maxComputeUnitsToReserve; } else if (customSettings.RayTracerType() == SceneType.RadeonRays) { useOpenCL = true; } } try { var deviceFilter = new ComputeDeviceFilter { type = computeDeviceType, requiresTrueAudioNext = (requiresTan) ? Bool.True : Bool.False, minReservableCUs = minReservableCUs, maxCUsToReserve = maxCUsToReserve }; computeDevice.Create(context, useOpenCL, deviceFilter); } catch (Exception e) { Debug.LogWarning(String.Format("Unable to initialize TrueAudio Next: {0}. Using Phonon convolution.", e.Message)); convolutionType = ConvolutionOption.Phonon; } var inEditor = !SteamAudioManager.IsAudioEngineInitializing(); var maxSources = settings.MaxSources; if (customSettings && convolutionType == ConvolutionOption.TrueAudioNext) { maxSources = customSettings.MaxSources; } if (customSettings && customSettings.RayTracerType() == SceneType.RadeonRays && reason == GameEngineStateInitReason.Baking) { maxSources = customSettings.BakingBatchSize; } var rayTracer = SceneType.Phonon; if (customSettings) { if (customSettings.RayTracerType() != SceneType.RadeonRays || reason != GameEngineStateInitReason.Playing) { rayTracer = customSettings.RayTracerType(); } } simulationSettings = new SimulationSettings { sceneType = rayTracer, occlusionSamples = settings.OcclusionSamples, rays = (inEditor) ? settings.BakeRays : settings.RealtimeRays, secondaryRays = (inEditor) ? settings.BakeSecondaryRays : settings.RealtimeSecondaryRays, bounces = (inEditor) ? settings.BakeBounces : settings.RealtimeBounces, threads = (inEditor) ? (int)Mathf.Max(1, (settings.BakeThreadsPercentage * SystemInfo.processorCount) / 100.0f) : (int)Mathf.Max(1, (settings.RealtimeThreadsPercentage * SystemInfo.processorCount) / 100.0f), irDuration = (customSettings && convolutionType == ConvolutionOption.TrueAudioNext) ? customSettings.Duration : settings.Duration, ambisonicsOrder = (customSettings && convolutionType == ConvolutionOption.TrueAudioNext) ? customSettings.AmbisonicsOrder : settings.AmbisonicsOrder, maxConvolutionSources = maxSources, bakingBatchSize = (customSettings && customSettings.RayTracerType() == SceneType.RadeonRays) ? customSettings.BakingBatchSize : 1 }; #if UNITY_EDITOR if (customSettings) { if (customSettings.RayTracerType() == SceneType.Embree) { if (!File.Exists(Directory.GetCurrentDirectory() + "/Assets/Plugins/x86_64/embree.dll")) { throw new Exception( "Steam Audio configured to use Embree, but Embree support package not installed. " + "Please import SteamAudio_Embree.unitypackage in order to use Embree support for " + "Steam Audio."); } } else if (customSettings.RayTracerType() == SceneType.RadeonRays) { if (!File.Exists(Directory.GetCurrentDirectory() + "/Assets/Plugins/x86_64/RadeonRays.dll")) { throw new Exception( "Steam Audio configured to use Radeon Rays, but Radeon Rays support package not " + "installed. Please import SteamAudio_RadeonRays.unitypackage in order to use Radeon " + "Rays support for Steam Audio."); } } if (customSettings.ConvolutionType() == ConvolutionOption.TrueAudioNext) { if (!File.Exists(Directory.GetCurrentDirectory() + "/Assets/Plugins/x86_64/tanrt64.dll")) { throw new Exception( "Steam Audio configured to use TrueAudio Next, but TrueAudio Next support package " + "not installed. Please import SteamAudio_TrueAudioNext.unitypackage in order to use " + "TrueAudio Next support for Steam Audio."); } } } #endif if (reason != GameEngineStateInitReason.ExportingScene) { scene.Create(computeDevice, simulationSettings, context); } if (reason == GameEngineStateInitReason.Playing) { probeManager.Create(context); } if (reason != GameEngineStateInitReason.ExportingScene && reason != GameEngineStateInitReason.GeneratingProbes) { try { environment.Create(computeDevice, simulationSettings, scene, probeManager, context); } catch (Exception e) { throw e; } } } }
public static extern Error iplCreateSimulationData(SimulationSettings simulationSettings, RenderingSettings renderingSettings, [In, Out] ref IntPtr simulationData);
public Error Export(ComputeDevice computeDevice, SimulationSettings simulationSettings, MaterialValue defaultMaterial, IntPtr globalContext, bool exportOBJ = false) { var error = Error.None; var objects = GameObject.FindObjectsOfType <SteamAudioGeometry>(); var totalNumVertices = 0; var totalNumTriangles = 0; var totalNumMaterials = 1; // Global material. for (var i = 0; i < objects.Length; ++i) { totalNumVertices += objects[i].GetNumVertices(); totalNumTriangles += objects[i].GetNumTriangles(); totalNumMaterials += objects[i].GetNumMaterials(); } simulationSettings.sceneType = SceneType.Phonon; // Scene type should always be Phonon when exporting. var vertices = new Vector3[totalNumVertices]; var triangles = new Triangle[totalNumTriangles]; var materialIndices = new int[totalNumTriangles]; var materials = new Material[totalNumMaterials + 1]; // Offset added to avoid creating Material // for each object and then copying it. var vertexOffset = 0; var triangleOffset = 0; var materialOffset = 1; materials[0].absorptionHigh = defaultMaterial.HighFreqAbsorption; materials[0].absorptionMid = defaultMaterial.MidFreqAbsorption; materials[0].absorptionLow = defaultMaterial.LowFreqAbsorption; materials[0].scattering = defaultMaterial.Scattering; materials[0].transmissionHigh = defaultMaterial.HighFreqTransmission; materials[0].transmissionMid = defaultMaterial.MidFreqTransmission; materials[0].transmissionLow = defaultMaterial.LowFreqTransmission; for (var i = 0; i < objects.Length; ++i) { objects[i].GetGeometry(vertices, ref vertexOffset, triangles, ref triangleOffset, materials, materialIndices, ref materialOffset); } error = PhononCore.iplCreateScene(globalContext, computeDevice.GetDevice(), simulationSettings, materials.Length, materials, null, null, null, null, IntPtr.Zero, ref scene); if (error != Error.None) { throw new Exception("Unable to create scene for export (" + objects.Length.ToString() + " materials): [" + error.ToString() + "]"); } var staticMesh = IntPtr.Zero; error = PhononCore.iplCreateStaticMesh(scene, totalNumVertices, totalNumTriangles, vertices, triangles, materialIndices, ref staticMesh); if (error != Error.None) { throw new Exception("Unable to create static mesh for export (" + totalNumVertices.ToString() + " vertices, " + totalNumTriangles.ToString() + " triangles): [" + error.ToString() + "]"); } #if UNITY_EDITOR if (!Directory.Exists(Application.streamingAssetsPath)) { UnityEditor.AssetDatabase.CreateFolder("Assets", "StreamingAssets"); } #endif if (exportOBJ) { PhononCore.iplDumpSceneToObjFile(scene, Common.ConvertString(ObjFileName())); Debug.Log("Scene dumped to " + ObjFileName() + "."); } else { var dataSize = PhononCore.iplSaveFinalizedScene(scene, null); var data = new byte[dataSize]; PhononCore.iplSaveFinalizedScene(scene, data); var fileName = SceneFileName(); File.WriteAllBytes(fileName, data); Debug.Log("Scene exported to " + fileName + "."); } PhononCore.iplDestroyStaticMesh(ref staticMesh); PhononCore.iplDestroyScene(ref scene); return(error); }
public static extern Error iplSimulatorCreate(IntPtr context, ref SimulationSettings settings, out IntPtr simulator);