Example #1
0
		private void ReadGndFile() {
			string Root = textBox2.Text;
			using( FileStream s = File.OpenRead( textBox1.Text ) ) {
				using( BinaryReader bin = new BinaryReader( s, Encoding.GetEncoding( "ISO-8859-1" ) ) ) {
					bin.BaseStream.Position += 6;

					mHeader = new HeaderInfo();
					mHeader.Width = bin.ReadUInt32();
					mHeader.Height = bin.ReadUInt32();
					mHeader.Ratio = bin.ReadUInt32();
					mHeader.TextureCount = bin.ReadUInt32();
					mHeader.TextureSize = bin.ReadUInt32();

					mTextures = new TextureInfo[ mHeader.TextureCount ];
					for( int i = 0; i < mTextures.Length; i++ ) {
						mTextures[ i ] = new TextureInfo();
						mTextures[ i ].TexPath = ReadWord( bin, 40 ).ToLower();
						mTextures[ i ].Unknown = ReadWord( bin, 40 ).ToCharArray();

						mTextures[ i ].TextureBmp = Bitmap.FromFile( Root + @"\" + mTextures[ i ].TexPath ) as Bitmap;
					}

					mLightmapCount = (uint)bin.ReadInt32();

					mGrid = new GridInfo();
					mGrid.X = bin.ReadUInt32();
					mGrid.Y = bin.ReadUInt32();
					mGrid.Cells = bin.ReadUInt32();

					mLightmaps = new LitghmapInfo[ mLightmapCount ];
					for( int i = 0; i < mLightmaps.Length; i++ ) {
						mLightmaps[ i ] = new LitghmapInfo();
						mLightmaps[ i ].brightness = bin.ReadChars( 64 );
						mLightmaps[ i ].colorrbg = bin.ReadChars( 192 );
					}


					mTileCount = (uint)bin.ReadInt32();
					mTiles = new TileInfo[ mTileCount ];
					for( int i = 0; i < mTiles.Length; i++ ) {
						mTiles[ i ] = new TileInfo();
						mTiles[ i ].VectorWidth = ReadVector4( bin );
						mTiles[ i ].VectorHeight = ReadVector4( bin );
						mTiles[ i ].TextureIndex = bin.ReadUInt16();
						mTiles[ i ].Lightmap = bin.ReadUInt16();
						mTiles[ i ].color = bin.ReadChars( 4 );
					}

					mCubeCount = mHeader.Width * mHeader.Height;
					mCubes = new CubeInfo[ mCubeCount ];
					for( int i = 0; i < mCubes.Length; i++ ) {
						mCubes[ i ] = new CubeInfo();
						mCubes[ i ].Height = ReadVector4( bin );
						mCubes[ i ].tile_up = bin.ReadInt32();
						mCubes[ i ].tile_side = bin.ReadInt32();
						mCubes[ i ].tile_aside = bin.ReadInt32();
					}

				}

			}

		}
Example #2
0
        private void ReadGndFile()
        {
            string Root = textBox2.Text;

            using (FileStream s = File.OpenRead(textBox1.Text)) {
                using (BinaryReader bin = new BinaryReader(s, Encoding.GetEncoding("ISO-8859-1"))) {
                    bin.BaseStream.Position += 6;

                    mHeader              = new HeaderInfo();
                    mHeader.Width        = bin.ReadUInt32();
                    mHeader.Height       = bin.ReadUInt32();
                    mHeader.Ratio        = bin.ReadUInt32();
                    mHeader.TextureCount = bin.ReadUInt32();
                    mHeader.TextureSize  = bin.ReadUInt32();

                    mTextures = new TextureInfo[mHeader.TextureCount];
                    for (int i = 0; i < mTextures.Length; i++)
                    {
                        mTextures[i]         = new TextureInfo();
                        mTextures[i].TexPath = ReadWord(bin, 40).ToLower();
                        mTextures[i].Unknown = ReadWord(bin, 40).ToCharArray();

                        mTextures[i].TextureBmp = Bitmap.FromFile(Root + @"\" + mTextures[i].TexPath) as Bitmap;
                    }

                    mLightmapCount = (uint)bin.ReadInt32();

                    mGrid       = new GridInfo();
                    mGrid.X     = bin.ReadUInt32();
                    mGrid.Y     = bin.ReadUInt32();
                    mGrid.Cells = bin.ReadUInt32();

                    mLightmaps = new LitghmapInfo[mLightmapCount];
                    for (int i = 0; i < mLightmaps.Length; i++)
                    {
                        mLightmaps[i]            = new LitghmapInfo();
                        mLightmaps[i].brightness = bin.ReadChars(64);
                        mLightmaps[i].colorrbg   = bin.ReadChars(192);
                    }


                    mTileCount = (uint)bin.ReadInt32();
                    mTiles     = new TileInfo[mTileCount];
                    for (int i = 0; i < mTiles.Length; i++)
                    {
                        mTiles[i]              = new TileInfo();
                        mTiles[i].VectorWidth  = ReadVector4(bin);
                        mTiles[i].VectorHeight = ReadVector4(bin);
                        mTiles[i].TextureIndex = bin.ReadUInt16();
                        mTiles[i].Lightmap     = bin.ReadUInt16();
                        mTiles[i].color        = bin.ReadChars(4);
                    }

                    mCubeCount = mHeader.Width * mHeader.Height;
                    mCubes     = new CubeInfo[mCubeCount];
                    for (int i = 0; i < mCubes.Length; i++)
                    {
                        mCubes[i]            = new CubeInfo();
                        mCubes[i].Height     = ReadVector4(bin);
                        mCubes[i].tile_up    = bin.ReadInt32();
                        mCubes[i].tile_side  = bin.ReadInt32();
                        mCubes[i].tile_aside = bin.ReadInt32();
                    }
                }
            }
        }