![JAR search and dependency download from the Maven repository](/logo.png)
ca.blarg.gdx.tilemap3d.assets.prefabs.TilePrefabSaver Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gdx-tilemap3d Show documentation
Show all versions of gdx-tilemap3d Show documentation
Library to handle management and rendering of a game world composed of 3D "tiles" arranged in a uniform 3D grid, via libGDX.
The newest version!
package ca.blarg.gdx.tilemap3d.assets.prefabs;
import ca.blarg.gdx.tilemap3d.assets.tilemap.TileDataSerializer;
import ca.blarg.gdx.tilemap3d.prefabs.TilePrefab;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.utils.Base64Coder;
import com.badlogic.gdx.utils.Json;
import java.nio.ByteBuffer;
public class TilePrefabSaver {
public static void save(TilePrefab prefab, String outputFilename) {
if (prefab == null)
throw new IllegalArgumentException();
JsonTilePrefab jsonPrefab = new JsonTilePrefab();
jsonPrefab.width = prefab.getWidth();
jsonPrefab.height = prefab.getHeight();
jsonPrefab.depth = prefab.getDepth();
byte[] dataBytes = new byte[prefab.getData().length * TileDataSerializer.TILE_SIZE_BYTES];
ByteBuffer buffer = ByteBuffer.wrap(dataBytes);
TileDataSerializer.serialize(prefab, buffer);
jsonPrefab.data = new String(Base64Coder.encode(dataBytes));
Json json = new Json();
String output = json.prettyPrint(jsonPrefab);
FileHandle outputFile = Gdx.files.local(outputFilename);
outputFile.writeString(output, false);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy