Beispiel #1
0
 public wnd1(EndianBinaryReader er)
     : base(er)
 {
     long basepos = er.BaseStream.Position - 0x4C;
     InflationLeft = er.ReadUInt16() / 16f;
     InflationRight = er.ReadUInt16() / 16f;
     InflationTop = er.ReadUInt16() / 16f;
     InflationBottom = er.ReadUInt16() / 16f;
     FrameSizeLeft = er.ReadUInt16();
     FrameSizeRight = er.ReadUInt16();
     FrameSizeTop = er.ReadUInt16();
     FrameSizeBottom = er.ReadUInt16();
     NrFrames = er.ReadByte();
     byte tmp = er.ReadByte();
     UseLTMaterial = (tmp & 1) == 1;
     UseVtxColorForAllWindow = (tmp & 2) == 2;
     Kind = (WindowKind)((tmp >> 2) & 3);
     DontDrawContent = (tmp & 8) == 16;
     Padding = er.ReadUInt16();
     ContentOffset = er.ReadUInt32();
     FrameOffsetTableOffset = er.ReadUInt32();
     er.BaseStream.Position = basepos + ContentOffset;
     Content = new WindowContent(er);
     er.BaseStream.Position = basepos + FrameOffsetTableOffset;
     WindowFrameOffsets = er.ReadUInt32s(NrFrames);
     WindowFrames = new WindowFrame[NrFrames];
     for (int i = 0; i < NrFrames; i++)
     {
         er.BaseStream.Position = basepos + WindowFrameOffsets[i];
         WindowFrames[i] = new WindowFrame(er);
     }
     er.BaseStream.Position = basepos + SectionSize;
 }
Beispiel #2
0
        public CANM(EndianBinaryReader er)
        {
            Signature = er.ReadString(Encoding.ASCII, 4);
            if (Signature != "CANM") throw new SignatureNotCorrectException(Signature, "CANM", er.BaseStream.Position);
            Revision = er.ReadUInt32();
            NameOffset = (UInt32)er.BaseStream.Position + er.ReadUInt32();
            TargetAnimationGroupNameOffset = (UInt32)er.BaseStream.Position + er.ReadUInt32();
            LoopMode = er.ReadUInt32();
            FrameSize = er.ReadSingle();
            NrMemberAnimations = er.ReadUInt32();
            MemberAnimationDictOffset = (UInt32)er.BaseStream.Position + er.ReadUInt32();
            NrUserDataEntries = er.ReadUInt32();
            UserDataOffset = er.ReadUInt32();

            long curpos = er.BaseStream.Position;
            er.BaseStream.Position = NameOffset;
            Name = er.ReadStringNT(Encoding.ASCII);
            er.BaseStream.Position = TargetAnimationGroupNameOffset;
            TargetAnimationGroupName = er.ReadStringNT(Encoding.ASCII);
            er.BaseStream.Position = MemberAnimationDictOffset;
            MemberAnimationDictionary = new DICT(er);

            MemberAnimations = new MemberAnimationData[NrMemberAnimations];
            for (int i = 0; i < NrMemberAnimations; i++)
            {
                er.BaseStream.Position = MemberAnimationDictionary[i].DataOffset;
                MemberAnimations[i] = new MemberAnimationData(er);
            }

            er.BaseStream.Position = curpos;
        }
Beispiel #3
0
        override public void decode(EndianBinaryReader binReader)
        {
        
            actorId = binReader.ReadInt16();
            
            m_byte = binReader.ReadSByte();
            
            m_date = binReader.ReadDate();
            
            m_float = binReader.ReadFloat();
            
            testStruct = new sendLogin_testStructVO();
            testStruct.decode(binReader);
            
            var len_playerList = binReader.ReadUInt16();
            playerList = new sendLogin_playerListVO[len_playerList];
            for (int i = 0; i < len_playerList; i++)
            {

            playerList[i] = new sendLogin_playerListVO();
            playerList[i].decode(binReader);
            
            }
            
        }
