コード例 #1
0
 public SoundBankFile(SoundBank parent, EndianReader reader)
 {
     ParentBank = parent;
     ID = reader.ReadUInt32();
     Offset = reader.ReadInt32();
     Size = reader.ReadInt32();
 }
コード例 #2
0
 public SoundPathPoint(EndianReader reader)
 {
     X = reader.ReadSingle();
     reader.Skip(4); // Unknown
     Y = reader.ReadSingle();
     Duration = reader.ReadInt32();
 }
コード例 #3
0
        public SoundBankMusicTrack(EndianReader reader, uint id)
        {
            ID = id;

            reader.Skip(0xC);
            AudioID = reader.ReadUInt32();
            SourceID = reader.ReadUInt32();
        }
コード例 #4
0
 public static void Copy(EndianReader input, EndianWriter output)
 {
     // http://stackoverflow.com/questions/230128/best-way-to-copy-between-two-stream-instances-c-sharp
     const int BufferSize = 0x1000;
     byte[] buffer = new byte[BufferSize];
     int read;
     while ((read = input.ReadBlock(buffer, 0, BufferSize)) > 0)
         output.WriteBlock(buffer, 0, read);
 }
コード例 #5
0
 public SoundPackFile(SoundPack parent, EndianReader reader)
 {
     ParentPack = parent;
     ID = reader.ReadUInt32();
     reader.Skip(4); // Flags?
     Size = reader.ReadInt32();
     Offset = reader.ReadInt32();
     FolderID = reader.ReadInt32();
 }
コード例 #6
0
        public SoundBankVoice(EndianReader reader, uint id)
        {
            ID = id;

            reader.Skip(4);
            StorageType = (SoundStorageType)reader.ReadInt32();
            AudioID = reader.ReadUInt32();
            SourceID = reader.ReadUInt32();
        }
コード例 #7
0
        public SoundBankEvent(EndianReader reader, uint id)
        {
            ID = id;

            // Read the action list
            int numActions = reader.ReadInt32();
            ActionIDs = new uint[numActions];
            for (int i = 0; i < numActions; i++)
                ActionIDs[i] = reader.ReadUInt32();
        }
コード例 #8
0
        public SoundBankAction(EndianReader reader, uint id)
        {
            ID = id;

            Type = (SoundBankActionType)reader.ReadSByte();
            Scope = (SoundBankActionScope)reader.ReadSByte();
            ObjectID = reader.ReadUInt32();

            // TODO: read parameters and state/switch group IDs
        }
コード例 #9
0
        public StateGroup(EndianReader reader)
        {
            ID = reader.ReadUInt32();
            ChangeMoment = (StateGroupChangeMoment)reader.ReadSByte();

            // Read custom states
            short numCustomStates = reader.ReadInt16();
            CustomStates = new CustomState[numCustomStates];
            for (short i = 0; i < numCustomStates; i++)
                CustomStates[i] = new CustomState(reader);
        }
コード例 #10
0
 public static void Copy(EndianReader input, EndianWriter output, int size)
 {
     const int BufferSize = 0x1000;
     byte[] buffer = new byte[BufferSize];
     while (size > 0)
     {
         int read = input.ReadBlock(buffer, 0, Math.Min(BufferSize, size));
         output.WriteBlock(buffer, 0, read);
         size -= BufferSize;
     }
 }
コード例 #11
0
        public SoundBankActorMixer(EndianReader reader, uint id)
        {
            ID = id;

            Info = new SoundInfo(reader);

            // Actor-mixers are just a list of children
            int numChildren = reader.ReadInt32();
            ChildIDs = new uint[numChildren];
            for (int i = 0; i < numChildren; i++)
                ChildIDs[i] = reader.ReadUInt32();
        }
コード例 #12
0
        private void ReadFiles(EndianReader reader)
        {
            // The file table comes after the folder list and padding
            reader.SeekTo(FolderListStart + _folderListSize);

            // Align 4
            reader.SeekTo((reader.Position + 3) & ~3);

            // TODO: Load these into separate lists or something to make stuff easier
            ReadFileTable(reader); // Sound banks
            ReadFileTable(reader); // Global files
        }
