L3DT development blog
Large 3D terrain generator

Mesh exporter

Hi Everyone,

Good news! There have been some big improvements in the latest build of L3DT (v2.9 build 25) that affect how users can export terrains as optimised mesh files. Please read on for more details…

Seamless tiled exporter

A long-standing request has been the ability to export the terrain as an optimised mesh that is split across multiple files. This was not possible in the past because the mesh decimator plugin did not have a way to force the edge triangles of adjoining tiles to match up exactly. This problem has now been fixed by rendering 'brute force' unoptimised triangles at tile edges. You can see the effect in this wireframe rendering, where the seam between each of the four tiles includes the unoptimised triangles:

Brute-force triangles at the tile edges of a 2×2 seamlessly tiled mesh, in Blender.

And, for the sake of eye-candy, below is a short video from earlier showing the output of the new mesh exporter. This terrain was a set of 16 seamlessly tiled OBJ mesh files with textures, which was loaded tile-by-tile in into Sapphire:

4×4 seamless tiled mesh, in Sapphire.

How to export tiles

To make use of the new mesh exporter, select the new 'File→Export→Export optimised mesh' menu option, which will open the new Export mesh window shown below:

The complete user guide for the new exporter is on-line here. The controls should be familiar to you if you've used the 'File→Export→Export OBJ and MTL' or the 'File→Export→Export 3DS and texture' menu options, except that this new window also includes controls for the tile size, and a few other handy options.

Mesh preview

The mesh exporter includes a preview button that allows you to check the output before exporting the mesh, so that you can make sure that all the settings are just right. This button will generate the mesh for your map (or for a single tile, if using tiled export), tell you the vertex/triangle count, and then show you the output mesh like so:

Optimised mesh preview

Please note that the mesh preview shows you the geometry and the vertex normals, but does not include texture rendering, bump maps, or the like. It's just a simple preview, so go easy on it ;)

Selected area export

Another useful feature of this new exporter is that it can be used to export only selected areas of the map as mesh files, which was not previously supported by the OBJ/MTL exporter. To make use of this feature, simply use the select area tool on the heightfield to hand-select the area to export (shown below), and then run the exporter using the 'File→Export→Export optimised mesh' menu option.

The select area tool button.

If you want to use precise coordinates instead of hand selection, you can also select the area using the 'Edit→Select map area' menu option (see user guide). Note that the coordinate origin (0, 0) is the south-west corner of the map.

Textures, bump maps, etc.

As with the old 'File→Export→Export OBJ and MTL' option, this new exporter also saves the texture and material definition for each tile, which makes it nice and easy for you to load the tiles into your game engine or renderer. The exporter also goes beyond the old exporter and includes the ability to export other 'auxiliary' maps such as alpha maps, normal maps, etc.

Please note that this feature only exports the auxiliary maps in the appropriate files. It does not add any references to these auxiliary maps within the mesh/material files. Hence, this option won't magically make mesh files render with bump maps or alpha maps. That is still your job for the moment.

For simplicity, all the texture/image data is exported as 24-bit bitmap images, partly because this prevents compression artefacts, and partly because the BMP plugin can export HUGE bitmaps without hitting any memory issues (c.f. JPG/PNG). However, if there is much wailing and gnashing of teeth, I will add support for some popular compressed formats (JPG/PNG/DDS). Is that gnashing I hear…?


Updated 2011/07/05: I have included in the next build of the plugin the option to select different file formats for the texture and auxiliary map images (JPG/PNG/DDS/etc.) This option will be available in the release version of L3DT 11.07, due later this month.

Mesh file formats

On the subject of file formats; this tiled exporter supports the DAE (COLLADA), 3DS, OBJ/MTL, and X file formats 1). Tiled exporter support for the other mesh files like B3D and TIN will be added as time permits. If you have particular need of a specific file format not yet supported by this mesh exporter, please let me know in this forum thread.

Highly observant users may also notice that the exporter also supports a 'ZMESH' file format. This is L3DT's very own mesh file format, which is a compact, compressed binary file that is very fast to load and save. However, this format is only supported by L3DT, and is not intended to be used as an exchange format with other applications. It's just there because it allows Sapphire to load certain resources more quickly (trees, helicopters, etc).

Bug fixes

A regrettably long-running problem with L3DT's mesh exports was that, when using the mesh decimator, the output files often contained, in addition to the correct geometry, some spurious triangles that had invalid coordinates. These were very uncool, and required manual editing to fix. I have now fixed the decimator so that it no-longer produces these dodgy triangles. Yay!

Another problem with the old decimator was that it didn't always wind triangles in the same direction; some were clockwise and some were counter-clockwise. This caused problems because backface culling would show triangles wound one way and skip triangles wound the other way. The new exporter winds all triangles in the same direction, which you can set in the exporter window using the face winding control, discussed below.

Other items of note

Vertex normals

The mesh decimator now generates vertex normals. However, vertex normals are only exported by the OBJ and X plugins at the moment. Vertex normal support will be added for the other mesh files (3DS, B3D, etc.) as time and specifications permit.

Coordinate systems & face winding

In the new mesh exporter, you can select from two coordinate systems:

XY plane, Z up The 'XY plane' option has the x-axis pointing east, the y-axis pointing north, and the z-axis pointing upwards. This is a right handed coordinate system used in OpenGL, Blender, and internally in L3DT. Face winding should be set to counter-clockwise.
XZ plane, Y up The 'XZ plane' option has the x-axis pointing east, the y-axis pointing up, and the z-axis pointing north. This is a left-handed coordinate system used in DirectX. Face winding should be set to clockwise.

You also have the choice of two face winding options:

CCW (OpenGL) Faces are wound counter-clockwise. This is the default option for OpenGL-based renderers such as Blender.
CW (DirectX) Faces are wound clockwise. This is the default option for DirectX-based renderers.

More details

For more details about the tiled mesh exporter, please consult the on-line user guide.

Still to do

This update is by no means the end point of mesh development in L3DT. There are many improvements still planned:

  • Support for water meshes will be added.
  • Support for further file formats will be added to the tiled exporter, as mentioned above.
  • A mesh rasteriser will be developed to convert mesh files back into heightfields, which would allow users to import terrain into L3DT from mesh files.

If you'd like to suggest other changes, please use this forum thread.

How to download

If you want to give the new mesh exporter a try, please follow the instructions below to download the update:

Standard edition (free) The installer is available from the downloads page.
Professional edition Please consult your sales/registration receipt e-mail for the download link, or e-mail sales@bundysoft.com if you can't find it.
Pro for Torque Please e-mail sales@bundysoft.com for the download link.

Feedback

I would dearly love to hear your feedback on these changes, particularly so if you've tried loading the exported mesh files into your game engine/renderer. Please make use of this forum thread.

End transmission

Cheers, Aaron.

1) Updated 24th of June 2011 to add DAE, as per this announcement.
 
l3dt/2011/jun/22.txt · Last modified: 2017/08/31 05:15 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
L3DT Development Blog RSS Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki