"id": "", \r
"meshes": [\r
{\r
- "attributes": ["POSITION", "NORMAL"], \r
+ "attributes": ["POSITION", "NORMAL", "TEXCOORD0"], \r
"vertices": [\r
- -1.000000, -1.000000, -1.000000, -0.577349, -0.577349, -0.577349, \r
- 1.000000, 1.000000, -1.000000, 0.577349, 0.577349, -0.577349, \r
- 1.000000, -1.000000, -1.000000, 0.577349, -0.577349, -0.577349, \r
- -1.000000, 1.000000, -1.000000, -0.577349, 0.577349, -0.577349, \r
- -1.000000, 1.000000, 1.000000, -0.577349, 0.577349, 0.577349, \r
- -1.000000, -1.000000, 1.000000, -0.577349, -0.577349, 0.577349, \r
- 1.000000, 0.999999, 1.000000, 0.577349, 0.577349, 0.577349, \r
- 0.999999, -1.000001, 1.000000, 0.577349, -0.577349, 0.577349\r
+ -1.000000, -1.000000, 0.000000, 0, 0, 1, 0, 0,\r
+ 1.000000, 1.000000, 0.000000, 0, 0, 1, 1, 1,\r
+ 1.000000, -1.000000, 0.000000, 0, 0, 1, 1, 0,\r
+ -1.000000, 1.000000, 0.000000, 0, 0, 1, 0, 1\r
], \r
"parts": [\r
{\r
"id": "mpart1", \r
"type": "TRIANGLES", \r
"indices": [\r
- 0, 1, 2, 1, 0, 3, 4, 5, 6, 6, 5, 7, \r
- 6, 2, 1, 2, 6, 7, 7, 0, 2, 0, 7, 5, \r
- 4, 0, 5, 0, 4, 3, 4, 6, 3, 6, 1, 3\r
+ 0, 1, 2, 2, 3, 0\r
]\r
}\r
]\r
}\r
], \r
"materials": [\r
- {"id": "unnamed", \r
- "diffuse": [ 0.800000, 0.800000, 0.800000], \r
- "emissive": [ 0.800000, 0.800000, 0.800000], \r
- "specular": [ 0.800000, 0.800000, 0.800000]}, \r
- {"id": "Material", \r
- "diffuse": [ 0.800000, 0.800000, 0.800000], \r
- "emissive": [ 0.800000, 0.800000, 0.800000],\r
+ {\r
+ "id": "Material", \r
+ "diffuse": [ 1, 0, 0], \r
"textures": [\r
{\r
"id": "Knight_png", \r
{\r
"id": "checkerboard", \r
"filename": "Knight.png", \r
- "type": "DIFFUSE"\r
+ "type": "NONE"\r
+ },\r
+ {\r
+ "id": "t1", \r
+ "filename": "ship.png", \r
+ "type": "NONE"\r
+ },\r
+ {\r
+ "id": "t2", \r
+ "filename": "space.jpg", \r
+ "type": "NONE"\r
+ },\r
+ {\r
+ "id": "t3", \r
+ "filename": "invader.png", \r
+ "type": "NONE"\r
}\r
]}\r
], \r
"nodes": [\r
{"id": "Cube", \r
- "rotation": [-0.707107, 0.000000, 0.000000, 0.707107], \r
- "scale": [ 1.000000, 1.000000, 1.000000], \r
"parts": [\r
{"meshpartid": "mpart1", \r
- "materialid": "Material"}\r
+ "materialid": "Material",\r
+ "uvMapping": [[ 0]]}\r
]\r
}\r
], \r
public class ModelLoaderTest extends GdxTest {
AssetManager assets;
PerspectiveCamera camera;
- ModelBatch modelBatch;
- Model model;
ModelInstance instance;
+ ModelBatch modelBatch;
SpriteBatch spriteBatch;
@Override
camera.update();
assets = new AssetManager();
assets.load("data/g3d/cube.g3dj", Model.class);
- modelBatch = new ModelBatch();
spriteBatch = new SpriteBatch();
+ modelBatch = new ModelBatch();
}
@Override
}
private void doneLoading() {
- model = assets.get("data/g3d/cube.g3dj", Model.class);
- instance = new ModelInstance(model);
+ instance = new ModelInstance(assets.get("data/g3d/cube.g3dj", Model.class));
}
+ float counter;
@Override
public void render () {
+ if ((instance != null) && ((counter += Gdx.graphics.getDeltaTime()) >= 1f)) {
+ counter = 0f;
+ instance = null;
+ assets.unload("data/g3d/cube.g3dj");
+ assets.load("data/g3d/cube.g3dj", Model.class);
+ assets.finishLoading(); // FIXME: Remove this line
+ }
+
Gdx.gl.glClearColor(0.2f, 0.2f, 0.2f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT);
Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);
modelBatch.begin(camera);
modelBatch.render(instance);
modelBatch.end();
-
spriteBatch.begin();
spriteBatch.draw(assets.get("data/g3d/checkboard.png", Texture.class), 0, 0, 100, 100);
spriteBatch.draw(assets.get("data/g3d/Knight.png", Texture.class), 100, 0, 100, 100);