Exemple #1
0
 public void Dispose()
 {
     _fbx?.Dispose();
     _textures.Dispose();
     _indices.Dispose();
     _vertices.Dispose();
     _skeletons.Dispose();
 }
Exemple #2
0
        internal static FbxSemanticsUnsafe <TVertex> ParseUnsafe(Stream stream, bool leaveStreamOpen = true, CancellationToken cancellationToken = default)
        {
            ValueTypeRentMemory <RawString> textures = default;
            FbxObject?fbx = null;

            try {
                var vertexCreator = SkinnedVertexCreator <TVertex> .Build();

                fbx = FbxParser.Parse(stream);
                using var resolver = new SemanticResolver(fbx);
                var objectsNode = resolver.ObjectsNode;
                var(meshes, skeletons) = ParseMeshAndSkeleton(resolver, vertexCreator, cancellationToken);
                try {
                    using (meshes) {
                        textures = ParseTexture(objectsNode, cancellationToken);
                        //ParseMaterial(objectsNode);
                        var(vertices, indices) = meshes.CreateCombined();
                        return(new FbxSemanticsUnsafe <TVertex>(ref fbx, ref indices, ref vertices, ref textures, ref skeletons));
                    }
                }
                catch {
                    skeletons.Dispose();
                    throw;
                }
            }
            catch {
                fbx?.Dispose();
                textures.Dispose();
                throw;
            }
            finally {
                if (leaveStreamOpen == false)
                {
                    stream?.Dispose();
                }
            }
        }