OpenGL Library for Delphi,
maintained by Eric Grange,
based on Mike Lischke's GLScene.

 

Reference Manual - THeightData


Used to define a tile when requested by the terrain renderer. The terrain renderer can be made up of many tiles or just one. The THeightData tile has an array of heights (either bytes, small integers or singles) and also the tile has texture coordinate properties that allows different parts of a terrain texture be applied to different tiles. This class is often used when using the TGLCustomHDS onstartpreparingdata handler which is called by the terrain renderer when it wants a tile (if the height data source is TGLCustomHDS). The user can set his own heights and texture coordinates on each tile passed into the handler.

Importants THeightData properties:
datatype : THeightDataType
Data type of the array that holds the heights. Includes bytes, small integers or single data types.

xleft : integer
The left x coordinate of the tile. Allows you to know where the tile is being placed on the terrain.

ytop: integer
The top y coordinate of the tile. Use with xleft for the position on terrain

size : integer
The size of the tile

procedure allocate(val : THeightDataType)
Call this procedure to allocate an array of height data of a certain data type. Set to hdtByte in order to use an array of bytes to define height. Once allocated it is possible to access and set the heights in the bytedata array if the byte type is used. If the tile has no height data then dont call this procedure. Instead set datastate to hdsNone.

datastate : THeightDataState
Commonly used when setting the state of the tile on the TGLCustomHDS onstartpreparingdata handler. Set to hdsNone if the tile has no height information otherwise set to hdsReady when height information has been put into the height arrays.

datasize : integer
The size of the array used in bytes. Is not the same as size where size is the size of the tile

texturecoordinatesoffset : TTexPoint
Texture coordinate of the texture. Will allow you to put different areas of a texture onto a tile eg top right of the texture rather than the entire texture

texturecoordinatesccale : TTexPoint
Scale of part of the texture

materialname : String
Name of material for the tile (if terrain uses multiple materials).


The following are methods for access and setting height values depending on the data type that you set. For example if the datatype is of type byte then then access the bytedata or byteraster arrays. The following is a more formal description of how to access height data arrays:

The raster is a square, whose size must be a power of two. Data can beaccessed through a base pointer ("bytedata[n]" f.i.), or through pointerindirections ("byteraster[y][x]" f.i.), this are the fastest way to accessheight data (and the most unsecure).
Secure (with range checking) data access is provided by specializedmethods (f.i. "byteheight"), in which coordinates (x & y) are alwaysconsidered relative (like in raster access).
The class offers conversion facility between the types (as a whole dataconversion), but in any case, the THeightData should be directly requestedfrom the THeightDataSource with the appropriate format.
Though this class can be instantiated, you will usually prefer to subclassit in real-world cases, f.i. to add texturing data.
bytedata : PByteArray
Access to data as a byte array (n = y*Size+x).
Note that if datatype is not of type hdtByte, this array is nil.

byteraster : PByteRaster
Access to data as a byte raster (y, x).
Note that if datatype is not of type hdtByte, this array is nil.

smallintdata : PSmallIntArray
Access to data as a SmallInt array (n = y*Size+x).
Note that if datatype is not of type hdtSmallInt, this array is nil.

smallintraster : PSmallIntRaster
Access to data as a SmallInt raster (y, x).
Note that if datatype is not of type hdtSmallInt, this array is nil.

singledata : PSingleArray
Access to data as a Single array (n = y*Size+x).
Note that if datatype is not of type hdtSingle, this array is nil.

singleraster : PSingleRaster
Access to data as a Single raster (y, x).
Note that if datatype is not of type hdtSingle, this array is nil.


Unit: GLHeightData

Descends from TObject.
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.2
Page was generated in 0.0448 seconds