Exemple #1
0
        public void Load(System.IO.BinaryReader reader)
        {
            OEIShared.Utils.FourCC cc = new OEIShared.Utils.FourCC(reader.ReadChars(4));

            if (cc != this._fourCC)
            {
                throw new ApplicationException(this._fourCC.ToString() + " not found in stream");
            }

            this._size    = reader.ReadInt32();
            this._width   = reader.ReadInt32();
            this._height  = reader.ReadInt32();
            this._padding = reader.ReadInt32();
        }
Exemple #2
0
        public void Load(System.IO.BinaryReader reader)
        {
            OEIShared.Utils.FourCC cc = new OEIShared.Utils.FourCC(reader.ReadChars(4));

            if (cc != this._fourCC)
            {
                throw new ApplicationException(this._fourCC.ToString() + " not found in stream");
            }

            this._size = reader.ReadInt32();
            long finalPosition = reader.BaseStream.Position + this._size;

            this._mapPart = OEIShared.Utils.CommonUtils.ConvertZeroTerminatedBytesToString(reader.ReadBytes(128)).TrimEnd('\0');

            this._ddsGroup = new DDSGroup(reader);

            for (int i = 0; i < 18; i++)
            {
                this._texVectors[i] = reader.ReadSingle();
            }

            this._vertexCount   = reader.ReadInt32();
            this._triangleCount = reader.ReadInt32();

            this._vertices = new Vertex[this._vertexCount];
            for (int i = 0; i < this._vertexCount; i++)
            {
                this._vertices[i] = new Vertex(reader);
            }

            this._triangles = new Triangle[this._triangleCount];
            for (int i = 0; i < this._triangleCount; i++)
            {
                this._triangles[i] = new Triangle(reader);
            }

            this._ddsGroup.Load(reader);
            this._ddsGroup.FirstVertex = this._vertices[0];

            this._unkownDataSize = (int)(finalPosition - reader.BaseStream.Position);
            if (this._unkownDataSize > 0)
            {
                this._unknownData = reader.ReadBytes(this._unkownDataSize);
            }
        }
Exemple #3
0
        public void Load(System.IO.BinaryReader reader)
        {
            this._unknownHeader = reader.ReadBytes(4);

            OEIShared.Utils.FourCC cc = new OEIShared.Utils.FourCC(reader.ReadChars(4));

            if (cc != this._fourCC)
            {
                throw new ApplicationException(
                          string.Format("{0} not found in stream.\nActual: ({1})\nStream Position: {2}",
                                        this._fourCC, cc.IntValue, reader.BaseStream.Position - 4));
            }

            this._unknown0    = reader.ReadInt32();
            this._unknown1    = reader.ReadInt32();
            this._width       = reader.ReadInt32();
            this._height      = reader.ReadInt32();
            this._unknown3    = reader.ReadBytes(108);
            this._textureData = reader.ReadBytes(this._width * this._height * 4);
        }
Exemple #4
0
        public void Load( System.IO.BinaryReader reader )
        {
            OEIShared.Utils.FourCC cc = new OEIShared.Utils.FourCC( reader.ReadChars( 4 ) );

            if ( cc != this._fourCC )
                throw new ApplicationException( this._fourCC.ToString() + " not found in stream" );

            this._size = reader.ReadInt32();
            cc = new OEIShared.Utils.FourCC( reader.ReadChars( 4 ) );

            if ( cc != this._compFourCC )
                throw new ApplicationException( this._compFourCC.ToString() + " not found in stream" );

            this._sizeComp = reader.ReadInt32();
            this._sizeDecomp = reader.ReadInt32();
            this._dataComp = reader.ReadBytes( this._sizeComp );

            reader.BaseStream.Seek( 0 - this._sizeComp, System.IO.SeekOrigin.Current );
            this._dataDecomp = new byte[this._sizeDecomp];
        }
Exemple #5
0
        public void Load(System.IO.BinaryReader reader)
        {
            OEIShared.Utils.FourCC cc = new OEIShared.Utils.FourCC(reader.ReadChars(4));

            if (cc != this._fourCC)
            {
                throw new ApplicationException(this._fourCC.ToString() + " not found in stream");
            }

            this._size = reader.ReadInt32();
            cc         = new OEIShared.Utils.FourCC(reader.ReadChars(4));

            if (cc != this._compFourCC)
            {
                throw new ApplicationException(this._compFourCC.ToString() + " not found in stream");
            }

            this._sizeComp   = reader.ReadInt32();
            this._sizeDecomp = reader.ReadInt32();
            this._dataComp   = reader.ReadBytes(this._sizeComp);

            reader.BaseStream.Seek(0 - this._sizeComp, System.IO.SeekOrigin.Current);
            this._dataDecomp = new byte[this._sizeDecomp];
        }
