public static void WritePadding(BinaryWriter bw) { var padding = BFast.ComputePadding(bw.BaseStream.Position); for (var i = 0; i < padding; ++i) { bw.Write((byte)0); } }
public G3D(IEnumerable <IAttribute> attributes, BFast buffer = null, string header = null) { Buffer = buffer; Header = header; Attributes = attributes.WhereNotNull(); VertexAttribute = this.FindAttribute(AttributeType.attr_vertex); IndexAttribute = this.FindAttribute(AttributeType.attr_index, false); FaceSizeAttribute = this.FindAttribute(AttributeType.attr_facesize, false); FaceIndexAttribute = this.FindAttribute(AttributeType.attr_faceindex, false); MaterialIdAttribute = this.FindAttribute(AttributeType.attr_materialid, false); // Check that everything is kosher // TODO: this is a long process, only do it in specific circumstances. //this.Validate(); }
public static G3D Create(BFast bfast) { if (bfast.Buffers.Count < 2) { throw new Exception("Expected at least two data buffers in file: header, and attribute descriptor array"); } var header = bfast.Buffers[0].ToBytes().ToUtf8(); var descriptors = bfast.Buffers[1].ToStructs <AttributeDescriptor>(); var buffers = bfast.Buffers.Skip(2).ToArray(); if (descriptors.Length != buffers.Length) { throw new Exception("Incorrect number of descriptors"); } return(new G3D(buffers.Zip(descriptors, G3DExtensions.ToAttribute), bfast, header)); }
public static List <IGeometry> LoadGeometries(this BFast bfast) => bfast.Buffers .AsParallel().AsOrdered() .Select(b => G3D.Create(b).ToIGeometry()) .ToList();
public static G3D ToG3D(this BFast bfast) => G3D.Create(bfast);