/// <summary> /// Libera los recursos de la malla /// </summary> public void Dispose() { enabled = false; if (boundingBox != null) { boundingBox.Dispose(); } //Si es una instancia no liberar nada, lo hace el original. if (parentInstance != null) { parentInstance = null; return; } //hacer dispose de instancias foreach (var meshInstance in meshInstances) { meshInstance.Dispose(); } meshInstances = null; //Dispose de mesh d3dMesh.Dispose(); d3dMesh = null; //Dispose de texturas if (diffuseMaps != null) { for (var i = 0; i < diffuseMaps.Length; i++) { diffuseMaps[i].dispose(); } diffuseMaps = null; } //Dispose de Box de joints if (skeletonRenderJoints != null) { foreach (var jointBox in skeletonRenderJoints) { jointBox.Dispose(); } skeletonRenderJoints = null; } //Dispose de lineas de Bones if (skeletonRenderBones != null) { foreach (var boneLine in skeletonRenderBones) { if (boneLine != null) { boneLine.Dispose(); } } skeletonRenderBones = null; } //Liberar attachments foreach (var attach in attachments) { attach.Mesh.Dispose(); } attachments = null; //VertexDeclaration vertexDeclaration.Dispose(); vertexDeclaration = null; }