use of com.badlogic.gdx.utils.JsonReader in project libgdx by libgdx.
the class ImportTest method create.
@Override
public void create() {
super.create();
ModelLoader g3djLoader = new G3dModelLoader(new JsonReader());
model = g3djLoader.loadModel(Gdx.files.internal("data/g3d/btscene1.g3dj"));
disposables.add(model);
importer = new MyImporter((btDynamicsWorld) world.collisionWorld);
importer.loadFile(Gdx.files.internal("data/g3d/btscene1.bullet"));
camera.position.set(10f, 15f, 20f);
camera.up.set(0, 1, 0);
camera.lookAt(-10, 8, 0);
camera.update();
}
use of com.badlogic.gdx.utils.JsonReader in project bdx by GoranM.
the class Mesh method copy.
public Mesh copy(String newName) {
Model uniqueModel = scene.createModel(new JsonReader().parse(serialized()));
Mesh newMesh = new Mesh(uniqueModel, scene, newName);
newMesh.materials.clear();
for (NodePart part : uniqueModel.nodes.get(0).parts) {
// Don't forget to cast to Material for it to be a true copy (see shader copying)
Material newMat = new Material((Material) part.material);
newMesh.materials.add(newMat);
part.material = newMat;
}
return newMesh;
}
use of com.badlogic.gdx.utils.JsonReader in project skin-composer by raeleus.
the class DialogFonts method initialize.
public void initialize(Main main, EventListener listener) {
this.main = main;
maxTextureWidth = 1024;
maxTextureHeight = 1024;
// extract max texture dimensions from defaults.json
FileHandle defaultsFile = Gdx.files.local("texturepacker/defaults.json");
if (defaultsFile.exists()) {
JsonReader reader = new JsonReader();
JsonValue val = reader.parse(defaultsFile);
for (JsonValue child : val.iterator()) {
if (child.name.equals("maxWidth") && child.isNumber()) {
maxTextureWidth = child.asInt();
} else if (child.name.equals("maxHeight") && child.isNumber()) {
maxTextureHeight = child.asInt();
}
}
}
this.listener = listener;
fonts = main.getJsonData().getFonts();
freeTypeFonts = main.getJsonData().getFreeTypeFonts();
drawables = main.getAtlasData().getDrawables();
fontMap = new ObjectMap<>();
produceAtlas();
filesDroppedListener = (Array<FileHandle> files) -> {
Iterator<FileHandle> iter = files.iterator();
while (iter.hasNext()) {
FileHandle file = iter.next();
if (file.isDirectory() || !file.name().toLowerCase().endsWith(".fnt")) {
iter.remove();
}
}
if (files.size > 0) {
fontNameDialog(files, 0);
}
};
main.getDesktopWorker().addFilesDroppedListener(filesDroppedListener);
populate();
}
use of com.badlogic.gdx.utils.JsonReader in project bladecoder-adventure-engine by bladecoder.
the class World method loadWorldDesc.
/**
* Load the world description in 'world.json'.
*
* @throws IOException
*/
public void loadWorldDesc() throws IOException {
String worldFilename = EngineAssetManager.WORLD_FILENAME;
if (!EngineAssetManager.getInstance().getModelFile(worldFilename).exists()) {
// Search the world file with ".json" ext if not found.
worldFilename = EngineAssetManager.WORLD_FILENAME + ".json";
if (!EngineAssetManager.getInstance().getModelFile(worldFilename).exists()) {
EngineLogger.error("ERROR LOADING WORLD: world file not found.");
dispose();
throw new IOException("ERROR LOADING WORLD: world file not found.");
}
}
SerializationHelper.getInstance().setMode(Mode.MODEL);
JsonValue root = new JsonReader().parse(EngineAssetManager.getInstance().getModelFile(worldFilename).reader("UTF-8"));
Json json = new Json();
json.setIgnoreUnknownFields(true);
int width = json.readValue("width", Integer.class, root);
int height = json.readValue("height", Integer.class, root);
// We know the world width, so we can set the scale
EngineAssetManager.getInstance().setScale(width, height);
float scale = EngineAssetManager.getInstance().getScale();
setWidth((int) (width * scale));
setHeight((int) (height * scale));
setInitChapter(json.readValue("initChapter", String.class, root));
verbs.read(json, root);
I18N.loadWorld(EngineAssetManager.MODEL_DIR + EngineAssetManager.WORLD_FILENAME);
}
use of com.badlogic.gdx.utils.JsonReader in project nhglib by VoidZombie.
the class SceneLoader method getScene.
private Scene getScene(byte[] bytes) {
Scene scene = null;
try {
String json = new String(bytes, "UTF-8");
SceneJson sceneJson = new SceneJson(entities);
sceneJson.parse(new JsonReader().parse(json).get("scene"));
scene = sceneJson.get();
} catch (UnsupportedEncodingException e) {
if (Nhg.debugLogs)
e.printStackTrace();
}
return scene;
}
Aggregations