Exemple #6
0
        public void Load( System.IO.BinaryReader reader )
        {
            this._unknownHeader = reader.ReadBytes( 4 );

            OEIShared.Utils.FourCC cc = new OEIShared.Utils.FourCC( reader.ReadChars( 4 ) );

            if ( cc != this._fourCC )
                throw new ApplicationException(
                    string.Format( "{0} not found in stream.\nActual: ({1})\nStream Position: {2}",
                    this._fourCC, cc.IntValue, reader.BaseStream.Position - 4 ) );

            this._unknown0 = reader.ReadInt32();
            this._unknown1 = reader.ReadInt32();
            this._width = reader.ReadInt32();
            this._height = reader.ReadInt32();
            this._unknown3 = reader.ReadBytes( 108 );
            this._textureData = reader.ReadBytes( this._width * this._height * 4 );
        }
Exemple #7
0
        public void Load( System.IO.BinaryReader reader )
        {
            OEIShared.Utils.FourCC cc = new OEIShared.Utils.FourCC( reader.ReadChars( 4 ) );

            if ( cc != this._fourCC )
                throw new ApplicationException( this._fourCC.ToString() + " not found in stream" );

            this._size = reader.ReadInt32();
            long finalPosition = reader.BaseStream.Position + this._size;
            this._mapPart = OEIShared.Utils.CommonUtils.ConvertZeroTerminatedBytesToString( reader.ReadBytes( 128 ) ).TrimEnd( '\0' );

            this._ddsGroup = new DDSGroup(reader);

            for( int i = 0; i < 18; i++ )
                this._texVectors[i] = reader.ReadSingle();

            this._vertexCount = reader.ReadInt32();
            this._triangleCount = reader.ReadInt32();

            this._vertices = new Vertex[this._vertexCount];
            for ( int i = 0; i < this._vertexCount; i++ )
                this._vertices[i] = new Vertex( reader );

            this._triangles = new Triangle[this._triangleCount];
            for ( int i = 0; i < this._triangleCount; i++ )
                this._triangles[i] = new Triangle( reader );

            this._ddsGroup.Load( reader );
            this._ddsGroup.FirstVertex = this._vertices[0];

            this._unkownDataSize = (int)( finalPosition - reader.BaseStream.Position );
            if ( this._unkownDataSize > 0 )
                this._unknownData = reader.ReadBytes( this._unkownDataSize );
        }
Exemple #8
0
 public void Load(System.IO.BinaryReader reader)
 {
     this.Type    = new OEIShared.Utils.FourCC(reader.ReadChars(4));
     this.Address = reader.ReadInt32();
 }
Exemple #9
0
        public void Load( System.IO.BinaryReader reader )
        {
            OEIShared.Utils.FourCC cc = new OEIShared.Utils.FourCC( reader.ReadChars( 4 ) );

            if ( cc != this._fourCC )
                throw new ApplicationException( this._fourCC.ToString() + " not found in stream" );

            this._size = reader.ReadInt32();
            this._width = reader.ReadInt32();
            this._height = reader.ReadInt32();
            this._padding = reader.ReadInt32();
        }
Exemple #10
0
        /// <summary>
        /// Load the TRN direct from a binary reader stream.
        /// Stream must be aligned with the beginning of a TRN
        /// </summary>
        /// <param name="reader"></param>
        public void Load(System.IO.BinaryReader reader)
        {
            OEIShared.Utils.FourCC cc = new OEIShared.Utils.FourCC(reader.ReadChars(4));

            if (cc != this._fourCC)
            {
                throw new ApplicationException(this._fourCC.ToString() + " not found in stream");
            }

            this._majorFileVersion = reader.ReadUInt16();
            this._minorFileVersion = reader.ReadUInt16();
            this._numPackets       = reader.ReadInt32();

            PacketPointer[] packetPointers = new PacketPointer[this._numPackets];
            for (int i = 0; i < this._numPackets; i++)
            {
                packetPointers[i].Type    = new OEIShared.Utils.FourCC(reader.ReadChars(4));
                packetPointers[i].Address = reader.ReadInt32();
            }

            int curTRRNIndex = 0;
            int curTRRNX     = 0;
            int curTRRNY     = 0;

            // use the above info to find the TRWH
            foreach (PacketPointer ptr in packetPointers)
            {
                if (ptr.Type == new OEIShared.Utils.FourCC("TRWH"))
                {
                    if (this._TRWH == null)
                    {
                        reader.BaseStream.Position = ptr.Address;
                        this._TRWH  = new TRWH(reader);
                        this._TRRNs = new TRRN[this.Width, this.Height];
                    }
                    else
                    {
                        System.Windows.Forms.MessageBox.Show("Ignoring Additional TRWH");
                    }
                }
                else if (ptr.Type == new OEIShared.Utils.FourCC("TRRN"))
                {
                    if (this._TRWH == null)
                    {
                        throw new ApplicationException("TRRN found but no TRWH. Can't load TRRN.");
                    }
                    else
                    {
                        curTRRNX = curTRRNIndex % Width;
                        curTRRNY = int.Parse(Math.Floor(curTRRNIndex / (double)Width).ToString());
                        curTRRNIndex++;

                        reader.BaseStream.Position      = ptr.Address;
                        this._TRRNs[curTRRNX, curTRRNY] = new TRRN(reader);
                        this._vertices.AddRange(this._TRRNs[curTRRNX, curTRRNY].Vertices);
                        this._ddsGroups.Add(this._TRRNs[curTRRNX, curTRRNY].DDSGroup);
                    }
                }
                else if (ptr.Type == new OEIShared.Utils.FourCC("ASWM"))
                {
                    reader.BaseStream.Position = ptr.Address;
                    this._ASWMs.Add(new ASWM(reader));
                }
            }
        }
Exemple #11
0
        /// <summary>
        /// Load the TRN direct from a binary reader stream.
        /// Stream must be aligned with the beginning of a TRN
        /// </summary>
        /// <param name="reader"></param>
        public void Load( System.IO.BinaryReader reader )
        {
            OEIShared.Utils.FourCC cc = new OEIShared.Utils.FourCC( reader.ReadChars( 4 ) );

            if ( cc != this._fourCC )
                throw new ApplicationException( this._fourCC.ToString() + " not found in stream" );

            this._majorFileVersion = reader.ReadUInt16();
            this._minorFileVersion = reader.ReadUInt16();
            this._numPackets = reader.ReadInt32();

            PacketPointer[] packetPointers = new PacketPointer[this._numPackets];
            for ( int i = 0; i < this._numPackets; i++ )
            {
                packetPointers[i].Type = new OEIShared.Utils.FourCC( reader.ReadChars( 4 ) );
                packetPointers[i].Address = reader.ReadInt32();
            }

            int curTRRNIndex = 0;
            int curTRRNX = 0;
            int curTRRNY = 0;
            // use the above info to find the TRWH
            foreach( PacketPointer ptr in packetPointers )
            {
                if ( ptr.Type == new OEIShared.Utils.FourCC( "TRWH" ) )
                {
                    if ( this._TRWH == null )
                    {
                        reader.BaseStream.Position = ptr.Address;
                        this._TRWH = new TRWH( reader );
                        this._TRRNs = new TRRN[ this.Width, this.Height ];
                    }
                    else
                    {
                        System.Windows.Forms.MessageBox.Show( "Ignoring Additional TRWH" );
                    }
                }
                else if ( ptr.Type == new OEIShared.Utils.FourCC( "TRRN" ) )
                {
                    if ( this._TRWH == null )
                        throw new ApplicationException( "TRRN found but no TRWH. Can't load TRRN." );
                    else
                    {
                        curTRRNX = curTRRNIndex % Width;
                        curTRRNY = int.Parse( Math.Floor( curTRRNIndex / (double)Width ).ToString() );
                        curTRRNIndex++;

                        reader.BaseStream.Position = ptr.Address;
                        this._TRRNs[curTRRNX, curTRRNY] = new TRRN( reader );
                        this._vertices.AddRange(this._TRRNs[curTRRNX, curTRRNY].Vertices);
                        this._ddsGroups.Add(this._TRRNs[curTRRNX, curTRRNY].DDSGroup);
                    }
                }
                else if ( ptr.Type == new OEIShared.Utils.FourCC( "ASWM" ) )
                {
                    reader.BaseStream.Position = ptr.Address;
                    this._ASWMs.Add( new ASWM( reader ) );
                }
            }
        }
Exemple #12
0
 public void Load( System.IO.BinaryReader reader )
 {
     this.Type = new OEIShared.Utils.FourCC( reader.ReadChars( 4 ) );
     this.Address = reader.ReadInt32();
 }