Beispiel #4
0
 public TEX0(EndianBinaryReader er)
 {
     long basepos = er.BaseStream.Position;
     Signature = er.ReadString(Encoding.ASCII, 4);
     if (Signature != "TEX0") throw new SignatureNotCorrectException(Signature, "TEX0", er.BaseStream.Position - 4);
     SectionSize = er.ReadUInt32();
     TexInfo = new texInfo(er);
     Tex4x4Info = new tex4x4Info(er);
     PlttInfo = new plttInfo(er);
     dictTex = new Dictionary<DictTexData>(er);
     for (int i = 0; i < dictTex.numEntry; i++)
     {
         dictTex[i].Value.ReadData(er, TexInfo.ofsTex, Tex4x4Info.ofsTex, Tex4x4Info.ofsTexPlttIdx, basepos);
     }
     dictPltt = new Dictionary<DictPlttData>(er);
     List<UInt32> Offset = new List<uint>();
     for (int i = 0; i < dictPltt.numEntry; i++)
     {
         Offset.Add(dictPltt[i].Value.offset);
     }
     Offset = Offset.Distinct().ToList();
     Offset.Sort();
     for (int i = 0; i < dictPltt.numEntry; i++)
     {
         int idx = Offset.IndexOf(dictPltt[i].Value.offset);
         if (idx == Offset.Count - 1)
         {
             dictPltt[i].Value.ReadData(er, PlttInfo.ofsPlttData, (uint)er.BaseStream.Length - (Offset[idx] + PlttInfo.ofsPlttData + (uint)basepos), basepos);
         }
         else
         {
             dictPltt[i].Value.ReadData(er, PlttInfo.ofsPlttData, Offset[idx + 1] - Offset[idx], basepos);
         }
     }
 }
Beispiel #5
0
 // Public Methods (2)
 /// <summary>
 /// Load NSBTX from stream.
 /// </summary>
 /// <param name="stream">Stream to use.</param>
 /// <returns>Material definitions.</returns>
 public static IEnumerable<NsbmdAnimation> LoadNsbca(Stream stream)
 {
     List<NsbmdAnimation> animation = new List<NsbmdAnimation>();
     var reader = new EndianBinaryReader(stream, Endianness.LittleEndian);
     byte[] id = reader.ReadBytes(4);
     if (id == new byte[] { 0x42, 0x43, 0x41, 0x30 })
     {
         throw new Exception();
     }
     int i = reader.ReadInt32();
     if (i == Nsbmd.NDS_TYPE_MAGIC1)
     {
         i = reader.ReadInt32();
         if (i == stream.Length)
         {
             int numblock = reader.ReadInt32();
             numblock >>= 16;
             int r = reader.ReadInt32();
             id = reader.ReadBytes(4);
             if (numblock == 1 && r == 0x14)
             {
                 animation.AddRange(ReadJnt0(stream, 0x14));
             }
         }
     }
     reader.Close();
     return animation;
 }
Beispiel #6
0
 public ImageTextureCtr(EndianBinaryReader er)
     : base(er)
 {
     TextureImageOffset = (UInt32)er.BaseStream.Position + er.ReadUInt32();
     long curpos = er.BaseStream.Position;
     er.BaseStream.Position = TextureImageOffset;
     TextureImage = new PixelBasedImageCtr(er);
     er.BaseStream.Position = curpos;
 }
 public KCLOctree(EndianBinaryReader er, int NrNodes)
 {
     long baseoffset = er.BaseStream.Position;
     RootNodes = new KCLOctreeNode[NrNodes];
     for (int i = 0; i < NrNodes; i++)
     {
         RootNodes[i] = new KCLOctreeNode(er, baseoffset);
     }
 }
