From fef884b17f5f0bd2ba366665451e5c88a79f3b8a Mon Sep 17 00:00:00 2001 From: Xoppa Date: Thu, 30 May 2013 20:08:56 +0200 Subject: [PATCH] Update ModelLoaderTest --- tests/gdx-tests-android/assets/data/g3d/cube.g3dj | 50 ++++++++++++---------- .../badlogic/gdx/tests/g3d/ModelLoaderTest.java | 18 +++++--- 2 files changed, 39 insertions(+), 29 deletions(-) diff --git a/tests/gdx-tests-android/assets/data/g3d/cube.g3dj b/tests/gdx-tests-android/assets/data/g3d/cube.g3dj index f06e661b5..dd44fdb70 100644 --- a/tests/gdx-tests-android/assets/data/g3d/cube.g3dj +++ b/tests/gdx-tests-android/assets/data/g3d/cube.g3dj @@ -3,38 +3,28 @@ "id": "", "meshes": [ { - "attributes": ["POSITION", "NORMAL"], + "attributes": ["POSITION", "NORMAL", "TEXCOORD0"], "vertices": [ - -1.000000, -1.000000, -1.000000, -0.577349, -0.577349, -0.577349, - 1.000000, 1.000000, -1.000000, 0.577349, 0.577349, -0.577349, - 1.000000, -1.000000, -1.000000, 0.577349, -0.577349, -0.577349, - -1.000000, 1.000000, -1.000000, -0.577349, 0.577349, -0.577349, - -1.000000, 1.000000, 1.000000, -0.577349, 0.577349, 0.577349, - -1.000000, -1.000000, 1.000000, -0.577349, -0.577349, 0.577349, - 1.000000, 0.999999, 1.000000, 0.577349, 0.577349, 0.577349, - 0.999999, -1.000001, 1.000000, 0.577349, -0.577349, 0.577349 + -1.000000, -1.000000, 0.000000, 0, 0, 1, 0, 0, + 1.000000, 1.000000, 0.000000, 0, 0, 1, 1, 1, + 1.000000, -1.000000, 0.000000, 0, 0, 1, 1, 0, + -1.000000, 1.000000, 0.000000, 0, 0, 1, 0, 1 ], "parts": [ { "id": "mpart1", "type": "TRIANGLES", "indices": [ - 0, 1, 2, 1, 0, 3, 4, 5, 6, 6, 5, 7, - 6, 2, 1, 2, 6, 7, 7, 0, 2, 0, 7, 5, - 4, 0, 5, 0, 4, 3, 4, 6, 3, 6, 1, 3 + 0, 1, 2, 2, 3, 0 ] } ] } ], "materials": [ - {"id": "unnamed", - "diffuse": [ 0.800000, 0.800000, 0.800000], - "emissive": [ 0.800000, 0.800000, 0.800000], - "specular": [ 0.800000, 0.800000, 0.800000]}, - {"id": "Material", - "diffuse": [ 0.800000, 0.800000, 0.800000], - "emissive": [ 0.800000, 0.800000, 0.800000], + { + "id": "Material", + "diffuse": [ 1, 0, 0], "textures": [ { "id": "Knight_png", @@ -44,17 +34,31 @@ { "id": "checkerboard", "filename": "Knight.png", - "type": "DIFFUSE" + "type": "NONE" + }, + { + "id": "t1", + "filename": "ship.png", + "type": "NONE" + }, + { + "id": "t2", + "filename": "space.jpg", + "type": "NONE" + }, + { + "id": "t3", + "filename": "invader.png", + "type": "NONE" } ]} ], "nodes": [ {"id": "Cube", - "rotation": [-0.707107, 0.000000, 0.000000, 0.707107], - "scale": [ 1.000000, 1.000000, 1.000000], "parts": [ {"meshpartid": "mpart1", - "materialid": "Material"} + "materialid": "Material", + "uvMapping": [[ 0]]} ] } ], diff --git a/tests/gdx-tests/src/com/badlogic/gdx/tests/g3d/ModelLoaderTest.java b/tests/gdx-tests/src/com/badlogic/gdx/tests/g3d/ModelLoaderTest.java index 6b7e068a3..2f69fd201 100644 --- a/tests/gdx-tests/src/com/badlogic/gdx/tests/g3d/ModelLoaderTest.java +++ b/tests/gdx-tests/src/com/badlogic/gdx/tests/g3d/ModelLoaderTest.java @@ -14,9 +14,8 @@ import com.badlogic.gdx.tests.utils.GdxTest; public class ModelLoaderTest extends GdxTest { AssetManager assets; PerspectiveCamera camera; - ModelBatch modelBatch; - Model model; ModelInstance instance; + ModelBatch modelBatch; SpriteBatch spriteBatch; @Override @@ -28,8 +27,8 @@ public class ModelLoaderTest extends GdxTest { camera.update(); assets = new AssetManager(); assets.load("data/g3d/cube.g3dj", Model.class); - modelBatch = new ModelBatch(); spriteBatch = new SpriteBatch(); + modelBatch = new ModelBatch(); } @Override @@ -38,12 +37,20 @@ public class ModelLoaderTest extends GdxTest { } 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); @@ -56,7 +63,6 @@ public class ModelLoaderTest extends GdxTest { 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); -- 2.11.0