Esempio n. 1
0
        /// <summary>
        /// Read a single primitive vertex from BIN.
        /// </summary>
        /// <param name="br">Binary Reader to use.</param>
        public BinPrimitiveVertex(DhBinaryReader br, byte useNBT, int uvCount, BinBatchAttributes attributes)
        {
            // Read Matrix Index.
            MatrixIndex = br.ReadS16();

            // Check position attribute.
            if (attributes.HasFlag(BinBatchAttributes.Position))
            {
                // Read Position Index.
                PositionIndex = br.ReadS16();
            }

            // Check normal attribute.
            if (attributes.HasFlag(BinBatchAttributes.Normal))
            {
                // Read Normal Index.
                NormalIndex = br.ReadS16();

                // Check UseNBT flag.
                if (useNBT == 1)
                {
                    // Read BiNormal Index.
                    BiNormalIndex = br.ReadS16();

                    // Read Tangent Index.
                    TangentIndex = br.ReadS16();
                }
            }

            // Define ColorIndex array to hold ColorIndex values.
            ColorIndex = new short[2];

            // Check color2 attribute.
            if (attributes.HasFlag(BinBatchAttributes.Color0))
            {
                // Read the Color1 value.
                ColorIndex[0] = br.ReadS16();
            }

            // Check color1 attribute.
            if (attributes.HasFlag(BinBatchAttributes.Color1))
            {
                // Read the Color1 value.
                ColorIndex[1] = br.ReadS16();
            }

            // Define UVIndex array to hold UVIndex values.
            UVIndex = new short[8];

            // Loop through texCoords.
            for (int i = 0; i < uvCount; i++)
            {
                // Check texCoordX attribute.
                if (attributes.HasFlag((BinBatchAttributes)(1 << (13 + i))))
                {
                    // Read the current UVIndex value.
                    UVIndex[i] = br.ReadS16();
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Read a single primitive from BIN.
        /// </summary>
        /// <param name="br">Binary Reader to use.</param>
        public BinPrimitive(DhBinaryReader br, byte useNBT, int uvCount, BinBatchAttributes attributes)
        {
            // Read Primitive Type.
            Type = br.Read();

            // Read number of vertices.
            VerticeCount = br.ReadS16();

            // Define ColorIndex array to hold primitive vertices.
            Vertices = new List <BinPrimitiveVertex>();

            // Loop through primitive vertices.
            for (int i = 0; i < VerticeCount; i++)
            {
                // Read a primitive vertex and add it to the list.
                Vertices.Add(new BinPrimitiveVertex(br, useNBT, uvCount, attributes));
            }
        }