Terrain Molecule
From oWiki
Preference Dialog
Attributes
type
string ( r )
Type of this molecule, 'terrain'.
pref.name
string ( r )
The scriptable name for this molecule. This name can be set using rename method dynamically.
pref.enableWhen
string ( r, w )
Specifies the event that activates this molecule. Default is 'load'.
pref.disableWhen
string ( r, w )
Specifies the event that deactivates this molecule. Default is 'none'.
pref.WorldTexture
string ( r, w )
Specifies the URL where the terrain texture image resides.
pref.DetailTexture
string ( r, w )
Specifies the URL where the detail texture image resides.
pref.DetailTile
int ( r, w )
This specifies the number of times that the detail texture will be repeated in each terrain tile. i.e., if the value is n, the detail texture will be displayed in an nxn grid within each terrain tile. Setting this can involve some experimentation. If this number is low, the terrain may appear blurry at close distances. If this number is high, the terrain may appear to have repeating patterns when viewed over a distance.
pref.PageSource
string ( r, w )
Specifies the source of the heightmap. By default, 'Heightmap'.
pref.Heightmap_image
string ( r, w )
Specifies the URL where the height map image resides. The image file from which the heightmap is drawn must be a square where each dimension is of size 2 ^ n+1, for some integer n. The larger the size of the heightmap, the more detail the terrain will have, but the more resources your application will consume (including longer application start time.) 8 bits or 16 bits height maps are supported. Important: The image format must be saved in monochrome mode - height maps in RGB mode (24bit) will throw an exception.
pref.Heightmap_flip
bool ( r, w )
When set to true, flips the heightmap.
pref.PageSize
int ( r, w )
The terrain will be PageSize x PageSize vertices large. PageSize must have the same value as the dimension of the heightmap image, and so must also have a value 2 ^ n+1 for some integer n.
pref.TileSize
int ( r, w )
Terrain tiles have the dimension TileSize x TileSize vertices. This number must be smaller than PageSize. TileSize must have a value 2 ^ n+1 for some integer n. Making tile size too small impacts performance significantly while making tiles too large may result in unnecessarily high detail in some parts of the scene.
pref.MaxPixelError
int ( r, w )
This specifies the maximum error tolerated when determining which level of detail to use. Setting this value too high can result in seams in the terrain. Setting the value too low can impact performance. This is the main way to control the distance at which the terrain displays LODs — it is not a distance in world units but rather how much error can appear on the screen. The more error allowed, the less detailed the LODs can become.
pref.PageWorldX
int ( r, w )
This sets the x-extent of the terrain in world coordinates. The larger the terrain, the lower the detail will be in the terrain, as the number of vertices used for the terrain is based on the heightmap, not the world size. This can be used to scale the terrain to any size you want.
pref.PageWorldZ
int ( r, w )
This sets the z-extent of the terrain in world coordinates. The larger the terrain, the lower the detail will be in the terrain, as the number of vertices used for the terrain is based on the heightmap, not the world size. This can be used to scale the terrain to any size you want.
pref.MaxHeight
int ( r, w )
The maximum height of the terrain in world coordinates. The 0-255 (resp. 0-65535) range from the heightmap is scaled to 0-MaxHeight in world coordinates.
pref.MaxMipMapLevel
int ( r, w )
Specifies the number of levels of detail that will be used in rendering the terrain. Terrain that is distant or is relatively flat can be rendered with less detail.
pref.VertexNormals
string yes or no ( r, w )
This makes the TerrainSceneManager calculate and set vertex normals in the hardware buffer. If you use lighting or a GPU program that requires it, you should turn this on. Default is 'yes'.
pref.VertexColours
string yes or no ( r, w )
This makes the TerrainSceneManager calculate and set the vertex colors in the hardware buffer. Turn this on if you use a GPU program that needs this information. Default is 'yes'.
pref.CustomMaterialName
string ( r, w )
Custom material name used to render the terrain.
pref.UseCustomMaterial
bool yes or no ( r, w )
Specifies whether to use custom material to render the texture.
Methods
rename(n)
n: string
| Rename this molecule. |
update()
| Force molecule to update with the current set of attributes. |
clone()
Return: a molecule
| Create a clone of this molecule. |
attach(droplet)
droplet: a droplet object (e.g. app.box.droplet)
| Attach this molecule to a droplet. |
detach()
| Remove this molecule from its droplet. |
deleteMod()
| Delete this molecule. |
serialize()
Return: string
| Serialize this molecule into its JSON representation. |
enableCollision()
| Enable collision detection on the terrain surface. |
disableCollision()
| Disable collision detection on the terrain surface. |
getHeightAt( x, z )
x: float
z: float
Return: float
| Returns the height of terrain at point (x, z). |

