Esempio n. 1
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
        }
        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...
        }
Esempio n. 3
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;
        }
Esempio n. 4
0
        public Block_B903(EndianReader reader)
            : base(reader, 0xB903)
        {
            Name = reader.ReadNullTerminatedString();
            ID = reader.ReadInt16();
            x2400 = reader.ReadInt16();

            unk0 = reader.ReadByte();
            unk1 = reader.ReadInt16(); //possibly flags
            unk2 = reader.ReadInt16(); //possibly flags

            VertCount = reader.ReadInt32();
            FaceCount = reader.ReadInt32();
        }
Esempio n. 5
0
 public Block_3201(EndianReader reader)
     : base(reader, 0x3201)
 {
     unkID0 = reader.ReadInt16(); //points to first inheritor if skincompound, otherwise parent bone
     unkCount0 = reader.ReadByte(); //number of inheritors/bones (starts at unkID0 and increments through object IDs)
     unkID1 = reader.ReadInt16(); //secondary parent bone
     unkCount1 = reader.ReadByte(); //secondary number of bones
 }
Esempio n. 6
0
        public Block_2F01(EndianReader reader)
            : base(reader, 0x2F01)
        {
            unkCC = reader.ReadByte(); //count

            reader.ReadByte(); //index
            unkC0 = reader.ReadInt32(); //material scale

            //first block is above, skip the rest
            for (int i = 1; i < unkCC; i++)
            {
                reader.ReadByte(); //index
                reader.ReadInt32(); //count
            }
        }
Esempio n. 7
0
        public int x4001; //not always 4001

        #endregion Fields

        #region Constructors

        public Block_2E01(EndianReader reader)
            : base(reader, 0x2E01)
        {
            //BaseAddress = (int)reader.Position;
            //x2E01 = reader.ReadInt16();
            //EOBAddress = reader.ReadInt32();

            x1200 = reader.ReadInt16();
            geomUnk01 = reader.ReadByte();
            x4001 = reader.ReadInt16();
        }
Esempio n. 8
0
        public Block_2801(EndianReader reader)
            : base(reader, 0x2801)
        {
            x81 = reader.ReadByte();
            unk4 = reader.ReadInt32();
            xFF = reader.ReadByte();
            x1300 = reader.ReadInt16(); //mesh type enum? 16 = standard, 18 = skin, 19 = skincompound

            VertexCount = reader.ReadInt16(); //vertex count
            IndexCount = reader.ReadInt16(); //face count * 3 [usually]
            unkID2 = reader.ReadInt32(); //object ID, unknown purpose, same as parent ID, only used on vertless meshes (inheritors)
            unk7 = reader.ReadInt32(); //increases with vert count
            unk8 = reader.ReadInt32(); //seems to increase with mesh size
            unk9a = reader.ReadInt16(); //not used on standard meshes
            unk9b = reader.ReadInt16(); //not used on standard meshes
        }