コード例 #13
0
        public SoundBankMusicSegment(EndianReader reader, uint id)
        {
            ID = id;

            Info = new SoundInfo(reader);

            // Read child IDs
            int numChildren = reader.ReadInt32();
            ChildIDs = new uint[numChildren];
            for (int i = 0; i < numChildren; i++)
                ChildIDs[i] = reader.ReadUInt32();
        }
コード例 #14
0
        public RTPC(EndianReader reader)
        {
            XAxisParameterID = reader.ReadUInt32();
            YAxisType = (RTPCYAxisType)reader.ReadInt32();

            reader.Skip(5);
            short numPoints = reader.ReadInt16();
            Points = new RTPCPoint[numPoints];

            // Read points
            for (byte i = 0; i < numPoints; i++)
                Points[i] = new RTPCPoint(reader);
        }
コード例 #15
0
        public SoundBankMusicPlaylist(EndianReader reader, uint id)
        {
            ID = id;

            Info = new SoundInfo(reader);

            // Read segment IDs
            int numSegments = reader.ReadInt32();
            SegmentIDs = new uint[numSegments];
            for (int i = 0; i < numSegments; i++)
                SegmentIDs[i] = reader.ReadUInt32();

            // TODO: read the rest of the data
        }
コード例 #16
0
        public SoundBankSequenceContainer(EndianReader reader, uint id)
        {
            ID = id;

            Info = new SoundInfo(reader);

            // hax
            reader.Skip(0x18);

            // Read child IDs
            int numChildren = reader.ReadInt32();
            ChildIDs = new uint[numChildren];
            for (int i = 0; i < numChildren; i++)
                ChildIDs[i] = reader.ReadUInt32();
        }
コード例 #17
0
        public SoundBankMusicSwitchContainer(EndianReader reader, uint id)
        {
            ID = id;

            Info = new SoundInfo(reader);

            // Read segment IDs
            // TODO: this is pretty similar to SoundBankMusicPlaylist,
            // maybe this can be factored out into a common class somehow?
            int numSegments = reader.ReadInt32();
            SegmentIDs = new uint[numSegments];
            for (int i = 0; i < numSegments; i++)
                SegmentIDs[i] = reader.ReadUInt32();

            // TODO: read the rest of the data
        }
コード例 #18
0
        public Vertex(EndianReader reader, XmlNode formatNode)
            : this()
        {
            if (!formatNode.HasChildNodes)
                throw new NotSupportedException(formatNode.Attributes["type"].Value + ":" + formatNode.Attributes["name"].Value + " has an empty definition.");
            
            var origin = (int)reader.Position;

            foreach (XmlNode val in formatNode.ChildNodes)
            {
                reader.SeekTo(origin + Convert.ToInt32(val.Attributes["offset"].Value, 16));
                Values.Add(new VertexValue(val, reader));
            }

            FormatName = formatNode.Attributes["name"].Value;
        }
コード例 #19
0
        public SoundInfo(EndianReader reader)
        {
            OverrideParentEffectSettings = (reader.ReadByte() != 0);

            ReadEffects(reader);

            BusID = reader.ReadUInt32();
            ParentID = reader.ReadUInt32();

            OverrideParentPrioritySettings = (reader.ReadByte() != 0);
            OffsetPriorityAtMaxDistance = (reader.ReadByte() != 0);

            byte numParameters = reader.ReadByte();
            // TODO: actually store the parameter values instead of skipping over them
            reader.Skip(numParameters);
            reader.Skip(numParameters * 4);

            sbyte unknownCount = reader.ReadSByte();
            if (unknownCount > 0)
            {
                reader.Skip(unknownCount);
                reader.Skip(unknownCount * 8);
            }

            ReadPositioningInfo(reader);

            // Read auxiliary send settings
            OverrideParentGameDefinedAuxiliarySendSettings = (reader.ReadByte() != 0);
            UseGameDefinedAuxiliarySends = (reader.ReadByte() != 0);
            OverrideParentUserDefinedAuxiliarySendSettings = (reader.ReadByte() != 0);
            ReadUserDefinedAuxiliarySends(reader);

            bool unknown = (reader.ReadByte() != 0);
            /*if (unknown)
                reader.Skip(4);*/

            // Read voice settings
            LimitMethod = (SoundLimitMethod)reader.ReadSByte();
            VirtualVoiceBehavior = (SoundVirtualVoiceBehavior)reader.ReadSByte();
            OverrideParentPlaybackLimitSettings = (reader.ReadByte() != 0);
            OverrideParentVirtualVoiceSettings = (reader.ReadByte() != 0);

            ReadStateGroups(reader);
            ReadRTPCs(reader);

            reader.Skip(4); // I think this is part of the sound info data...
        }
