Are you looking to have 3D models with animations or just static models like in
Droid Invaders? For models with animations you need to download the libgdx source code by typing the following into command prompt (on windows):
- Code: Select all
svn checkout http://libgdx.googlecode.com/svn/trunk/ libgdx-read-only
You need to have a program such as
Subversion to do that though I believe. This should download a folder called
libgdx-read-only in your user directory. Open up eclipse and set your workspace as this folder. You then need to import all the projects from this folder. Find a project named,
model-loaders, then right click and export > java > jar file. This should create a model-loaders.jar file in your user directory which you then need to add to the libs folder of your gdx project. Make sure to edit your project's properties to include model-loaders.jar in the build path as well. Your project can now use the model-loaders extension.
If you built your app following the model, view, controller pattern then it will be easier to add 3D to your game. Go back to the model-loaders project in the libgdx source and a have a look at package com.badlogic.gdx.graphics.g3d.experimental.HybridLightTest.java. You should be able to compile and run it as a java application. You'll see a lot of knights moving around in place. If you click, you'll change their animation. You can drag the camera around by clicking and dragging. After messing around with some things in this file I was able to learn how to use the 3d part of libgdx. Make sure to check the include normals box when exporting .obj files from Blender or else your models won't be textured.
Let me know if you need help.
Edit: Also include the model-loaders.jar in your android project as well or else when you test your app on a device it will stop with a missing class error.
Another important edit: Copy the
assets/data/shaders/ from the
model-loaders-android project to your android project's asset folder or else you will get a missing shader error.
And another: Also make sure useGL20 is set equal to true in your application configuration. If you want to use shaders in your app.