Esempio n. 9
0
        public VertexValue(XmlNode Node, EndianReader reader)
        {
            if (Convert.ToInt32(Node.Attributes["stream"].Value) > 0) throw new NotSupportedException("Multi-streamed vertices not supported");
            Type = (ValueType)Enum.Parse(typeof(ValueType), Node.Attributes["type"].Value);
            Usage = Node.Attributes["usage"].Value;
            UsageIndex = Convert.ToInt32(Node.Attributes["usageIndex"].Value);
            
            switch (Type)
            {
                case ValueType.Float32_2:
                    Data = new Vector(reader.ReadSingle(), reader.ReadSingle());
                    break;

                case ValueType.Float32_3:
                    Data = new Vector(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                    break;

                case ValueType.Float32_4:
                    Data = new Vector(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                    break;

                case ValueType.Int8_N4:
                    Data = new Vector((float)reader.ReadByte() / (float)0x7F, (float)reader.ReadByte() / (float)0x7F, (float)reader.ReadByte() / (float)0x7F, (float)reader.ReadByte() / (float)0x7F);
                    break;

                case ValueType.UInt8_2:
                    Data = new Vector(reader.ReadByte(), reader.ReadByte(), 0, 0);
                    break;

                case ValueType.UInt8_3:
                    Data = new Vector(reader.ReadByte(), reader.ReadByte(), reader.ReadByte(), 0);
                    break;

                case ValueType.UInt8_4:
                    Data = Vector.FromUByte4(reader.ReadUInt32());
                    break;

                case ValueType.UInt8_N2:
                    Data = new Vector((float)reader.ReadByte() / (float)0xFF, (float)reader.ReadByte() / (float)0xFF, 0, 0);
                    break;

                case ValueType.UInt8_N3:
                    Data = new Vector((float)reader.ReadByte() / (float)0xFF, (float)reader.ReadByte() / (float)0xFF, (float)reader.ReadByte() / (float)0xFF, 0);
                    break;

                case ValueType.UInt8_N4:
                    Data = Vector.FromUByteN4(reader.ReadUInt32());
                    break;

                case ValueType.Int16_N3:
                    Data = new Vector(((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, ((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, ((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, 0);
                    break;

                case ValueType.Int16_N4:
                    Data = new Vector(((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, ((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, ((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF, ((float)reader.ReadInt16() + (float)0x7FFF) / (float)0xFFFF);
                    break;

                case ValueType.UInt16_2:
                    Data = new Vector(reader.ReadUInt16(), reader.ReadUInt16());
                    break;

                case ValueType.UInt16_4:
                    Data = new Vector(reader.ReadUInt16(), reader.ReadUInt16(), reader.ReadUInt16(), reader.ReadUInt16());
                    break;

                case ValueType.UInt16_N2:
                    Data = new Vector((float)reader.ReadUInt16() / (float)0xFFFF, (float)reader.ReadUInt16() / (float)0xFFFF);
                    break;

                case ValueType.UInt16_N4:
                    Data = new Vector((float)reader.ReadUInt16() / (float)0xFFFF, (float)reader.ReadUInt16() / (float)0xFFFF, (float)reader.ReadUInt16() / (float)0xFFFF, (float)reader.ReadUInt16() / (float)0xFFFF);
                    break;

                case ValueType.DecN4:
                    Data = Vector.FromDecN4(reader.ReadUInt32());
                    break;

                case ValueType.UDecN4:
                    Data = Vector.FromUDecN4(reader.ReadUInt32());
                    break;

                case ValueType.DHenN3:
                    Data = Vector.FromDHenN3(reader.ReadUInt32());
                    break;

                case ValueType.UDHenN3:
                    Data = Vector.FromUDHenN3(reader.ReadUInt32());
                    break;

                case ValueType.HenDN3:
                    Data = Vector.FromHenDN3(reader.ReadUInt32());
                    break;

                case ValueType.UHenDN3:
                    Data = Vector.FromUHenDN3(reader.ReadUInt32());
                    break;

                case ValueType.Float16_2:
                    Data = new Vector(Half.ToHalf(reader.ReadUInt16()), Half.ToHalf(reader.ReadUInt16()));
                    break;

                case ValueType.Float16_4:
                    Data = new Vector(Half.ToHalf(reader.ReadUInt16()), Half.ToHalf(reader.ReadUInt16()), Half.ToHalf(reader.ReadUInt16()), Half.ToHalf(reader.ReadUInt16()));
                    break;

                case ValueType.D3DColour:
                    reader.ReadUInt32();
                    break;
            }
        }
Esempio n. 10
0
 private void ReadUserDefinedAuxiliarySends(EndianReader reader)
 {
     HasUserDefinedAuxiliarySends = (reader.ReadByte() != 0);
     if (HasUserDefinedAuxiliarySends)
     {
         AuxiliaryBusIDs = new uint[4];
         for (int i = 0; i < 4; i++)
             AuxiliaryBusIDs[i] = reader.ReadUInt32();
     }
     else
     {
         AuxiliaryBusIDs = new uint[0];
     }
 }
Esempio n. 11
0
        private void ReadPositioningInfo(EndianReader reader)
        {
            HasPositioning = (reader.ReadByte() != 0);
            if (!HasPositioning)
                return;

            PositionType = (SoundPositionType)reader.ReadByte();
            if (PositionType == SoundPositionType.Position2D)
            {
                EnablePanner = (reader.ReadByte() != 0);
            }
            else
            {
                PositionSourceType = (SoundPositionSourceType)reader.ReadInt32();
                AttenuationID = reader.ReadUInt32();
                EnableSpatialization = (reader.ReadByte() != 0);

                if (PositionSourceType == SoundPositionSourceType.UserDefined)
                {
                    PlayType = (SoundPlayType)reader.ReadInt32();
                    Loop = (reader.ReadByte() != 0);
                    TransitionTime = reader.ReadUInt32();
                    FollowListenerOrientation = (reader.ReadByte() != 0);

                    ReadPaths(reader);
                }
                else if (PositionSourceType == SoundPositionSourceType.GameDefined)
                {
                    UpdateEachFrame = (reader.ReadByte() != 0);
                }
            }
        }
Esempio n. 12
0
 private void ReadEffects(EndianReader reader)
 {
     byte numEffects = reader.ReadByte();
     if (numEffects > 0)
     {
         EffectBypassMask = reader.ReadByte();
         EffectIDs = new uint[numEffects];
         for (byte i = 0; i < numEffects; i++)
         {
             reader.Skip(1); // Effect index, useless
             EffectIDs[i] = reader.ReadUInt32();
             reader.Skip(2);
         }
     }
     else
     {
         EffectIDs = new uint[0];
     }
 }