Beispiel #8
0
        public void modelOpen()
        {
            string path = textBox1.Text;
            EndianBinaryReader readModel = new EndianBinaryReader(File.OpenRead(path), Endianness.LittleEndian);
            nsbmd = new NSBMD_File();
            if (readModel.ReadString(Encoding.ASCII, 4) != "BMD0")
            {
                readModel.Close();
                return;
            }
            else
            {
                nsbmd.Header.ID = "BMD0";
                nsbmd.Header.Magic = readModel.ReadBytes(4);
                nsbmd.Header.file_size = readModel.ReadInt32();
                nsbmd.Header.header_size = readModel.ReadInt16();
                nsbmd.Header.nSection = readModel.ReadInt16();
                nsbmd.Header.Section_Offset = new Int32[nsbmd.Header.nSection];
                for (int i = 0; i < nsbmd.Header.nSection; i++)
                {
                    nsbmd.Header.Section_Offset[i] = readModel.ReadInt32();
                }
                nsbmd.MDL0.ID = readModel.ReadString(Encoding.ASCII, 4);
                if (nsbmd.MDL0.ID != "MDL0")
                {
                    readModel.Close();
                    return;
                }

                nsbmd.MDL0.Section_size = readModel.ReadInt32();
                nsbmd.MDL0.Padding1 = readModel.ReadByte();
                nsbmd.MDL0.Model_count = readModel.ReadByte();
                nsbmd.MDL0.Section_size = readModel.ReadInt16();
                nsbmd.MDL0.Constant = readModel.ReadInt16();
                nsbmd.MDL0.Subsection_size = readModel.ReadInt16();
                nsbmd.MDL0.Constant2 = readModel.ReadInt32();
                nsbmd.MDL0.Unknown = new int[nsbmd.MDL0.Model_count];
                for (int i = 0; i < nsbmd.MDL0.Model_count; i++)
                {
                    nsbmd.MDL0.Unknown[i] = readModel.ReadInt32();
                }
                nsbmd.MDL0.Constant3 = readModel.ReadInt16();
                nsbmd.MDL0.Section2_size = readModel.ReadInt16();
                nsbmd.MDL0.Model_offset = new int[nsbmd.MDL0.Model_count];
                for (int i = 0; i < nsbmd.MDL0.Model_count; i++)
                {
                    nsbmd.MDL0.Model_offset[i] = readModel.ReadInt32();
                }
                nsbmd.MDL0.Model_name = new string[nsbmd.MDL0.Model_count];
                for (int i = 0; i < nsbmd.MDL0.Model_count; i++)
                {
                    nsbmd.MDL0.Model_name[i] = readModel.ReadString(Encoding.ASCII, 16);
                }
                readModel.Close();
            }
        }
 public static BoundingVolume FromStream(EndianBinaryReader er)
 {
     uint type = er.ReadUInt32();
     er.BaseStream.Position -= 4;
     switch (type)
     {
         case 0x80000000:
             return new OrientedBoundingBox(er);
     }
     return new BoundingVolume(er);
 }
Beispiel #10
0
        public DICT(EndianBinaryReader er)
        {
            Signature = er.ReadString(Encoding.ASCII, 4);
            if (Signature != "DICT") throw new SignatureNotCorrectException(Signature, "DICT", er.BaseStream.Position);
            SectionSize = er.ReadUInt32();
            NrEntries = er.ReadUInt32();

            RootNode = new Node(er);
            Entries = new List<Node>();// new Node[NrEntries];
            for (int i = 0; i < NrEntries; i++)
            {
                Entries.Add(new Node(er));
            }
        }
Beispiel #11
0
 public MaterialEntry(EndianBinaryReader er)
 {
     Name = er.ReadString(Encoding.ASCII, 20).Replace("\0", "");
     BufferColor = er.ReadColor8();
     ConstColors = new Color[6];
     ConstColors[0] = er.ReadColor8();
     ConstColors[1] = er.ReadColor8();
     ConstColors[2] = er.ReadColor8();
     ConstColors[3] = er.ReadColor8();
     ConstColors[4] = er.ReadColor8();
     ConstColors[5] = er.ReadColor8();
     Flags = er.ReadUInt32();
     //Material Flag:
     //  0-1: Nr texMap
     //  2-3: Nr texMatrix
     //  4-5: Nr texCoordGen
     //  6-8: Nr tevStage
     //    9: Has alphaCompare
     //   10: Has blendMode
     //   11: Use Texture Only
     //   12: Separate Blend Mode
     //   14: Has Indirect Parameter
     //15-16: Nr projectionTexGenParameter
     //   17: Has Font Shadow Parameter
     TexMaps = new TexMap[Flags & 3];
     for (int i = 0; i < (Flags & 3); i++)
     {
         TexMaps[i] = new TexMap(er);
     }
     TexMatrices = new TexMatrix[(Flags >> 2) & 3];
     for (int i = 0; i < ((Flags >> 2) & 3); i++)
     {
         TexMatrices[i] = new TexMatrix(er);
     }
     TexCoordGens = new TexCoordGen[(Flags >> 4) & 3];
     for (int i = 0; i < ((Flags >> 4) & 3); i++)
     {
         TexCoordGens[i] = new TexCoordGen(er);
     }
     TevStages = new TevStage[(Flags >> 6) & 7];
     for (int i = 0; i < ((Flags >> 6) & 7); i++)
     {
         TevStages[i] = new TevStage(er);
     }
     if (((Flags >> 9) & 1) == 1) AlphaTest = new AlphaCompare(er);
     if (((Flags >> 10) & 1) == 1) ColorBlendMode = new BlendMode(er);
     if (((Flags >> 12) & 1) == 1) AlphaBlendMode = new BlendMode(er);
     //Some more things
 }
Beispiel #12
0
 public pic1(EndianBinaryReader er)
     : base(er)
 {
     VertexColorLT = er.ReadColor8();
     VertexColorRT = er.ReadColor8();
     VertexColorLB = er.ReadColor8();
     VertexColorRB = er.ReadColor8();
     MaterialId = er.ReadUInt16();
     NrTexCoordEntries = er.ReadUInt16();
     TexCoordEntries = new TexCoord[NrTexCoordEntries];
     for (int i = 0; i < NrTexCoordEntries; i++)
     {
         TexCoordEntries[i] = new TexCoord(er);
     }
 }
Beispiel #13
0
 public MDL0(EndianBinaryReader er)
 {
     long basepos = er.BaseStream.Position;
     Signature = er.ReadString(Encoding.ASCII, 4);
     if (Signature != "MDL0") throw new SignatureNotCorrectException(Signature, "MDL0", er.BaseStream.Position - 4);
     SectionSize = er.ReadUInt32();
     dict = new Dictionary<MDL0Data>(er);
     models = new Model[dict.numEntry];
     long curpos = er.BaseStream.Position;
     for (int i = 0; i < dict.numEntry; i++)
     {
         er.BaseStream.Position = dict[i].Value.Offset + basepos;//er.GetMarker("ModelSet");
         models[i] = new Model(er);
     }
 }
Beispiel #14
0
            public PixelBasedImageCtr(EndianBinaryReader er)
            {
                Height = er.ReadUInt32();
                Width = er.ReadUInt32();
                DataSize = er.ReadUInt32();
                DataOffset = (UInt32)er.BaseStream.Position + er.ReadUInt32();
                DynamicAllocator = er.ReadUInt32();
                BitsPerPixel = er.ReadUInt32();
                LocationAddress = er.ReadUInt32();
                MemoryAddress = er.ReadUInt32();

                long curpos = er.BaseStream.Position;
                er.BaseStream.Position = DataOffset;
                Data = er.ReadBytes((int)DataSize);
                er.BaseStream.Position = curpos;
            }
Beispiel #15
0
 public pan1(EndianBinaryReader er)
 {
     Signature = er.ReadString(Encoding.ASCII, 4);
     if (Signature != "pan1" && Signature != "pic1" && Signature != "txt1" && Signature != "bnd1" && Signature != "wnd1" && Signature != "prt1")
         throw new SignatureNotCorrectException(Signature, "pan1, pic1, txt1, bnd1, wnd1, prt1", er.BaseStream.Position - 4);
     SectionSize = er.ReadUInt32();
     Flags = (PaneFlags)er.ReadByte();
     Origin = er.ReadByte();
     Alpha = er.ReadByte();
     MagnifyFlags = (PaneMagnifyFlags)er.ReadByte();
     Name = er.ReadString(Encoding.ASCII, 24).Replace("\0", "");
     Translation = er.ReadVector3();
     Rotation = er.ReadVector3();
     Scale = er.ReadVector2();
     Size = er.ReadVector2();
 }
Beispiel #16
0
 public void decode(EndianBinaryReader binReader)
 {
 
     m_ushort = binReader.ReadUInt16();
     
     m_int = binReader.ReadInt32();
     
     m_uint = binReader.ReadUInt32();
     
     m_Boolean = binReader.ReadBoolean();
     
     m_Binary = binReader.ReadBytes(binReader.ReadInt32());
     
     m_string = binReader.ReadUTF();
     
 }
Beispiel #17
0
 public mat1(EndianBinaryReader er)
 {
     long startpos = er.BaseStream.Position;
     Signature = er.ReadString(Encoding.ASCII, 4);
     if (Signature != "mat1") throw new SignatureNotCorrectException(Signature, "mat1", er.BaseStream.Position - 4);
     SectionSize = er.ReadUInt32();
     NrMaterials = er.ReadUInt32();
     MaterialEntryOffsets = er.ReadUInt32s((int)NrMaterials);
     Materials = new MaterialEntry[NrMaterials];
     for (int i = 0; i < NrMaterials; i++)
     {
         er.BaseStream.Position = startpos + MaterialEntryOffsets[i];
         Materials[i] = new MaterialEntry(er);
     }
     er.BaseStream.Position = startpos + SectionSize;
 }
 public void decode(EndianBinaryReader binReader)
 {
 
     battleId = binReader.ReadInt16();
     
     teamId = binReader.ReadInt16();
     
     actorId = binReader.ReadInt16();
     
     curX = binReader.ReadInt16();
     
     curY = binReader.ReadInt16();
     
     fast = binReader.ReadBoolean();
     
 }
        override public void decode(EndianBinaryReader binReader)
        {
        
            battleId = binReader.ReadInt16();
            
            var len_damageList = binReader.ReadUInt16();
            damageList = new CommonStructVO[len_damageList];
            for (int i = 0; i < len_damageList; i++)
            {

            damageList[i] = new CommonStructVO();
            damageList[i].decode(binReader);
            
            }
            
        }
Beispiel #20
0
 public txt1(EndianBinaryReader er)
     : base(er)
 {
     long baseoffset = er.BaseStream.Position - 0x4C;
     NrCharacters = er.ReadUInt16();
     NrCharacters2 = er.ReadUInt16();
     MaterialId = er.ReadUInt16();
     FontId = er.ReadUInt16();
     PositionType = er.ReadByte();
     TextAlignment = er.ReadByte();
     TextFlags = er.ReadByte();
     Padding = er.ReadByte();
     StringOffset = er.ReadUInt32();
     TopColor = er.ReadColor8();
     BottomColor = er.ReadColor8();
     FontSize = er.ReadVector2();
     CharSize = er.ReadSingle();
     LineSize = er.ReadSingle();
     er.BaseStream.Position = baseoffset + StringOffset;
     Text = er.ReadStringNT(Encoding.Unicode);
     er.BaseStream.Position = baseoffset + SectionSize;
 }
Beispiel #21
0
        private static void ConvertPath(string path)
        {
            using (var reader = new EndianBinaryReader(new FileStream(path, FileMode.Open)))
            {
                string outpath;
                bool toyaml;

                if (reader.ReadString(Encoding.ASCII, 2) == "BY")
                {
                    toyaml = true;
                    outpath = Path.ChangeExtension(path, "xml");
                    if (outpath == path)
                        outpath = path + ".xml";
                }
                else
                {
                    toyaml = false;
                    outpath = Path.ChangeExtension(path, "byaml");
                    if (outpath == path)
                        outpath = path + ".byaml";
                }

                reader.BaseStream.Seek(0, SeekOrigin.Begin);

                if (toyaml)
                {
                    ConvertFromByaml(reader, outpath);
                }
                else
                {
                    ConvertToByaml(reader, outpath);
                }

                reader.Close();
            }
        }
 public BoundingVolume(EndianBinaryReader er)
 {
     Type = er.ReadUInt32();
 }
