GeoMipTerrain

Inheritance:

Methods of GeoMipTerrain:

Constants in GeoMipTerrain:

GeoMipTerrain
GeoMipTerrain::GeoMipTerrain(string const &name);

Description:

clearColorMap
void GeoMipTerrain::clear_color_map(void);

Description: Clears the color map.

colorMap
PNMImage &GeoMipTerrain::color_map(void);

Description: Returns a reference to the color map (a PNMImage) contained inside GeoMipTerrain. You can use the reference to alter the color map.

generate
void GeoMipTerrain::generate(void);

Description: (Re)generates the entire terrain, erasing the current. This call un-flattens the terrain, so make sure you have set auto-flatten if you want to keep your terrain flattened.

getBlockFromPos
LVecBase2f GeoMipTerrain::get_block_from_pos(double x, double y);

Description: Gets the coordinates of the block at the specified position. This position must be relative to the terrain, not to render. Returns an array containing two values: the block x and the block y coords. If the positions are out of range, the closest block is taken. Note that the VecBase returned does not represent a vector, position, or rotation, but it contains the block index of the block which you can use in GeoMipTerrain::get_block_node_path.

getBlockNodePath
NodePath const GeoMipTerrain::get_block_node_path(unsigned short int mx, unsigned short int my);

Description: Returns the NodePath of the specified block. If auto-flatten is enabled and the node is getting removed during the flattening process, it will still return a NodePath with the appropriate terrain chunk, but it will be in a temporary scenegraph. Please note that this returns a const object and you can not modify the node. Modify the heightfield instead.

getBlockSize
unsigned short int GeoMipTerrain::get_block_size(void);

Description: Gets the block size.

getBruteforce
bool GeoMipTerrain::get_bruteforce(void);

Description: Returns a boolean whether the terrain is rendered bruteforce or not. See set_bruteforce for more information.

getElevation
double GeoMipTerrain::get_elevation(double x, double y);

Description: Fetches the elevation at (x, y), where the input coordinate is specified in pixels. This ignores the current LOD level and instead provides an accurate number. Linear blending is used for non-integral coordinates. Terrain scale is NOT taken into account! To get accurate normals, please multiply this with the terrain Z scale!
trueElev = terr.get_elevation(x,y) * terr.get_sz();

getFactor
float GeoMipTerrain::get_factor(void);

Description: Gets the quality factor at which blocks must be generated. The higher this level, the better quality the terrain will be, but more expensive to render. A value of 0 makes the terrain the lowest quality possible, depending on blocksize. The default value is 100.

getFocalPoint
NodePath GeoMipTerrain::get_focal_point(void) const;

Description: Returns the focal point, as a NodePath. If you have set it to be just a point, it will return an empty node at the focal position.

getMinLevel
unsigned short int GeoMipTerrain::get_min_level(void);

Description: Gets the minimum level of detail at which blocks may be generated by generate() or update(). The default value is 0, which is the highest quality.

getNormal
LVector3f GeoMipTerrain::get_normal(int x, int y);

Description: Fetches the terrain normal at (x,y), where the input coordinate is specified in pixels. This ignores the current LOD level and instead provides an accurate number. Terrain scale is NOT taken into account! To get accurate normals, please divide it by the terrain scale and normalize it again!
Description: Fetches the terrain normal at (x, y), where the input coordinate is specified in pixels. This ignores the current LOD level and instead provides an accurate number. Terrain scale is NOT taken into account! To get accurate normals, please divide it by the terrain scale and normalize it again, like this:
LVector3f normal (terr.get_normal(mx, my, x, y)); normal.set(normal.get_x() / terr.get_sx(), normal.get_y() / terr.get_sy(), normal.get_z() / terr.get_sz()); normal.normalize();

getRoot
NodePath GeoMipTerrain::get_root(void) const;

Description: Returns the root of the terrain. This is a single PandaNode to which all the rest of the terrain is parented. The generate and update operations replace the nodes which are parented to this root, but they don't replace this root itself.

hasColorMap
bool GeoMipTerrain::has_color_map(void);

Description: Returns whether a color map has been set.

heightfield
PNMImage &GeoMipTerrain::heightfield(void);

Description: Returns a reference to the heightfield (a PNMImage) contained inside GeoMipTerrain. You can use the reference to alter the heightfield.

isDirty
bool GeoMipTerrain::is_dirty(void);

Description: Returns a bool indicating whether the terrain is marked 'dirty', that means the terrain has to be regenerated on the next update() call, because for instance the heightfield has changed. Once the terrain has been regenerated, the dirty flag automatically gets reset internally.

setAutoFlatten
void GeoMipTerrain::set_auto_flatten(int mode);

Description: The terrain can be automatically flattened (using flatten_light, flatten_medium, or flatten_strong) after each update. This only affects future updates, it doesn't flatten the current terrain.

setBlockSize
void GeoMipTerrain::set_block_size(unsigned short int newbs);

Description: Sets the block size. If it is not a power of two, the closest power of two is used.

setBruteforce
void GeoMipTerrain::set_bruteforce(bool bf);

Description: Sets a boolean specifying whether the terrain will be rendered bruteforce. If the terrain is rendered bruteforce, there will be no Level of Detail, and the update() call will only update the terrain if it is marked dirty.

setColorMap
bool GeoMipTerrain::set_color_map(Filename const &filename, PNMFileType *type = ((void *)(0)));

Description: Loads the specified image as color map. The next time generate() is called, the terrain is painted with this color map using the vertex color column. Returns a boolean indicating whether the operation has succeeded.

setFactor
void GeoMipTerrain::set_factor(float factor);

Description: Sets the quality factor at which blocks must be generated. The higher this level, the better quality the terrain will be, but more expensive to render. A value of 0 makes the terrain the lowest quality possible, depending on blocksize. The default value is 100.

setFocalPoint
void GeoMipTerrain::set_focal_point(LPoint2d fp);

The focal point is the point at which the terrain will have the lowest level of detail (highest quality). Parts farther away from the focal point will hae a higher level of detail. The focal point is not taken in respect if bruteforce is set true.
Description: Sets the focal point. GeoMipTerrain generates high-resolution terrain around the focal point, and progressively lower and lower resolution terrain as you get farther away. If a point is supplied and not a NodePath, make sure it's relative to the terrain. Only the x and y coordinates of the focal point are taken in respect.

setHeightfield
bool GeoMipTerrain::set_heightfield(Filename const &filename, PNMFileType *type = ((void *)(0)));

Description: Loads the specified heightmap image file into the heightfield. Returns true if succeeded, or false if an error has occured. If the heightmap is not a power of two plus one, it is scaled up using a gaussian filter.

setMinLevel
void GeoMipTerrain::set_min_level(unsigned short int minlevel);

Description: Sets the minimum level of detail at which blocks may be generated by generate() or update(). The default value is 0, which is the highest quality. This value is also taken in respect when generating the terrain bruteforce.

update
bool GeoMipTerrain::update(void);

Description: Loops through all of the terrain blocks, and checks whether they need to be updated. If that is indeed the case, it regenerates the mipmap. Returns a true when the terrain has changed. Returns false when the terrain isn't updated at all. If there is no terrain yet, it generates the entire terrain. This call un-flattens the terrain, so make sure you have set auto-flatten if you want to keep your terrain flattened.