コード例 #20
0
        public Block_0503(EndianReader reader)
            : base(reader, 0x0503)
        {
            reader.ReadInt16(); //0D03
            reader.ReadInt32(); //EOB

            DataCount = reader.ReadInt32();
            unk0 = reader.ReadInt16(); //always 3
            unk1 = reader.ReadByte(); //0, 2 or 3

            if (unk1 != 3)
            {
                for (int i = 0; i < DataCount; i++)
                {
                    var m11 = reader.ReadSingle();
                    var m12 = reader.ReadSingle();
                    var m13 = reader.ReadSingle();
                    reader.ReadSingle(); //0.0f

                    var m21 = reader.ReadSingle();
                    var m22 = reader.ReadSingle();
                    var m23 = reader.ReadSingle();
                    reader.ReadSingle(); //0.0f

                    var m31 = reader.ReadSingle();
                    var m32 = reader.ReadSingle();
                    var m33 = reader.ReadSingle();
                    reader.ReadSingle(); //0.0f

                    var m41 = reader.ReadSingle();
                    var m42 = reader.ReadSingle();
                    var m43 = reader.ReadSingle();
                    reader.ReadSingle(); //1.0f

                    Data.Add(
                        new Matrix4x3(
                            m11, m12, m13,
                            m21, m22, m23,
                            m31, m32, m33,
                            m41, m42, m43));
                }
            }

            //technically not part of the block
            reader.ReadInt16(); //0100
            reader.ReadInt32(); //address
        }
コード例 #21
0
 public StringBlock_BA01(EndianReader reader)
     : base(reader, 0xBA01)
 {
     Data = reader.ReadNullTerminatedString();
 }
コード例 #22
0
        public float unk11; //almost always 1

        #endregion Fields

        #region Constructors

        public Block_0A03(EndianReader reader)
            : base(reader, 0x0A03)
        {
            unk11 = reader.ReadSingle();
        }
コード例 #23
0
 public ScriptRefBlock_8304(EndianReader reader)
     : base(reader, 0x8304)
 {
     Reference = reader.ReadInt32();
 }
コード例 #24
0
        protected S3DBlock(EndianReader reader, int ident)
        {
            BaseAddress = (int)reader.Position;
            Ident = reader.ReadUInt16(EndianFormat.BigEndian);

            if (Ident != ident)
                throw new InvalidOperationException(string.Format("Block identifier mismatch. Expected 0x{0:X4}, got 0x{1:X4}.", ident, Ident));

            EOBOffset = reader.ReadInt32();
            BlockSize = EOBOffset - (BaseAddress + 6);
        }
