示例#1
0
文件: Batch.cs 项目: opeyx/Dolhouse
        /// <summary>
        /// Read a single batch from BIN.
        /// </summary>
        /// <param name="br">The binaryreader to write with.</param>
        /// <param name="batchesOffset">Offset to batches.</param>
        public Batch(DhBinaryReader br, long batchesOffset)
        {
            // Read face count.
            FaceCount = br.ReadU16();

            // Read primitive list size.
            ListSize = br.ReadS16();

            // Read vertex attributes.
            VertexAttributes = (Attributes)br.ReadU32();

            // Read UseNormals flag.
            UseNormals = br.ReadBool8();

            // Read Position Winding.
            Positions = br.Read();

            // Read UV Count.
            UvCount = br.Read();

            // Read UseNBT flag.
            UseNBT = br.ReadBool8();

            // Read Primitive offset.
            PrimitiveOffset = br.ReadU32();

            // Read Unknown 1. (Padding?)
            Unknown1 = br.ReadS32s(2);

            // Save the current position.
            long currentPosition = br.Position();

            // Go to the batch's primitive offset offset.
            br.Goto(batchesOffset + PrimitiveOffset);

            // Define list to hold batch's primitives.
            Primitives = new List <Primitive>();

            // Define int to keep track of the amount of faces read.
            int readFaces = 0;

            // Read primitives until batch's face count has been reached.
            while ((readFaces < FaceCount) && (br.Position() < (batchesOffset + PrimitiveOffset + (ListSize << 5))))
            {
                // Read primitive.
                Primitive binPrimitive = new Primitive(br, VertexAttributes, UseNBT);

                // Add the primitive to the batch's primitives.
                Primitives.Add(binPrimitive);

                // Add primitive's face count to the read faces counter.
                readFaces += binPrimitive.FaceCount;
            }

            // Go to the previously saved offset.
            br.Goto(currentPosition);
        }
示例#2
0
        /// <summary>
        /// Reads ANM from a data stream.
        /// </summary>
        /// <param name="stream">The stream containing the ANM data.</param>
        public ANM(Stream stream)
        {
            // Define a binary reader to read with.
            DhBinaryReader br = new DhBinaryReader(stream, DhEndian.Big);

            // Reader ANM's Header.
            Version        = br.ReadU8();
            Loop           = br.ReadBool8();
            Unknown1       = br.ReadS16();
            KeyFrameCount  = br.ReadU32();
            KeyFrameOffset = br.ReadU32();
            Unknown2       = br.ReadS32();
            Unknown3       = br.ReadS32();
            Unknown4       = br.ReadS32();

            /*
             *  Keyframes - Interpolation type list:
             *  https://ia800802.us.archive.org/9/items/GCN_SDK_Documentation/Game%20Engine%20Programming.pdf
             */
        }
示例#3
0
        /// <summary>
        /// Read a single shader from BIN.
        /// </summary>
        /// <param name="br">Binary Reader to use.</param>
        public Shader(DhBinaryReader br)
        {
            // Read Dynamic Lighting Flag.
            UseDynamicLighting = br.ReadBool8();

            // Read Unknown 2.
            Unknown2 = br.Read();

            // Read Unknown 3.
            Unknown3 = br.Read();

            // Read Tint.
            Tint = br.ReadClr4();

            // Read Unknown 4. (Padding)
            Unknown4 = br.Read();

            // Read Material Indices array.
            MaterialIndices = br.ReadS16s(8);

            // Read Unknown 5 array. (Indices?)
            Unknown5 = br.ReadS16s(8);
        }