This tutorial will provide you the following: - Guidance, recommendations, and information on creating your first terrain meshes for the Away3D environment - An example of loading the mesh into Away3D from a URL at runtime - An example of loading the texture onto your Mesh from a URL at runtime
Who is this for
This guide is written for someone with a beginners understanding of Away3D and 3D concepts in general, but assumes some basic knowledge, such as understanding what a mesh is, and how to create a basic Away3D application such as one of the many tutorials available on away3d.com demonstrate.
Part 1: Generating a terrain
First, there are a few primary concepts to understand in generating a terrain mesh. Most terrains are represtented as a simple mesh of triangles, but it is also possible to represent a terrain as something called a heightmap. A heightmap is simply a bitmap (JPG, PNG, BMP) image in which different shades of color are translated to a height.
Most terrain generating applications can create both mesh output and heightmap output. Away3D is capable of loading a mesh, or generating a mesh from a heightmap (the final is ultimately a mesh in any case). In this article we will focus on generating a mesh as it is more common, but also because it's easier to generate an optimized mesh. If you use a heightmap to generate the terrain mesh in Away3D the resulting mesh will not be as optimized as the one we will produce in this tutorial. A key benefit of a heightmap is that it is a much smaller file size than a similar mesh.
When an "optimized mesh" is mentioned, it mean that the resulting terrain mesh will contain more gemetry in areas where the terrain changes shape (thus creating a smooth looking transition), but less geometry where the terrain is mostly the same, such as a flat surface. This way the terrain looks good, but doesn't overwhelm the flash player with unneeded geometry.
There are numerous tools that will allow you to generate a terrain. You could do it in any 3D editor as well (but it would be painfully slow), so many apps are dedicated to the task. Some of the common names you might come across are listed below with a few notes about them, this list is far from exhaustive. After some experimentation I have settled on using L3DT, which I find to be easy to use, flexible, and produces optimized results for a flash environment,
L3DT - Great for creating game environments. Allows easy 3D based control over the terrain, can also generate terrains based on a predefined algorithm. Optimizes the resulting terrain mesh and allows for fine control over the size of the resulting mesh. It is provided free for "most" projects (including commercial with some limitations), and offers advanced features at a reasonable price.
Nem's Mega 3D terrain generator - From a usability standpoint I found this to be the best app available. However it is easier to produce a nice final result from L3DT due to it's better optimization techniques. The resulting mesh from Nem's is not optimized as it is in L3DT. You could potentially optimize the mesh outside of Nem's, however Nem's doesn't easily support high poly counts which would be advantageous if you were going to import it to a 3D tool to reduce the mesh size.
Terragen - This is probably the biggest name in 3D terrain generation, and produces purely stunning results, however its feature set is geared more towards cinematic production than game production. L3DT has nearly the same capabilities while providing functions important to game production (such as mesh output, optimization and reduction).
Toymaker 2 - This is a great utility, and provides numerous beautiful skybox examples that might be of benefit, however it does not provide convenient 3D control over the resulting terrain.
Below are some quick steps to follow to generate a terrain in L3DT. L3DT can produce sophisticated terrains which are outside the scope of this tutorial. You should also consider following the excellent in-product tutorial that pops up when you first run L3DT. Feel free to experiment with the settings, they are provided below for completeness, not to suggest that you are limited to these settings.
-- Best approach for loading the texture: explain texture loader & bitmapfilematerial & other approaches --
-- Performance tips: splitting up the mesh and performing object culling; ??making sure textures are 1:1 --
-- Explain the OBJ, MTL, and texture files and how they relate (for example, MTL contains references to the textures, give little trouble shooting help like that --
--Troubleshooting section: White texture, not loading mesh, mesh rotated, mesh not visible (normals), mesh saved in right handed coordinate system --
In this article I introduce you to a short series on storage duration in C++....
In this article I introduce you to the series, Specifiers in C++....
In this article I introduce you to a tutorial series titled, Some Features of C++ Entities....
C++ is a computer language I want to teach in these tutorials. C++ is a very developed language...
In C++ an array is a set of consecutive objects of the same type, in memory. We see how to crea...
A class provided which re-directs STDERR and STDOUT to Commons Logging and looks up the class n...
I am a developer using Amazon Simple DB currently in a project, and decided to write up a simpl...
If you use Terracotta with Smartfox server 1.6.6 and are receiving the following java error wit...
This is just a short post about the art of getting laundry done in Bangkok, Thailand for foreig...
This paper provides an overview of a new Game currently in prototype. As I am currently looking...