コード例 #25
0
        public Vector Data; //relative position coords

        #endregion Fields

        #region Constructors

        public PosBlock_FA02(EndianReader reader)
            : base(reader, 0xFA02)
        {
            Data = new Vector(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
        }
コード例 #26
0
        public MatrixBlock_F900(EndianReader reader)
            : base(reader, 0xF900)
        {
            var m11 = reader.ReadSingle();
            var m12 = reader.ReadSingle();
            var m13 = reader.ReadSingle();
            reader.ReadSingle(); //0.0f

            var m21 = reader.ReadSingle();
            var m22 = reader.ReadSingle();
            var m23 = reader.ReadSingle();
            reader.ReadSingle(); //0.0f

            var m31 = reader.ReadSingle();
            var m32 = reader.ReadSingle();
            var m33 = reader.ReadSingle();
            reader.ReadSingle(); //0.0f

            var m41 = reader.ReadSingle();
            var m42 = reader.ReadSingle();
            var m43 = reader.ReadSingle();
            reader.ReadSingle(); //1.0f

            Data = new Matrix4x3(
                m11, m12, m13,
                m21, m22, m23,
                m31, m32, m33,
                m41, m42, m43);
        }
コード例 #27
0
 public MatRefBlock_5601(EndianReader reader)
     : base(reader, 0x5601)
 {
     Reference = reader.ReadNullTerminatedString();
 }
コード例 #28
0
 public unkBlock_XXXX(EndianReader reader, int ident)
     : base(reader, ident)
 {
     reader.SeekTo(EOBOffset);
 }
コード例 #29
0
        public UVDataBlock_3001(EndianReader reader, bool loadMesh, Vertex[] Vertices)
            : base(reader, 0x3001)
        {
            DataCount = reader.ReadInt32(); //vCount

            x2E00 = reader.ReadInt16(); //2E00
            reader.EndianType = EndianFormat.BigEndian;

            unkUV0 = reader.ReadInt16(); //flags? 0x1C00 when world
            unkUV1 = reader.ReadByte();
            unkUV2 = reader.ReadByte();
            unkUV3 = reader.ReadByte();
            unkUV4 = reader.ReadByte(); //0x00 when world, else 0x20
            DataSize = reader.ReadByte();

            if (!loadMesh) reader.SeekTo(EOBOffset);
            else for (int i = 0; i < DataCount; i++)
            {
                Vector tex0 = new Vector();

                #region switch
                switch (DataSize)
                {
                    case 8:
                        tex0 = Vector.FromUByteN4(reader.ReadUInt32());
                        reader.Skip(0);
                        break;
                    case 12:
                        reader.Skip(4);
                        break;
                    case 16:
                        reader.Skip(12);
                        break;
                    case 20:
                        reader.Skip(16);
                        break;
                    case 24:
                        reader.Skip(16);
                        break;
                    case 28:
                        reader.Skip(20);
                        break;
                    case 32:
                        reader.Skip(16);
                        break;
                    case 36:
                        reader.Skip(24);
                        break;
                    case 44:
                        reader.Skip(28);
                        break;
                }
                #endregion

                int u = reader.ReadInt16();
                int v = reader.ReadInt16();

                //var tex0 = new RealQuat(((float)a + (float)0) / (float)0xFFFF, ((float)b + (float)0) / (float)0xFFFF);
                var tex1 = new Vector((float)u / (float)(0x7FFF), (float)v / (float)(0x7FFF));

                #region switch
                switch (DataSize)
                {
                    case 8:
                        reader.Skip(0);
                        break;
                    case 12:
                        reader.Skip(4);
                        break;
                    case 16:
                        reader.Skip(0);
                        break;
                    case 20:
                        reader.Skip(0);
                        break;
                    case 24:
                        reader.Skip(4);
                        break;
                    case 28:
                        reader.Skip(4);
                        break;
                    case 32:
                        reader.Skip(12);
                        break;
                    case 36:
                        reader.Skip(8);
                        break;
                    case 44:
                        reader.Skip(12);
                        break;
                }
                #endregion

                //Vertices[i].Values.Add(new VertexValue(tex0, 0, "normal", 0));
                Vertices[i].Values.Add(new VertexValue(tex1, VertexValue.ValueType.Int16_N2, "texcoords", 0));
            }

            reader.EndianType = EndianFormat.LittleEndian;
        }
コード例 #30
0
        public IndexBlock_F200(EndianReader reader, bool loadMesh)
            : base(reader, 0xF200)
        {
            DataCount = reader.ReadInt32();
            Data = new int[DataCount * 3];
            if (DataCount == 0) return;

            if (!loadMesh) reader.SeekTo(EOBOffset);
            else for (int i = 0; i < DataCount * 3; i++)
                    Data[i] = reader.ReadUInt16();
        }