--- /dev/null
+package com.badlogic.gdx.tests.g3d;
+
+import com.badlogic.gdx.ApplicationListener;
+import com.badlogic.gdx.Gdx;
+import com.badlogic.gdx.InputMultiplexer;
+import com.badlogic.gdx.graphics.Color;
+import com.badlogic.gdx.graphics.GL10;
+import com.badlogic.gdx.graphics.PerspectiveCamera;
+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.ModelInstance;
+import com.badlogic.gdx.graphics.g3d.lights.DirectionalLight;
+import com.badlogic.gdx.graphics.g3d.lights.Lights;
+import com.badlogic.gdx.graphics.g3d.materials.ColorAttribute;
+import com.badlogic.gdx.graphics.g3d.materials.Material;
+import com.badlogic.gdx.graphics.g3d.utils.CameraInputController;
+import com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder;
+import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder;
+import com.badlogic.gdx.tests.utils.GdxTest;
+
+public class Basic3DTest extends GdxTest implements ApplicationListener {
+ public PerspectiveCamera cam;
+ public CameraInputController inputController;
+ public ModelBatch modelBatch;
+ public Model model;
+ public ModelInstance instance;
+ public Lights lights;
+
+ @Override
+ public void create () {
+ modelBatch = new ModelBatch();
+ lights = new Lights();
+ lights.ambientLight.set(0.4f, 0.4f, 0.4f, 1f);
+ lights.add(new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -1f, 0f));
+
+ cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
+ cam.position.set(10f, 10f, 10f);
+ cam.lookAt(0,0,0);
+ cam.near = 0.1f;
+ cam.far = 300f;
+ cam.update();
+
+ ModelBuilder modelBuilder = new ModelBuilder();
+ model = modelBuilder.createBox(5f, 5f, 5f, new Material(ColorAttribute.createDiffuse(Color.GREEN)), Usage.Position | Usage.Normal);
+ instance = new ModelInstance(model);
+
+ Gdx.input.setInputProcessor(new InputMultiplexer(this, inputController = new CameraInputController(cam)));
+ }
+
+ @Override
+ public void render () {
+ inputController.update();
+
+ Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
+ Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);
+
+ modelBatch.begin(cam);
+ modelBatch.render(instance, lights);
+ modelBatch.end();
+ }
+
+ @Override
+ public void dispose () {
+ modelBatch.dispose();
+ model.dispose();
+ }
+
+ public boolean needsGL20 () {
+ return true;
+ }
+
+ public void resume () {
+ }
+
+ public void resize (int width, int height) {
+ }
+
+ public void pause () {
+ }
+}
\ No newline at end of file
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.utils.Array;
-public class NewModelTest extends BaseG3dHudTest {
+public class ModelTest extends BaseG3dHudTest {
Lights lights = new Lights(0.4f, 0.4f, 0.4f).add(
new DirectionalLight().set(0.8f, 0.8f, 0.8f, -1f, -1f, 0f)
//new PointLight().set(1f, 0f, 0f, 5f, 5f, 5f, 15f),
instances.clear();
final ModelInstance instance = new ModelInstance(assets.get(currentAsset = "data/"+name, Model.class));
instances.add(instance);
-
- /*for (float x = -10; x <= 10; x += 10) {
- for (float z = -10; z <= 10; z += 10) {
- final ModelInstance instance = new ModelInstance(assets.get("data/"+name, Model.class));
- instance.transform.translate(x, 9.492372f, z);
- instances.add(instance);
- }
- }*/
}
protected void switchAnimation() {
import com.badlogic.gdx.tests.*;\r
import com.badlogic.gdx.tests.bench.TiledMapBench;\r
import com.badlogic.gdx.tests.examples.MoveSpriteExample;\r
-import com.badlogic.gdx.tests.g3d.NewModelTest;\r
+import com.badlogic.gdx.tests.g3d.Basic3DTest;\r
+import com.badlogic.gdx.tests.g3d.ModelTest;\r
import com.badlogic.gdx.tests.gles2.HelloTriangle;\r
import com.badlogic.gdx.tests.gles2.SimpleVertexShader;\r
import com.badlogic.gdx.tests.net.NetAPITest;\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
- NewModelTest.class, HexagonalTiledMapTest.class));\r
+ ModelTest.class, Basic3DTest.class, HexagonalTiledMapTest.class));\r
\r
public static List<String> getNames () {\r
List<String> names = new ArrayList<String>(tests.size());\r