mod_sim_terrain_tile.cc File Reference

Divides heightmap into tiles, and divides tiles into triangles. More...

#include "base.hh"
#include "base_settings.hh"
#include "gfx.hh"
#include "eng.hh"
#include "eng_graph_maker.hh"
#include "mod_base.hh"
#include "mod_sim.hh"
#include "mod_sim_misc.hh"
#include "mod_sim_world.hh"
#include "mod_sim_terrain.hh"
#include "mod_sim_terrain_heightmap.hh"
#include "mod_sim_terrain_tile.hh"

Namespaces

namespace  mod_sim

Defines

#define MOD_SIM_TERRAIN_TILE_CC   1
#define TILE_LOOP_NxN_END   (mTileArgs.mTileWidthInWorld)
#define TILE_LOOP_N1xN1_END   (mTileArgs.mTileWidthInWorld_plus_subtileWidthInWorld)
#define TILE_LOOP_INC   (mTileArgs.mSubtileWidthInWorld)
#define TILE_FP_LESS(F1, F2)   ((F1) + 0.05) < (F2)
#define POSITION_HEIGHTMAP(W_LAT, W_LON)

Variables

static const
ColorsNode::Value 
mod_sim::sColorsNodeValue (RGBA(1.0, 1.0, 1.0, 0.7))


Detailed Description

Divides heightmap into tiles, and divides tiles into triangles.

Id
LastChangedDate

Author:
Jim E. Brooks http://www.palomino3d.org
NxN versus (N+1)x(N+1): ----------------------- This Tile has 2x2 subdivisions (subdivision is two paired triangles). But it has 3x3 vertexs!

+--+--+ | /| /| |/ |/ | +--+--+ | /| /| |/ |/ | +--+--+ 0 1 2 = 3

Heightmap and tile coordinate mapping: -------------------------------------- Heightmap coordinates and tile coordinates are 1:1 mapped. Tile coordinates start at (0,) which is relative to given (hmLat,hmLon). Therefore, conversion is just translation (no scaling/multiplying).

hmLat hmLat+3 tileLat=0 tileLat=3 ^ ^ +--+--+--+--+ | /| /| /| /| |/ |/ |/ |/ | +--+--+--+--+ | /| /| /| /| |/ |/ |/ |/ | +--+--+--+--+ | /| /| /| /| |/ |/ |/ |/ | +--+--+--+--+ | /| /| /| /| |/ |/ |/ |/ | +--+--+--+--+

Other notes: ------------ Many tile computations are done in 2D using the Array2D<> template class. A key method is Array2D::GetIdx() which converts 2D coordinates to a flat index, as ultimately flat arrays will be produced for the nodes of a Graph.

Future optimizations: --------------------- Subdivisioning could vary according to an area of the heightmap. Flatter areas can be adequately modelled by fewer and larger triangles.

Known inefficiencies: --------------------- The same normal vectors are recomputed. An obstacle to storing precomputed normal vectors in a table is that they correlate to a float (lat,lon) since vertexs are computed by float increments. Converting to integral would cause float inaccuracy and fetching the wrong adjacent normal vector. This inefficiency is tolerable (isn't the bottleneck) if the amount of subtiles stays small.


Define Documentation

#define MOD_SIM_TERRAIN_TILE_CC   1

#define POSITION_HEIGHTMAP ( W_LAT,
W_LON   ) 

Value:

LAT_LON_ALT( (W_LAT),                                                       \
             (W_LON),                                                       \
             (mHeightmap->GetHeightScaledInterpolated((W_LAT),(W_LON)))     \
             )
Macros.

#define TILE_FP_LESS ( F1,
F2   )     ((F1) + 0.05) < (F2)

#define TILE_LOOP_INC   (mTileArgs.mSubtileWidthInWorld)

#define TILE_LOOP_N1xN1_END   (mTileArgs.mTileWidthInWorld_plus_subtileWidthInWorld)

#define TILE_LOOP_NxN_END   (mTileArgs.mTileWidthInWorld)

Palomino 3D Engine documents generated by doxygen 1.5.3 on Fri Nov 23 11:26:16 2007