Class: tbterrain

tiletexture-based terrain, uses elevation data and surface layers, which are organized as tiles.
Every tile has 4 layers of surfacetiles. You can use up to 256 surfacetiletypes, each with a unique texture. However on an area of 32x32 tiles no more than eight textures can be used.

Hierarchy

o-+ resource
  o-+ tbterrain

Interfaces:

Methods:

Method overview:


defaultpath ([string])
returns: ([string])
returns or sets the default resource path. Luxinia will search in those when resources are not found.
getcoords (tbterrain,float x,y,z)
returns: (int x,y)
converts world position into terrain coords
getheights (tbterrain)
returns: (floatarray)
returns a mounted floatarray, in which you can directly access heights of the terrain grid. There is steps*2+1 floats for each dimension.
getrestype ()
returns: (int restype)
returns the resource type as int value, useful for resdata or reschunk functions
height (tbterrain self, float x,y)
returns: (float height)
returns interpolated height at x/y
newblank (string name, int width,int height, float heightfactor)
returns: (tbterrain)
creates a new tbterrain. Dimensions must be >= 32.
After setting all used tiletypes and layers run the newfinish function.
newfinish (tbterrain)
returns: ()
initializes all needed data for rendering. Set all known tiletypes and layers before
newfromtex (string name, texture heightmap, float heightfactor, [texture colormap])
returns: (tbterrain)
creates a new tbterrain using the given elevation and color data. Make sure the textures kept their data, and you can free the data afterwards. If the heightmap has 4 colorvalues it is used as float texture, else the red value is multiplied by heightfactor.
After setting all used tiletypes and layers run the newfinish function.
newspecs ([int tilesize, int blocksize, int camtolerance, int atlascount])
returns: ([int tilesize, int blocksize, int camtolerance, int atlascount])
default specifications for newly generated terrains. Tilesize is the length of a single tile. Blocksize is the square grid that is visible. Camtolerance means that if camera moved more than this many tiles the block is updated. Atlascount is the number of surfacetiles that can be active within current visible block.

All values passed must be even, and atlascount should be power of 2.
save (tbterrain)
returns: ()
saves a terrain by storing the data into the savenames
savecolorname (tbterrain,[string])
returns: ([string])
returns or sets the savename for the colormap (by default same as on set)
saveheightname (tbterrain,[string])
returns: ([string])
returns or sets the savename for the heightmap (by default same as on set)
saveobjname (tbterrain,int layer,[string])
returns: ([string])
returns or sets the savename for the object layer (by default same as on set)
savesurfname (tbterrain,int layer,[string])
returns: ([string])
returns or sets the savename for the surface layer (by default same as on set)
size (tbterrain)
returns: (int width,height)
returns width and height of terrain
surfacelayer (tbterrain,int id, data texture)
returns: ()
sets the given layer with the data from the data texture.
surfacetile (tbterrain,int id, string tiletexturename)
returns: ()
creates a new surface tile using the given id (1..255) and creates a special texture from the given texturename.
tilecolor (tbterrain,int x,int y,[float r,g,b,a])
returns: (float r,g,b,a)
returns or sets tile color
tileheight (tbterrain,int x,int y,[float height])
returns: (TBTerrain terr)
returns or sets tile height
tilesurf (tbterrain,int x,int y,int layer,[int id])
returns: (TBTerrain terr)
returns or sets tile surface id
tileupdate (tbterrain,int x,int y,[int region])
returns: ()
updates tile, makes changes effective, optionally a whole region

Inherited Methods:

From resource

condition, getresname, getresshortname, resuserstring