Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Assuming size.x and size.y are 4 bytes, and heightmap.getHeight( ix, iy ) is 1 byte
- // Writing
- buffer.writeInt( size.x );
- buffer.writeInt( size.y );
- for ( int ix = 0; ix < size.x; ++ix )
- {
- for ( int iy = 0; iy < size.y; ++iy )
- {
- byte height = heightmap.getHeight( ix, iy );
- buffer.writeByte( height );
- }
- }
- // Reading
- size.x = buffer.readInt();
- size.y = buffer.readInt();
- for ( int ix = 0; ix < size.x; ++ix )
- {
- for ( int iy = 0; iy < size.y; ++iy )
- {
- byte height = buffer.readByte();
- heightmap.setHeight( ix, iy, height );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement