Book Image

Learning LibGDX Game Development- Second Edition

Book Image

Learning LibGDX Game Development- Second Edition

Overview of this book

Table of Contents (21 chapters)
Learning LibGDX Game Development Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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 example

  • tiretext.jpg and yellowtaxi.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 updated on each render...