diff options
| author | Bryan Galdrikian <[email protected]> | 2017-02-24 09:32:20 -0800 |
|---|---|---|
| committer | Bryan Galdrikian <[email protected]> | 2017-02-24 09:32:20 -0800 |
| commit | e1bf674c16e3c8472b29574159c789cd3f0c64e0 (patch) | |
| tree | 9f0cfce09c71a2c27ff19589fcad6cd83504477c /examples/UnityExample | |
| parent | first commit (diff) | |
| download | blast-e1bf674c16e3c8472b29574159c789cd3f0c64e0.tar.xz blast-e1bf674c16e3c8472b29574159c789cd3f0c64e0.zip | |
Updating to [email protected] and [email protected] with a new directory structure.
NvBlast folder is gone, files have been moved to top level directory. README is changed to reflect this.
Diffstat (limited to 'examples/UnityExample')
51 files changed, 3735 insertions, 0 deletions
diff --git a/examples/UnityExample/Assets/Materials.meta b/examples/UnityExample/Assets/Materials.meta new file mode 100644 index 0000000..df23794 --- /dev/null +++ b/examples/UnityExample/Assets/Materials.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: d31aa341fef8dc847b06afe139915599 +folderAsset: yes +timeCreated: 1481726695 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/Assets/Materials/CubeMaterial.mat b/examples/UnityExample/Assets/Materials/CubeMaterial.mat new file mode 100644 index 0000000..d5b3782 --- /dev/null +++ b/examples/UnityExample/Assets/Materials/CubeMaterial.mat @@ -0,0 +1,127 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: CubeMaterial + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: _EMISSION + m_LightmapFlags: 1 + m_CustomRenderQueue: -1 + stringTagMap: {} + m_SavedProperties: + serializedVersion: 2 + m_TexEnvs: + - first: + name: _BumpMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _DetailAlbedoMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _DetailMask + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _DetailNormalMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _EmissionMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _MainTex + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _MetallicGlossMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _OcclusionMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _ParallaxMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - first: + name: _BumpScale + second: 1 + - first: + name: _Cutoff + second: 0.5 + - first: + name: _DetailNormalMapScale + second: 1 + - first: + name: _DstBlend + second: 0 + - first: + name: _GlossMapScale + second: 1 + - first: + name: _Glossiness + second: 0.5 + - first: + name: _GlossyReflections + second: 1 + - first: + name: _Metallic + second: 0 + - first: + name: _Mode + second: 0 + - first: + name: _OcclusionStrength + second: 1 + - first: + name: _Parallax + second: 0.02 + - first: + name: _SmoothnessTextureChannel + second: 0 + - first: + name: _SpecularHighlights + second: 1 + - first: + name: _SrcBlend + second: 1 + - first: + name: _UVSec + second: 0 + - first: + name: _ZWrite + second: 1 + m_Colors: + - first: + name: _Color + second: {r: 1, g: 1, b: 1, a: 1} + - first: + name: _EmissionColor + second: {r: 0, g: 0, b: 0, a: 1} diff --git a/examples/UnityExample/Assets/Materials/CubeMaterial.mat.meta b/examples/UnityExample/Assets/Materials/CubeMaterial.mat.meta new file mode 100644 index 0000000..c09f976 --- /dev/null +++ b/examples/UnityExample/Assets/Materials/CubeMaterial.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 737d44acaf66b744197a3bf85c73a150 +timeCreated: 1483016941 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/Assets/Materials/HitToolMaterial.mat b/examples/UnityExample/Assets/Materials/HitToolMaterial.mat new file mode 100644 index 0000000..8fe71b4 --- /dev/null +++ b/examples/UnityExample/Assets/Materials/HitToolMaterial.mat @@ -0,0 +1,128 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: HitToolMaterial + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: _ALPHAPREMULTIPLY_ON _EMISSION + m_LightmapFlags: 1 + m_CustomRenderQueue: 3000 + stringTagMap: + RenderType: Transparent + m_SavedProperties: + serializedVersion: 2 + m_TexEnvs: + - first: + name: _BumpMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _DetailAlbedoMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _DetailMask + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _DetailNormalMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _EmissionMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _MainTex + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _MetallicGlossMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _OcclusionMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - first: + name: _ParallaxMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - first: + name: _BumpScale + second: 1 + - first: + name: _Cutoff + second: 0.5 + - first: + name: _DetailNormalMapScale + second: 1 + - first: + name: _DstBlend + second: 10 + - first: + name: _GlossMapScale + second: 1 + - first: + name: _Glossiness + second: 0 + - first: + name: _GlossyReflections + second: 1 + - first: + name: _Metallic + second: 0.156 + - first: + name: _Mode + second: 3 + - first: + name: _OcclusionStrength + second: 1 + - first: + name: _Parallax + second: 0.02 + - first: + name: _SmoothnessTextureChannel + second: 0 + - first: + name: _SpecularHighlights + second: 1 + - first: + name: _SrcBlend + second: 1 + - first: + name: _UVSec + second: 0 + - first: + name: _ZWrite + second: 0 + m_Colors: + - first: + name: _Color + second: {r: 1, g: 0, b: 0, a: 0.259} + - first: + name: _EmissionColor + second: {r: 0, g: 0, b: 0, a: 1} diff --git a/examples/UnityExample/Assets/Materials/HitToolMaterial.mat.meta b/examples/UnityExample/Assets/Materials/HitToolMaterial.mat.meta new file mode 100644 index 0000000..da8036a --- /dev/null +++ b/examples/UnityExample/Assets/Materials/HitToolMaterial.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 680819e140a18024bba58e6fdc3651d2 +timeCreated: 1483016941 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/Assets/Plugins.meta b/examples/UnityExample/Assets/Plugins.meta new file mode 100644 index 0000000..cb9f934 --- /dev/null +++ b/examples/UnityExample/Assets/Plugins.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 92d69ff37d33e1c48959dc367d045c85 +folderAsset: yes +timeCreated: 1481019334 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/Assets/Plugins/Blast.meta b/examples/UnityExample/Assets/Plugins/Blast.meta new file mode 100644 index 0000000..2413c51 --- /dev/null +++ b/examples/UnityExample/Assets/Plugins/Blast.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: ba11cec7e53a49943b7e620c809850c9 +folderAsset: yes +timeCreated: 1483018139 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtShadersWrapper.cs b/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtShadersWrapper.cs new file mode 100644 index 0000000..68b311d --- /dev/null +++ b/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtShadersWrapper.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using UnityEngine; + +[StructLayout(LayoutKind.Sequential)] +public class NvBlastExtRadialDamageDesc +{ + public float compressive; //!< compressive (radial) damage component + public float p0; + public float p1; + public float p2; + public float minRadius; //!< inner radius of damage action + public float maxRadius; //!< outer radius of damage action +}; + +[StructLayout(LayoutKind.Sequential)] +public class NvBlastExtMaterial +{ + public float singleChunkThreshold; //!< subsupport chunks only take damage surpassing this value + public float graphChunkThreshold; //!< support chunks only take damage surpassing this value + public float bondTangentialThreshold; //!< bond only take damage surpassing this value + public float bondNormalThreshold; //!< currently unused - forward damage propagation + public float damageAttenuation; //!< factor of damage attenuation while forwarding +}; + + +public static class NvBlastExtShadersWrapper +{ + public const string DLL_NAME = "NvBlastExtShaders" + NvBlastWrapper.DLL_POSTFIX + "_" + NvBlastWrapper.DLL_PLATFORM; + + #region Dll + [DllImport(DLL_NAME)] + private static extern bool NvBlastExtDamageActorRadialFalloff(IntPtr actor, NvBlastFractureBuffers buffers, NvBlastExtRadialDamageDesc damageDescBuffer, UInt32 damageDescCount, NvBlastExtMaterial material, NvBlastWrapper.NvBlastLog logFn, NvBlastTimers timers); + #endregion + + public static bool DamageRadialFalloff(this NvBlastActor actor, NvBlastFractureBuffers buffers, NvBlastExtRadialDamageDesc damageDescBuffer, UInt32 damageDescCount, NvBlastExtMaterial material) + { + return NvBlastExtDamageActorRadialFalloff(actor.ptr, buffers, damageDescBuffer, damageDescCount, material, NvBlastWrapper.Log, null); + } +}
\ No newline at end of file diff --git a/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtShadersWrapper.cs.meta b/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtShadersWrapper.cs.meta new file mode 100644 index 0000000..edf8ac2 --- /dev/null +++ b/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtShadersWrapper.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 47339a6d798176c41969193e9b3ecb30 +timeCreated: 1481725762 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtUtilsWrapper.cs b/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtUtilsWrapper.cs new file mode 100644 index 0000000..8f81a2e --- /dev/null +++ b/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtUtilsWrapper.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using UnityEngine; + + +public static class NvBlastExtUtilsWrapper +{ + public const string DLL_NAME = "NvBlastExtUtils" + NvBlastWrapper.DLL_POSTFIX + "_" + NvBlastWrapper.DLL_PLATFORM; + + #region Dll + [DllImport(DLL_NAME)] + private static extern void NvBlastReorderAssetDescChunks([In, Out] NvBlastChunkDesc[] chunkDescs, uint chunkCount, [In, Out] NvBlastBondDesc[] bondDescs, uint bondCount, [In, Out] uint[] chunkReorderMap); + #endregion + + public static void ReorderAssetDescChunks(NvBlastAssetDesc assetDesc, uint[] chunkReorderMap) + { + NvBlastReorderAssetDescChunks(assetDesc.chunkDescs, assetDesc.chunkCount, assetDesc.bondDescs, assetDesc.bondCount, chunkReorderMap); + } +}
\ No newline at end of file diff --git a/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtUtilsWrapper.cs.meta b/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtUtilsWrapper.cs.meta new file mode 100644 index 0000000..caf4278 --- /dev/null +++ b/examples/UnityExample/Assets/Plugins/Blast/NvBlastExtUtilsWrapper.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 79da9e4b8c3adf543b406ce704084d62 +timeCreated: 1481725762 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/Assets/Plugins/Blast/NvBlastWrapper.cs b/examples/UnityExample/Assets/Plugins/Blast/NvBlastWrapper.cs new file mode 100644 index 0000000..ccda6c4 --- /dev/null +++ b/examples/UnityExample/Assets/Plugins/Blast/NvBlastWrapper.cs @@ -0,0 +1,587 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using UnityEngine; +using UnityEngine.Assertions; + +public struct NvBlastChunkDesc +{ + public enum Flags + { + NoFlags = 0, + SupportFlag = (1 << 0) + }; + + /** Central position in chunk. */ + public Single c0; + public Single c1; + public Single c2; + + + /** Volume of chunk. */ + public Single volume; + + /** Index of this chunk's parent. If this is a root chunk, then this value must be UINT32_MAX. */ + public UInt32 parentChunkIndex; + + /** See Flags enum for possible flags. */ + public UInt32 flags; + + /** User-supplied data which will be accessible to the user in chunk fracture events. */ + public UInt32 userData; +} + +public struct NvBlastBond +{ + public Single n0; + public Single n1; + public Single n2; + + public Single area; + + public Single c0; + public Single c1; + public Single c2; + + UInt32 userData; +}; + +public struct NvBlastBondDesc +{ + /** The indices of the chunks linked by this bond. They must be different support chunk indices. */ + public UInt32 chunk0; + public UInt32 chunk1; + + /** Bond data (see NvBlastBond). */ + public NvBlastBond bond; +} + +[StructLayout(LayoutKind.Sequential)] +public class NvBlastAssetDesc +{ + public UInt32 chunkCount; + public NvBlastChunkDesc[] chunkDescs; + public UInt32 bondCount; + public NvBlastBondDesc[] bondDescs; +} + +/** +Actor descriptor, used to create an instance of an NvBlastAsset with NvBlastActorCreate + 6 +See NvBlastActorCreate. +*/ +[StructLayout(LayoutKind.Sequential)] +public class NvBlastActorDesc +{ + /** + Initial health of all bonds, if initialBondHealths is NULL (see initialBondHealths). + */ + public Single uniformInitialBondHealth; + + /** + Initial bond healths. If not NULL, this array must be of length NvBlastAssetGetChunkCount(asset, ... ). + If NULL, uniformInitialBondHealth must be set. + */ + public Single[] initialBondHealths = null; + + /** + Initial health of all lower-support chunks, if initialSupportChunkHealths is NULL (see initialSupportChunkHealths). + */ + public Single uniformInitialLowerSupportChunkHealth; + + /** + Initial health of all support chunks. If not NULL, this must be of length + NvBlastAssetGetSupportGraph(asset, ... ).nodeCount. The elements in the initialSupportChunkHealth + array will correspond to the chunk indices in the NvBlastAssetGetSupportGraph(asset, ... ).chunkIndices + array. Every descendent of a support chunk will have its health initialized to its ancestor support + chunk's health, so this initializes all lower-support chunk healths. + If NULL, uniformInitialLowerSupportChunkHealth must be set. + */ + public Single[] initialSupportChunkHealths = null; +}; + + +public struct NvBlastChunk +{ + /** + Central position for the chunk's volume + */ + public Single c0; + public Single c1; + public Single c2; + + /** + Volume of the chunk + */ + public Single volume; + + /** + Index of parent (UINT32_MAX denotes no parent) + */ + public UInt32 parentChunkIndex; + + /** + Index of first child + */ + public UInt32 firstChildIndex; + + /** + Stop for child indices + */ + public UInt32 childIndexStop; + + /** + Field for user to associate with external data + */ + public UInt32 userData; +}; + +public struct NvBlastChunkGraph +{ + UInt32 nodeCount; + public IntPtr chunkIndices; + public IntPtr adjacencyPartition; + public IntPtr adjacentNodeIndices; + public IntPtr adjacentBondIndices; +}; + +[StructLayout(LayoutKind.Sequential)] +public class NvBlastTimers +{ + public Int64 material; //!< Time spent in material function + public Int64 fracture; //!< Time spent applying damage + public Int64 island; //!< Time spent discovering islands + public Int64 partition; //!< Time spent partitioning the graph + public Int64 visibility; //!< Time spent updating visibility +}; + + +/////////////////////////////////////////////////////////////////////////////// +// Types used for damage and fracturing +/////////////////////////////////////////////////////////////////////////////// + +public struct NvBlastChunkFractureData +{ + public UInt32 userdata; //!< chunk's user data + public UInt32 chunkIndex; //!< asset chunk index + public Single health; //!< health value (damage or remains) +}; + +public struct NvBlastBondFractureData +{ + public UInt32 userdata; //!< bond's user data + public UInt32 nodeIndex0; //!< graph node index of bond + public UInt32 nodeIndex1; //!< pair graph node index of bond + public Single health; //!< health value (damage or remains) +}; + +[StructLayout(LayoutKind.Sequential)] +public class NvBlastFractureBuffers +{ + public UInt32 bondFractureCount; + public UInt32 chunkFractureCount; + public IntPtr bondFractures; // NvBlastBondFractureData[] + public IntPtr chunkFractures; // NvBlastChunkFractureData[] +}; + +[StructLayout(LayoutKind.Sequential)] +public class NvBlastActorSplitEvent +{ + public IntPtr deletedActor; //!< deleted actor or nullptr if actor has not changed + public IntPtr newActors; //!< list of created actors +}; + +[StructLayout(LayoutKind.Sequential)] +public class NvBlastGraphShaderActor +{ + UInt32 firstGraphNodeIndex; //<! Entry index for graphNodeIndexLinks + public UInt32[] graphNodeIndexLinks; //<! Linked index list of connected nodes. Traversable with nextIndex = graphNodeIndexLinks[currentIndex], terminates with 0xFFFFFFFF. + public UInt32[] chunkIndices; //<! Graph's map from node index to support chunk index. + public UInt32[] adjacencyPartition; //<! See NvBlastChunkGraph::adjacencyPartition. + public UInt32[] adjacentNodeIndices; //<! See NvBlastChunkGraph::adjacentNodeIndices. + public UInt32[] adjacentBondIndices; //<! See NvBlastChunkGraph::adjacentBondIndices. + public NvBlastBond[] assetBonds; //<! NvBlastBonds geometry in the NvBlastAsset. + public Single[] familyBondHealths; //<! Actual bond health values for broken bond detection. +}; + +[StructLayout(LayoutKind.Sequential)] +public class NvBlastProgramParams +{ + public IntPtr damageDescBuffer; //!< array of damage descriptions + public UInt32 damageDescCount; //!< number of damage descriptions in array + public IntPtr material; //!< pointer to material +}; + +[StructLayout(LayoutKind.Sequential)] +public class NvBlastSubgraphShaderActor +{ + public UInt32 chunkIndex; //<! Index of chunk represented by this actor. + public NvBlastChunk[] assetChunks; //<! NvBlastChunks geometry in the NvBlastAsset. +}; + +public struct NvBlastDamageProgram +{ + public delegate void NvBlastGraphShaderFunction(System.IntPtr commandBuffers, System.IntPtr actor, System.IntPtr p); + public delegate void NvBlastSubgraphShaderFunction(NvBlastFractureBuffers commandBuffers, NvBlastSubgraphShaderActor actor, NvBlastProgramParams p); + + public NvBlastGraphShaderFunction graphShaderFunction; + public NvBlastSubgraphShaderFunction subgraphShaderFunction; +}; + + +public class NvBlastWrapper +{ + //////// DLL //////// + + public const string DLL_POSTFIX = "DEBUG"; //DEBUG + public const string DLL_PLATFORM = "x64"; + public const string DLL_NAME = "NvBlast" + DLL_POSTFIX + "_" + DLL_PLATFORM; + + + //////// Internal Types //////// + + public delegate IntPtr NvBlastAlloc(Int64 size); + public delegate void NvBlastFree(IntPtr ptr); + public delegate void NvBlastLog(Int32 type, string msg, string file, Int32 line); + + + //////// Public Types //////// + + + + //////// Helpers //////// + + public static IntPtr Alloc(Int64 size) + { + return Marshal.AllocHGlobal((Int32)size); + } + + public static void Free(IntPtr ptr) + { + Marshal.FreeHGlobal(ptr); + } + + public static void Log(Int32 type, string msg, string file, Int32 line) + { + Debug.Log(DLL_NAME + ": [" + type + "] " + msg + "(" + file + ":" + line + ")"); + } + + public static IntPtr GetScratch(int size) + { + return _greedyScratch.GetScratch(size); + } + + private static GreedyScratch _greedyScratch = new GreedyScratch(); +} + + +public class GreedyScratch : IDisposable +{ + public IntPtr GetScratch(int size) + { + if (_size < size) + { + releaseScratch(); + _scratch = Marshal.AllocHGlobal(size); + _size = size; + } + + return _scratch; + } + + private void releaseScratch() + { + if (_size > 0) + { + Marshal.FreeHGlobal(_scratch); + _scratch = IntPtr.Zero; + } + } + + public void Dispose() + { + Dispose(true); + } + + protected virtual void Dispose(bool bDisposing) + { + releaseScratch(); + + if (bDisposing) + { + GC.SuppressFinalize(this); + } + } + + ~GreedyScratch() + { + Dispose(false); + } + + private int _size = 0; + private IntPtr _scratch = IntPtr.Zero; +} + + +public abstract class DisposablePtr : IDisposable +{ + protected void Initialize(IntPtr ptr) + { + Assert.IsTrue(this._ptr == IntPtr.Zero); + this._ptr = ptr; + } + + protected void ResetPtr() + { + this._ptr = IntPtr.Zero; + } + + protected abstract void Release(); + + public IntPtr ptr + { + get { return _ptr; } + } + + + public void Dispose() + { + Dispose(true); + } + + protected virtual void Dispose(bool bDisposing) + { + if (_ptr != IntPtr.Zero) + { + Release(); + _ptr = IntPtr.Zero; + } + + if (bDisposing) + { + GC.SuppressFinalize(this); + } + } + + ~DisposablePtr() + { + Dispose(false); + } + + private IntPtr _ptr = IntPtr.Zero; +} + + +public class NvBlastAsset : DisposablePtr +{ + #region Dll + [DllImport(NvBlastWrapper.DLL_NAME)] + static extern UInt64 NvBlastAssetCreateRequiredScratch(NvBlastAssetDesc desc); + + [DllImport(NvBlastWrapper.DLL_NAME)] + static extern IntPtr NvBlastAssetCreate(NvBlastAssetDesc desc, NvBlastWrapper.NvBlastAlloc allocFn, IntPtr scratch, NvBlastWrapper.NvBlastLog logFn); + + [DllImport(NvBlastWrapper.DLL_NAME)] + static extern void NvBlastAssetRelease(IntPtr asset, NvBlastWrapper.NvBlastFree freeFn, NvBlastWrapper.NvBlastLog logFn); + + [DllImport(NvBlastWrapper.DLL_NAME)] + static extern UInt32 NvBlastAssetGetLeafChunkCount(IntPtr asset, NvBlastWrapper.NvBlastLog logFn); + + [DllImport(NvBlastWrapper.DLL_NAME)] + static extern NvBlastChunkGraph NvBlastAssetGetSupportGraph(IntPtr asset, NvBlastWrapper.NvBlastLog logFn); + #endregion + + public NvBlastAsset(NvBlastAssetDesc desc) + { + var scratchSize = NvBlastAssetCreateRequiredScratch(desc); + var asset = NvBlastAssetCreate(desc, NvBlastWrapper.Alloc, NvBlastWrapper.GetScratch((int)scratchSize), NvBlastWrapper.Log); + Initialize(asset); + } + + protected override void Release() + { + NvBlastAssetRelease(ptr, NvBlastWrapper.Free, NvBlastWrapper.Log); + } + + public UInt32 leafChunkCount + { + get + { + return NvBlastAssetGetLeafChunkCount(ptr, NvBlastWrapper.Log); + } + } + + public NvBlastChunkGraph chunkGraph + { + get + { + if (!_graph.HasValue) + { + _graph = NvBlastAssetGetSupportGraph(ptr, NvBlastWrapper.Log); + } + return _graph.Value; + } + } + + private NvBlastChunkGraph? _graph = null; +} + + +public class NvBlastFamily : DisposablePtr +{ + #region Dll + [DllImport(NvBlastWrapper.DLL_NAME)] + static extern IntPtr NvBlastFamilyCreate(IntPtr asset, NvBlastWrapper.NvBlastAlloc allocFn, NvBlastWrapper.NvBlastLog logFn); + + [DllImport(NvBlastWrapper.DLL_NAME)] + static extern void NvBlastFamilyRelease(IntPtr family, NvBlastWrapper.NvBlastFree freeFn, NvBlastWrapper.NvBlastLog logFn); + #endregion + + public NvBlastAsset asset + { + get; + private set; + } + + public NvBlastFamily(NvBlastAsset asset_) + { + asset = asset_; + var family = NvBlastFamilyCreate(asset.ptr, NvBlastWrapper.Alloc, NvBlastWrapper.Log); + Initialize(family); + } + + protected override void Release() + { + NvBlastFamilyRelease(ptr, NvBlastWrapper.Free, NvBlastWrapper.Log); + } +} + + +public class NvBlastActor : DisposablePtr +{ + #region Dll + [DllImport(NvBlastWrapper.DLL_NAME)] + static extern UInt64 NvBlastActorCreateRequiredScratch(IntPtr asset); + + [DllImport(NvBlastWrapper.DLL_NAME)] + static extern IntPtr NvBlastActorCreate(IntPtr family, NvBlastActorDesc desc, IntPtr scratch, NvBlastWrapper.NvBlastLog logFn); + + [DllImport(NvBlastWrapper.DLL_NAME)] + static extern void NvBlastActorRelease(IntPtr actor); + + [DllImport(NvBlastWrapper.DLL_NAME)] + static extern UInt32 NvBlastActorGetVisibleChunkCount(IntPtr actor, NvBlastWrapper.NvBlastLog logFn); + + [DllImport(NvBlastWrapper.DLL_NAME)] + static extern UInt32 NvBlastActorGetVisibleChunkIndices([In, Out] UInt32[] visibleChunkIndices, UInt32 visibleChunkIndicesSize, IntPtr actor, NvBlastWrapper.NvBlastLog logFn); + + [DllImport(NvBlastWrapper.DLL_NAME)] + static extern UInt32 NvBlastActorGetGraphNodeCount(IntPtr actor, NvBlastWrapper.NvBlastLog logFn); + + [DllImport(NvBlastWrapper.DLL_NAME)] + static extern UInt32 NvBlastActorGetGraphNodeIndices([In, Out] UInt32[] graphNodeIndices, UInt32 graphNodeIndicesSize, IntPtr actor, NvBlastWrapper.NvBlastLog logFn); + + [DllImport(NvBlastWrapper.DLL_NAME)] + static extern void NvBlastActorGenerateFracture(NvBlastFractureBuffers commandBuffers, IntPtr actor, NvBlastDamageProgram program, NvBlastProgramParams programParams, NvBlastWrapper.NvBlastLog logFn, NvBlastTimers timers); + + [DllImport(NvBlastWrapper.DLL_NAME)] + static extern void NvBlastActorApplyFracture(IntPtr eventBuffers, IntPtr actor, NvBlastFractureBuffers commands, NvBlastWrapper.NvBlastLog logFn, NvBlastTimers timers); + + [DllImport(NvBlastWrapper.DLL_NAME)] + static extern UInt64 NvBlastActorSplitRequiredScratch(IntPtr actor); + + [DllImport(NvBlastWrapper.DLL_NAME)] + static extern UInt32 NvBlastActorSplit([In, Out] NvBlastActorSplitEvent result, UInt32 newActorsMaxCount, IntPtr actor, IntPtr scratch, NvBlastWrapper.NvBlastLog logFn, NvBlastTimers timers); + #endregion + + public NvBlastFamily family + { + get; + private set; + } + + public object userData = null; + + public NvBlastActor(NvBlastFamily family_, NvBlastActorDesc desc) + { + family = family_; + + var scratchSize = NvBlastActorCreateRequiredScratch(family_.asset.ptr); + var actor = NvBlastActorCreate(family.ptr, desc, NvBlastWrapper.GetScratch((int)scratchSize), NvBlastWrapper.Log); + Initialize(actor); + } + + public NvBlastActor(NvBlastFamily family_, IntPtr ptr) + { + family = family_; + + Initialize(ptr); + } + + protected override void Release() + { + NvBlastActorRelease(ptr); + } + + public UInt32 visibleChunkCount + { + get { return NvBlastActorGetVisibleChunkCount(ptr, NvBlastWrapper.Log); } + } + + public UInt32[] visibleChunkIndices + { + get + { + if(_visibleChunkIndices == null) + { + _visibleChunkIndices = new UInt32[visibleChunkCount]; + NvBlastActorGetVisibleChunkIndices(_visibleChunkIndices, visibleChunkCount, ptr, NvBlastWrapper.Log); + } + return _visibleChunkIndices; + } + } + + public UInt32 graphNodeCount + { + get { return NvBlastActorGetGraphNodeCount(ptr, NvBlastWrapper.Log); } + } + + public UInt32[] graphNodeIndices + { + get + { + if (_graphNodeIndices == null) + { + _graphNodeIndices = new UInt32[graphNodeCount]; + NvBlastActorGetGraphNodeIndices(_graphNodeIndices, graphNodeCount, ptr, NvBlastWrapper.Log); + } + return _graphNodeIndices; + } + } + + public void GenerateFracture(NvBlastFractureBuffers buffers, NvBlastDamageProgram program, NvBlastProgramParams programParams) + { + NvBlastActorGenerateFracture(buffers, ptr, program, programParams, NvBlastWrapper.Log, null); + } + + public void ApplyFracture(NvBlastFractureBuffers commands) + { + NvBlastActorApplyFracture(IntPtr.Zero, ptr, commands, NvBlastWrapper.Log, null); + } + + public UInt32 Split(NvBlastActorSplitEvent result, UInt32 newActorsMaxCount) + { + var scratchSize = NvBlastActorSplitRequiredScratch(ptr); + UInt32 newActorsCount = NvBlastActorSplit(result, newActorsMaxCount, ptr, NvBlastWrapper.GetScratch((int)scratchSize), NvBlastWrapper.Log, null); + if(result.deletedActor != IntPtr.Zero) + { + ResetPtr(); + } + return newActorsCount; + } + + private UInt32[] _visibleChunkIndices = null; + private UInt32[] _graphNodeIndices = null; +} + diff --git a/examples/UnityExample/Assets/Plugins/Blast/NvBlastWrapper.cs.meta b/examples/UnityExample/Assets/Plugins/Blast/NvBlastWrapper.cs.meta new file mode 100644 index 0000000..6cb40de --- /dev/null +++ b/examples/UnityExample/Assets/Plugins/Blast/NvBlastWrapper.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 50e876cfa58ea5a46935955772ce78d6 +timeCreated: 1481552179 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/Assets/Plugins/Blast/x64.meta b/examples/UnityExample/Assets/Plugins/Blast/x64.meta new file mode 100644 index 0000000..1d8c5b7 --- /dev/null +++ b/examples/UnityExample/Assets/Plugins/Blast/x64.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 7efc8ea30a371b14b9de21b07f5666b1 +folderAsset: yes +timeCreated: 1481552179 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastDEBUG_x64.dll.meta b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastDEBUG_x64.dll.meta new file mode 100644 index 0000000..3b289f8 --- /dev/null +++ b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastDEBUG_x64.dll.meta @@ -0,0 +1,68 @@ +fileFormatVersion: 2 +guid: 5fc0a2604d2987b4680e41464be1c22e +timeCreated: 1482762574 +licenseType: Free +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Any: + enabled: 1 + settings: + Exclude Editor: 0 + Exclude Linux: 0 + Exclude Linux64: 0 + Exclude LinuxUniversal: 0 + Exclude OSXIntel: 0 + Exclude OSXIntel64: 0 + Exclude OSXUniversal: 0 + Exclude WebGL: 0 + Exclude Win: 1 + Exclude Win64: 0 + Editor: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 1 + settings: + CPU: None + Linux64: + enabled: 1 + settings: + CPU: x86_64 + LinuxUniversal: + enabled: 1 + settings: + CPU: AnyCPU + OSXIntel: + enabled: 1 + settings: + CPU: None + OSXIntel64: + enabled: 1 + settings: + CPU: AnyCPU + OSXUniversal: + enabled: 1 + settings: + CPU: AnyCPU + WebGL: + enabled: 1 + settings: {} + Win: + enabled: 0 + settings: + CPU: None + Win64: + enabled: 1 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtCommonDEBUG_x64.dll.meta b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtCommonDEBUG_x64.dll.meta new file mode 100644 index 0000000..fd62927 --- /dev/null +++ b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtCommonDEBUG_x64.dll.meta @@ -0,0 +1,54 @@ +fileFormatVersion: 2 +guid: 819acd10daddc114cb79447732a44ff3 +timeCreated: 1482926953 +licenseType: Free +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Any: + enabled: 1 + settings: {} + Editor: + enabled: 0 + settings: + CPU: x86_64 + DefaultValueInitialized: true + Linux: + enabled: 0 + settings: + CPU: None + Linux64: + enabled: 1 + settings: + CPU: x86_64 + LinuxUniversal: + enabled: 1 + settings: + CPU: x86_64 + OSXIntel: + enabled: 0 + settings: + CPU: None + OSXIntel64: + enabled: 1 + settings: + CPU: AnyCPU + OSXUniversal: + enabled: 0 + settings: + CPU: x86_64 + Win: + enabled: 0 + settings: + CPU: None + Win64: + enabled: 1 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtShadersDEBUG_x64.dll.meta b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtShadersDEBUG_x64.dll.meta new file mode 100644 index 0000000..e35fbdc --- /dev/null +++ b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtShadersDEBUG_x64.dll.meta @@ -0,0 +1,68 @@ +fileFormatVersion: 2 +guid: 52823d20a4352e84d84af3b61814dc42 +timeCreated: 1482762574 +licenseType: Free +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Any: + enabled: 1 + settings: + Exclude Editor: 0 + Exclude Linux: 0 + Exclude Linux64: 0 + Exclude LinuxUniversal: 0 + Exclude OSXIntel: 0 + Exclude OSXIntel64: 0 + Exclude OSXUniversal: 0 + Exclude WebGL: 0 + Exclude Win: 1 + Exclude Win64: 0 + Editor: + enabled: 1 + settings: + CPU: x86_64 + DefaultValueInitialized: true + OS: AnyOS + Linux: + enabled: 1 + settings: + CPU: None + Linux64: + enabled: 1 + settings: + CPU: x86_64 + LinuxUniversal: + enabled: 1 + settings: + CPU: AnyCPU + OSXIntel: + enabled: 1 + settings: + CPU: None + OSXIntel64: + enabled: 1 + settings: + CPU: AnyCPU + OSXUniversal: + enabled: 1 + settings: + CPU: AnyCPU + WebGL: + enabled: 1 + settings: {} + Win: + enabled: 0 + settings: + CPU: None + Win64: + enabled: 1 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtUtilsDEBUG_x64.dll.meta b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtUtilsDEBUG_x64.dll.meta new file mode 100644 index 0000000..4423045 --- /dev/null +++ b/examples/UnityExample/Assets/Plugins/Blast/x64/NvBlastExtUtilsDEBUG_x64.dll.meta @@ -0,0 +1,54 @@ +fileFormatVersion: 2 +guid: 26135af3d3f04804dbaebd13245d00ce +timeCreated: 1482926953 +licenseType: Free +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + Any: + enabled: 1 + settings: {} + Editor: + enabled: 0 + settings: + CPU: x86_64 + DefaultValueInitialized: true + Linux: + enabled: 0 + settings: + CPU: None + Linux64: + enabled: 1 + settings: + CPU: x86_64 + LinuxUniversal: + enabled: 1 + settings: + CPU: x86_64 + OSXIntel: + enabled: 0 + settings: + CPU: None + OSXIntel64: + enabled: 1 + settings: + CPU: AnyCPU + OSXUniversal: + enabled: 0 + settings: + CPU: x86_64 + Win: + enabled: 0 + settings: + CPU: None + Win64: + enabled: 1 + settings: + CPU: AnyCPU + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/Assets/Resources.meta b/examples/UnityExample/Assets/Resources.meta new file mode 100644 index 0000000..4f939db --- /dev/null +++ b/examples/UnityExample/Assets/Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 71f2224643a5f3d4fa31d3d53571d22d +folderAsset: yes +timeCreated: 1481710917 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/Assets/Resources/CubePrefab.prefab b/examples/UnityExample/Assets/Resources/CubePrefab.prefab new file mode 100644 index 0000000..e7e13c1 --- /dev/null +++ b/examples/UnityExample/Assets/Resources/CubePrefab.prefab @@ -0,0 +1,94 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1794769123409596} + m_IsPrefabParent: 1 +--- !u!1 &1794769123409596 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4401640667841860} + - component: {fileID: 33951265812587310} + - component: {fileID: 65730351288524680} + - component: {fileID: 23414374623188592} + m_Layer: 0 + m_Name: CubePrefab + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4401640667841860 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1794769123409596} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!23 &23414374623188592 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1794769123409596} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 737d44acaf66b744197a3bf85c73a150, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 +--- !u!33 &33951265812587310 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1794769123409596} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!65 &65730351288524680 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1794769123409596} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} diff --git a/examples/UnityExample/Assets/Resources/CubePrefab.prefab.meta b/examples/UnityExample/Assets/Resources/CubePrefab.prefab.meta new file mode 100644 index 0000000..0c1036b --- /dev/null +++ b/examples/UnityExample/Assets/Resources/CubePrefab.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 94b4444853fb8ab48bbf65be8101f9ec +timeCreated: 1481710929 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/Assets/Scenes.meta b/examples/UnityExample/Assets/Scenes.meta new file mode 100644 index 0000000..deb5063 --- /dev/null +++ b/examples/UnityExample/Assets/Scenes.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: cf46863e64ac2db4994ac4df55ad7bde +folderAsset: yes +timeCreated: 1481021055 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/Assets/Scenes/Test.unity b/examples/UnityExample/Assets/Scenes/Test.unity new file mode 100644 index 0000000..7091f7c --- /dev/null +++ b/examples/UnityExample/Assets/Scenes/Test.unity @@ -0,0 +1,452 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 7 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 7 + m_GIWorkflowMode: 0 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 4 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 1 + m_CompAOExponentDirect: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 1 + m_DirectLightInLightProbes: 1 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 256 + m_ReflectionCompression: 2 + m_LightingDataAsset: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666667 + accuratePlacement: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &1097545995 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1097545997} + - component: {fileID: 1097545996} + m_Layer: 0 + m_Name: Directional Light + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!108 &1097545996 +Light: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1097545995} + m_Enabled: 1 + serializedVersion: 7 + m_Type: 1 + m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_CookieSize: 10 + m_Shadows: + m_Type: 2 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_Lightmapping: 4 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!4 &1097545997 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1097545995} + m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} + m_LocalPosition: {x: 0, y: 3, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} +--- !u!1 &1231262489 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1231262494} + - component: {fileID: 1231262493} + - component: {fileID: 1231262492} + - component: {fileID: 1231262491} + - component: {fileID: 1231262490} + - component: {fileID: 1231262495} + m_Layer: 0 + m_Name: Main Camera + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &1231262490 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1231262489} + m_Enabled: 1 +--- !u!124 &1231262491 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1231262489} + m_Enabled: 1 +--- !u!92 &1231262492 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1231262489} + m_Enabled: 1 +--- !u!20 &1231262493 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1231262489} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: -1 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 + m_StereoMirrorMode: 0 +--- !u!4 &1231262494 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1231262489} + m_LocalRotation: {x: 0.26193652, y: 0, z: 0, w: 0.96508515} + m_LocalPosition: {x: 0, y: 180, z: -455} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 30.37, y: 0, z: 0} +--- !u!114 &1231262495 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1231262489} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 29f022fb3768b8c4196631a9526aebcc, type: 3} + m_Name: + m_EditorClassIdentifier: + cameraSensitivity: 180 + climbSpeed: 40 + normalMoveSpeed: 100 + slowMoveFactor: 0.25 + fastMoveFactor: 3 +--- !u!1 &1755768756 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1755768758} + - component: {fileID: 1755768757} + m_Layer: 0 + m_Name: Demo + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1755768757 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1755768756} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 7a62789bffb0bef4e9757f9848620e3f, type: 3} + m_Name: + m_EditorClassIdentifier: + hitSphere: {fileID: 1828855647} +--- !u!4 &1755768758 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1755768756} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 22.74558, y: 0.29925728, z: 67.52241} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1828855647 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1828855651} + - component: {fileID: 1828855650} + - component: {fileID: 1828855648} + m_Layer: 0 + m_Name: HitSphere + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!23 &1828855648 +MeshRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1828855647} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 2100000, guid: 680819e140a18024bba58e6fdc3651d2, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 +--- !u!33 &1828855650 +MeshFilter: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1828855647} + m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &1828855651 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1828855647} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 1.4304204, y: 4.4981146, z: -0.2158227} + m_LocalScale: {x: 0.1, y: 0.1, z: 0.1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &2120916518 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 2120916522} + - component: {fileID: 2120916521} + - component: {fileID: 2120916520} + - component: {fileID: 2120916519} + m_Layer: 0 + m_Name: Plane + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 4294967295 + m_IsActive: 1 +--- !u!23 &2120916519 +MeshRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 2120916518} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 +--- !u!64 &2120916520 +MeshCollider: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 2120916518} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Convex: 0 + m_InflateMesh: 0 + m_SkinWidth: 0.01 + m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} +--- !u!33 &2120916521 +MeshFilter: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 2120916518} + m_Mesh: {fileID: 10209, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &2120916522 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 2120916518} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 100, y: 1, z: 100} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/examples/UnityExample/Assets/Scenes/Test.unity.meta b/examples/UnityExample/Assets/Scenes/Test.unity.meta new file mode 100644 index 0000000..21dc2d9 --- /dev/null +++ b/examples/UnityExample/Assets/Scenes/Test.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0daa4f0291a2d794cb9066dd6bc74061 +timeCreated: 1481021055 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/Assets/Scripts.meta b/examples/UnityExample/Assets/Scripts.meta new file mode 100644 index 0000000..aad561f --- /dev/null +++ b/examples/UnityExample/Assets/Scripts.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: c68a13922b97bab4da262a0e7422de7f +folderAsset: yes +timeCreated: 1481018329 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/Assets/Scripts/CubeAssetGenerator.cs b/examples/UnityExample/Assets/Scripts/CubeAssetGenerator.cs new file mode 100644 index 0000000..fdb6fa0 --- /dev/null +++ b/examples/UnityExample/Assets/Scripts/CubeAssetGenerator.cs @@ -0,0 +1,183 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class CubeAsset +{ + public struct DepthInfo + { + public DepthInfo(Vector3 slices, NvBlastChunkDesc.Flags flag_ = NvBlastChunkDesc.Flags.NoFlags) + { + this.slicesPerAxis = slices; + this.flag = flag_; + } + + public Vector3 slicesPerAxis; + public NvBlastChunkDesc.Flags flag; + }; + + public enum BondFlags + { + NO_BONDS = 0, + X_BONDS = 1, + Y_BONDS = 2, + Z_BONDS = 4, + ALL_BONDS = X_BONDS | Y_BONDS | Z_BONDS + }; + + public class Settings + { + public List<DepthInfo> depths = new List<DepthInfo>(); + public Vector3 extents; + public BondFlags bondFlags = BondFlags.ALL_BONDS; + public float staticHeight = float.NegativeInfinity; + }; + + public struct BlastChunkCube + { + public BlastChunkCube(Vector3 position_, Vector3 extents_, bool isStatic_) + { + this.position = position_; + this.extents = extents_; + this.isStatic = isStatic_; + } + + public Vector3 position; + public Vector3 extents; + public bool isStatic; + }; + + public List<BlastChunkCube> chunks = new List<BlastChunkCube>(); + public NvBlastAssetDesc solverAssetDesc = new NvBlastAssetDesc(); + public Vector3 extents { get; private set; } + + public static CubeAsset generate(Settings settings) + { + CubeAsset asset = new CubeAsset(); + asset.extents = settings.extents; + + List<NvBlastChunkDesc> solverChunks = new List<NvBlastChunkDesc>(); + List<NvBlastBondDesc> solverBonds = new List<NvBlastBondDesc>(); + + // initial params + List<uint> depthStartIDs = new List<uint>(); + List<Vector3> depthSlicesPerAxisTotal = new List<Vector3>(); + uint currentID = 0; + Vector3 extents = settings.extents; + + // Iterate over depths and create children + for (int depth = 0; depth<settings.depths.Count; depth++) + { + Vector3 slicesPerAxis = settings.depths[depth].slicesPerAxis; + Vector3 slicesPerAxisTotal = (depth == 0) ? slicesPerAxis : Vector3.Scale(slicesPerAxis, (depthSlicesPerAxisTotal[depth - 1])); + depthSlicesPerAxisTotal.Add(slicesPerAxisTotal); + + depthStartIDs.Add(currentID); + + extents.x /= slicesPerAxis.x; + extents.y /= slicesPerAxis.y; + extents.z /= slicesPerAxis.z; + + for (uint z = 0; z< (uint)slicesPerAxisTotal.z; ++z) + { + uint parent_z = z / (uint)slicesPerAxis.z; + for (uint y = 0; y< (uint)slicesPerAxisTotal.y; ++y) + { + uint parent_y = y / (uint)slicesPerAxis.y; + for (uint x = 0; x< (uint)slicesPerAxisTotal.x; ++x) + { + uint parent_x = x / (uint)slicesPerAxis.x; + uint parentID = depth == 0 ? uint.MaxValue : + depthStartIDs[depth - 1] + parent_x + (uint)depthSlicesPerAxisTotal[depth - 1].x * (parent_y + (uint)depthSlicesPerAxisTotal[depth - 1].y * parent_z); + + Vector3 position; + position.x = ((float)x - (slicesPerAxisTotal.x / 2) + 0.5f) * extents.x; + position.y = ((float)y - (slicesPerAxisTotal.y / 2) + 0.5f) * extents.y; + position.z = ((float)z - (slicesPerAxisTotal.z / 2) + 0.5f) * extents.z; + + NvBlastChunkDesc chunkDesc; + + chunkDesc.c0 = position.x; + chunkDesc.c1 = position.y; + chunkDesc.c2 = position.z; + chunkDesc.volume = extents.x * extents.y * extents.z; + chunkDesc.flags = (uint)settings.depths[depth].flag; + chunkDesc.userData = currentID++; + chunkDesc.parentChunkIndex = parentID; + solverChunks.Add(chunkDesc); + + bool isStatic = false; + + if (settings.depths[depth].flag == NvBlastChunkDesc.Flags.SupportFlag) + { + isStatic = position.y - (extents.y - asset.extents.y) / 2 <= settings.staticHeight; + + // x-neighbor + if (x > 0 && (settings.bondFlags & BondFlags.X_BONDS) != 0) + { + Vector3 xNeighborPosition = position - new Vector3(extents.x, 0, 0); + uint neighborID = chunkDesc.userData - 1; + + fillBondDesc(solverBonds, chunkDesc.userData, neighborID, position, xNeighborPosition, extents, extents.y* extents.z); + } + + // y-neighbor + if (y > 0 && (settings.bondFlags & BondFlags.Y_BONDS) != 0) + { + Vector3 yNeighborPosition = position - new Vector3(0, extents.y, 0); + uint neighborID = chunkDesc.userData - (uint)slicesPerAxisTotal.x; + + fillBondDesc(solverBonds, chunkDesc.userData, neighborID, position, yNeighborPosition, extents, extents.z* extents.x); + } + + // z-neighbor + if (z > 0 && (settings.bondFlags & BondFlags.Z_BONDS) != 0) + { + Vector3 zNeighborPosition = position - new Vector3(0, 0, extents.z); + uint neighborID = chunkDesc.userData - (uint)slicesPerAxisTotal.x * (uint)slicesPerAxisTotal.y; + + fillBondDesc(solverBonds, chunkDesc.userData, neighborID, position, zNeighborPosition, extents, extents.x* extents.y); + } + } + + asset.chunks.Add(new BlastChunkCube(position, extents, isStatic)); + } + } + } + } + + // Prepare solver asset desc + asset.solverAssetDesc.chunkCount = (uint)solverChunks.Count; + asset.solverAssetDesc.chunkDescs = solverChunks.ToArray(); + asset.solverAssetDesc.bondCount = (uint)solverBonds.Count; + asset.solverAssetDesc.bondDescs = solverBonds.ToArray(); + + // Reorder chunks + uint[] chunkReorderMap = new uint[asset.solverAssetDesc.chunkCount]; + NvBlastExtUtilsWrapper.ReorderAssetDescChunks(asset.solverAssetDesc, chunkReorderMap); + BlastChunkCube[] chunksTemp = asset.chunks.ToArray(); + for (uint i = 0; i < chunkReorderMap.Length; ++i) + { + asset.chunks[(int)chunkReorderMap[i]] = chunksTemp[i]; + } + + return asset; + } + + static void fillBondDesc(List<NvBlastBondDesc> bondDescs, uint id0, uint id1, Vector3 pos0, Vector3 pos1, Vector3 size, float area) + { + NvBlastBondDesc bondDesc = new NvBlastBondDesc(); + bondDesc.chunk0 = id0; + bondDesc.chunk1 = id1; + bondDesc.bond.area = area; + Vector3 centroid = (pos0 + pos1) * 0.5f; + bondDesc.bond.c0 = centroid.x; + bondDesc.bond.c1 = centroid.y; + bondDesc.bond.c2 = centroid.z; + Vector3 normal = (pos0 - pos1).normalized; + bondDesc.bond.n0 = normal.x; + bondDesc.bond.n1= normal.y; + bondDesc.bond.n2 = normal.z; + bondDescs.Add(bondDesc); + } +} diff --git a/examples/UnityExample/Assets/Scripts/CubeAssetGenerator.cs.meta b/examples/UnityExample/Assets/Scripts/CubeAssetGenerator.cs.meta new file mode 100644 index 0000000..0a37254 --- /dev/null +++ b/examples/UnityExample/Assets/Scripts/CubeAssetGenerator.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: efa082786df108947a6fb5d672c1fb1a +timeCreated: 1481121968 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/Assets/Scripts/CubeFamily.cs b/examples/UnityExample/Assets/Scripts/CubeFamily.cs new file mode 100644 index 0000000..fda0760 --- /dev/null +++ b/examples/UnityExample/Assets/Scripts/CubeFamily.cs @@ -0,0 +1,202 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using UnityEngine; + + +public class CubeFamily : MonoBehaviour +{ + public void Initialize(CubeAsset asset) + { + // Blast asset creation + _cubeAsset = asset; + + NvBlastAssetDesc desc = _cubeAsset.solverAssetDesc; + _blastAsset = new NvBlastAsset(desc); + Debug.Log(_blastAsset.leafChunkCount); + + // Actual Cubes + var cubePrefab = Resources.Load<GameObject>("CubePrefab"); + _cubes = new GameObject[desc.chunkCount]; + for (int i = 0; i < desc.chunkCount; ++i) + { + GameObject cube = GameObject.Instantiate<GameObject>(cubePrefab); + cube.transform.parent = transform; + cube.transform.localScale = _cubeAsset.chunks[i].extents; + cube.transform.localPosition = _cubeAsset.chunks[i].position; + cube.transform.localRotation = Quaternion.identity; + cube.SetActive(false); + Color color = Color.HSVToRGB(UnityEngine.Random.Range(0f, 1f), 0.42f, 1.0f); + cube.GetComponent<Renderer>().material.color = color; + _cubes[i] = cube; + } + + // First actor + _blastFamily = new NvBlastFamily(_blastAsset); + + NvBlastActorDesc actorDesc = new NvBlastActorDesc(); + actorDesc.uniformInitialBondHealth = 1.0f; + actorDesc.uniformInitialLowerSupportChunkHealth = 1.0f; + var actor = new NvBlastActor(_blastFamily, actorDesc); + Debug.Log(actor.visibleChunkCount); + + OnActorCreated(actor, Vector3.zero, Quaternion.identity); + + // Reserved buffers + _fractureBuffers = new NvBlastFractureBuffers(); + _fractureBuffers.chunkFractures = Marshal.AllocHGlobal((int)desc.chunkCount * Marshal.SizeOf(typeof(NvBlastChunkFractureData))); + _fractureBuffers.bondFractures = Marshal.AllocHGlobal((int)desc.bondCount * Marshal.SizeOf(typeof(NvBlastBondFractureData))); + _leafChunkCount = (uint)_blastAsset.leafChunkCount; + _newActorsBuffer = Marshal.AllocHGlobal((int)_leafChunkCount * Marshal.SizeOf(typeof(IntPtr))); + } + + private void OnActorCreated(NvBlastActor actor, Vector3 localPosition, Quaternion localRotation) + { + var rigidBodyGO = new GameObject("RigidActor"); + rigidBodyGO.transform.SetParent(this.transform, false); + var rigidbody = rigidBodyGO.AddComponent<Rigidbody>(); + rigidbody.transform.localPosition = localPosition; + rigidbody.transform.localRotation = localRotation; + + // chunks + var chunkIndices = actor.visibleChunkIndices; + foreach (var chunkIndex in chunkIndices) + { + var chunkCube = _cubes[chunkIndex]; + chunkCube.transform.SetParent(rigidbody.transform, false); + chunkCube.SetActive(true); + } + + // search for static chunks + var graphNodeIndices = actor.graphNodeIndices; + var chunkGraph = _blastAsset.chunkGraph; + foreach(var node in graphNodeIndices) + { + var chunkIndex = Marshal.ReadInt32(chunkGraph.chunkIndices, Marshal.SizeOf(typeof(UInt32)) * (int)node); + var chunkCube = _cubeAsset.chunks[chunkIndex]; + if(chunkCube.isStatic) + { + rigidbody.isKinematic = true; + break; + } + } + + actor.userData = rigidbody; + _actors.Add(rigidbody, actor); + } + + private void OnActorDestroyed(NvBlastActor actor) + { + var chunkIndices = actor.visibleChunkIndices; + foreach (var chunkIndex in chunkIndices) + { + var chunkCube = _cubes[chunkIndex]; + chunkCube.transform.SetParent(transform, false); + chunkCube.SetActive(false); + } + + var rigidbody = (actor.userData as Rigidbody); + _actors.Remove(rigidbody); + Destroy(rigidbody.gameObject); + actor.userData = null; + } + + public void ApplyRadialDamage(Vector3 position, float minRadius, float maxRadius, float compressive) + { + var hits = Physics.OverlapSphere(position, maxRadius); + foreach (var hit in hits) + { + var rb = hit.GetComponentInParent<Rigidbody>(); + if (rb != null) + { + ApplyRadialDamage(rb, position, minRadius, maxRadius, compressive); + } + } + } + + public bool ApplyRadialDamage(Rigidbody rb, Vector3 position, float minRadius, float maxRadius, float compressive) + { + if (_actors.ContainsKey(rb)) + { + Vector3 localPosition = rb.transform.InverseTransformPoint(position); + ApplyRadialDamage(_actors[rb], localPosition, minRadius, maxRadius, compressive); + return true; + } + return false; + } + + private void ApplyRadialDamage(NvBlastActor actor, Vector3 localPosition, float minRadius, float maxRadius, float compressive) + { + _fractureBuffers.chunkFractureCount = _cubeAsset.solverAssetDesc.chunkCount; + _fractureBuffers.bondFractureCount = _cubeAsset.solverAssetDesc.bondCount; + + NvBlastExtRadialDamageDesc desc = new NvBlastExtRadialDamageDesc(); + desc.minRadius = minRadius; + desc.maxRadius = maxRadius; + desc.compressive = compressive; + desc.p0 = localPosition.x; + desc.p1 = localPosition.y; + desc.p2 = localPosition.z; + + if (actor.DamageRadialFalloff(_fractureBuffers, desc, 1, null)) + { + Split(actor); + } + } + + private void Split(NvBlastActor actor) + { + NvBlastActorSplitEvent split = new NvBlastActorSplitEvent(); + split.newActors = _newActorsBuffer; + var count = actor.Split(split, _leafChunkCount); + + Vector3 localPosition = Vector3.zero; + Quaternion localRotation = Quaternion.identity; + + if (split.deletedActor != IntPtr.Zero) + { + if (actor.userData != null) + { + var parentRigidbody = (actor.userData as Rigidbody); + localPosition = parentRigidbody.transform.localPosition; + localRotation = parentRigidbody.transform.localRotation; + } + OnActorDestroyed(actor); + } + for (int i = 0; i < count; i++) + { + int elementSize = Marshal.SizeOf(typeof(IntPtr)); + var ptr = Marshal.ReadIntPtr(split.newActors, elementSize * i); + OnActorCreated(new NvBlastActor(_blastFamily, ptr), localPosition, localRotation); + } + } + + private void OnDestroy() + { + if (_fractureBuffers != null) + { + Marshal.FreeHGlobal(_fractureBuffers.chunkFractures); + Marshal.FreeHGlobal(_fractureBuffers.bondFractures); + _fractureBuffers = null; + } + + if (_newActorsBuffer != IntPtr.Zero) + { + Marshal.FreeHGlobal(_newActorsBuffer); + } + + _actors.Clear(); + _blastFamily = null; + _blastAsset = null; + } + + private CubeAsset _cubeAsset; + private NvBlastAsset _blastAsset; + private NvBlastFamily _blastFamily; + private Dictionary<Rigidbody, NvBlastActor> _actors = new Dictionary<Rigidbody, NvBlastActor>(); + private GameObject[] _cubes; + private NvBlastFractureBuffers _fractureBuffers; + private IntPtr _newActorsBuffer; + private uint _leafChunkCount; +}
\ No newline at end of file diff --git a/examples/UnityExample/Assets/Scripts/CubeFamily.cs.meta b/examples/UnityExample/Assets/Scripts/CubeFamily.cs.meta new file mode 100644 index 0000000..f61e39a --- /dev/null +++ b/examples/UnityExample/Assets/Scripts/CubeFamily.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0fe5c9affaa641644b99cb8e384234d4 +timeCreated: 1481725814 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/Assets/Scripts/Demo.cs b/examples/UnityExample/Assets/Scripts/Demo.cs new file mode 100644 index 0000000..eb60d26 --- /dev/null +++ b/examples/UnityExample/Assets/Scripts/Demo.cs @@ -0,0 +1,120 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Demo : MonoBehaviour +{ + public GameObject hitSphere; + + void Awake () + { + generateCity(); + } + + private void generateCity() + { + const int BUILDING_TYPE_COUNT = 5; + Vector3 BUILDING_MIN_SIZE = new Vector3(10, 10, 10); + Vector3 BUILDING_MAX_SIZE = new Vector3(50, 200, 50); + + List<CubeAsset> buildingTypes = new List<CubeAsset>(BUILDING_TYPE_COUNT); + for (int i = 0; i < BUILDING_TYPE_COUNT; ++i) + { + CubeAsset.Settings settings = new CubeAsset.Settings(); + settings.depths.Add(new CubeAsset.DepthInfo(new Vector3(1, 1, 1), NvBlastChunkDesc.Flags.NoFlags)); + settings.depths.Add(new CubeAsset.DepthInfo(new Vector3(1, 2, 1), NvBlastChunkDesc.Flags.NoFlags)); + settings.depths.Add(new CubeAsset.DepthInfo(new Vector3(2, 3, 2), NvBlastChunkDesc.Flags.NoFlags)); + settings.depths.Add(new CubeAsset.DepthInfo(new Vector3(2, 2, 2), NvBlastChunkDesc.Flags.SupportFlag)); + settings.extents = new Vector3(Random.Range(BUILDING_MIN_SIZE.x, BUILDING_MAX_SIZE.x), Random.Range(BUILDING_MIN_SIZE.y, BUILDING_MAX_SIZE.y), Random.Range(BUILDING_MIN_SIZE.z, BUILDING_MAX_SIZE.z)); + settings.staticHeight = 10.0f; + + CubeAsset cubeAsset = CubeAsset.generate(settings); + + buildingTypes.Add(cubeAsset); + } + + int totalBuildings = 0; + + const float CITY_HALF_SIZE = 200.0f; + const float SPARSITY = 30.0f; + const int BUILDING_COUNT_MAX = 20; + Vector2 pos = new Vector2(-CITY_HALF_SIZE, -CITY_HALF_SIZE); + float buildingYMax = 0.0f; + while (pos.y < CITY_HALF_SIZE && totalBuildings < BUILDING_COUNT_MAX) + { + // random jump + pos.x += Random.Range(0.0f, SPARSITY); + if(pos.x > CITY_HALF_SIZE) + { + pos.x = -CITY_HALF_SIZE; + pos.y += buildingYMax + Random.Range(0.0f, SPARSITY); + buildingYMax = 0.0f; + continue; + } + + // random bulding type spawn + int type = Random.Range(0, buildingTypes.Count); + var cubeFamily = (new GameObject("Cube Actor #" + type)).AddComponent<CubeFamily>(); + CubeAsset asset = buildingTypes[type]; + cubeFamily.transform.localPosition = new Vector3(pos.x, asset.extents.y / 2.0f, pos.y); + pos.x += asset.extents.x; + buildingYMax = Mathf.Max(buildingYMax, asset.extents.z); + cubeFamily.Initialize(asset); + totalBuildings++; + } + } + + private IEnumerator applyRadialDamage(Vector3 position, float minRadius, float maxRadius, float compressive, float explosive = 3000.0f) + { + var hits = Physics.OverlapSphere(position, maxRadius); + foreach (var hit in hits) + { + var rb = hit.GetComponentInParent<Rigidbody>(); + var family = hit.GetComponentInParent<CubeFamily>(); + if (rb != null && family != null) + { + family.ApplyRadialDamage(rb, position, minRadius, maxRadius, compressive); + } + } + + yield return new WaitForEndOfFrame(); + + hits = Physics.OverlapSphere(position, maxRadius); + foreach (var hit in hits) + { + var rb = hit.GetComponentInParent<Rigidbody>(); + if(rb != null) + { + rb.AddExplosionForce(explosive, position, maxRadius, 3.0f); + } + } + } + + private void Update() + { + hitSphere.SetActive(false); + bool isActive = false; + if (true) + { + var ray = Camera.main.ScreenPointToRay(Input.mousePosition); + RaycastHit hit; + if(Physics.Raycast(ray, out hit)) + { + hitSphere.transform.position = hit.point; + isActive = true; + } + } + + _hitSphereSize += Input.GetAxis("Mouse ScrollWheel") * 10.0f; + + if (Input.GetMouseButton(0)) + { + StartCoroutine(applyRadialDamage(hitSphere.transform.position, 0.0f, _hitSphereSize, 10.0f)); + } + + hitSphere.SetActive(isActive); + hitSphere.transform.localScale = new Vector3(_hitSphereSize, _hitSphereSize, _hitSphereSize); + } + + private float _hitSphereSize = 25.0f; +} diff --git a/examples/UnityExample/Assets/Scripts/Demo.cs.meta b/examples/UnityExample/Assets/Scripts/Demo.cs.meta new file mode 100644 index 0000000..edd0d3b --- /dev/null +++ b/examples/UnityExample/Assets/Scripts/Demo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 7a62789bffb0bef4e9757f9848620e3f +timeCreated: 1481120125 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/Assets/Scripts/FreeCamera.cs b/examples/UnityExample/Assets/Scripts/FreeCamera.cs new file mode 100644 index 0000000..1e9fd67 --- /dev/null +++ b/examples/UnityExample/Assets/Scripts/FreeCamera.cs @@ -0,0 +1,61 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class FreeCamera : MonoBehaviour +{ + public float cameraSensitivity = 90; + public float climbSpeed = 4; + public float normalMoveSpeed = 10; + public float slowMoveFactor = 0.25f; + public float fastMoveFactor = 3; + + private float rotationX = 0.0f; + private float rotationY = 0.0f; + + void Start() + { + Cursor.lockState = CursorLockMode.Confined; + rotationX = transform.localRotation.eulerAngles.y; + rotationY = -transform.localRotation.eulerAngles.x; + } + + void Update() + { + if(!Input.GetMouseButton(1)) + { + return; + } + + rotationX += Input.GetAxis("Mouse X") * cameraSensitivity * Time.deltaTime; + rotationY += Input.GetAxis("Mouse Y") * cameraSensitivity * Time.deltaTime; + rotationY = Mathf.Clamp(rotationY, -90, 90); + + transform.localRotation = Quaternion.AngleAxis(rotationX, Vector3.up); + transform.localRotation *= Quaternion.AngleAxis(rotationY, Vector3.left); + + if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) + { + transform.position += transform.forward * (normalMoveSpeed * fastMoveFactor) * Input.GetAxis("Vertical") * Time.deltaTime; + transform.position += transform.right * (normalMoveSpeed * fastMoveFactor) * Input.GetAxis("Horizontal") * Time.deltaTime; + } + else if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) + { + transform.position += transform.forward * (normalMoveSpeed * slowMoveFactor) * Input.GetAxis("Vertical") * Time.deltaTime; + transform.position += transform.right * (normalMoveSpeed * slowMoveFactor) * Input.GetAxis("Horizontal") * Time.deltaTime; + } + else + { + transform.position += transform.forward * normalMoveSpeed * Input.GetAxis("Vertical") * Time.deltaTime; + transform.position += transform.right * normalMoveSpeed * Input.GetAxis("Horizontal") * Time.deltaTime; + } + + if (Input.GetKey(KeyCode.Q)) { transform.position -= transform.up * climbSpeed * Time.deltaTime; } + if (Input.GetKey(KeyCode.E)) { transform.position += transform.up * climbSpeed * Time.deltaTime; } + + //if (Input.GetKeyDown(KeyCode.End)) + //{ + // Cursor.lockState = (Cursor.lockState == CursorLockMode.Confined) ? CursorLockMode.None : CursorLockMode.Confined; + //} + } +} diff --git a/examples/UnityExample/Assets/Scripts/FreeCamera.cs.meta b/examples/UnityExample/Assets/Scripts/FreeCamera.cs.meta new file mode 100644 index 0000000..081cae7 --- /dev/null +++ b/examples/UnityExample/Assets/Scripts/FreeCamera.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 29f022fb3768b8c4196631a9526aebcc +timeCreated: 1482928025 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/examples/UnityExample/ProjectSettings/AudioManager.asset b/examples/UnityExample/ProjectSettings/AudioManager.asset new file mode 100644 index 0000000..2c4f5a1 --- /dev/null +++ b/examples/UnityExample/ProjectSettings/AudioManager.asset @@ -0,0 +1,16 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!11 &1 +AudioManager: + m_ObjectHideFlags: 0 + m_Volume: 1 + Rolloff Scale: 1 + Doppler Factor: 1 + Default Speaker Mode: 2 + m_SampleRate: 0 + m_DSPBufferSize: 0 + m_VirtualVoiceCount: 512 + m_RealVoiceCount: 32 + m_SpatializerPlugin: + m_DisableAudio: 0 + m_VirtualizeEffects: 1 diff --git a/examples/UnityExample/ProjectSettings/ClusterInputManager.asset b/examples/UnityExample/ProjectSettings/ClusterInputManager.asset new file mode 100644 index 0000000..e7886b2 --- /dev/null +++ b/examples/UnityExample/ProjectSettings/ClusterInputManager.asset @@ -0,0 +1,6 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!236 &1 +ClusterInputManager: + m_ObjectHideFlags: 0 + m_Inputs: [] diff --git a/examples/UnityExample/ProjectSettings/DynamicsManager.asset b/examples/UnityExample/ProjectSettings/DynamicsManager.asset new file mode 100644 index 0000000..6be6910 --- /dev/null +++ b/examples/UnityExample/ProjectSettings/DynamicsManager.asset @@ -0,0 +1,18 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!55 &1 +PhysicsManager: + m_ObjectHideFlags: 0 + serializedVersion: 3 + m_Gravity: {x: 0, y: -9.81, z: 0} + m_DefaultMaterial: {fileID: 0} + m_BounceThreshold: 2 + m_SleepThreshold: 0.005 + m_DefaultContactOffset: 0.01 + m_DefaultSolverIterations: 6 + m_DefaultSolverVelocityIterations: 1 + m_QueriesHitBackfaces: 0 + m_QueriesHitTriggers: 1 + m_EnableAdaptiveForce: 0 + m_EnablePCM: 1 + m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff diff --git a/examples/UnityExample/ProjectSettings/EditorBuildSettings.asset b/examples/UnityExample/ProjectSettings/EditorBuildSettings.asset new file mode 100644 index 0000000..7a146e2 --- /dev/null +++ b/examples/UnityExample/ProjectSettings/EditorBuildSettings.asset @@ -0,0 +1,9 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1045 &1 +EditorBuildSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Scenes: + - enabled: 1 + path: Assets/Scenes/Test.unity diff --git a/examples/UnityExample/ProjectSettings/EditorSettings.asset b/examples/UnityExample/ProjectSettings/EditorSettings.asset new file mode 100644 index 0000000..7dff13c --- /dev/null +++ b/examples/UnityExample/ProjectSettings/EditorSettings.asset @@ -0,0 +1,14 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!159 &1 +EditorSettings: + m_ObjectHideFlags: 0 + serializedVersion: 3 + m_ExternalVersionControlSupport: Visible Meta Files + m_SerializationMode: 2 + m_DefaultBehaviorMode: 0 + m_SpritePackerMode: 2 + m_SpritePackerPaddingPower: 1 + m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd + m_ProjectGenerationRootNamespace: + m_UserGeneratedProjectSuffix: diff --git a/examples/UnityExample/ProjectSettings/GraphicsSettings.asset b/examples/UnityExample/ProjectSettings/GraphicsSettings.asset new file mode 100644 index 0000000..0502153 --- /dev/null +++ b/examples/UnityExample/ProjectSettings/GraphicsSettings.asset @@ -0,0 +1,64 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!30 &1 +GraphicsSettings: + m_ObjectHideFlags: 0 + serializedVersion: 9 + m_Deferred: + m_Mode: 1 + m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} + m_DeferredReflections: + m_Mode: 1 + m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} + m_ScreenSpaceShadows: + m_Mode: 1 + m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} + m_LegacyDeferred: + m_Mode: 1 + m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} + m_DepthNormals: + m_Mode: 1 + m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} + m_MotionVectors: + m_Mode: 1 + m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} + m_LightHalo: + m_Mode: 1 + m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} + m_LensFlare: + m_Mode: 1 + m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} + m_AlwaysIncludedShaders: + - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} + - {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0} + m_PreloadedShaders: [] + m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, + type: 0} + m_TierSettings_Tier1: + renderingPath: 1 + useCascadedShadowMaps: 1 + m_TierSettings_Tier2: + renderingPath: 1 + useCascadedShadowMaps: 1 + m_TierSettings_Tier3: + renderingPath: 1 + useCascadedShadowMaps: 1 + m_DefaultRenderingPath: 1 + m_DefaultMobileRenderingPath: 1 + m_TierSettings: [] + m_LightmapStripping: 0 + m_FogStripping: 0 + m_LightmapKeepPlain: 1 + m_LightmapKeepDirCombined: 1 + m_LightmapKeepDirSeparate: 1 + m_LightmapKeepDynamicPlain: 1 + m_LightmapKeepDynamicDirCombined: 1 + m_LightmapKeepDynamicDirSeparate: 1 + m_FogKeepLinear: 1 + m_FogKeepExp: 1 + m_FogKeepExp2: 1 diff --git a/examples/UnityExample/ProjectSettings/InputManager.asset b/examples/UnityExample/ProjectSettings/InputManager.asset new file mode 100644 index 0000000..17c8f53 --- /dev/null +++ b/examples/UnityExample/ProjectSettings/InputManager.asset @@ -0,0 +1,295 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!13 &1 +InputManager: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Axes: + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: left + positiveButton: right + altNegativeButton: a + altPositiveButton: d + gravity: 3 + dead: 0.001 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: down + positiveButton: up + altNegativeButton: s + altPositiveButton: w + gravity: 3 + dead: 0.001 + sensitivity: 3 + snap: 1 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left ctrl + altNegativeButton: + altPositiveButton: mouse 0 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left alt + altNegativeButton: + altPositiveButton: mouse 1 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: left shift + altNegativeButton: + altPositiveButton: mouse 2 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: space + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse X + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: 0.1 + snap: 0 + invert: 0 + type: 1 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse Y + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: 0.1 + snap: 0 + invert: 0 + type: 1 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Mouse ScrollWheel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0 + sensitivity: 0.1 + snap: 0 + invert: 0 + type: 1 + axis: 2 + joyNum: 0 + - serializedVersion: 3 + m_Name: Horizontal + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0.19 + sensitivity: 1 + snap: 0 + invert: 0 + type: 2 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Vertical + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: + altNegativeButton: + altPositiveButton: + gravity: 0 + dead: 0.19 + sensitivity: 1 + snap: 0 + invert: 1 + type: 2 + axis: 1 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire1 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 0 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire2 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 1 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Fire3 + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 2 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Jump + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: joystick button 3 + altNegativeButton: + altPositiveButton: + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Submit + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: return + altNegativeButton: + altPositiveButton: joystick button 0 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Submit + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: enter + altNegativeButton: + altPositiveButton: space + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 + - serializedVersion: 3 + m_Name: Cancel + descriptiveName: + descriptiveNegativeName: + negativeButton: + positiveButton: escape + altNegativeButton: + altPositiveButton: joystick button 1 + gravity: 1000 + dead: 0.001 + sensitivity: 1000 + snap: 0 + invert: 0 + type: 0 + axis: 0 + joyNum: 0 diff --git a/examples/UnityExample/ProjectSettings/NavMeshAreas.asset b/examples/UnityExample/ProjectSettings/NavMeshAreas.asset new file mode 100644 index 0000000..3a99a5a --- /dev/null +++ b/examples/UnityExample/ProjectSettings/NavMeshAreas.asset @@ -0,0 +1,71 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!126 &1 +NavMeshProjectSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + areas: + - name: Walkable + cost: 1 + - name: Not Walkable + cost: 1 + - name: Jump + cost: 2 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 + - name: + cost: 1 diff --git a/examples/UnityExample/ProjectSettings/NetworkManager.asset b/examples/UnityExample/ProjectSettings/NetworkManager.asset new file mode 100644 index 0000000..5dc6a83 --- /dev/null +++ b/examples/UnityExample/ProjectSettings/NetworkManager.asset @@ -0,0 +1,8 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!149 &1 +NetworkManager: + m_ObjectHideFlags: 0 + m_DebugLevel: 0 + m_Sendrate: 15 + m_AssetToPrefab: {} diff --git a/examples/UnityExample/ProjectSettings/Physics2DSettings.asset b/examples/UnityExample/ProjectSettings/Physics2DSettings.asset new file mode 100644 index 0000000..dd4738c --- /dev/null +++ b/examples/UnityExample/ProjectSettings/Physics2DSettings.asset @@ -0,0 +1,34 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!19 &1 +Physics2DSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Gravity: {x: 0, y: -9.81} + m_DefaultMaterial: {fileID: 0} + m_VelocityIterations: 8 + m_PositionIterations: 3 + m_VelocityThreshold: 1 + m_MaxLinearCorrection: 0.2 + m_MaxAngularCorrection: 8 + m_MaxTranslationSpeed: 100 + m_MaxRotationSpeed: 360 + m_MinPenetrationForPenalty: 0.01 + m_BaumgarteScale: 0.2 + m_BaumgarteTimeOfImpactScale: 0.75 + m_TimeToSleep: 0.5 + m_LinearSleepTolerance: 0.01 + m_AngularSleepTolerance: 2 + m_QueriesHitTriggers: 1 + m_QueriesStartInColliders: 1 + m_ChangeStopsCallbacks: 0 + m_AlwaysShowColliders: 0 + m_ShowColliderSleep: 1 + m_ShowColliderContacts: 0 + m_ShowColliderAABB: 0 + m_ContactArrowScale: 0.2 + m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} + m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} + m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} + m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} + m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff diff --git a/examples/UnityExample/ProjectSettings/ProjectSettings.asset b/examples/UnityExample/ProjectSettings/ProjectSettings.asset new file mode 100644 index 0000000..eea2fe5 --- /dev/null +++ b/examples/UnityExample/ProjectSettings/ProjectSettings.asset @@ -0,0 +1,459 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!129 &1 +PlayerSettings: + m_ObjectHideFlags: 0 + serializedVersion: 10 + productGUID: aff441ea2948d744488d81806e73ef59 + AndroidProfiler: 0 + defaultScreenOrientation: 4 + targetDevice: 2 + useOnDemandResources: 0 + accelerometerFrequency: 60 + companyName: DefaultCompany + productName: BlastUnity + defaultCursor: {fileID: 0} + cursorHotspot: {x: 0, y: 0} + m_SplashScreenBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21176471, a: 1} + m_ShowUnitySplashScreen: 1 + m_ShowUnitySplashLogo: 1 + m_SplashScreenOverlayOpacity: 1 + m_SplashScreenAnimation: 1 + m_SplashScreenLogoStyle: 1 + m_SplashScreenDrawMode: 0 + m_SplashScreenBackgroundAnimationZoom: 1 + m_SplashScreenLogoAnimationZoom: 1 + m_SplashScreenBackgroundLandscapeAspect: 1 + m_SplashScreenBackgroundPortraitAspect: 1 + m_SplashScreenBackgroundLandscapeUvs: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + m_SplashScreenBackgroundPortraitUvs: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + m_SplashScreenLogos: [] + m_SplashScreenBackgroundLandscape: {fileID: 0} + m_SplashScreenBackgroundPortrait: {fileID: 0} + m_VirtualRealitySplashScreen: {fileID: 0} + m_HolographicTrackingLossScreen: {fileID: 0} + defaultScreenWidth: 1024 + defaultScreenHeight: 768 + defaultScreenWidthWeb: 960 + defaultScreenHeightWeb: 600 + m_StereoRenderingPath: 0 + m_ActiveColorSpace: 0 + m_MTRendering: 1 + m_MobileMTRendering: 0 + m_StackTraceTypes: 010000000100000001000000010000000100000001000000 + iosShowActivityIndicatorOnLoading: -1 + androidShowActivityIndicatorOnLoading: -1 + tizenShowActivityIndicatorOnLoading: -1 + iosAppInBackgroundBehavior: 0 + displayResolutionDialog: 1 + iosAllowHTTPDownload: 1 + allowedAutorotateToPortrait: 1 + allowedAutorotateToPortraitUpsideDown: 1 + allowedAutorotateToLandscapeRight: 1 + allowedAutorotateToLandscapeLeft: 1 + useOSAutorotation: 1 + use32BitDisplayBuffer: 1 + disableDepthAndStencilBuffers: 0 + defaultIsFullScreen: 1 + defaultIsNativeResolution: 1 + runInBackground: 0 + captureSingleScreen: 0 + muteOtherAudioSources: 0 + Prepare IOS For Recording: 0 + submitAnalytics: 1 + usePlayerLog: 1 + bakeCollisionMeshes: 0 + forceSingleInstance: 0 + resizableWindow: 0 + useMacAppStoreValidation: 0 + gpuSkinning: 0 + graphicsJobs: 0 + xboxPIXTextureCapture: 0 + xboxEnableAvatar: 0 + xboxEnableKinect: 0 + xboxEnableKinectAutoTracking: 0 + xboxEnableFitness: 0 + visibleInBackground: 0 + allowFullscreenSwitch: 1 + macFullscreenMode: 2 + d3d9FullscreenMode: 1 + d3d11FullscreenMode: 1 + xboxSpeechDB: 0 + xboxEnableHeadOrientation: 0 + xboxEnableGuest: 0 + xboxEnablePIXSampling: 0 + n3dsDisableStereoscopicView: 0 + n3dsEnableSharedListOpt: 1 + n3dsEnableVSync: 0 + uiUse16BitDepthBuffer: 0 + ignoreAlphaClear: 0 + xboxOneResolution: 0 + xboxOneMonoLoggingLevel: 0 + xboxOneLoggingLevel: 1 + videoMemoryForVertexBuffers: 0 + psp2PowerMode: 0 + psp2AcquireBGM: 1 + wiiUTVResolution: 0 + wiiUGamePadMSAA: 1 + wiiUSupportsNunchuk: 0 + wiiUSupportsClassicController: 0 + wiiUSupportsBalanceBoard: 0 + wiiUSupportsMotionPlus: 0 + wiiUSupportsProController: 0 + wiiUAllowScreenCapture: 1 + wiiUControllerCount: 0 + m_SupportedAspectRatios: + 4:3: 1 + 5:4: 1 + 16:10: 1 + 16:9: 1 + Others: 1 + bundleIdentifier: com.Company.ProductName + bundleVersion: 1.0 + preloadedAssets: [] + metroInputSource: 0 + m_HolographicPauseOnTrackingLoss: 1 + xboxOneDisableKinectGpuReservation: 0 + protectGraphicsMemory: 0 + AndroidBundleVersionCode: 1 + AndroidMinSdkVersion: 9 + AndroidPreferredInstallLocation: 1 + aotOptions: + apiCompatibilityLevel: 2 + stripEngineCode: 1 + iPhoneStrippingLevel: 0 + iPhoneScriptCallOptimization: 0 + iPhoneBuildNumber: 0 + ForceInternetPermission: 0 + ForceSDCardPermission: 0 + CreateWallpaper: 0 + APKExpansionFiles: 0 + preloadShaders: 0 + StripUnusedMeshComponents: 0 + VertexChannelCompressionMask: + serializedVersion: 2 + m_Bits: 238 + iPhoneSdkVersion: 988 + iOSTargetOSVersionString: + tvOSSdkVersion: 0 + tvOSRequireExtendedGameController: 0 + tvOSTargetOSVersionString: + uIPrerenderedIcon: 0 + uIRequiresPersistentWiFi: 0 + uIRequiresFullScreen: 1 + uIStatusBarHidden: 1 + uIExitOnSuspend: 0 + uIStatusBarStyle: 0 + iPhoneSplashScreen: {fileID: 0} + iPhoneHighResSplashScreen: {fileID: 0} + iPhoneTallHighResSplashScreen: {fileID: 0} + iPhone47inSplashScreen: {fileID: 0} + iPhone55inPortraitSplashScreen: {fileID: 0} + iPhone55inLandscapeSplashScreen: {fileID: 0} + iPadPortraitSplashScreen: {fileID: 0} + iPadHighResPortraitSplashScreen: {fileID: 0} + iPadLandscapeSplashScreen: {fileID: 0} + iPadHighResLandscapeSplashScreen: {fileID: 0} + appleTVSplashScreen: {fileID: 0} + tvOSSmallIconLayers: [] + tvOSLargeIconLayers: [] + tvOSTopShelfImageLayers: [] + tvOSTopShelfImageWideLayers: [] + iOSLaunchScreenType: 0 + iOSLaunchScreenPortrait: {fileID: 0} + iOSLaunchScreenLandscape: {fileID: 0} + iOSLaunchScreenBackgroundColor: + serializedVersion: 2 + rgba: 0 + iOSLaunchScreenFillPct: 100 + iOSLaunchScreenSize: 100 + iOSLaunchScreenCustomXibPath: + iOSLaunchScreeniPadType: 0 + iOSLaunchScreeniPadImage: {fileID: 0} + iOSLaunchScreeniPadBackgroundColor: + serializedVersion: 2 + rgba: 0 + iOSLaunchScreeniPadFillPct: 100 + iOSLaunchScreeniPadSize: 100 + iOSLaunchScreeniPadCustomXibPath: + iOSDeviceRequirements: [] + iOSURLSchemes: [] + iOSBackgroundModes: 0 + iOSMetalForceHardShadows: 0 + appleDeveloperTeamID: + AndroidTargetDevice: 0 + AndroidSplashScreenScale: 0 + androidSplashScreen: {fileID: 0} + AndroidKeystoreName: + AndroidKeyaliasName: + AndroidTVCompatibility: 1 + AndroidIsGame: 1 + androidEnableBanner: 1 + m_AndroidBanners: + - width: 320 + height: 180 + banner: {fileID: 0} + androidGamepadSupportLevel: 0 + resolutionDialogBanner: {fileID: 0} + m_BuildTargetIcons: [] + m_BuildTargetBatching: [] + m_BuildTargetGraphicsAPIs: [] + m_BuildTargetVRSettings: [] + openGLRequireES31: 0 + openGLRequireES31AEP: 0 + webPlayerTemplate: APPLICATION:Default + m_TemplateCustomTags: {} + wiiUTitleID: 0005000011000000 + wiiUGroupID: 00010000 + wiiUCommonSaveSize: 4096 + wiiUAccountSaveSize: 2048 + wiiUOlvAccessKey: 0 + wiiUTinCode: 0 + wiiUJoinGameId: 0 + wiiUJoinGameModeMask: 0000000000000000 + wiiUCommonBossSize: 0 + wiiUAccountBossSize: 0 + wiiUAddOnUniqueIDs: [] + wiiUMainThreadStackSize: 3072 + wiiULoaderThreadStackSize: 1024 + wiiUSystemHeapSize: 128 + wiiUTVStartupScreen: {fileID: 0} + wiiUGamePadStartupScreen: {fileID: 0} + wiiUDrcBufferDisabled: 0 + wiiUProfilerLibPath: + actionOnDotNetUnhandledException: 1 + enableInternalProfiler: 0 + logObjCUncaughtExceptions: 1 + enableCrashReportAPI: 0 + cameraUsageDescription: + locationUsageDescription: + microphoneUsageDescription: + XboxTitleId: + XboxImageXexPath: + XboxSpaPath: + XboxGenerateSpa: 0 + XboxDeployKinectResources: 0 + XboxSplashScreen: {fileID: 0} + xboxEnableSpeech: 0 + xboxAdditionalTitleMemorySize: 0 + xboxDeployKinectHeadOrientation: 0 + xboxDeployKinectHeadPosition: 0 + ps4NPAgeRating: 12 + ps4NPTitleSecret: + ps4NPTrophyPackPath: + ps4ParentalLevel: 1 + ps4ContentID: ED1633-NPXX51362_00-0000000000000000 + ps4Category: 0 + ps4MasterVersion: 01.00 + ps4AppVersion: 01.00 + ps4AppType: 0 + ps4ParamSfxPath: + ps4VideoOutPixelFormat: 0 + ps4VideoOutInitialWidth: 1920 + ps4VideoOutReprojectionRate: 120 + ps4PronunciationXMLPath: + ps4PronunciationSIGPath: + ps4BackgroundImagePath: + ps4StartupImagePath: + ps4SaveDataImagePath: + ps4SdkOverride: + ps4BGMPath: + ps4ShareFilePath: + ps4ShareOverlayImagePath: + ps4PrivacyGuardImagePath: + ps4NPtitleDatPath: + ps4RemotePlayKeyAssignment: -1 + ps4RemotePlayKeyMappingDir: + ps4PlayTogetherPlayerCount: 0 + ps4EnterButtonAssignment: 1 + ps4ApplicationParam1: 0 + ps4ApplicationParam2: 0 + ps4ApplicationParam3: 0 + ps4ApplicationParam4: 0 + ps4DownloadDataSize: 0 + ps4GarlicHeapSize: 2048 + ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ + ps4UseDebugIl2cppLibs: 0 + ps4pnSessions: 1 + ps4pnPresence: 1 + ps4pnFriends: 1 + ps4pnGameCustomData: 1 + playerPrefsSupport: 0 + restrictedAudioUsageRights: 0 + ps4UseResolutionFallback: 0 + ps4ReprojectionSupport: 0 + ps4UseAudio3dBackend: 0 + ps4SocialScreenEnabled: 0 + ps4ScriptOptimizationLevel: 3 + ps4Audio3dVirtualSpeakerCount: 14 + ps4attribCpuUsage: 0 + ps4PatchPkgPath: + ps4PatchLatestPkgPath: + ps4PatchChangeinfoPath: + ps4PatchDayOne: 0 + ps4attribUserManagement: 0 + ps4attribMoveSupport: 0 + ps4attrib3DSupport: 0 + ps4attribShareSupport: 0 + ps4attribExclusiveVR: 0 + ps4disableAutoHideSplash: 0 + ps4IncludedModules: [] + monoEnv: + psp2Splashimage: {fileID: 0} + psp2NPTrophyPackPath: + psp2NPSupportGBMorGJP: 0 + psp2NPAgeRating: 12 + psp2NPTitleDatPath: + psp2NPCommsID: + psp2NPCommunicationsID: + psp2NPCommsPassphrase: + psp2NPCommsSig: + psp2ParamSfxPath: + psp2ManualPath: + psp2LiveAreaGatePath: + psp2LiveAreaBackroundPath: + psp2LiveAreaPath: + psp2LiveAreaTrialPath: + psp2PatchChangeInfoPath: + psp2PatchOriginalPackage: + psp2PackagePassword: F69AzBlax3CF3EDNhm3soLBPh71Yexui + psp2KeystoneFile: + psp2MemoryExpansionMode: 0 + psp2DRMType: 0 + psp2StorageType: 0 + psp2MediaCapacity: 0 + psp2DLCConfigPath: + psp2ThumbnailPath: + psp2BackgroundPath: + psp2SoundPath: + psp2TrophyCommId: + psp2TrophyPackagePath: + psp2PackagedResourcesPath: + psp2SaveDataQuota: 10240 + psp2ParentalLevel: 1 + psp2ShortTitle: Not Set + psp2ContentID: IV0000-ABCD12345_00-0123456789ABCDEF + psp2Category: 0 + psp2MasterVersion: 01.00 + psp2AppVersion: 01.00 + psp2TVBootMode: 0 + psp2EnterButtonAssignment: 2 + psp2TVDisableEmu: 0 + psp2AllowTwitterDialog: 1 + psp2Upgradable: 0 + psp2HealthWarning: 0 + psp2UseLibLocation: 0 + psp2InfoBarOnStartup: 0 + psp2InfoBarColor: 0 + psp2UseDebugIl2cppLibs: 0 + psmSplashimage: {fileID: 0} + splashScreenBackgroundSourceLandscape: {fileID: 0} + splashScreenBackgroundSourcePortrait: {fileID: 0} + spritePackerPolicy: + webGLMemorySize: 256 + webGLExceptionSupport: 1 + webGLDataCaching: 0 + webGLDebugSymbols: 0 + webGLEmscriptenArgs: + webGLModulesDirectory: + webGLTemplate: APPLICATION:Default + webGLAnalyzeBuildSize: 0 + webGLUseEmbeddedResources: 0 + webGLUseWasm: 0 + webGLCompressionFormat: 1 + scriptingDefineSymbols: {} + platformArchitecture: {} + scriptingBackend: {} + incrementalIl2cppBuild: {} + additionalIl2CppArgs: + m_RenderingPath: 1 + m_MobileRenderingPath: 1 + metroPackageName: BlastUnity + metroPackageVersion: + metroCertificatePath: + metroCertificatePassword: + metroCertificateSubject: + metroCertificateIssuer: + metroCertificateNotAfter: 0000000000000000 + metroApplicationDescription: BlastUnity + wsaImages: {} + metroTileShortName: + metroCommandLineArgsFile: + metroTileShowName: 0 + metroMediumTileShowName: 0 + metroLargeTileShowName: 0 + metroWideTileShowName: 0 + metroDefaultTileSize: 1 + metroTileForegroundText: 2 + metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0} + metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, + a: 1} + metroSplashScreenUseBackgroundColor: 0 + platformCapabilities: {} + metroFTAName: + metroFTAFileTypes: [] + metroProtocolName: + metroCompilationOverrides: 1 + tizenProductDescription: + tizenProductURL: + tizenSigningProfileName: + tizenGPSPermissions: 0 + tizenMicrophonePermissions: 0 + tizenDeploymentTarget: + tizenDeploymentTargetType: 0 + tizenMinOSVersion: 0 + n3dsUseExtSaveData: 0 + n3dsCompressStaticMem: 1 + n3dsExtSaveDataNumber: 0x12345 + n3dsStackSize: 131072 + n3dsTargetPlatform: 2 + n3dsRegion: 7 + n3dsMediaSize: 0 + n3dsLogoStyle: 3 + n3dsTitle: GameName + n3dsProductCode: + n3dsApplicationId: 0xFF3FF + stvDeviceAddress: + stvProductDescription: + stvProductAuthor: + stvProductAuthorEmail: + stvProductLink: + stvProductCategory: 0 + XboxOneProductId: + XboxOneUpdateKey: + XboxOneSandboxId: + XboxOneContentId: + XboxOneTitleId: + XboxOneSCId: + XboxOneGameOsOverridePath: + XboxOnePackagingOverridePath: + XboxOneAppManifestOverridePath: + XboxOnePackageEncryption: 0 + XboxOnePackageUpdateGranularity: 2 + XboxOneDescription: + XboxOneLanguage: + - enus + XboxOneCapability: [] + XboxOneGameRating: {} + XboxOneIsContentPackage: 0 + XboxOneEnableGPUVariability: 0 + XboxOneSockets: {} + XboxOneSplashScreen: {fileID: 0} + XboxOneAllowedProductIds: [] + XboxOnePersistentLocalStorageSize: 0 + vrEditorSettings: {} + cloudServicesEnabled: {} + cloudProjectId: + projectName: + organizationId: + cloudEnabled: 0 diff --git a/examples/UnityExample/ProjectSettings/ProjectVersion.txt b/examples/UnityExample/ProjectSettings/ProjectVersion.txt new file mode 100644 index 0000000..66e05aa --- /dev/null +++ b/examples/UnityExample/ProjectSettings/ProjectVersion.txt @@ -0,0 +1 @@ +m_EditorVersion: 5.5.0f3 diff --git a/examples/UnityExample/ProjectSettings/QualitySettings.asset b/examples/UnityExample/ProjectSettings/QualitySettings.asset new file mode 100644 index 0000000..0d9af3e --- /dev/null +++ b/examples/UnityExample/ProjectSettings/QualitySettings.asset @@ -0,0 +1,180 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!47 &1 +QualitySettings: + m_ObjectHideFlags: 0 + serializedVersion: 5 + m_CurrentQuality: 5 + m_QualitySettings: + - serializedVersion: 2 + name: Fastest + pixelLightCount: 0 + shadows: 0 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 15 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + blendWeights: 1 + textureQuality: 1 + anisotropicTextures: 0 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 0 + lodBias: 0.3 + maximumLODLevel: 0 + particleRaycastBudget: 4 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Fast + pixelLightCount: 0 + shadows: 0 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 20 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 0 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 0 + lodBias: 0.4 + maximumLODLevel: 0 + particleRaycastBudget: 16 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Simple + pixelLightCount: 1 + shadows: 1 + shadowResolution: 0 + shadowProjection: 1 + shadowCascades: 1 + shadowDistance: 20 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 1 + antiAliasing: 0 + softParticles: 0 + softVegetation: 0 + realtimeReflectionProbes: 0 + billboardsFaceCameraPosition: 0 + vSyncCount: 1 + lodBias: 0.7 + maximumLODLevel: 0 + particleRaycastBudget: 64 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Good + pixelLightCount: 2 + shadows: 2 + shadowResolution: 1 + shadowProjection: 1 + shadowCascades: 2 + shadowDistance: 40 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + blendWeights: 2 + textureQuality: 0 + anisotropicTextures: 1 + antiAliasing: 0 + softParticles: 0 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 1 + maximumLODLevel: 0 + particleRaycastBudget: 256 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Beautiful + pixelLightCount: 3 + shadows: 2 + shadowResolution: 2 + shadowProjection: 1 + shadowCascades: 2 + shadowDistance: 70 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + blendWeights: 4 + textureQuality: 0 + anisotropicTextures: 2 + antiAliasing: 2 + softParticles: 1 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 1.5 + maximumLODLevel: 0 + particleRaycastBudget: 1024 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + excludedTargetPlatforms: [] + - serializedVersion: 2 + name: Fantastic + pixelLightCount: 4 + shadows: 2 + shadowResolution: 2 + shadowProjection: 1 + shadowCascades: 4 + shadowDistance: 150 + shadowNearPlaneOffset: 3 + shadowCascade2Split: 0.33333334 + shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} + blendWeights: 4 + textureQuality: 0 + anisotropicTextures: 2 + antiAliasing: 2 + softParticles: 1 + softVegetation: 1 + realtimeReflectionProbes: 1 + billboardsFaceCameraPosition: 1 + vSyncCount: 1 + lodBias: 2 + maximumLODLevel: 0 + particleRaycastBudget: 4096 + asyncUploadTimeSlice: 2 + asyncUploadBufferSize: 4 + excludedTargetPlatforms: [] + m_PerPlatformDefaultQuality: + Android: 2 + Nintendo 3DS: 5 + PS4: 5 + PSM: 5 + PSP2: 2 + Samsung TV: 2 + Standalone: 5 + Tizen: 2 + Web: 5 + WebGL: 3 + WiiU: 5 + Windows Store Apps: 5 + XboxOne: 5 + iPhone: 2 + tvOS: 5 diff --git a/examples/UnityExample/ProjectSettings/TagManager.asset b/examples/UnityExample/ProjectSettings/TagManager.asset new file mode 100644 index 0000000..1c92a78 --- /dev/null +++ b/examples/UnityExample/ProjectSettings/TagManager.asset @@ -0,0 +1,43 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!78 &1 +TagManager: + serializedVersion: 2 + tags: [] + layers: + - Default + - TransparentFX + - Ignore Raycast + - + - Water + - UI + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + m_SortingLayers: + - name: Default + uniqueID: 0 + locked: 0 diff --git a/examples/UnityExample/ProjectSettings/TimeManager.asset b/examples/UnityExample/ProjectSettings/TimeManager.asset new file mode 100644 index 0000000..558a017 --- /dev/null +++ b/examples/UnityExample/ProjectSettings/TimeManager.asset @@ -0,0 +1,9 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!5 &1 +TimeManager: + m_ObjectHideFlags: 0 + Fixed Timestep: 0.02 + Maximum Allowed Timestep: 0.33333334 + m_TimeScale: 1 + Maximum Particle Timestep: 0.03 diff --git a/examples/UnityExample/ProjectSettings/UnityConnectSettings.asset b/examples/UnityExample/ProjectSettings/UnityConnectSettings.asset new file mode 100644 index 0000000..2943e44 --- /dev/null +++ b/examples/UnityExample/ProjectSettings/UnityConnectSettings.asset @@ -0,0 +1,29 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!310 &1 +UnityConnectSettings: + m_ObjectHideFlags: 0 + m_Enabled: 0 + m_TestMode: 0 + m_TestEventUrl: + m_TestConfigUrl: + CrashReportingSettings: + m_EventUrl: https://perf-events.cloud.unity3d.com/api/events/crashes + m_Enabled: 0 + m_CaptureEditorExceptions: 1 + UnityPurchasingSettings: + m_Enabled: 0 + m_TestMode: 0 + UnityAnalyticsSettings: + m_Enabled: 0 + m_InitializeOnStartup: 1 + m_TestMode: 0 + m_TestEventUrl: + m_TestConfigUrl: + UnityAdsSettings: + m_Enabled: 0 + m_InitializeOnStartup: 1 + m_TestMode: 0 + m_EnabledPlatforms: 4294967295 + m_IosGameId: + m_AndroidGameId: diff --git a/examples/UnityExample/copy_dlls.bat b/examples/UnityExample/copy_dlls.bat new file mode 100644 index 0000000..620a0db --- /dev/null +++ b/examples/UnityExample/copy_dlls.bat @@ -0,0 +1,24 @@ +@echo off + +CALL :COPY_DLL NvBlast_x64.dll ..\..\bin\vc14win64-cmake Assets\Plugins\Blast\x64 +CALL :COPY_DLL NvBlastDEBUG_x64.dll ..\..\bin\vc14win64-cmake Assets\Plugins\Blast\x64 +CALL :COPY_DLL NvBlastExtCommonDEBUG_x64.dll ..\..\bin\vc14win64-cmake Assets\Plugins\Blast\x64 +CALL :COPY_DLL NvBlastExtCommon_x64.dll ..\..\bin\vc14win64-cmake Assets\Plugins\Blast\x64 +CALL :COPY_DLL NvBlastExtShadersDEBUG_x64.dll ..\..\bin\vc14win64-cmake Assets\Plugins\Blast\x64 +CALL :COPY_DLL NvBlastExtShaders_x64.dll ..\..\bin\vc14win64-cmake Assets\Plugins\Blast\x64 +CALL :COPY_DLL NvBlastExtUtilsDEBUG_x64.dll ..\..\bin\vc14win64-cmake Assets\Plugins\Blast\x64 +CALL :COPY_DLL NvBlastExtUtils_x64.dll ..\..\bin\vc14win64-cmake Assets\Plugins\Blast\x64 + +GOTO END + +:COPY_DLL +if NOT EXIST %3 MKDIR %3 +IF NOT EXIST %2\%1 ( + REM ECHO File doesn't exist %1 +) ELSE ( + ECHO COPY "%2\%1" "%3\%1" + COPY "%2\%1" "%3\%1" +) +GOTO END + +:END diff --git a/examples/UnityExample/readme.md b/examples/UnityExample/readme.md new file mode 100644 index 0000000..4d36e9b --- /dev/null +++ b/examples/UnityExample/readme.md @@ -0,0 +1,15 @@ +# Blast Unity3D Integration Example + +This project shows simple Unity3D Blast integration. + +## Running + +[Optionally] Build Blast SDK, Blast LowLevel Dll and Extension Dlls are used for this example and copy needed dlls into Asset/Plugins/Blast/x64 or use copy_dlls.bat + +1. Open root folder in Unity3D. +2. Open Test.scene +3. Hit 'Play' ! + +## Supported Platforms + +* Windows x64 |