コード例 #1
0
        public static void WritePadding(BinaryWriter bw)
        {
            var padding = BFast.ComputePadding(bw.BaseStream.Position);

            for (var i = 0; i < padding; ++i)
            {
                bw.Write((byte)0);
            }
        }
コード例 #2
0
ファイル: G3d.cs プロジェクト: vimaec/ara3d-dev
        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();
        }
コード例 #3
0
ファイル: G3d.cs プロジェクト: vimaec/ara3d-dev
        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));
        }
コード例 #4
0
ファイル: GeometryReader.cs プロジェクト: vimaec/ara3d-dev
 public static List <IGeometry> LoadGeometries(this BFast bfast)
 => bfast.Buffers
 .AsParallel().AsOrdered()
 .Select(b => G3D.Create(b).ToIGeometry())
 .ToList();
コード例 #5
0
ファイル: G3DExtensions.cs プロジェクト: vimaec/ara3d-dev
 public static G3D ToG3D(this BFast bfast)
 => G3D.Create(bfast);