protected void CreateBufferFromFile(Device device, string fileName) { DebugVertexType[] vertices; UInt16[] indices; ModelLoader modelLoader = new ModelLoader(device); modelLoader.LoadPrimitveFromFile(fileName, out vertices, out indices); m_vertexCount = vertices.Length; m_indexCount = indices.Length; BufferDescription vertexBufferDescription = new BufferDescription(Utilities.SizeOf <DebugVertexType>() * m_vertexCount, BindFlags.VertexBuffer, ResourceUsage.Default); m_vertexBuffer = Buffer.Create(device, vertices, vertexBufferDescription); m_indexBuffer = Buffer.Create(device, BindFlags.IndexBuffer, indices); BufferDescription instanceBufferDesc = new BufferDescription() { BindFlags = BindFlags.VertexBuffer, CpuAccessFlags = CpuAccessFlags.Write, OptionFlags = ResourceOptionFlags.None, SizeInBytes = Utilities.SizeOf <PrimitivePerInstanceData>() * MAX_NUM_INSTANCES, Usage = ResourceUsage.Dynamic }; m_instanceBuffer = new Buffer(device, instanceBufferDesc); modelLoader.Dispose(); }
public void CleanByScene() { //Debug.Log("Assembler.Clean "); mCorout_isRunning = false; this.StopCoroutine("LoadCoroutine"); //StopAllCoroutines(); foreach (var gameObj in m_Objects.Values) { GameObject go = (GameObject)gameObj; if (go != null) { go.SetActive(true); UnityEngine.Object.DestroyImmediate(go); go = null; } } m_Objects.Clear(); foreach (CharacterLoader item in s_CharacterLoaders.Values) { CharacterLoader loader = (CharacterLoader)item; loader.Dispose(); loader = null; } s_CharacterLoaders.Clear(); foreach (ModelLoader item in s_ModelLoaders.Values) { ModelLoader loader = (ModelLoader)item; loader.Dispose(); loader = null; } s_ModelLoaders.Clear(); foreach (CharacterElementLoader item in s_CharacterElementLoaders.Values) { CharacterElementLoader loader = (CharacterElementLoader)item; loader.Dispose(); loader = null; } s_CharacterElementLoaders.Clear(); foreach (AnimationLoader item in s_AnimationAssemblers.Values) { AnimationLoader loader = (AnimationLoader)item; loader.Dispose(); loader = null; } s_AnimationAssemblers.Clear(); foreach (var item in m_Assemblers.Values) { AssemblerInfo loader = (AssemblerInfo)item; loader = null; } m_Assemblers.Clear(); mUniqueID = 1; OnFinishLoading = null; }