Libgdx Setup On Linux Platform
In this article we will look at setting up Libgdx on Ubuntu 12.04 from sources and running a sample test utility for 3D models.
libGDX is a cross-platform Java game development framework based on OpenGL (ES) that works on Windows, Linux, Mac OS X, Android, your WebGL enabled browser and iOS.
Setting up Eclipse
To develop your application via Eclipse, you need to install the following softwares.
- Java Development Kit 7+ (JDK)
- Eclipse, the “Eclipse IDE for Java Developers” .
- Android SDK, you only need the SDK, Install the latest stable Android platforms via the SDK Manager in eclipse.
- Android Development Tools for Eclipse, aka ADT Plugin. Update site: https://dl-ssl.google.com/android/eclipse/
- Git distributed version control system
Libgdx download
-
Get the libgdx sources by cloning the libgdx github repository or downloading the repository
-
Let the source be placed at the path
$WORKSPACE/libgdx
Libgdx Eclipse Setup
- Select the option File->Import
- Choose General->Existing Projects into Workspace
- Navigate to the
$WORKSPACE/libgdx
directory and complete the import process. - All the libgdx projects would have been imported into eclipse
- Build all the sources successfully to make sure there are no dependency issues
Testing libgdx
- Run the
gdx-tests-lwjgl
project .Which is default testing utility shipped with the sources. - Select the various options to test and checkout the features of libgdx
Testing utility for Linux
We will look at a small test program that can be used to test 3D static and animated models on linux
libgdx allows static models files in obj,g3dj,gd3b format and animated models in g3dj and g3db format.
Presently the test utility has the following basic features
- Display the models at their default location
- Sequentiall play animations
- Rotate the view about the origin
The test utility has following main classes
BaseCharacter
- used for static modelsAnimatedBaseCharacter
- used for dynamic modelsGameWorld
- configures the world,camera and initiates the rendering process
To change the scale or position of the object you can modify the following lines in initializeActors
function in GameWorld.java
file
Pose p=new Pose(); p.mPosition=new Vector3(0,0,0f); p.mOrientation.setFromAxis(new Vector3(1,0,0),90); p.mScale=new Vector3(1f,1f,1f);
The models files are placed in same directory as the project in the assets
sub-directory.
Upon running the project the GUI will display the list of models in the folder.Upon selection of the model a new window will open which will display the 3D view of the model.
If the model is a obj file directly a static model is loaded ,
The source for the testing utility can be downloaded from the bitbucket repository https://pi19404@bitbucket.org/pi19404/libgdx-apps.git
Import the project into eclipse to and select the suitable model file to run
Converting the models
Models can be converted from fbx to g3dj or g3db format using The source for the conversion utility can be found at link or can be downloaded from build server link
Currently libgdx only supports pose transformations and material transformations are not supported.
Use the command
fbx-conv -f -o G3DJ A.fbx
or fbx-conv -f -o G3DB A.fbx
to convert the fbx model files to libgdx compatible files.