Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 17 in printed book and digital formats -- plus a one-year subscription (beginning with 18.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 4.3

COLUMN

The Hills Are Alive...

Generating Terrain

Issue: 4.3 (January/February 2006)
Author: Joe Nastasi
Author Bio: Joe Nastasi is the president of Pyramid Design, the developers of A-OK! The Wings of Mercury, A-OK! Spacecraft Simulation System, and FTP Suite.
Article Description: No description available.
Article Length (in bytes): 10,634
Starting Page Number: 32
Article Number: 4315
Related Link(s): None

Excerpt of article text...

After a bit of stagnation, the REALbasic 3D API got a huge upgrade for REALbasic 2005 Release 3. Much of Quesa's functionality that previously could only be accessed via declares or wrapper classes are now part of the REALbasic API. One of the biggest improvements is the ability to create 3D models under program control. We are not talking about hacking 3DMF files here, but creating and modifying trimeshes using the new Trimesh class.

What we are going to discuss in this issue is a fairly standard technique called terrain mapping. The basic idea is that a grayscale image is used to generate a landscape. In the simplest form, each pixel maps to a vertex, mapping out the terrain's depth and breadth. The height of each vertex is generated from each pixel in the image. In other words, the intensity of the pixel drives the Y component of the vertex's position vector. The map is typically called a height map.

Why do it this way? After all, we could build an editor that allows you to generate a flat terrain and then pull vertexes up or down manually. In fact, most terrain editors do allow you to edit a terrain in this manner. But for the initial generation of the terrain, it is a tedious method.

It's much easier, especially for an artist/level designer, to use all the tools a commercial image editor offers to draw a 2D representation of the terrain. Designer's brains quickly assimilate the concept that pure black is "sea level" and the closer to white you paint, the higher the ground rises at that point. The amount of contrast determines if a terrain is gently sloped or rough and jagged.

Of course, even with a great image editor, there will be a point in the terrain design process where more precision is needed and an actual 3D image of the terrain is required for proper feedback. That's when a terrain editing program can import the height map and manipulate the trimesh that it generates.

...End of Excerpt. Please purchase the magazine to read the full article.