Loading a model
In a game, we need an actual model exported from Blender or any other 3D animation software.
Note
The assets for our example are provided with the code bundle of this chapter.
Copy these three files to the assets
folder of the android
project:
car.g3dj
: This is the model file to be used in our exampletiretext.jpg
andyellowtaxi.jpg
: These are the materials for the model
Replacing the ModelBuilder
class in our ModelTest.java
file, we add the following code:
assets = new AssetManager(); assets.load("car.g3dj", Model.class); assets.finishLoading(); model = assets.get("car.g3dj", Model.class); instance = new ModelInstance(model);
Additionally, a camera input controller is also added to inspect the model from various angles as follows:
camController = new CameraInputController(cam); Gdx.input.setInputProcessor(camController); camController.update();
This camera input controller will be...