Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: The Landscape FAQ  (Read 16378 times)
JohnnyC
Customers
Community Member
*****
Posts: 1488


WWW
« on: December 31, 2004, 10:20:57 AM »

Question
·  How does the TV3D landscape system work ? Sizing & Generation


Answer
·  How does the TV3D landscape system work ? Sizing & Generation

The Landscape Object – A Basic Introduction - Part 1 Sizing & Generation. written by JohnnyC - TV3D Land Expert

The Landscape Object is powerful, complex and highly optimised. It is very easy to use once the programmer has grasped the basic concepts. It can make mountains, lakes, and coastline complete with wave effects etc.

Landscapes are described in ‘World Units’. A ‘world unit’ can be anything the programmer decides upon. Kilometres / Miles / Metres / Microns – anything. You just decide upon the scale and size your models accordingly.

Landscape Object has two modes: Terrain and HugeTerrain.

Terrain is almost never used, as it is limited in size (256 x 256) and is small by current standards.

‘HugeTerrain’ has a composite structure and is divided into ‘sub-terrains’ called chunks. A chunk, at generation time, is 256 by 256 world units. After generation the Landscape can be scaled to any size required. Unlike most engines, the Landscape does NOT need to be square.

The easiest way to generate a landscape is from a Heightmap. This is a bitmap (usually grayscale) that represents higher land as whiter values and black is the lowest. Heightmaps can be made in bitmap programs like Photoshop or Paintshop Pro or a terrain generation programs like Terragen and Bryce. They can also be set up programmatically.

Typical HugeTerrain generation code

Land.SetAffineDetail = TV_AFFINE_LOW ' = 1
tWidth=2 ‘ Width of the terrain in CHUNKS
tLength=3 ‘ Length of the terrain in CHUNKS
tPosX=0 ‘ Position of terrain (useful for multiple terrain or paged terrain systems)
tPosZ=0 ‘Position of terrain (useful for multiple terrain or paged terrain systems)
tAffine=true ‘ Apply smoothing
Land.GenerateHugeTerrain “Heightmap.bmp”, TV_Precision_Best, tWidth, tLength, tPosX, tPosZ, tAffine

=> This will generate a highly detailed (but smoothed) terrain that is 512 x 768 world units in size.



‘Land.SetAffineDetail’ defines the smoothing amount and the options are:

TV_AFFINE_HIGH = 2
TV_AFFINE_LOW = 1
TV_AFFINE_NO = 0

The default setting is
Land.SetAffineDetail = TV_AFFINE_LOW

It is important to note that there is a relationship between the vertices of the mesh and the world unit. This relationship is the Landscape Precision. In the example above the constant TV_Precision_Best = 4.

The number of vertices on one side of a chunk is: 256 / TV_Precision_Best = 256 / 4 = 64

TV_PRECISION_ULTRA= 2
TV_PRECISION_BEST = 4
TV_PRECISION_HIGH = 8
TV_PRECISION_AVERAGE = 16
TV_PRECISION_LOW = 32
TV_PRECISION_VERY_LOW = 64
TV_PRECISION_ULTRA_LOW = 128


To represent every HeightMap pixel fully in the terrain we would need to map one pixel to one vertex and so make a terrain that is sized like this:

If the HeightMap is 512 x 768 in size and we are using TV_Precision_Best:

tWidth = (512 * TV_Precision_Best) / 256 = (512 * 4) / 256
tLength = (768 * TV_Precision_Best) / 256 = (768* 4) / 256

Land.GenerateHugeTerrain “Heightmap.bmp”, TV_Precision_Best, tWidth, tLength, tPosX, tPosZ, tAffine



NOTE the Landscape generated is flipped from the Heightmap – so if this is important to you - flip the Heightmap first. Wink

---------------------------------------------------------
Thanks for JohnnyC to have written this helpful article !
Logged

_________________

John Chewter
Keyne Image
www.keyneimage.co.uk
darqSHADOW
Administrator
Community Member
*****
Posts: 2817


« Reply #1 on: December 31, 2004, 10:46:04 AM »

Stickied!  Thx JC!

DS
Logged

TrueVision3D Project Manager
The fast and simple way of 3D development.
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks