OSDN Git Service

Use new model for bullet tests
authorXoppa <contact@xoppa.nl>
Sun, 24 Mar 2013 22:30:38 +0000 (23:30 +0100)
committerXoppa <contact@xoppa.nl>
Sun, 24 Mar 2013 22:30:38 +0000 (23:30 +0100)
28 files changed:
gdx/src/com/badlogic/gdx/graphics/g3d/Model.java
gdx/src/com/badlogic/gdx/graphics/g3d/ModelBatch.java
gdx/src/com/badlogic/gdx/graphics/g3d/old/loaders/wavefront/ObjLoader.java
gdx/src/com/badlogic/gdx/graphics/g3d/test/test.fragment.glsl
gdx/src/com/badlogic/gdx/graphics/g3d/test/test.vertex.glsl
tests/gdx-tests/src/com/badlogic/gdx/tests/BulletTestCollection.java
tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/BaseBulletTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/BaseEntity.java
tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/BaseWorld.java
tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/BulletConstructor.java
tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/BulletEntity.java
tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/BulletWorld.java
tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/CollisionTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/CollisionWorldTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/ConstraintsTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/ContactCallbackTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/ConvexHullTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/FrustumCullingTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/InternalTickTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/KinematicTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/MeshShapeTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/RayCastTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/RayPickRagdollTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/ShootTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/SoftBodyTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/SoftMeshTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/g3d/BatchRenderTest.java
tests/gdx-tests/src/com/badlogic/gdx/tests/utils/GdxTests.java

index a0b2b47..0ab0e67 100644 (file)
@@ -28,6 +28,7 @@ import com.badlogic.gdx.graphics.g3d.old.materials.MaterialAttribute;
 import com.badlogic.gdx.graphics.g3d.utils.TextureDescriptor;
 import com.badlogic.gdx.graphics.g3d.utils.TextureProvider;
 import com.badlogic.gdx.graphics.g3d.utils.TextureProvider.FileTextureProvider;
+import com.badlogic.gdx.math.collision.BoundingBox;
 import com.badlogic.gdx.utils.Array;
 import com.badlogic.gdx.utils.BufferUtils;
 import com.badlogic.gdx.utils.ObjectMap;
@@ -253,4 +254,14 @@ public class Model {
                        node.calculateTransforms(true);
                }
        }
+       
+       private final BoundingBox meshBounds = new BoundingBox();
+       public BoundingBox getBoundingBox(final BoundingBox out) {
+               out.inf();
+               for (Mesh mesh : meshes) {
+                       mesh.calculateBoundingBox(meshBounds);
+                       out.ext(meshBounds);
+               }
+               return out;
+       }
 }
\ No newline at end of file
index 643bc78..527e724 100644 (file)
@@ -1,5 +1,6 @@
 package com.badlogic.gdx.graphics.g3d;
 
+import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.graphics.Camera;
 import com.badlogic.gdx.graphics.g3d.test.Light;
 import com.badlogic.gdx.graphics.g3d.utils.DefaultRenderableSorter;
@@ -93,7 +94,7 @@ public class ModelBatch {
                        Renderable renderable = renderables.get(i);
                        renderable.lights = lights;
                        renderable.shader = shader;
-                       renderable.shader = shader;
+                       renderable.transform.set(transform);
 //                     renderable.transform; FIXME multiply transform!
                        reuseableRenderables.add(renderable);
                }
index a8637d3..4295289 100644 (file)
@@ -33,20 +33,29 @@ import com.badlogic.gdx.graphics.Texture;
 import com.badlogic.gdx.graphics.Texture.TextureFilter;
 import com.badlogic.gdx.graphics.VertexAttribute;
 import com.badlogic.gdx.graphics.VertexAttributes.Usage;
+import com.badlogic.gdx.graphics.g3d.materials.ColorAttribute;
+import com.badlogic.gdx.graphics.g3d.materials.NewMaterial;
+import com.badlogic.gdx.graphics.g3d.materials.TextureAttribute;
+import com.badlogic.gdx.graphics.g3d.Model;
+import com.badlogic.gdx.graphics.g3d.model.data.ModelData;
+import com.badlogic.gdx.graphics.g3d.model.data.ModelMaterial;
+import com.badlogic.gdx.graphics.g3d.model.data.ModelMesh;
+import com.badlogic.gdx.graphics.g3d.model.data.ModelMeshPart;
+import com.badlogic.gdx.graphics.g3d.model.data.ModelMeshPartMaterial;
+import com.badlogic.gdx.graphics.g3d.model.data.ModelNode;
+import com.badlogic.gdx.graphics.g3d.model.data.ModelTexture;
 import com.badlogic.gdx.graphics.g3d.old.ModelLoaderHints;
-import com.badlogic.gdx.graphics.g3d.old.loaders.StillModelLoader;
-import com.badlogic.gdx.graphics.g3d.old.materials.ColorAttribute;
-import com.badlogic.gdx.graphics.g3d.old.materials.Material;
-import com.badlogic.gdx.graphics.g3d.old.materials.TextureAttribute;
-import com.badlogic.gdx.graphics.g3d.old.model.still.StillModel;
-import com.badlogic.gdx.graphics.g3d.old.model.still.StillSubMesh;
+import com.badlogic.gdx.graphics.g3d.utils.TextureDescriptor;
 import com.badlogic.gdx.graphics.glutils.ShaderProgram;
+import com.badlogic.gdx.math.Quaternion;
+import com.badlogic.gdx.math.Vector3;
+import com.badlogic.gdx.utils.Array;
 import com.badlogic.gdx.utils.FloatArray;
 
 /** Loads Wavefront OBJ files.
  * 
  * @author mzechner, espitz */
