Xoppa, Bach and I have been working on a new 3D API, with short breaks (cause iOS…). We are now in full swing of finishing that puppy. You can follow the progress in this thread. Lots of design discussions have been had, we are trying to make the API as simple to use as SpriteBatch, while giving you as much flexibility as possible. Here’s a taste of what it looks like working with this thing at the moment:
// load the model, create an instance that we can freely manipulate without destroying the original
// loader API is gonna be simplified :)
JsonModelLoader loader = new JsonModelLoader();
model = new Model(loader.parseModel(Gdx.files.internal("data/g3d/cubes.g3dj"), null));
instance = new ModelInstance(model);
modelBatch = new ModelBatch();
// position the instance
instance.transform.translate(0, 0, 3);
// render it, using a specific camera and providing a list of lights to be applied
// uses the smart default sorting strategy and über-shader, but you an plugin whatever you want
You can find the full thingy on the new3dapi branch. I spare you the details for now, once we merged with master i’ll give you a full wiki article on all things 3D. Here’s a quick rundown of the features we are aiming for:
- flexibility and small API über-alles
- OpenGL ES 2.0 only for now, the API is flexible enough for you to write a GLES 1.x shader should you need that
- Format support: FBX converter, based on Gameplay SDK. Spits out custom format more suitable for runtime consumption. Provides us with the best coverage of modelling apps. Bach’s been slaving away on this in January and its pretty much complete, save for some modelling app specific issues.
- Modelling app support: the FBX converter is a standalone app, that’s really simple to wrap as a plugin for modelling apps. We’ll initially provide an addon for Blender, but will also try to get Maya, Softimage and 3DSMax going. Writting a plugin yourself by wrapping the converter should be extremely simple as well, much more so than writting a full-blown plugin.
- Models, Instances and ModelBatch: models are the templates holding meshes, node hierarchy and materials. The Model is the one responsible for disposing meshes/textures, in a single place, which makes asset managment really easy. A model is analogues to a TextureAtlas/Texture/TextureRegion when working with SpriteBatch. You don’t directly render/animate a model, but create instances from the model, which share the meshes and textures. This allows you to modify materials and the node hierarchy of an instance without destroying the originals in the model. Think of instances as Sprites in the 2D analogy, you can modify it without touching the texture it may share with other sprites. Finally the ModelBatch (name change pending) allows you to render instances (it’s more flexible than that, but more on that another time).
- Animation: skeletal animation (GPU only) and keyframed animation (ala MD2, GPU only)
- Materials: flexible, and customizable. We try to support as many material attributes out of the box as possible.
- Shaders: we’ll provide an über-shader that includes lighting, skinning and keyframe interpolation. You can plug in your own shading easily.
The goal of the API is to be as flexible as possible. We will likely not provide everything but the kitchen sink out of the box, but continuously add new features over time. Our biggest concern has been to make this as flexible as possible, while retaining a minimal API that’s easy to use and extend. I think we achieved that goal. What’s left to be done:
- AssetManager support (really simple due to our data model)
- Update current tests and demos, especially gdx-invaders. The bullet tests already use the new API on the branch
- More comprehensive default shader
- Node based animation
- Keyframed animation
That may look like a lot, but the API design is actually what takes the most time. That’s pretty much done now, safe for some minor modifications here and there. The rest should be comparatively “easy” (yeah, i said it…).
The old API will disappear completely when we merge the new3dapi branch with the master branch in a few days