My Project
|
Contains Terrain functions. More...
#include <ParaScriptingTerrain.h>
Static Public Member Functions | |
static ParaAttributeObject | GetAttributeObject () |
get the attribute object associated with the global terrain. More... | |
static void | GetAttributeObject_ (ParaAttributeObject &output) |
used for API exportation. More... | |
static ParaAttributeObject | GetBlockAttributeObject () |
get block terrain manager's attribute object. More... | |
static int | GetTextureCount (float x, float y) |
get the total number of textures in the texture set of the terrain tile specified by a world position (x,y) One can get each of the textures by calling GetTexture() function. | |
static void | GetTexturesInCell (float x, float y, const object &out) |
get all texture indices in the cell specified by point(x,y) GetTextureCount() returns all textures used by the entire terrain tile (i.e. More... | |
static bool | RemoveTextureInCell (float x, float y, int nIndex) |
remove the given texture in the cell specified by the point(x,y). More... | |
static ParaAssetObject | GetTexture (float x, float y, int nIndex) |
get the terrain detailed texture by index. More... | |
static void | GetTexture__ (ParaAssetObject *pOut, float x, float y, int nIndex) |
only used for API exporting. More... | |
static bool | ReplaceTexture (float x, float y, int nIndex, ParaAssetObject &TextureAsset) |
replace the texture at the given index. More... | |
static bool | ReplaceTexture_ (float x, float y, int nIndex, const object &sTextureAsset) |
static ParaAttributeObject | GetAttributeObjectAt (float x, float y) |
get the attribute object associated with the terrain tile that contains the given point. More... | |
static void | GetAttributeObjectAt_ (ParaAttributeObject &output, float x, float y) |
used for API exportation. More... | |
static float | GetElevation (float x, float y) |
get the terrain height at the specified position. More... | |
static DWORD | GetRegionValue (const char *sLayerName, float x, float y) |
get value of a given terrain region layer More... | |
static DWORD | GetRegionValue4 (const char *sLayerName, float x, float y, const char *argb) |
get value of a given terrain region layer More... | |
static string | GetTerrainOnloadScript (float x, float y) |
get the on load script which created all objects on this terrain that contains the point (x,y) | |
static const char * | GetTerrainOnloadScript__ (float x, float y) |
solely used for API exporting. More... | |
static string | GetTerrainElevFile (float x, float y) |
get the height map file name for the terrain tile that contains the point (x,y) | |
static const char * | GetTerrainElevFile__ (float x, float y) |
solely used for API exporting. More... | |
static void | SaveTerrain (bool bHeightMap, bool bTextures) |
save modified terrain to disk. More... | |
static void | ReloadTerrain (bool bHeightMap, bool bTextures) |
reload terrain from disk. More... | |
static void | UpdateTerrain () |
update terrain. More... | |
static void | UpdateTerrain1 (bool bForceUpdate) |
static void | SnapPointToVertexGrid (float x, float y, float *vertex_x, float *vertex_y) |
snap any 2D point on the height map to a vertex position on the height map. More... | |
static float | GetVertexSpacing () |
Returns the number of real units between vertices in the terrain's mesh. More... | |
static void | Paint (const char *detailTexture, float brushRadius, float brushIntensity, float maxIntensity, bool erase, float x, float y) |
paint on the specified location of the global terrain. More... | |
static void | Paint_ (int nDetailTextureID, float brushRadius, float brushIntensity, float maxIntensity, bool erase, float x, float y) |
static void | DigCircleFlat (float x, float y, float radius, float fFlatPercentage, float factor) |
flatten a land centered at x,y, with a specified radius. More... | |
static void | Flatten (float x, float y, float radius, int flatten_op, float elevation, float factor) |
Flatten the terrain both up and down to the specified elevation, using using the tightness parameter to determine how much the altered points are allowed to deviate from the specified elevation. More... | |
static void | RadialScale (float x, float y, float scale_factor, float min_dist, float max_dist, float smooth_factor) |
Note: terrain data should be in normalized space with height in the range [0,1]. More... | |
static void | GaussianHill (float x, float y, float radius, float hscale, float standard_deviation, float smooth_factor) |
static void | Spherical (float x, float y, float radius, float offset) |
offset in a spherical region More... | |
static void | Roughen_Smooth (float x, float y, float radius, bool roughen, bool big_grid, float factor) |
square filter for sharpening and smoothing. More... | |
static void | Ramp (float x1, float y1, float x2, float y2, float radius, float borderpercentage, float factor) |
create a ramp (inclined slope) from (x1,y1) to (x2,y2). More... | |
static void | AddHeightField (float x, float y, const char *filename, int nSmoothPixels) |
Add rectangular height field from file to the current terrain. More... | |
static void | MergeHeightField (float x, float y, const char *filename, int mergeOperation=0, float weight1=1.0, float weight2=1.0, int nSmoothPixels=7) |
merge a rectangular height field from file to the current terrain. More... | |
static void | UpdateHoles (float x, float y) |
Update all holes in the terrain tile that contains the input point. More... | |
static bool | IsHole (float x, float y) |
Whether the terrain contains a hole at the specified location. More... | |
static void | SetHole (float x, float y, bool bIsHold) |
set a new terrain hole at the specified location. More... | |
static bool | IsModified () |
return true, if the terrain is modified and should be saved. More... | |
static void | SetContentModified (float x, float y, bool bIsModified) |
set the content of the terrain modified. More... | |
static void | SetContentModified4 (float x, float y, bool bIsModified, DWORD dwModifiedBits) |
set the content of the terrain modified. More... | |
static void | SetAllLoadedModified (bool bIsModified, DWORD dwModifiedBits) |
set all loaded terrain tile content modified. More... | |
static void | EnableLighting (bool bEnable) |
Enable both global and local lighting. More... | |
static void | PaintTerrainData (float x, float y, float radius, unsigned int data, unsigned int dataMask, unsigned int bitOffset) |
static uint32 | GetTerrainData (float x, float y, uint32 dataMask, byte bitOffset) |
static void | SetVisibleDataMask (uint32 mask, byte bitOffset) |
static void | EnterBlockWorld (float x, float y, float z) |
static void | LeaveBlockWorld () |
static bool | IsInBlockWorld () |
static void | SaveBlockWorld (bool saveToTemp) |
static void | DeleteAllBlocks () |
static void | SetBlockTemplateId (float x, float y, float z, uint16_t templateId) |
static void | SetBlockTemplateIdByIdx (uint16_t x, uint16_t y, uint16_t z, uint32_t templateId) |
static uint32_t | GetBlockTemplateId (float x, float y, float z) |
static uint32_t | GetBlockTemplateIdByIdx (uint16_t x, uint16_t y, uint16_t z) |
static void | SetBlockUserData (float x, float y, float z, uint32_t data) |
static void | SetBlockUserDataByIdx (uint16_t x, uint16_t y, uint16_t z, uint32_t data) |
static uint32_t | GetBlockUserData (float x, float y, float z) |
static uint32_t | GetBlockUserDataByIdx (uint16_t x, uint16_t y, uint16_t z) |
static object | Pick (float rayX, float rayY, float rayZ, float dirX, float dirY, float dirZ, float fMaxDistance, const object &result, uint32_t filter=0xffffffff) |
static object | MousePick (float fMaxDistance, const object &result, uint32_t filter=0xffffffff) |
static bool | RegisterBlockTemplate (uint16_t templateId, const object ¶ms) |
static void | SetTemplateTexture (uint16_t templateId, const char *fileName) |
static void | SetBlockWorldYOffset (float offset) |
static object | GetBlocksInRegion (int32_t startChunkX, int32_t startChunkY, int32_t startChunkZ, int32_t endChunkX, int32_t endChunkY, int32_t endChunkZ, uint32_t matchType, const object &result) |
get block in [startChunk,endChunk] More... | |
static object | GetVisibleChunkRegion (const object &result) |
static void | SetBlockWorldSunIntensity (float value) |
static void | SelectBlock (uint16_t x, uint16_t y, uint16_t z, bool isSelect) |
add/remove block to/from highlight block list More... | |
static void | SelectBlock1 (uint16_t x, uint16_t y, uint16_t z, bool isSelect, int nGroupID) |
static void | DeselectAllBlock1 (int nGroupID) |
static void | DeselectAllBlock () |
static void | SetDamagedBlock (uint16_t x, uint16_t y, uint16_t z) |
static void | SetDamageDegree (float damagedDegree) |
static int | FindFirstBlock (uint16_t x, uint16_t y, uint16_t z, uint16_t nSide=4, uint32_t max_dist=32, uint32_t attrFilter=0xffffffff, int nCategoryID=-1) |
find a block in the side direction that matched filter from block(x,y,z) this function can be used to check for free space upward or download More... | |
static int | GetFirstBlock (uint16_t x, uint16_t y, uint16_t z, int nBlockId, uint16_t nSide=4, uint32_t max_dist=32) |
get the y pos of the first block of nBlockID, start searching from x, y, z in the side direction | |
static int32_t | GetChunkColumnTimeStamp (uint32_t chunkX, uint32_t chunkZ) |
get the time stamp of for the given chunk column 0 means not available, >1 means loaded before | |
static void | SetChunkColumnTimeStamp (uint32_t chunkX, uint32_t chunkZ, uint32_t nTimeStamp) |
set chunk column time stamp. More... | |
static const std::string & | GetMapChunkData (uint32_t chunkX, uint32_t chunkZ, bool bIncludeInit, uint32_t verticalSectionFilter) |
static object | ApplyMapChunkData (uint32_t chunkX, uint32_t chunkZ, uint32_t verticalSectionFilter, const std::string &chunkData, const object &out) |
static void | GetBlockFullData (uint16_t x, uint16_t y, uint16_t z, uint16_t *pId, uint32_t *pUserData) |
get block id and userdata at the given block position. More... | |
Contains Terrain functions.
|
static |
Add rectangular height field from file to the current terrain.
x | center of the rect in world unit |
y | center of the rect in world unit |
filename | : the raw elevation or gray scale image file that contains the height field. |
nSmoothPixels | the number of pixels to smooth from the edge of the height field. if this is 0, the original height field will be loaded unmodified. if it is greater than 0, the loaded height field will be smoothed for nSmoothPixels from the edge, where the edge is always 0. |
|
static |
nGroupID | 0 for animated selection, 1 for wire frame selection. -1 for all |
|
static |
flatten a land centered at x,y, with a specified radius.
Algorithm: (1) flatten a circle with radius same as fFlatPercentage*radius (2) smooth the entire region twice.
x | center of the circle in world unit |
y | center of the circle in world unit |
radius | radius of the inner circle in world unit |
fFlatPercentage | value is between [0,1]. fFlatPercentage*radius is the actual radius that got flattened. |
factor | value is between [0,1]. 1 means fully transformed; 0 means nothing is changed |
|
static |
Enable both global and local lighting.
Turn off lighting will greatly improve performance, such as on slower computers
|
static |
find a block in the side direction that matched filter from block(x,y,z) this function can be used to check for free space upward or download
side | 4 is top. 5 is bottom. |
attrFilter | attribute to match. 0 means air. default to any block |
nCategoryID | -1 means any category_id. default to -1 |
|
static |
Flatten the terrain both up and down to the specified elevation, using using the tightness parameter to determine how much the altered points are allowed to deviate from the specified elevation.
x | center of the circle in world unit |
y | center of the circle in world unit |
radius | radius of the inner circle in world unit |
flatten_op | enum FlattenOperation{ Fill_Op=0, //Flatten the terrain up to the specified elevation ShaveTop_Op=1, //Flatten the terrain down to the specified elevation Flatten_Op=2, //Flatten the terrain up and down to the specified elevation }; |
elevation | the desired height |
factor | value is between [0,1]. 1 means fully transformed; 0 means nothing is changed |
|
static |
get the attribute object associated with the global terrain.
|
static |
used for API exportation.
|
static |
get the attribute object associated with the terrain tile that contains the given point.
x | in world unit |
y | in world unit |
|
static |
used for API exportation.
|
static |
get block terrain manager's attribute object.
|
static |
get block id and userdata at the given block position.
|
static |
get block in [startChunk,endChunk]
startChunkY,endChunkY | if negative, and startChunkY == endChunkY, -startChunkY will be used as verticalSectionFilter(a bitwise filter). |
|
static |
get the terrain height at the specified position.
x | position in world unit |
y | position in world unit |
|
static |
verticalSectionFilter | default to 0xffff. each bit is for one of the 16 vertical sections. |
|
static |
get value of a given terrain region layer
sLayerName | the layer name |
x | The x location of the point on the Terrain's surface in world units. |
y | The y location of the point on the Terrain's surface in world units. |
|
static |
get value of a given terrain region layer
sLayerName | the layer name |
x | The x location of the point on the Terrain's surface in world units. |
y | The y location of the point on the Terrain's surface in world units. |
argb | it can be a string containing "argb", where the sum of them are returned. for example, specify "r" to get only the red channel value. specify "rgb" for the sum of the grey scale image. if this is empty string "", the 32bits color value is returned as int. |
|
static |
solely used for API exporting.
Not thread-safe
|
static |
solely used for API exporting.
Not thread-safe
|
static |
get the terrain detailed texture by index.
Please note that each terrain tile contains its own texture set. the total number of textures can be returned by GetTextureCount().
nIndex | Texture index in the current terrain tile. this should be smaller than the total number of textures in the texture set. see GetTextureCount(). there are two reserved negative index for the common and main textures -1: common texture, which is repeated several times over each terrain tile surface. -2: main texture, which is chopped and mapped to the entire terrain surface. |
|
static |
only used for API exporting.
|
static |
get all texture indices in the cell specified by point(x,y) GetTextureCount() returns all textures used by the entire terrain tile (i.e.
500*500). however, each terrain tile is further subdevided into 8*8=64 terrain cell (each cell takes up about 64*64 meters). Alpha channels of a terrain texture is only created on a per cell basis. A single alpha image (128*128) will be created for each used texture in the cell.
x | in world unit |
y | in world unit |
out | this should be an empty table to be filled with textures in the cell, so that {[1]=tex_index, [2]=tex_index, ...}. |
|
static |
Returns the number of real units between vertices in the terrain's mesh.
|
static |
Whether the terrain contains a hole at the specified location.
Currently, we allow user to load a low resolution hole maps at the beginning of terrain creation.
x | The x location of the point on the Terrain's surface in world units. |
y | The y location of the point on the Terrain's surface in world units. |
|
static |
return true, if the terrain is modified and should be saved.
|
static |
merge a rectangular height field from file to the current terrain.
x | center of the rect in world unit |
y | center of the rect in world unit |
filename | : the raw elevation or gray scale image file that contains the height field. |
MergeOperation | { Addition=0, Subtract=1, Multiplication=2, Division=3, Minimum=4, Maximum=5, }; |
weight1 | the destination merging weight |
weight2 | the source file merging weight |
nSmoothPixels | the number of pixels to smooth from the edge of the height field. if this is 0, the original height field will be loaded unmodified. if it is greater than 0, the loaded height field will be smoothed for nSmoothPixels from the edge, where the edge is always 0. |
|
static |
paint on the specified location of the global terrain.
detailTexture | the texture entity to paint on the terrain. The texture is usually tilable such as road and grass. if this is "", it means the base layer or layer 0. Since version 0.9.9, the base layer also has an editable alpha mask . |
brushRadius | The width of the brush to paint with in DetailTexture layer pixels. There are typically 256 of these pixels across a TextureCell. |
brushIntensity | The intensity with which to paint, ranging from 0.0 to 1.0. This determines how opaque the painted "splat" will be. |
maxIntensity | The maximum intensity of the painted splat, ranging from 0.0 to 1.0, accounting for mixing with a splat that may already reside on the surface. |
erase | Specifies whether to add the splat to the surface or remove existing splat texels already on the surface (pass false to paint and pass true to erase existing splats) |
x | The x location of the point to paint on the Terrain's surface in world units. |
y | The y location of the point to paint on the Terrain's surface in world units. |
|
static |
nDetailTextureID | multi-texture layer ID, beginning from 0. Such as 0,1,2,3. -1,-2 are reserved for special terrain editor textures. -1 means the base layer. |
|
static |
Note: terrain data should be in normalized space with height in the range [0,1].
Picks a point and scales the surrounding terrain in a circular manner. Can be used to make all sorts of circular shapes. Still needs some work. radial_scale: pick a point (center_x, center_y) and scale the points where distance is mindist<=distance<=maxdist linearly. The formula we'll use for a nice sloping smoothing factor is (-cos(x*3)/2)+0.5.
x | center of the circle in world unit |
y | center of the circle in world unit |
scale_factor | height of the scaled portion in world unit. This value can be negative. |
|
static |
create a ramp (inclined slope) from (x1,y1) to (x2,y2).
The ramp's half width is radius. this is usually used to created a slope path connecting a high land with a low land.
radius | The ramp's half width |
borderpercentage | borderpercentage*radius is how long the ramp boarder is to linearly interpolate with the original terrain. specify 0 for sharp ramp border. |
factor | in range[0,1]. it is the smoothness to merge with other border heights.Specify 1.0 for a complete merge |
|
static |
params | it can be attFlag of int type. |
|
static |
reload terrain from disk.
User will lose changes since last save operation. one can UNDO changes with this function.
bHeightMap | true to save height map |
bTextures | true to save textures: alpha maps, etc |
|
static |
remove the given texture in the cell specified by the point(x,y).
x | in world unit |
y | in world unit |
nIndex | Texture index in the current terrain tile. this should be smaller than the total number of textures in the texture set. see GetTextureCount(). |
|
static |
replace the texture at the given index.
or append a new texture, or delete a texture if TextureAsset or sTextureAsset is NULL.
nIndex | if it is smaller than the total number of textures in the texture set. see GetTextureCount(). there are two reserved negative index for the common and main textures -1: common texture, which is repeated several times over each terrain tile surface. -2: main texture, which is chopped and mapped to the entire terrain surface. |
sTextureAsset | filename. if nil, texture will be removed. |
|
static |
square filter for sharpening and smoothing.
Use neighbour-averaging to roughen or smooth the height field. The factor determines how much of the computed roughening is actually applied to the height field. In it's default invocation, the 4 directly neighboring squares are used to calculate the roughening. If you select big sampling grid, all 8 neighboring cells will be used.
x | center of the circle in world unit |
y | center of the circle in world unit |
radius | radius of the inner circle in world unit |
roughen | true for sharpening, false for smoothing. |
big_grid | true for 8 neighboring cells, false for 4. |
factor | value is between [0,1]. 1 means fully transformed; 0 means nothing is changed |
|
static |
save modified terrain to disk.
bHeightMap | true to save height map |
bTextures | true to save textures: alpha maps, etc |
|
static |
add/remove block to/from highlight block list
x,y,z | world space block id; |
isSelect | : true to select block, false to de-select block |
nGroupID | group id. 0 for highlight 1 for wireframe. |
|
static |
set all loaded terrain tile content modified.
This is the refered way to perform a save all operation
|
static |
set chunk column time stamp.
usually 0 for non-generated. 1 for generated. this is usually called by world generators, so that we will not generate again next time we load the world.
|
static |
set the content of the terrain modified.
the terrain is specified by a 2D point. the on load script will be rebuilt once saving the terrain.
x | a position on the terrain where content is changed. |
y | a position on the terrain where content is changed. |
bIsModified | true to set modified. |
|
static |
set the content of the terrain modified.
the terrain is specified by a 2D point. the on load script will be rebuilt once saving the terrain.
bIsModified | true to set modified. |
dwModifiedBits | this is any combination of TERRAIN_MODIFIED_BITS. Default value is MODIFIED_ON_LOAD_SCRIPT (16) enum TERRAIN_MODIFIED_BITS { MODIFIED_NONE = 0, detailed terrain texture(with mask) has been modified. MODIFIED_TEXTURE = 0x1, height map has modified MODIFIED_HEIGHTMAP = 0x1<<1, configuration such as base texture, common file, holes, etc has been modified. MODIFIED_CONFIGURATION = 0x1<<2, holes have been changed. this should mean the same thing as MODIFIED_CONFIGURATION MODIFIED_HOLES = 0x1<<3, if static objects have been modified, so that we will need to update the on load script MODIFIED_ON_LOAD_SCRIPT = 0x1<<4, MODIFIED_ALL = 0xffff }; |
|
static |
set a new terrain hole at the specified location.
Currently, we will allow user to dynamically dig holes in terrain. After calling this function, the user must manually Call UpdateHoles() to inform that the holes in the terrain has been updated.
x | The x location of the point on the Terrain's surface in world units. |
y | The y location of the point on the Terrain's surface in world units. |
|
static |
snap any 2D point on the height map to a vertex position on the height map.
in NPL, one should write as below: local x,y = ParaTerrain.SnapPointToVertexGrid(10,10);
x | arbitrary 2D point on the height map |
y | arbitrary 2D point on the height map |
vertex_x | [out] vertex position on the height map |
vertex_y | [out] vertex position on the height map |
|
static |
offset in a spherical region
x | center of the circle in world unit |
y | center of the circle in world unit |
radius | radius of the inner circle in world unit |
|
static |
Update all holes in the terrain tile that contains the input point.
x | The x location of the point on the Terrain's surface in world units. |
y | The y location of the point on the Terrain's surface in world units. |
|
static |
update terrain.
this function is called, when the user changes the terrain surface.
bForceUpdate | if true it will update the terrain even if the camera does not moves. |