FbxConv task

When building a 3D libgdx game with 3D models created in Blender, you need to convert these models to a format supported by libgdx. Libgdx provides a command line tool to do this: fbx-conv.

The com.eowise.blender.fbxconv.FbxConv task wrap the fbx-conv command line. You specify the files you want to convert, where to write the converted files, and the format in witch you want to convert the files.

To use this feature, the path to the fbx-conv command line must be available in the PATH environment variable.

In the example below, the convertFbx task take all the .fbx files in the resources folder and convert them to the G3DB format in the assets/3d folder:

task convertFbx(type: com.eowise.blender.fbxconv.FbxConv) {
    from 'resources'
    include '*.fbx'
    into 'assets/3d'
    g3db()
}
Incremental processing

The FbxConv task take advantage of a Gradle feature allowing to track when input files are modified. Therefore the processed input files are only those that have changed since the last execution.

You can go further with the methods reference below or with several use cases.

Methods

You can use the above methods to configure a com.eowise.blender.fbxconv.FbxConv task.

from(Object path)
required

Set the base path of the .fbx files to be converted. The given path is evaluated as per Gradle Project.file().

include(String... includes) or include(Closure closure)

Adds an include pattern as defined in Gradle PatternFilterable. This method may be called multiple times to append new patterns.

If includes are not provided, then all files in the base path folder and sub folders will be included.

exclude(String... excludes) or exclude(Closure closure)

Adds an exclude pattern as defined in Gradle PatternFilterable. This method may be called multiple times to append new patterns.

into(Object path)

Set the base folder where the converted files will be created. Just like the from method, the given path is evaluated as per Gradle Project.file().

If the destination base folder is not specified, each converted file will be created in the same folder of the corresponding .fbx file.

g3dj() or g3db()
required

Use one of the above method to set the type of the output files, either G3DJ or G3DB.

flip(), pack() and other optionals methods

It's possible to set other fbx-conv flags with theses methods:

Method Description
flip()

Flip the V texture coordinates.

fbx-conv command line flag-f
pack()

Pack vertex colors to one float.

fbx-conv command line flag-p
maxVertices(String size)

The maximum amount of vertices or indices a mesh may contain.

fbx-conv command line flag-m <size>
maxBones(String size)

The maximum amount of bones a nodepart can contain.

fbx-conv command line flag-b <size>
maxBoneWeights(String size)

The maximum amount of bone weights per vertex.

fbx-conv command line flag-w <size>

Use cases

Integrate in Gradle build

Work in progress