private static Boolean TryGetNamedMesh(BinaryReader reader, Double fbxVersion, FbxNodeMetaData meta, out NamedMesh mesh) { var meshName = GetNameFromProperties(reader, meta); return(TryGetNamedMesh(reader, meshName, fbxVersion, out mesh)); }
private static Boolean TryGetNamedMesh(BinaryReader reader, String meshName, Double fbxVersion, out NamedMesh mesh) { Double[]? allMyPoints = null; Int32[]? allMyIndeces = null; Vector3[]? allMyVectors = null; while (true) { var meta = GetNodeMeta(reader, fbxVersion); if (meta.IsEmpty) { if (allMyPoints == null || allMyIndeces == null || allMyVectors == null) { goto fail; } Debug.WriteLine("mesh " + meshName + " has " + allMyVectors.Length + " vectors"); var allMyFaces = EarClipping.GetFaces(allMyVectors, allMyIndeces); mesh = new NamedMesh(allMyVectors, allMyFaces, meshName); return(true); } var nomnom = meta.GetName(reader); switch (nomnom) { case "Vertices": switch ((Char)reader.ReadByte()) { case 'd': allMyPoints = ReadArray(reader, br => br.ReadDouble()); allMyVectors = new Vector3[allMyPoints.Length / 3]; var i = 0; for (var c = 0; c + 2 < allMyPoints.Length;) { allMyVectors[i++] = new Vector3(allMyPoints[c++], allMyPoints[c++], allMyPoints[c++]); } break; default: throw new NotImplementedException(); } break; case "PolygonVertexIndex": var doWot = (Char)reader.ReadByte(); switch (doWot) { case 'i': allMyIndeces = ReadArray(reader, br => br.ReadInt32()); break; default: throw new NotImplementedException(); } break; default: meta.SkipData(reader); break; } } fail: mesh = default !;