-public class ObjLoader implements StillModelLoader {
+public class ObjLoader /* implements StillModelLoader */ {
        final FloatArray verts;
        final FloatArray norms;
        final FloatArray uvs;
@@ -62,7 +71,7 @@ public class ObjLoader implements StillModelLoader {
        /** Loads a Wavefront OBJ file from a given file handle.
         * 
         * @param file the FileHandle */
-       public StillModel loadObj (FileHandle file) {
+       public Model loadObj (FileHandle file) {
                return loadObj(file, false);
        }
 
@@ -70,7 +79,7 @@ public class ObjLoader implements StillModelLoader {
         * 
         * @param file the FileHandle
         * @param flipV whether to flip the v texture coordinate (Blender, Wings3D, et al) */
-       public StillModel loadObj (FileHandle file, boolean flipV) {
+       public Model loadObj (FileHandle file, boolean flipV) {
                return loadObj(file, file.parent(), flipV);
        }
 
@@ -79,7 +88,7 @@ public class ObjLoader implements StillModelLoader {
         * @param file the FileHandle
         * @param textureDir
         * @param flipV whether to flip the v texture coordinate (Blender, Wings3D, et al) */
-       public StillModel loadObj (FileHandle file, FileHandle textureDir, boolean flipV) {
+       public Model loadObj (FileHandle file, FileHandle textureDir, boolean flipV) {
                String line;
                String[] tokens;
                char firstChar;
@@ -91,10 +100,13 @@ public class ObjLoader implements StillModelLoader {
                groups.add(activeGroup);
 
                BufferedReader reader = new BufferedReader(new InputStreamReader(file.read()), 4096);
+               int id = 0;
                try {
                        while ((line = reader.readLine()) != null) {
 
                                tokens = line.split("\\s+");
+                               if (tokens.length < 1)
+                                       break;
 
                                if (tokens[0].length() == 0) {
                                        continue;
@@ -178,7 +190,7 @@ public class ObjLoader implements StillModelLoader {
                // Get number of objects/groups remaining after removing empty ones
                final int numGroups = groups.size();
 
-               final StillModel model = new StillModel(new StillSubMesh[numGroups]);
+               final ModelData data = new ModelData();
 
                for (int g = 0; g < numGroups; g++) {
                        Group group = groups.get(g);
@@ -216,23 +228,43 @@ public class ObjLoader implements StillModelLoader {
                                        finalIndices[i] = (short)i;
                                }
                        }
-                       final Mesh mesh;
 
                        ArrayList<VertexAttribute> attributes = new ArrayList<VertexAttribute>();
                        attributes.add(new VertexAttribute(Usage.Position, 3, ShaderProgram.POSITION_ATTRIBUTE));
                        if (hasNorms) attributes.add(new VertexAttribute(Usage.Normal, 3, ShaderProgram.NORMAL_ATTRIBUTE));
                        if (hasUVs) attributes.add(new VertexAttribute(Usage.TextureCoordinates, 2, ShaderProgram.TEXCOORD_ATTRIBUTE + "0"));
-
-                       mesh = new Mesh(true, numFaces * 3, numIndices, attributes.toArray(new VertexAttribute[attributes.size()]));
-                       mesh.setVertices(finalVerts);
-                       if (numIndices > 0) mesh.setIndices(finalIndices);
-
-                       StillSubMesh subMesh = new StillSubMesh(group.name, mesh, GL10.GL_TRIANGLES);
-                       subMesh.material = mtl.getMaterial(group.materialName);
-                       model.subMeshes[g] = subMesh;
-
+               
+                       String nodeId = "node" + (++id);
+                       String meshId = "mesh" + id;
+                       String partId = "part" + id;
+                       ModelNode node = new ModelNode();
+                       node.id = nodeId;
+                       node.meshId = meshId;
+                       node.scale = new Vector3(1,1,1);
+                       node.translation = new Vector3();
+                       node.rotation = new Quaternion();
+                       ModelMeshPartMaterial pm = new ModelMeshPartMaterial();
+                       pm.meshPartId = partId;
+                       pm.materialId = group.materialName;
+                       node.meshPartMaterials = new ModelMeshPartMaterial[] { pm };
+                       ModelMeshPart part = new ModelMeshPart();
+                       part.id = partId;
+                       part.indices = finalIndices;
+                       part.primitiveType = GL10.GL_TRIANGLES;
+                       ModelMesh mesh = new ModelMesh();
+                       mesh.id = meshId;
+                       mesh.attributes = attributes.toArray(new VertexAttribute[attributes.size()]);
+                       mesh.vertices = finalVerts;
+                       mesh.parts = new ModelMeshPart[] { part };
+                       data.nodes.add(node);
+                       data.meshes.add(mesh);
+                       ModelMaterial mm = mtl.getMaterial(group.materialName);
+                       data.materials.add(mm);
                }
 
+               //for (ModelMaterial m : mtl.materials)
+                       //data.materials.add(m);
+               
                // An instance of ObjLoader can be used to load more than one OBJ.
                // Clearing the ArrayList cache instead of instantiating new
                // ArrayLists should result in slightly faster load times for
@@ -242,7 +274,7 @@ public class ObjLoader implements StillModelLoader {
                if (uvs.size > 0) uvs.clear();
                if (groups.size() > 0) groups.clear();
 
-               return model;
+               return new Model(data);
        }
 
        private Group setActiveGroup (String name) {
@@ -272,25 +304,24 @@ public class ObjLoader implements StillModelLoader {
                int numFaces;
                boolean hasNorms;
                boolean hasUVs;
-               Material mat;
+               NewMaterial mat;
 
                Group (String name) {
                        this.name = name;
                        this.faces = new ArrayList<Integer>(200);
                        this.numFaces = 0;
-                       this.mat = new Material("");
+                       this.mat = new NewMaterial("");
                        this.materialName = "default";
                }
        }
 
-       @Override
-       public StillModel load (FileHandle handle, ModelLoaderHints hints) {
+       public Model load (FileHandle handle, ModelLoaderHints hints) {
                return loadObj(handle, hints.flipV);
        }
 }
 
 class MtlLoader {
-       private ArrayList<Material> materials = new ArrayList<Material>();
+       public ArrayList<ModelMaterial> materials = new ArrayList<ModelMaterial>();
        private static AssetManager assetManager;
        private static Texture emptyTexture = null;
 
@@ -312,7 +343,7 @@ class MtlLoader {
                String curMatName = "default";
                Color difcolor = Color.WHITE;
                Color speccolor = Color.WHITE;
-               Texture texture = emptyTexture;
+               String texFilename = null;
 
                FileHandle file = Gdx.files.internal(name);
                if (file == null || file.exists() == false) return;
@@ -330,8 +361,14 @@ class MtlLoader {
                                } else if (tokens[0].charAt(0) == '#')
                                        continue;
                                else if (tokens[0].toLowerCase().equals("newmtl")) {
-                                       Material mat = new Material(curMatName, new TextureAttribute(texture, 0, TextureAttribute.diffuseTexture),
-                                               new ColorAttribute(difcolor, ColorAttribute.diffuse), new ColorAttribute(speccolor, ColorAttribute.specular));
+                                       ModelMaterial mat = new ModelMaterial();
+                                       mat.id = curMatName;
+                                       mat.diffuse = new Color(difcolor);
+                                       mat.specular = new Color(speccolor);
+                                       mat.diffuseTextures = new Array<ModelTexture>();
+                                       ModelTexture tex = new ModelTexture();
+                                       tex.fileName = new String(texFilename);
+                                       mat.diffuseTextures.add(tex);
                                        materials.add(mat);
 
                                        if (tokens.length > 1) {
@@ -360,13 +397,9 @@ class MtlLoader {
                                } else if (tokens[0].toLowerCase().equals("map_kd")) {
                                        String textureName = tokens[1];
                                        if (textureName.length() > 0) {
-                                               String texname = textureDir.child(textureName).toString();
-                                               assetManager.load(texname, Texture.class);
-                                               assetManager.finishLoading();
-                                               texture = assetManager.get(texname, Texture.class);
-                                               texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
+                                               texFilename = textureDir.child(textureName).toString();
                                        } else
-                                               texture = emptyTexture;
+                                               texFilename = null; 
 
                                }
 
@@ -377,18 +410,27 @@ class MtlLoader {
                }
 
                // last material
-               Material mat = new Material(curMatName, new TextureAttribute(texture, 0, TextureAttribute.diffuseTexture),
-                       new ColorAttribute(difcolor, ColorAttribute.diffuse), new ColorAttribute(speccolor, ColorAttribute.specular));
+               ModelMaterial mat = new ModelMaterial();
+               mat.id = curMatName;
+               mat.diffuse = new Color(difcolor);
+               mat.specular = new Color(speccolor);
+               mat.diffuseTextures = new Array<ModelTexture>();
+               ModelTexture tex = new ModelTexture();
+               tex.fileName = new String(texFilename);
+               mat.diffuseTextures.add(tex);
                materials.add(mat);
 
                return;
        }
-
-       public Material getMaterial (String name) {
-               name = name.replace('.', '_');
-               for (Material mat : materials) {
-                       if (mat.getName().equals(name)) return mat;
-               }
-               return new Material("default");
+       
+       public ModelMaterial getMaterial(final String name) {
+               for (final ModelMaterial m : materials)
+                       if (m.id.equals(name))
+                               return m;
+               ModelMaterial mat = new ModelMaterial();
+               mat.id = name;
+               mat.diffuse = new Color(Color.WHITE);
+               materials.add(mat);
+               return mat;
        }
 }
index c983060..4aa2c1b 100644 (file)
@@ -8,8 +8,6 @@ precision mediump float;
 #define LOWP
 #endif
 
-varying vec3 v_normal;
-
 #if defined(diffuseTextureFlag) || defined(specularTextureFlag)
 varying MED vec2 v_texCoords0;
 #endif
@@ -42,6 +40,7 @@ struct Light
 uniform Light lights[NUM_LIGHTS];
 
 varying vec3 v_lightLambert;
+varying vec3 v_normal;
 #endif
 #endif
 
index 6ca4d05..7ab3856 100644 (file)
@@ -3,10 +3,13 @@
 #endif
 
 attribute vec3 a_position;
+
+#ifdef NUM_LIGHTS
 attribute vec3 a_normal;
 
 uniform mat3 u_normalMatrix;
 varying vec3 v_normal;
+#endif
 
 #ifdef textureFlag
 attribute vec2 a_texCoord0;
@@ -38,9 +41,10 @@ void main() {
                
        vec4 pos = u_modelTrans * vec4(a_position, 1.0);
        gl_Position = u_projTrans * pos;
+
+       #ifdef NUM_LIGHTS
        v_normal = u_normalMatrix * a_normal;
        
-       #ifdef NUM_LIGHTS
        vec3 aggDir = vec3(0.0);
        float aggWeight = 0.0;
        vec3 aggCol = vec3(0.0);
index 2ac9d6c..d50319e 100644 (file)
@@ -160,7 +160,7 @@ public class BulletTestCollection extends GdxTest implements InputProcessor, Ges
 
        @Override
        public boolean needsGL20 () {
-               return false;
+               return true;
        }
 
        @Override
index 4ccfbda..274ab51 100644 (file)
@@ -19,14 +19,26 @@ package com.badlogic.gdx.tests.bullet;
 import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.Application.ApplicationType;
 import com.badlogic.gdx.Input.Keys;
+import com.badlogic.gdx.graphics.Color;
 import com.badlogic.gdx.graphics.GL10;
 import com.badlogic.gdx.graphics.Mesh;
 import com.badlogic.gdx.graphics.PerspectiveCamera;
 import com.badlogic.gdx.graphics.VertexAttribute;
 import com.badlogic.gdx.graphics.VertexAttributes.Usage;
+import com.badlogic.gdx.graphics.g3d.Model;
+import com.badlogic.gdx.graphics.g3d.ModelBatch;
+import com.badlogic.gdx.graphics.g3d.model.data.ModelData;
+import com.badlogic.gdx.graphics.g3d.model.data.ModelMaterial;
+import com.badlogic.gdx.graphics.g3d.model.data.ModelMesh;
+import com.badlogic.gdx.graphics.g3d.model.data.ModelMeshPart;
+import com.badlogic.gdx.graphics.g3d.model.data.ModelMeshPartMaterial;
+import com.badlogic.gdx.graphics.g3d.model.data.ModelNode;
+import com.badlogic.gdx.graphics.g3d.old.loaders.wavefront.ObjLoader;
 import com.badlogic.gdx.graphics.g3d.old.materials.Material;
-import com.badlogic.gdx.graphics.g3d.old.model.still.StillModel;
-import com.badlogic.gdx.graphics.g3d.old.model.still.StillSubMesh;
+import com.badlogic.gdx.graphics.g3d.test.Light;
+import com.badlogic.gdx.graphics.g3d.test.TestShader;
+import com.badlogic.gdx.math.Quaternion;
+import com.badlogic.gdx.math.Vector3;
 import com.badlogic.gdx.math.collision.Ray;
 import com.badlogic.gdx.physics.bullet.Bullet;
 import com.badlogic.gdx.physics.bullet.btIDebugDraw;
@@ -52,20 +64,57 @@ public class BaseBulletTest extends BulletTest {
                initialized = true;
        }
        
-       final float lightAmbient[] = new float[] {0.5f, 0.5f, 0.5f, 1f};
-       final float lightPosition[] = new float[] {10f, 10f, 10f, 1f};
-       final float lightDiffuse[] = new float[] {0.5f, 0.5f, 0.5f, 1f};
+       public Light[] lights = new Light[] {
+               //new Light(Color.WHITE, Vector3.tmp.set(-10f, 10f, -10f), 150f),
+               //new Light(Color.BLUE, Vector3.tmp.set(10f, 5f, 0f), 10f),
+               //new Light(Color.GREEN, Vector3.tmp.set(0f, 10f, 5f), 5f)
+       };
 
-       PerspectiveCamera camera;
-       BulletWorld world;
-       
+       public PerspectiveCamera camera;
+       public BulletWorld world;
+       public ObjLoader objLoader = new ObjLoader();
+       public ModelBatch modelBatch;
+                       
        public BulletWorld createWorld() {
                return new BulletWorld();
        }
        
+       public static Model createSimpleModel(final VertexAttribute[] attributes, final float[] vertices, final short[] indices) {
+               final ModelMesh mesh = new ModelMesh();
+               mesh.attributes = attributes;
+               mesh.id = "mesh1";
+               mesh.vertices = vertices;
+               ModelMeshPart mp = new ModelMeshPart();
+               mp.id = "part1";
+               mp.indices = indices;
+               mp.primitiveType = GL10.GL_TRIANGLES;
+               mesh.parts = new ModelMeshPart[] { mp };
+               ModelNode node = new ModelNode();
+               node.id = "node1";
+               node.meshId = "mesh1";
+               node.translation = new Vector3();
+               node.rotation = new Quaternion();
+               node.scale = new Vector3(1,1,1);
+               ModelMeshPartMaterial pm = new ModelMeshPartMaterial();
+               pm.meshPartId = "part1";
+               pm.materialId = "mat1";
+               node.meshPartMaterials = new ModelMeshPartMaterial[] { pm };
+               ModelMaterial mat = new ModelMaterial();
+               mat.id = "mat1";
+               mat.diffuse = new Color(Color.WHITE);
+               final ModelData data = new ModelData();
+               data.meshes.add(mesh);
+               data.nodes.add(node);
+               data.materials.add(mat);
+               return new Model(data);
+       }
+       
        @Override
        public void create () {
                init();
+               modelBatch = new ModelBatch();
+               TestShader.ignoreUnimplemented = true;
+               
                world = createWorld();
                world.performanceCounter = performanceCounter;
 
@@ -80,22 +129,20 @@ public class BaseBulletTest extends BulletTest {
                camera.update();
                
                // Create some simple meshes
-               final Mesh groundMesh = new Mesh(true, 4, 6, new VertexAttribute(Usage.Position, 3, "a_position"));
-               groundMesh.setVertices(new float[] {20f, 0f, 20f, 20f, 0f, -20f, -20f, 0f, 20f, -20f, 0f, -20f});
-               groundMesh.setIndices(new short[] {0, 1, 2, 1, 2, 3});
-               final StillModel groundModel = new StillModel(new StillSubMesh("ground", groundMesh, GL10.GL_TRIANGLES, new Material()));
+               final Model groundModel = createSimpleModel(new VertexAttribute[] { new VertexAttribute(Usage.Position, 3, "a_position") },
+                       new float[] {20f, 0f, 20f, 20f, 0f, -20f, -20f, 0f, 20f, -20f, 0f, -20f},
+                       new short[] {0, 1, 2, 1, 2, 3}); 
 
-               final Mesh boxMesh = new Mesh(true, 8, 36, new VertexAttribute(Usage.Position, 3, "a_position"));
-               boxMesh.setVertices(new float[] {0.5f, 0.5f, 0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, -0.5f,
-                       0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f});
-               boxMesh.setIndices(new short[] {0, 1, 2, 1, 2, 3, // top
-                       4, 5, 6, 5, 6, 7, // bottom
-                       0, 2, 4, 4, 6, 2, // front
-                       1, 3, 5, 5, 7, 3, // back
-                       2, 3, 6, 6, 7, 3, // left
-                       0, 1, 4, 4, 5, 1 // right
-                       });
-               final StillModel boxModel = new StillModel(new StillSubMesh("box", boxMesh, GL10.GL_TRIANGLES, new Material()));
+               final Model boxModel = createSimpleModel(new VertexAttribute[] { new VertexAttribute(Usage.Position, 3, "a_position") },
+                       new float[] {0.5f, 0.5f, 0.5f, 0.5f, 0.5f, -0.5f, -0.5f, 0.5f, 0.5f, -0.5f, 0.5f, -0.5f,
+                                               0.5f, -0.5f, 0.5f, 0.5f, -0.5f, -0.5f, -0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f},
+                       new short[] {0, 1, 2, 1, 2, 3, // top
+                                               4, 5, 6, 5, 6, 7, // bottom
+                                               0, 2, 4, 4, 6, 2, // front
+                                               1, 3, 5, 5, 7, 3, // back
+                                               2, 3, 6, 6, 7, 3, // left
+                                               0, 1, 4, 4, 5, 1 // right
+                               });
 
                // Add the constructors
                world.addConstructor("ground", new BulletConstructor(groundModel, 0f)); // mass = 0: static body
@@ -132,7 +179,10 @@ public class BaseBulletTest extends BulletTest {
        }
        
        protected void beginRender(boolean lighting) {
-               GL10 gl = Gdx.gl10;
+               Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
+               Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
+               camera.update();
+               /* GL10 gl = Gdx.gl10;
                gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
                gl.glEnable(GL10.GL_DEPTH_TEST);
                gl.glDepthFunc(GL10.GL_LEQUAL);
@@ -145,11 +195,13 @@ public class BaseBulletTest extends BulletTest {
                        gl.glLightfv(GL10.GL_LIGHT0, GL10.GL_DIFFUSE, lightDiffuse, 0);
                } else
                        gl.glDisable(GL10.GL_LIGHTING);
-               camera.apply(Gdx.gl10);
+               camera.apply(Gdx.gl10); */
        }
        
        protected void renderWorld() {
-               world.render();
+               modelBatch.begin(camera);
+               world.render(modelBatch, lights);
+               modelBatch.end();
        }
        
        public void update() {
@@ -168,7 +220,7 @@ public class BaseBulletTest extends BulletTest {
                // Shoot a box
                Ray ray = camera.getPickRay(x, y);
                BulletEntity entity = world.add(what, ray.origin.x, ray.origin.y, ray.origin.z);
-               entity.color.set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
+               entity.getColor().set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
                ((btRigidBody)entity.body).applyCentralImpulse(ray.direction.mul(impulse));
                return entity;
        }
index 4ae4499..e0e7bb0 100644 (file)
@@ -17,7 +17,9 @@ package com.badlogic.gdx.tests.bullet;
 
 import com.badlogic.gdx.graphics.Color;
 import com.badlogic.gdx.graphics.Mesh;
-import com.badlogic.gdx.graphics.g3d.old.model.Model;
+import com.badlogic.gdx.graphics.g3d.Model;
+import com.badlogic.gdx.graphics.g3d.materials.ColorAttribute;
+import com.badlogic.gdx.graphics.g3d.materials.NewMaterial;
 import com.badlogic.gdx.math.Matrix4;
 import com.badlogic.gdx.utils.Disposable;
 
@@ -27,5 +29,21 @@ import com.badlogic.gdx.utils.Disposable;
 public abstract class BaseEntity implements Disposable {
        public Matrix4 transform = new Matrix4();
        public Model model;
-       public Color color = new Color(1f, 1f, 1f, 1f);
+       private Color color = new Color(1f, 1f, 1f, 1f);
+       public Color getColor () {
+               return color;
+       }
+       public void setColor (Color color) {
+               setColor(color.r, color.g, color.b, color.a);
+       }
+       public void setColor (float r, float g, float b, float a) {
+               if (model != null) {
+                       NewMaterial m = model.materials.get(0);
+                       if (m != null) {
+                               ColorAttribute ca = (ColorAttribute)m.get(ColorAttribute.Diffuse);
+                               if (ca != null)
+                                       ca.color.set(r, g, b, a);
+                       }                               
+               }
+       }
 }
\ No newline at end of file
index c611591..4a3a9e3 100644 (file)
 package com.badlogic.gdx.tests.bullet;
 
 import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.graphics.Camera;
 import com.badlogic.gdx.graphics.Color;
 import com.badlogic.gdx.graphics.GL10;
 import com.badlogic.gdx.graphics.Mesh;
-import com.badlogic.gdx.graphics.g3d.old.model.Model;
+import com.badlogic.gdx.graphics.g3d.Model;
+import com.badlogic.gdx.graphics.g3d.ModelBatch;
+import com.badlogic.gdx.graphics.g3d.test.Light;
 import com.badlogic.gdx.math.Matrix4;
 import com.badlogic.gdx.utils.Array;
 import com.badlogic.gdx.utils.Disposable;
@@ -65,22 +68,23 @@ public class BaseWorld<T extends BaseEntity> implements Disposable {
                return entity;
        }
        
-       public void render() {
-               render(entities);
+       public void render(final ModelBatch batch, final Light[] lights) {
+               render(batch, lights, entities);
        }
        
-       public void render(final Iterable<T> entities) {
+       public void render(final ModelBatch batch, final Light[] lights, final Iterable<T> entities) {
                for (final T e : entities)
-                       render(e);
+                       batch.addModel(e.model, e.transform, lights);
        }
        
-       public void render(final T entity) {
-               final GL10 gl = Gdx.gl10;
-               gl.glPushMatrix();
-               gl.glMultMatrixf(entity.transform.val, 0);
-               gl.glColor4f(entity.color.r, entity.color.g, entity.color.b, entity.color.a);
-               entity.model.render();
-               gl.glPopMatrix();
+       public void render(final ModelBatch batch, final Light[] lights, final T entity) {
+               batch.addModel(entity.model, entity.transform, lights);
+               //final GL10 gl = Gdx.gl10;
+               //gl.glPushMatrix();
+               //gl.glMultMatrixf(entity.transform.val, 0);
+               //gl.glColor4f(entity.color.r, entity.color.g, entity.color.b, entity.color.a);
+               //entity.model.render();
+               //gl.glPopMatrix();
        }
        
        public void update() {  }
@@ -95,8 +99,8 @@ public class BaseWorld<T extends BaseEntity> implements Disposable {
                        constructor.dispose();
                constructors.clear();
                
-               for (int i = 0; i < models.size; i++)
-                       models.get(i).dispose();
+               //for (int i = 0; i < models.size; i++)
+                       //models.get(i).dispose();
                models.clear();
        }
 }
\ No newline at end of file
index d81651e..bf9337b 100644 (file)
@@ -16,7 +16,7 @@
 package com.badlogic.gdx.tests.bullet;
 
 import com.badlogic.gdx.graphics.Mesh;
-import com.badlogic.gdx.graphics.g3d.old.model.Model;
+import com.badlogic.gdx.graphics.g3d.Model;
 import com.badlogic.gdx.math.Matrix4;
 import com.badlogic.gdx.math.Vector3;
 import com.badlogic.gdx.math.collision.BoundingBox;
index 36157ba..74b6dc3 100644 (file)
@@ -16,7 +16,7 @@
 package com.badlogic.gdx.tests.bullet;
 
 import com.badlogic.gdx.graphics.Mesh;
-import com.badlogic.gdx.graphics.g3d.old.model.Model;
+import com.badlogic.gdx.graphics.g3d.Model;
 import com.badlogic.gdx.math.Matrix4;
 import com.badlogic.gdx.physics.bullet.btCollisionObject;
 import com.badlogic.gdx.physics.bullet.btCollisionShape;
index 014dd20..b679585 100644 (file)
@@ -16,6 +16,8 @@
 package com.badlogic.gdx.tests.bullet;
 
 import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.graphics.g3d.ModelBatch;
+import com.badlogic.gdx.graphics.g3d.test.Light;
 import com.badlogic.gdx.math.Matrix4;
 import com.badlogic.gdx.math.Vector3;
 import com.badlogic.gdx.math.WindowedMean;
@@ -110,14 +112,14 @@ public class BulletWorld extends BaseWorld<BulletEntity> {
        }
        
        @Override
-       public void render() {
+       public void render (ModelBatch batch, Light[] lights, Iterable<BulletEntity> entities) {
                if (debugDrawer != null && debugDrawer.getDebugMode() > 0) {
                        debugDrawer.begin();
                        collisionWorld.debugDrawWorld();
                        debugDrawer.end();
                }
                if (renderMeshes)
-                       super.render();
+                       super.render(batch, lights, entities);
        }
        
        @Override
index f8f789b..437770f 100644 (file)
@@ -95,8 +95,8 @@ public class CollisionTest extends ShootTest {
                
                // Check what the projectile hits
                if (projectile != null) {
-                       color = projectile.color;
-                       projectile.color = Color.RED;
+                       color = projectile.getColor();
+                       projectile.setColor(Color.RED);
                        world.collisionWorld.contactTest(projectile.body, contactCB);
                }
                // Check for other collisions
@@ -104,23 +104,23 @@ public class CollisionTest extends ShootTest {
                
                if (hits.size > 0) {
                        for (int i = 0; i < hits.size; i++) {
-                               colors.add(hits.get(i).color);
-                               hits.get(i).color = Color.RED;
+                               colors.add(hits.get(i).getColor());
+                               hits.get(i).setColor(Color.RED);
                        }
                }
                if (contacts.size > 0) {
                        for (int i = 0; i < contacts.size; i++) {
-                               colors.add(contacts.get(i).color);
-                               contacts.get(i).color = Color.BLUE;
+                               colors.add(contacts.get(i).getColor());
+                               contacts.get(i).setColor(Color.BLUE);
                        }
                }
                render(false);
                if (projectile != null)
-                       projectile.color = color;
+                       projectile.setColor(color);
                for (int i = 0; i < hits.size; i++)
-                       hits.get(i).color = colors.get(i);
+                       hits.get(i).setColor(colors.get(i));
                for (int i = 0; i < contacts.size; i++)
-                       contacts.get(i).color = colors.get(hits.size+i);
+                       contacts.get(i).setColor(colors.get(hits.size+i));
        }
        
        @Override
index 9ebdc7f..98e7a55 100644 (file)
@@ -18,7 +18,7 @@ package com.badlogic.gdx.tests.bullet;
 
 import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.graphics.Color;
-import com.badlogic.gdx.graphics.g3d.old.model.Model;
+import com.badlogic.gdx.graphics.g3d.Model;
 import com.badlogic.gdx.math.Matrix4;
 import com.badlogic.gdx.math.Vector3;
 import com.badlogic.gdx.physics.bullet.ContactResultCallback;
@@ -77,16 +77,16 @@ public class CollisionWorldTest extends BaseBulletTest {
                world.addConstructor("collisionBox", new BulletConstructor(boxModel));
                
                world.add("collisionGround", 0f, 0f, 0f)
-                       .color.set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
+                       .getColor().set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
                
                world.add("collisionBox", 0f, 1f, 5f)
-                       .color.set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
+                       .getColor().set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
                world.add("collisionBox", 0f, 1f, -5f)
-                       .color.set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
+                       .getColor().set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
                world.add("collisionBox", 5f, 1f, 0f)
-                       .color.set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
+                       .getColor().set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
                world.add("collisionBox", -5f, 1f, 0f)
-                       .color.set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
+                       .getColor().set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
                movingBox = world.add("collisionBox", -5f, 1f, 0f);
                normalColor.set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
        }
@@ -118,19 +118,19 @@ public class CollisionWorldTest extends BaseBulletTest {
                hit = false;
                other = null;
                world.collisionWorld.contactTest(movingBox.body, contactCB);
-               movingBox.color.set(hit ? Color.RED : normalColor);
+               movingBox.getColor().set(hit ? Color.RED : normalColor);
                
                BulletEntity e = null;
                if (other != null && other.userData != null && other.userData instanceof BulletEntity) { 
                        e = (BulletEntity)(other.userData);
-                       tmpColor.set(e.color);
-                       e.color.set(Color.RED);
+                       tmpColor.set(e.getColor());
+                       e.getColor().set(Color.RED);
                }
                
                super.renderWorld();
 
                if (e != null)
-                       e.color.set(tmpColor);
+                       e.getColor().set(tmpColor);
        }
        
        @Override
index 66992c0..8917a2f 100644 (file)
@@ -21,9 +21,7 @@ import com.badlogic.gdx.graphics.GL10;
 import com.badlogic.gdx.graphics.Mesh;
 import com.badlogic.gdx.graphics.VertexAttribute;
 import com.badlogic.gdx.graphics.VertexAttributes.Usage;
-import com.badlogic.gdx.graphics.g3d.old.materials.Material;
-import com.badlogic.gdx.graphics.g3d.old.model.still.StillModel;
-import com.badlogic.gdx.graphics.g3d.old.model.still.StillSubMesh;
+import com.badlogic.gdx.graphics.g3d.Model;
 import com.badlogic.gdx.math.Vector3;
 import com.badlogic.gdx.physics.bullet.btDiscreteDynamicsWorld;
 import com.badlogic.gdx.physics.bullet.btDynamicsWorld;
@@ -41,28 +39,27 @@ public class ConstraintsTest extends BaseBulletTest {
        public void create () {
                super.create();
 
-               final Mesh barMesh = new Mesh(true, 8, 36, new VertexAttribute(Usage.Position, 3, "a_position"));
-               barMesh.setVertices(new float[] {5f, 0.5f, 0.5f, 5f, 0.5f, -0.5f, -5f, 0.5f, 0.5f, -5f, 0.5f, -0.5f,
-                       5f, -0.5f, 0.5f, 5f, -0.5f, -0.5f, -5f, -0.5f, 0.5f, -5f, -0.5f, -0.5f});
-               barMesh.setIndices(new short[] {0, 1, 2, 1, 2, 3, // top
-                       4, 5, 6, 5, 6, 7, // bottom
-                       0, 2, 4, 4, 6, 2, // front
-                       1, 3, 5, 5, 7, 3, // back
-                       2, 3, 6, 6, 7, 3, // left
-                       0, 1, 4, 4, 5, 1 // right
+               final Model barModel = createSimpleModel(new VertexAttribute[] { new VertexAttribute(Usage.Position, 3, "a_position")},
+                       new float[] {5f, 0.5f, 0.5f, 5f, 0.5f, -0.5f, -5f, 0.5f, 0.5f, -5f, 0.5f, -0.5f,
+                               5f, -0.5f, 0.5f, 5f, -0.5f, -0.5f, -5f, -0.5f, 0.5f, -5f, -0.5f, -0.5f},
+                       new short[] {0, 1, 2, 1, 2, 3, // top
+                               4, 5, 6, 5, 6, 7, // bottom
+                               0, 2, 4, 4, 6, 2, // front
+                               1, 3, 5, 5, 7, 3, // back
+                               2, 3, 6, 6, 7, 3, // left
+                               0, 1, 4, 4, 5, 1 // right
                        });
-               final StillModel barModel = new StillModel(new StillSubMesh("bar", barMesh, GL10.GL_TRIANGLES, new Material()));
                world.addConstructor("bar", new BulletConstructor(barModel, 0f)); // mass = 0: static body
                
                // Create the entities
                world.add("ground", 0f, 0f, 0f)
-                       .color.set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
+                       .getColor().set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
                
                BulletEntity bar = world.add("bar", 0f, 7f, 0f);
-               bar.color.set(0.75f + 0.25f * (float)Math.random(), 0.75f + 0.25f * (float)Math.random(), 0.75f + 0.25f * (float)Math.random(), 1f);
+               bar.getColor().set(0.75f + 0.25f * (float)Math.random(), 0.75f + 0.25f * (float)Math.random(), 0.75f + 0.25f * (float)Math.random(), 1f);
                
                BulletEntity box1 = world.add("box", -4.5f, 6f, 0f);
-               box1.color.set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
+               box1.getColor().set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
                btPoint2PointConstraint constraint = new btPoint2PointConstraint((btRigidBody)bar.body, (btRigidBody)box1.body, Vector3.tmp.set(-5, -0.5f, -0.5f), Vector3.tmp2.set(-0.5f, 0.5f, -0.5f));
                ((btDynamicsWorld)world.collisionWorld).addConstraint(constraint, false);
                constraints.add(constraint);
@@ -70,11 +67,11 @@ public class ConstraintsTest extends BaseBulletTest {
                for (int i = 0; i < 10; i++) {
                        if (i % 2 == 0) {
                                box2 = world.add("box", -3.5f + (float)i, 6f, 0f);
-                               box2.color.set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
+                               box2.getColor().set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
                                constraint = new btPoint2PointConstraint((btRigidBody)box1.body, (btRigidBody)box2.body, Vector3.tmp.set(0.5f, -0.5f, 0.5f), Vector3.tmp2.set(-0.5f, -0.5f, 0.5f));
                        } else {
                                box1 = world.add("box", -3.5f + (float)i, 6f, 0f);
-                               box1.color.set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
+                               box1.getColor().set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
                                constraint = new btPoint2PointConstraint((btRigidBody)box2.body, (btRigidBody)box1.body, Vector3.tmp.set(0.5f, 0.5f, -0.5f), Vector3.tmp2.set(-0.5f, 0.5f, -0.5f));
                        }
                        ((btDynamicsWorld)world.collisionWorld).addConstraint(constraint, false);
index 57a0d68..681773c 100644 (file)
@@ -38,14 +38,14 @@ public class ContactCallbackTest extends BaseBulletTest {
                                final BulletEntity e = (BulletEntity)(entities.get(userValue0));
                                // Disable future callbacks for this entity
                                e.body.setContactCallbackFilter(0);
-                               e.color.set(Color.RED);
+                               e.getColor().set(Color.RED);
                                Gdx.app.log("ContactCallbackTest", "Contact processed "+(++c));
                        }
                        if (match1) {
                                final BulletEntity e = (BulletEntity)(entities.get(userValue1));
                                // Disable future callbacks for this entity
                                e.body.setContactCallbackFilter(0);
-                               e.color.set(Color.RED);
+                               e.getColor().set(Color.RED);
                                Gdx.app.log("ContactCallbackTest", "Contact processed "+(++c));
                        }
                }
@@ -69,13 +69,13 @@ public class ContactCallbackTest extends BaseBulletTest {
                
                // Create the entities
                (ground = world.add("ground", 0f, 0f, 0f))
-                       .color.set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
+                       .getColor().set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
                
                for (int x = 0; x < BOXCOUNT_X; x++) {
                        for (int y = 0; y < BOXCOUNT_Y; y++) {
                                for (int z = 0; z < BOXCOUNT_Z; z++) {
                                        final BulletEntity e = (BulletEntity)world.add("box", BOXOFFSET_X + x * 2f, BOXOFFSET_Y + y * 2f, BOXOFFSET_Z + z * 2f);
-                                       e.color.set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
+                                       e.getColor().set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
 
                                        e.body.setContactCallbackFlag(2);
                                        e.body.setContactCallbackFilter(2);
index 35526fd..b09d146 100644 (file)
@@ -19,10 +19,7 @@ package com.badlogic.gdx.tests.bullet;
 import com.badlogic.gdx.Gdx;
 import com.badlogic.gdx.graphics.GL10;
 import com.badlogic.gdx.graphics.Mesh;
-import com.badlogic.gdx.graphics.g3d.old.loaders.ModelLoaderRegistry;
-import com.badlogic.gdx.graphics.g3d.old.loaders.wavefront.ObjLoader;
-import com.badlogic.gdx.graphics.g3d.old.model.still.StillModel;
-import com.badlogic.gdx.graphics.g3d.old.model.still.StillSubMesh;
+import com.badlogic.gdx.graphics.g3d.Model;
 import com.badlogic.gdx.physics.bullet.btConvexHullShape;
 import com.badlogic.gdx.physics.bullet.btShapeHull;
 
@@ -33,17 +30,16 @@ public class ConvexHullTest extends BaseBulletTest {
        public void create () {
                super.create();
 
-               final StillModel sceneModel = ModelLoaderRegistry.loadStillModel(Gdx.files.internal("data/car.obj"));
-               final Mesh sceneMesh = sceneModel.subMeshes[0].getMesh();
-               world.addConstructor("car", new BulletConstructor(sceneModel, 5f, createConvexHullShape(sceneMesh)));
+               final Model sceneModel = objLoader.loadObj(Gdx.files.internal("data/car.obj"));
+               world.addConstructor("car", new BulletConstructor(sceneModel, 5f, createConvexHullShape(sceneModel)));
 
                // Create the entities
                world.add("ground", 0f, 0f, 0f)
-                       .color.set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
+                       .getColor().set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
                
                for (float y = 10f; y < 50f; y += 5f)
                        world.add("car", -2f+(float)Math.random()*4f, y, -2f+(float)Math.random()*4f)
-                               .color.set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
+                               .getColor().set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
        }
        
        @Override
@@ -52,7 +48,8 @@ public class ConvexHullTest extends BaseBulletTest {
                return true;
        }
        
-       public static btConvexHullShape createConvexHullShape(final Mesh mesh) {
+       public static btConvexHullShape createConvexHullShape(final Model model) {
+               final Mesh mesh = model.meshes.get(0);
                final btConvexHullShape shape = new btConvexHullShape(mesh.getVerticesBuffer(), mesh.getNumVertices(), mesh.getVertexSize());
                // now optimize the shape
                final btShapeHull hull = new btShapeHull(shape);
index 604d963..2ff8087 100644 (file)
@@ -22,10 +22,7 @@ import com.badlogic.gdx.graphics.Mesh;
 import com.badlogic.gdx.graphics.PerspectiveCamera;
 import com.badlogic.gdx.graphics.VertexAttribute;
 import com.badlogic.gdx.graphics.VertexAttributes.Usage;
-import com.badlogic.gdx.graphics.g3d.old.materials.Material;
-import com.badlogic.gdx.graphics.g3d.old.model.Model;
-import com.badlogic.gdx.graphics.g3d.old.model.still.StillModel;
-import com.badlogic.gdx.graphics.g3d.old.model.still.StillSubMesh;
+import com.badlogic.gdx.graphics.g3d.Model;
 import com.badlogic.gdx.math.Matrix4;
 import com.badlogic.gdx.math.Quaternion;
 import com.badlogic.gdx.math.Vector3;
@@ -115,12 +112,11 @@ public class FrustumCullingTest extends BaseBulletTest {
        }
        
        public static Model createFrustumModel(final Vector3... p) {
-               final Mesh mesh = new Mesh(true, 8, 32, new VertexAttribute(Usage.Position, 3, "a_position"));
-               mesh.setVertices(new float[] {
-                       p[0].x, p[0].y, p[0].z, p[1].x, p[1].y, p[1].z, p[2].x, p[2].y, p[2].z, p[3].x, p[3].y, p[3].z, // near
-                       p[4].x, p[4].y, p[4].z, p[5].x, p[5].y, p[5].z, p[6].x, p[6].y, p[6].z, p[7].x, p[7].y, p[7].z});// far
-               mesh.setIndices(new short[] {0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7});
-               return new StillModel(new StillSubMesh("frustum", mesh, GL10.GL_LINES, new Material()));
+               return createSimpleModel(new VertexAttribute[] { new VertexAttribute(Usage.Position, 3, "a_position")},
+                       new float[] {
+                               p[0].x, p[0].y, p[0].z, p[1].x, p[1].y, p[1].z, p[2].x, p[2].y, p[2].z, p[3].x, p[3].y, p[3].z, // near
+                               p[4].x, p[4].y, p[4].z, p[5].x, p[5].y, p[5].z, p[6].x, p[6].y, p[6].z, p[7].x, p[7].y, p[7].z},// far
+                       new short[] {0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6, 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7});
        }
        
        private float angleX, angleY, angleZ;
@@ -150,7 +146,7 @@ public class FrustumCullingTest extends BaseBulletTest {
                                        BOX_X_MIN + dX * (float)Math.random(), 
                                        BOX_Y_MIN + dY * (float)Math.random(), 
                                        BOX_Z_MIN + dZ * (float)Math.random()
-                               ).color.set(Color.GRAY);
+                               ).getColor().set(Color.GRAY);
                
                frustumCam = new PerspectiveCamera(camera.fieldOfView, camera.viewportWidth, camera.viewportHeight);
                frustumCam.far = Vector3.len(BOX_X_MAX, BOX_Y_MAX, BOX_Z_MAX);
@@ -165,7 +161,7 @@ public class FrustumCullingTest extends BaseBulletTest {
                final Model frustumModel = createFrustumModel(frustumCam.frustum.planePoints);
                frustumObject = createFrustumObject(frustumCam.frustum.planePoints);
                world.add(frustumEntity = new BulletEntity(frustumModel, frustumObject, 0, 0, 0));
-               frustumEntity.color.set(Color.BLUE);
+               frustumEntity.getColor().set(Color.BLUE);
                
                world.renderMeshes = false;
        }
@@ -236,16 +232,18 @@ public class FrustumCullingTest extends BaseBulletTest {
                        world.performanceCounter.stop();
                
                for (int i = 0; i < visibleEntities.size; i++)
-                       visibleEntities.get(i).color.set(Color.RED);
-               
+                       visibleEntities.get(i).getColor().set(Color.RED);
+
+               modelBatch.begin(camera);
                if ((state & CULL_FRUSTUM) == CULL_FRUSTUM) {
-                       world.render(visibleEntities);
-                       world.render(frustumEntity);
+                       world.render(modelBatch, lights, visibleEntities);
+                       world.render(modelBatch, lights, frustumEntity);
                } else
-                       world.render(world.entities);
+                       world.render(modelBatch, lights);
+               modelBatch.end();
                
                for (int i = 0; i < visibleEntities.size; i++)
-                       visibleEntities.get(i).color.set(Color.GRAY);
+                       visibleEntities.get(i).getColor().set(Color.GRAY);
        }
        
        @Override
index 125fb1f..7139afd 100644 (file)
@@ -64,13 +64,13 @@ public class InternalTickTest extends BaseBulletTest {
 
                // Create the entities
                world.add("ground", 0f, 0f, 0f)
-                       .color.set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
+                       .getColor().set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
 
                for (int x = 0; x < BOXCOUNT_X; x++) {
                        for (int y = 0; y < BOXCOUNT_Y; y++) {
                                for (int z = 0; z < BOXCOUNT_Z; z++) {
                                        world.add("box", BOXOFFSET_X + x, BOXOFFSET_Y + y, BOXOFFSET_Z + z)
-                                               .color.set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
+                                               .getColor().set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
                                }
                        }
                }
index 59dcb86..02ebc38 100644 (file)
@@ -37,16 +37,16 @@ public class KinematicTest extends BaseBulletTest {
 
                // Create the entities
                world.add("ground", 0f, 0f, 0f)
-                       .color.set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
+                       .getColor().set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
                
                kinematicBox1 = world.add("staticbox", position1.x, position1.y, position1.z);
-               kinematicBox1.color.set(Color.RED);
+               kinematicBox1.getColor().set(Color.RED);
                kinematicBox1.body.setCollisionFlags(kinematicBox1.body.getCollisionFlags() | btCollisionObject.CollisionFlags.CF_KINEMATIC_OBJECT);
                kinematicBox2 = world.add("staticbox", position2.x, position2.y, position2.z);
-               kinematicBox2.color.set(Color.RED);
+               kinematicBox2.getColor().set(Color.RED);
                kinematicBox2.body.setCollisionFlags(kinematicBox2.body.getCollisionFlags() | btCollisionObject.CollisionFlags.CF_KINEMATIC_OBJECT);;
                kinematicBox3 = world.add("staticbox", position3.x, position3.y, position3.z);
-               kinematicBox3.color.set(Color.RED);
+               kinematicBox3.getColor().set(Color.RED);
                kinematicBox3.body.setCollisionFlags(kinematicBox3.body.getCollisionFlags() | btCollisionObject.CollisionFlags.CF_KINEMATIC_OBJECT);;
                // This makes bullet call btMotionState#getWorldTransform on every update:
                kinematicBox3.body.setActivationState(gdxBullet.DISABLE_DEACTIVATION);
index 4177694..8fca0f9 100644 (file)
@@ -17,8 +17,7 @@
 package com.badlogic.gdx.tests.bullet;
 
 import com.badlogic.gdx.Gdx;
-import com.badlogic.gdx.graphics.g3d.old.loaders.ModelLoaderRegistry;
-import com.badlogic.gdx.graphics.g3d.old.model.still.StillModel;
+import com.badlogic.gdx.graphics.g3d.Model;
 import com.badlogic.gdx.math.Matrix4;
 import com.badlogic.gdx.math.Vector3;
 import com.badlogic.gdx.math.collision.BoundingBox;
@@ -32,8 +31,8 @@ public class MeshShapeTest extends BaseBulletTest {
        public void create () {
                super.create();
                
-               final StillModel sphereModel = ModelLoaderRegistry.loadStillModel(Gdx.files.internal("data/sphere.obj"));
-               sphereModel.subMeshes[0].getMesh().scale(0.25f, 0.25f, 0.25f);
+               final Model sphereModel = objLoader.loadObj(Gdx.files.internal("data/sphere.obj"));
+               // sphereModel.subMeshes[0].getMesh().scale(0.25f, 0.25f, 0.25f);
                final BoundingBox sphereBounds = new BoundingBox();
                sphereModel.getBoundingBox(sphereBounds);
        
@@ -41,21 +40,21 @@ public class MeshShapeTest extends BaseBulletTest {
                sphereConstructor.bodyInfo.setM_restitution(1f);
                world.addConstructor("sphere", sphereConstructor);
                
-               // final StillModel sceneModel = ModelLoaderRegistry.loadStillModel(Gdx.files.internal("data/scene.obj"));
-               // final BulletConstructor sceneConstructor = new BulletConstructor(sceneModel, 0f, new btBvhTriangleMeshShape(true, sceneModel));
-               // sceneConstructor.bodyInfo.setM_restitution(0.25f);
-               // world.addConstructor("scene", sceneConstructor);
+               final Model sceneModel = objLoader.loadObj(Gdx.files.internal("data/scene.obj"));
+               final BulletConstructor sceneConstructor = new BulletConstructor(sceneModel, 0f, new btBvhTriangleMeshShape(true, sceneModel));
+               sceneConstructor.bodyInfo.setM_restitution(0.25f);
+               world.addConstructor("scene", sceneConstructor);
                
-               // world.add("scene", (new Matrix4()).setToTranslation(0f, 2f, 0f).rotate(Vector3.Y, -90))
-                       // .color.set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
+               world.add("scene", (new Matrix4()).setToTranslation(0f, 2f, 0f).rotate(Vector3.Y, -90))
+                       .getColor().set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
 
                world.add("ground", 0f, 0f, 0f)
-                       .color.set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
+                       .getColor().set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
                
                for (float x = -3; x < 7; x++) {
                        for (float z = -5; z < 5; z++) {
                                world.add("sphere", x, 10f + (float)Math.random() * 0.1f, z)
-                                       .color.set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
+                                       .getColor().set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
                        }
                }
        }
index 9885870..0085a92 100644 (file)
@@ -49,13 +49,13 @@ public class RayCastTest extends BaseBulletTest {
 
                // Create the entities
                world.add("ground", -7f, 0f, -7f)
-                       .color.set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
+                       .getColor().set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
 
                for (int x = 0; x < BOXCOUNT_X; x++) {
                        for (int y = 0; y < BOXCOUNT_Y; y++) {
                                for (int z = 0; z < BOXCOUNT_Z; z++) {
                                        world.add("box", BOXOFFSET_X + x, BOXOFFSET_Y + y, BOXOFFSET_Z + z)
-                                               .color.set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
+                                               .getColor().set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
                                }
                        }
                }
index 399e93e..181c964 100644 (file)
@@ -20,10 +20,7 @@ import com.badlogic.gdx.graphics.GL10;
 import com.badlogic.gdx.graphics.Mesh;
 import com.badlogic.gdx.graphics.VertexAttribute;
 import com.badlogic.gdx.graphics.VertexAttributes.Usage;
-import com.badlogic.gdx.graphics.g3d.old.materials.Material;
-import com.badlogic.gdx.graphics.g3d.old.model.Model;
-import com.badlogic.gdx.graphics.g3d.old.model.still.StillModel;
-import com.badlogic.gdx.graphics.g3d.old.model.still.StillSubMesh;
+import com.badlogic.gdx.graphics.g3d.Model;
 import com.badlogic.gdx.math.MathUtils;
 import com.badlogic.gdx.math.Matrix4;
 import com.badlogic.gdx.math.Vector3;
@@ -67,7 +64,7 @@ public class RayPickRagdollTest extends BaseBulletTest {
                world.addConstructor("lowerarm", new BulletConstructor(createCapsuleModel(0.04f, 0.25f), 1f, new btCapsuleShape(0.04f, 0.25f)));
                
                world.add("ground", 0f, 0f, 0f)
-                       .color.set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
+                       .getColor().set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
                
                addRagdoll(0, 3f, 0);
                addRagdoll(1f, 6f, 0);
@@ -251,16 +248,16 @@ public class RayPickRagdollTest extends BaseBulletTest {
        
        protected Model createCapsuleModel(float radius, float height) {
                final float hh = radius + 0.5f * height;
-               final Mesh mesh = new Mesh(true, 8, 36, new VertexAttribute(Usage.Position, 3, "a_position"));
-               mesh.setVertices(new float[] {radius, hh, radius, radius, hh, -radius, -radius, hh, radius, -radius, hh, -radius,
-                       radius, -hh, radius, radius, -hh, -radius, -radius, -hh, radius, -radius, -hh, -radius});
-               mesh.setIndices(new short[] {0, 1, 2, 1, 2, 3, // top
-                       4, 5, 6, 5, 6, 7, // bottom
-                       0, 2, 4, 4, 6, 2, // front
-                       1, 3, 5, 5, 7, 3, // back
-                       2, 3, 6, 6, 7, 3, // left
-                       0, 1, 4, 4, 5, 1 // right
+               return createSimpleModel(new VertexAttribute[] { new VertexAttribute(Usage.Position, 3, "a_position") }, 
+                       new float[] {radius, hh, radius, radius, hh, -radius, -radius, hh, radius, -radius, hh, -radius,
+                               radius, -hh, radius, radius, -hh, -radius, -radius, -hh, radius, -radius, -hh, -radius},
+                       new short[] {0, 1, 2, 1, 2, 3, // top
+                               4, 5, 6, 5, 6, 7, // bottom
+                               0, 2, 4, 4, 6, 2, // front
+                               1, 3, 5, 5, 7, 3, // back
+                               2, 3, 6, 6, 7, 3, // left
+                               0, 1, 4, 4, 5, 1 // right
                        });
-               return new StillModel(new StillSubMesh("capsule", mesh, GL10.GL_TRIANGLES, new Material()));
+               // return new StillModel(new StillSubMesh("capsule", mesh, GL10.GL_TRIANGLES, new Material()));
        }
 }
index 2c4aa74..b4e178b 100644 (file)
@@ -34,13 +34,13 @@ public class ShootTest extends BaseBulletTest {
 
                // Create the entities
                (ground = world.add("ground", 0f, 0f, 0f))
-                       .color.set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
+                       .setColor(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
 
                for (int x = 0; x < BOXCOUNT_X; x++) {
                        for (int y = 0; y < BOXCOUNT_Y; y++) {
                                for (int z = 0; z < BOXCOUNT_Z; z++) {
                                        world.add("box", BOXOFFSET_X + x, BOXOFFSET_Y + y, BOXOFFSET_Z + z)
-                                               .color.set(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
+                                               .setColor(0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 0.5f + 0.5f * (float)Math.random(), 1f);
                                }
                        }
                }
index ed0daa6..6d0a9d0 100644 (file)
@@ -70,7 +70,7 @@ public class SoftBodyTest extends BaseBulletTest {
                super.create();
                
                world.add("ground", 0f, 0f, 0f)
-               .color.set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
+               .getColor().set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
                
                float x0 = -2f, y0 = 6f, z0 = -2f;
                float x1 = 8f, y1 = 6f, z1 = 8f;
index ad15f4b..0ca2030 100644 (file)
@@ -67,7 +67,7 @@ public class SoftMeshTest extends BaseBulletTest {
                world.maxSubSteps = 20;
                
                world.add("ground", 0f, 0f, 0f)
-               .color.set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
+               .getColor().set(0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 0.25f + 0.5f * (float)Math.random(), 1f);
                
                // Note: not every model is suitable for a one on one translation with a soft body, a better model might be added later.
                final StillModel model = ModelLoaderRegistry.loadStillModel(Gdx.files.internal("data/wheel.obj"));
index baa4f4f..7e84447 100644 (file)
@@ -6,16 +6,12 @@ import com.badlogic.gdx.graphics.GL10;
 import com.badlogic.gdx.graphics.GL20;
 import com.badlogic.gdx.graphics.PerspectiveCamera;
 import com.badlogic.gdx.graphics.Texture;
-import com.badlogic.gdx.graphics.g3d.RenderBatch;
+import com.badlogic.gdx.graphics.g3d.Model;
+import com.badlogic.gdx.graphics.g3d.ModelBatch;
 import com.badlogic.gdx.graphics.g3d.loader.JsonModelLoader;
-import com.badlogic.gdx.graphics.g3d.old.loaders.ModelLoaderRegistry;
-import com.badlogic.gdx.graphics.g3d.old.materials.Material;
-import com.badlogic.gdx.graphics.g3d.old.materials.TextureAttribute;
-import com.badlogic.gdx.graphics.g3d.old.model.still.StillModel;
-import com.badlogic.gdx.graphics.g3d.old.model.still.StillSubMesh;
-import com.badlogic.gdx.graphics.g3d.test.InterimModel;
+import com.badlogic.gdx.graphics.g3d.old.loaders.wavefront.ObjLoader;
 import com.badlogic.gdx.graphics.g3d.test.Light;
-import com.badlogic.gdx.graphics.g3d.test.NewModel;
+import com.badlogic.gdx.graphics.g3d.test.TestShader;
 import com.badlogic.gdx.graphics.g3d.utils.DefaultTextureBinder;
 import com.badlogic.gdx.math.Matrix4;
 import com.badlogic.gdx.math.Vector3;
@@ -32,23 +28,23 @@ public class BatchRenderTest extends GdxTest {
        float SIZE_X = 20f, SIZE_Y = 20f, SIZE_Z = 20f;
        
        public static class ModelInstance {
-               public NewModel model;
+               public Model model;
                public Matrix4 transform;
-               public ModelInstance(NewModel model, Matrix4 transform) {
+               public ModelInstance(Model model, Matrix4 transform) {
                        this.model = model;
                        this.transform = transform;
                }
        }
        PerspectiveCamera cam;
        Array<ModelInstance> instances = new Array<ModelInstance>();
-       NewModel sphereModel;
-       NewModel sceneModel;
-       StillModel cubeModel;
-       NewModel carModel;
-       NewModel testModel;
-       Array<NewModel> cubes = new Array<NewModel>();
+       Model sphereModel;
+       Model sceneModel;
+       Model cubeModel;
+       Model carModel;
+       Model testModel;
+       Array<Model> cubes = new Array<Model>();
        Array<Texture> textures = new Array<Texture>();
-       RenderBatch renderBatch;
+       ModelBatch renderBatch;
        DefaultTextureBinder exclusiveTextures;
        Light[] lights;
        
@@ -59,6 +55,8 @@ public class BatchRenderTest extends GdxTest {
        
        @Override
        public void create () {
+               TestShader.ignoreUnimplemented = true;
+               
                final JsonModelLoader loader = new JsonModelLoader();
 
                // need more higher resolution textures for this test...
@@ -68,15 +66,17 @@ public class BatchRenderTest extends GdxTest {
                for (int i = 0; i < TEXTURE_COUNT; i++)
                        textures.add(new Texture(Gdx.files.internal(TEXTURES[i%TEXTURES.length])));
                
-               sphereModel = new InterimModel(ModelLoaderRegistry.loadStillModel(Gdx.files.internal("data/sphere.obj")));
-               sceneModel = new InterimModel(ModelLoaderRegistry.loadStillModel(Gdx.files.internal("data/scene.obj")));
-               cubeModel = ModelLoaderRegistry.loadStillModel(Gdx.files.internal("data/cube.obj"));
-               carModel = new InterimModel(ModelLoaderRegistry.loadStillModel(Gdx.files.internal("data/car.obj")));
-               testModel = new InterimModel(loader.load(Gdx.files.internal("data/g3d/test.g3dj"), null));
+               ObjLoader objLoader = new ObjLoader();
+               sphereModel = objLoader.loadObj(Gdx.files.internal("data/sphere.obj"));
+               sceneModel = objLoader.loadObj(Gdx.files.internal("data/scene.obj"));
+               cubeModel = objLoader.loadObj(Gdx.files.internal("data/cube.obj"));
+               carModel = objLoader.loadObj(Gdx.files.internal("data/car.obj"));
+               testModel = new Model(loader.parseModel(Gdx.files.internal("data/g3d/head.g3dj"),  null));
                
-               StillSubMesh mesh = (StillSubMesh)(cubeModel.subMeshes[0]);
+               //StillSubMesh mesh = (StillSubMesh)(cubeModel.subMeshes[0]);
                for (int i = 0; i < textures.size; i++)
-                       cubes.add(new InterimModel(new StillModel(new StillSubMesh(mesh.name, mesh.mesh, mesh.primitiveType, new Material("mat", new TextureAttribute(textures.get(i), 0, TextureAttribute.diffuseTexture))))));
+                       cubes.add(cubeModel);
+                       // cubes.add(new InterimModel(new StillModel(new StillSubMesh(mesh.name, mesh.mesh, mesh.primitiveType, new Material("mat", new TextureAttribute(textures.get(i), 0, TextureAttribute.diffuseTexture))))));
                
                createScene2();
                
@@ -87,7 +87,7 @@ public class BatchRenderTest extends GdxTest {
                cam.lookAt(0, 0, 0);
                cam.update();
                
-               renderBatch = new RenderBatch();
+               renderBatch = new ModelBatch();
                
                lights = new Light[] {
                        new Light(Color.WHITE, Vector3.tmp.set(-10f, 10f, -10f), 15f),
@@ -118,8 +118,8 @@ public class BatchRenderTest extends GdxTest {
        public void render () {
                if ((dbgTimer += Gdx.graphics.getDeltaTime()) >= 1f) {
                        dbgTimer -= 1f;
-                       Gdx.app.log("Test", "FPS: "+Gdx.graphics.getFramesPerSecond()+", binds: "+exclusiveTextures.getBindCount()+", reused: "+exclusiveTextures.getReuseCount());
-                       exclusiveTextures.resetCounts();
+                       // Gdx.app.log("Test", "FPS: "+Gdx.graphics.getFramesPerSecond()+", binds: "+exclusiveTextures.getBindCount()+", reused: "+exclusiveTextures.getReuseCount());
+                       // exclusiveTextures.resetCounts();
                }
                GL20 gl = Gdx.gl20;
                gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
@@ -128,8 +128,12 @@ public class BatchRenderTest extends GdxTest {
                Gdx.gl.glDisable(GL20.GL_CULL_FACE);
                
                renderBatch.begin(cam);
-               for (int i = 0; i < instances.size; i++)
-                       renderBatch.addModel(instances.get(i).model, instances.get(i).transform, lights);
+               for (int i = 0; i < instances.size; i++) {
+                       if (instances.get(i).model == null)
+                               Gdx.app.log("Test", "Model "+i+" is null");
+                       else
+                               renderBatch.addModel(instances.get(i).model, instances.get(i).transform, lights);
+               }
                renderBatch.end();              
        }
        
index 9d25e81..42c6ca4 100644 (file)
@@ -37,6 +37,7 @@ import com.badlogic.gdx.tests.*;
 import com.badlogic.gdx.tests.bench.TiledMapBench;\r
 import com.badlogic.gdx.tests.examples.MoveSpriteExample;\r
 import com.badlogic.gdx.tests.g3d.BatchRenderTest;\r
+import com.badlogic.gdx.tests.g3d.NewModelTest;\r
 import com.badlogic.gdx.tests.g3d.JsonModelLoaderTest;\r
 import com.badlogic.gdx.tests.gles2.HelloTriangle;\r
 import com.badlogic.gdx.tests.gles2.SimpleVertexShader;\r
@@ -77,10 +78,10 @@ public class GdxTests {
                // SoundTouchTest.class, Mpg123Test.class, WavTest.class, FreeTypeTest.class,\r
                // InternationalFontsTest.class, VorbisTest.class\r
                TextButtonTest.class, TextButtonTestGL2.class, TextureBindTest.class, SortedSpriteTest.class,\r
-               ExternalMusicTest.class, SoftKeyboardTest.class, DirtyRenderingTest.class, YDownTest.class,  BatchRenderTest.class,\r
+               ExternalMusicTest.class, SoftKeyboardTest.class, DirtyRenderingTest.class, YDownTest.class,\r
                ScreenCaptureTest.class, BitmapFontTest.class, LabelScaleTest.class, GamepadTest.class, NetAPITest.class, TideMapAssetManagerTest.class, TideMapDirectLoaderTest.class, TiledMapAssetManagerTest.class, TiledMapBench.class,\r
                RunnablePostTest.class, Vector2dTest.class, SuperKoalio.class, NinePatchTest.class,\r
-               JsonModelLoaderTest.class, BatchRenderTest.class));\r
+               JsonModelLoaderTest.class, BatchRenderTest.class, NewModelTest.class));\r
        \r
        public static List<String> getNames () {\r
                List<String> names = new ArrayList<String>(tests.size());\r