Beispiel #23
0
 public texInfo(EndianBinaryReader er)
 {
     vramKey = er.ReadUInt32();
     sizeTex = (UInt32)(er.ReadUInt16() << 3);
     ofsDict = er.ReadUInt16();
     flag = er.ReadUInt16();
     er.ReadBytes(2);//PADDING(2 bytes);
     ofsTex = er.ReadUInt32();
 }
Beispiel #24
0
 public void ReadData(EndianBinaryReader er, uint BaseOffsetTex, uint BaseOffsetTex4x4, uint BaseOffsetTex4x4Info, long TexplttSetOffset)
 {
     long curpos = er.BaseStream.Position;
     if (Fmt == Textures.ImageFormat.COMP4x4)
     {
         er.BaseStream.Position = Offset + BaseOffsetTex4x4 + TexplttSetOffset;//er.GetMarker("TexplttSet");
         Data = er.ReadBytes((S * T * DataLength[(int)Fmt]) / 8);
         er.BaseStream.Position = Offset / 2 + BaseOffsetTex4x4Info + TexplttSetOffset;//er.GetMarker("TexplttSet");
         Data4x4 = er.ReadBytes((S * T * DataLength[(int)Fmt]) / 8 / 2);
     }
     else
     {
         er.BaseStream.Position = Offset + BaseOffsetTex + TexplttSetOffset;//er.GetMarker("TexplttSet");
         Data = er.ReadBytes((S * T * DataLength[(int)Fmt]) / 8);
     }
     er.BaseStream.Position = curpos;
 }
Beispiel #25
0
 public plttInfo(EndianBinaryReader er)
 {
     vramKey = er.ReadUInt32();
     sizePltt = (UInt32)(er.ReadUInt16() << 3);
     flag = er.ReadUInt16();
     ofsDict = er.ReadUInt16();
     er.ReadBytes(2);//PADDING(2 bytes);
     ofsPlttData = er.ReadUInt32();
 }
Beispiel #26
0
 public override void Read(EndianBinaryReader er)
 {
     texImageParam = er.ReadUInt32();
     Offset = (texImageParam & 0xFFFF) << 3;
     S = (UInt16)(8 << (int)((texImageParam & 0x700000) >> 20));
     T = (UInt16)(8 << (int)((texImageParam & 0x3800000) >> 23));
     Fmt = (Textures.ImageFormat)((texImageParam & 0x1C000000) >> 26);
     TransparentColor = ((texImageParam >> 29) & 1) == 1;
     extraParam = er.ReadUInt32();
 }
Beispiel #27
0
 public void ReadData(EndianBinaryReader er, uint BaseOffsetPltt, uint Length, long TexplttSetOffset)
 {
     long curpos = er.BaseStream.Position;
     er.BaseStream.Position = offset + BaseOffsetPltt + TexplttSetOffset;//er.GetMarker("TexplttSet");
     Data = er.ReadBytes((int)Length);
     er.BaseStream.Position = curpos;
 }
Beispiel #28
0
 public override void Read(EndianBinaryReader er)
 {
     offset = (uint)(er.ReadUInt16() << 3);
     flag = er.ReadUInt16();
 }
 public OrientedBoundingBox(EndianBinaryReader er)
     : base(er)
 {
     CenterPosition = er.ReadVector3();
     OrientationMatrix = er.ReadSingles(3 * 3);
     Size = er.ReadVector3();
 }
 public AxisAlignedBoundingBox(EndianBinaryReader er)
     : base(er)
 {
     CenterPosition = er.ReadVector3();
     Size = er.ReadVector3();
 }