GeoMipTerrain
from panda3d.core import GeoMipTerrain
- class GeoMipTerrain
Bases:
TypedObject
GeoMipTerrain, meaning Panda3D GeoMipMapping, can convert a heightfield image into a 3D terrain, consisting of several GeomNodes. It uses the GeoMipMapping algorithm, or Geometrical MipMapping, based on the LOD (Level of Detail) algorithm. For more information about the GeoMipMapping algoritm, see this paper, written by Willem H. de Boer: https://flipcode.com/articles/article_geomipmaps.pdf
Inheritance diagram
- AFMLight = 1
- AFMMedium = 2
- AFMOff = 0
- AFMStrong = 3
- AFM_light = 1
- AFM_medium = 2
- AFM_off = 0
- AFM_strong = 3
- __init__(*args, **kwargs)
- calcAmbientOcclusion()
C++ Interface: calc_ambient_occlusion(const GeoMipTerrain self, float radius, float contrast, float brightness)
- /**
Calculates an approximate for the ambient occlusion and stores it in the
color map, so that it will be written to the vertex colors. Any existing
color map will be discarded. You need to call this before generating the
geometry.
*/
- calc_ambient_occlusion()
C++ Interface: calc_ambient_occlusion(const GeoMipTerrain self, float radius, float contrast, float brightness)
- /**
Calculates an approximate for the ambient occlusion and stores it in the
color map, so that it will be written to the vertex colors. Any existing
color map will be discarded. You need to call this before generating the
geometry.
*/
- clearColorMap()
C++ Interface: clear_color_map(const GeoMipTerrain self)
- /**
Clears the color map.
*/
- clear_color_map()
C++ Interface: clear_color_map(const GeoMipTerrain self)
- /**
Clears the color map.
*/
- colorMap()
C++ Interface: color_map(const GeoMipTerrain self)
- /**
Returns a reference to the color map (a PNMImage) contained inside
GeoMipTerrain. You can use the reference to alter the color map.
*/
- color_map()
C++ Interface: color_map(const GeoMipTerrain self)
- /**
Returns a reference to the color map (a PNMImage) contained inside
GeoMipTerrain. You can use the reference to alter the color map.
*/
- generate()
C++ Interface: generate(const GeoMipTerrain self)
- /**
(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()
C++ Interface: get_block_from_pos(const GeoMipTerrain self, double x, double y)
- /**
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()
C++ Interface: get_block_node_path(const GeoMipTerrain self, int mx, int my)
- /**
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.
*/
- getBorderStitching()
C++ Interface: get_border_stitching(const GeoMipTerrain self)
- /**
Returns the current stitching setting. False by default, unless
set_stitching has been set.
*/
- getBruteforce()
C++ Interface: get_bruteforce(const GeoMipTerrain self)
- /**
Returns a boolean whether the terrain is rendered bruteforce or not. See
set_bruteforce for more information.
*/
- getClassType()
C++ Interface: get_class_type()
- getElevation()
C++ Interface: get_elevation(const GeoMipTerrain self, double x, double y)
- /**
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();
*/
- getFar()
C++ Interface: get_far(const GeoMipTerrain self)
- /**
Returns the far LOD distance in the terrain coordinate space
*/
- getFlattenMode()
C++ Interface: get_flatten_mode(const GeoMipTerrain self)
- /**
Returns the automatic-flatten mode (e.g., off, flatten_light,
flatten_medium, or flatten_strong)
*/
- getFocalPoint()
C++ Interface: get_focal_point(GeoMipTerrain self)
- /**
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.
*/
- getMaxLevel()
C++ Interface: get_max_level(const GeoMipTerrain self)
- /**
Returns the highest level possible for this block size. When a block is at
this level, it will be the worst quality possible.
*/
- getMinLevel()
C++ Interface: get_min_level(const GeoMipTerrain self)
- /**
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.
*/
- getNear()
C++ Interface: get_near(const GeoMipTerrain self)
- /**
Returns the near LOD distance in the terrain coordinate space
*/
- getNormal()
C++ Interface: get_normal(const GeoMipTerrain self, int x, int y) get_normal(const GeoMipTerrain self, int mx, int my, int x, int y)
- /**
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!
*/
- /**
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:
LVector3 normal (terr.get_normal(x, y)); normal.set(normal.get_x() /
root.get_sx(), normal.get_y() / root.get_sy(), normal.get_z() /
root.get_sz()); normal.normalize();
*/
- getRoot()
C++ Interface: get_root(GeoMipTerrain self)
- /**
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.
*/
- get_block_from_pos()
C++ Interface: get_block_from_pos(const GeoMipTerrain self, double x, double y)
- /**
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.
*/
- get_block_node_path()
C++ Interface: get_block_node_path(const GeoMipTerrain self, int mx, int my)
- /**
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.
*/
- get_block_size()
C++ Interface: get_block_size(const GeoMipTerrain self)
- /**
Gets the block size.
*/
- get_border_stitching()
C++ Interface: get_border_stitching(const GeoMipTerrain self)
- /**
Returns the current stitching setting. False by default, unless
set_stitching has been set.
*/
- get_bruteforce()
C++ Interface: get_bruteforce(const GeoMipTerrain self)
- /**
Returns a boolean whether the terrain is rendered bruteforce or not. See
set_bruteforce for more information.
*/
- get_class_type()
C++ Interface: get_class_type()
- get_elevation()
C++ Interface: get_elevation(const GeoMipTerrain self, double x, double y)
- /**
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();
*/
- get_far()
C++ Interface: get_far(const GeoMipTerrain self)
- /**
Returns the far LOD distance in the terrain coordinate space
*/
- get_flatten_mode()
C++ Interface: get_flatten_mode(const GeoMipTerrain self)
- /**
Returns the automatic-flatten mode (e.g., off, flatten_light,
flatten_medium, or flatten_strong)
*/
- get_focal_point()
C++ Interface: get_focal_point(GeoMipTerrain self)
- /**
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.
*/
- get_max_level()
C++ Interface: get_max_level(const GeoMipTerrain self)
- /**
Returns the highest level possible for this block size. When a block is at
this level, it will be the worst quality possible.
*/
- get_min_level()
C++ Interface: get_min_level(const GeoMipTerrain self)
- /**
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.
*/
- get_near()
C++ Interface: get_near(const GeoMipTerrain self)
- /**
Returns the near LOD distance in the terrain coordinate space
*/
- get_normal()
C++ Interface: get_normal(const GeoMipTerrain self, int x, int y) get_normal(const GeoMipTerrain self, int mx, int my, int x, int y)
- /**
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!
*/
- /**
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:
LVector3 normal (terr.get_normal(x, y)); normal.set(normal.get_x() /
root.get_sx(), normal.get_y() / root.get_sy(), normal.get_z() /
root.get_sz()); normal.normalize();
*/
- get_root()
C++ Interface: get_root(GeoMipTerrain self)
- /**
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()
C++ Interface: has_color_map(GeoMipTerrain self)
- /**
Returns whether a color map has been set.
*/
- has_color_map()
C++ Interface: has_color_map(GeoMipTerrain self)
- /**
Returns whether a color map has been set.
*/
- heightfield()
C++ Interface: heightfield(const GeoMipTerrain self)
- /**
Returns a reference to the heightfield (a PNMImage) contained inside
GeoMipTerrain. You can use the reference to alter the heightfield.
*/
- isDirty()
C++ Interface: is_dirty(const GeoMipTerrain self)
- /**
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.
*/
- is_dirty()
C++ Interface: is_dirty(const GeoMipTerrain self)
- /**
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.
*/
- makeSlopeImage()
C++ Interface: make_slope_image(const GeoMipTerrain self)
- /**
Returns a new grayscale image containing the slope angles. A white pixel
value means a vertical slope, while a black pixel will mean that the
terrain is entirely flat at that pixel. You can translate it to degrees by
mapping the greyscale values from 0 to 90 degrees. The resulting image
will have the same size as the heightfield image. The scale will be taken
into respect – meaning, if you change the terrain scale, the slope image
will need to be regenerated in order to be correct.
*/
- make_slope_image()
C++ Interface: make_slope_image(const GeoMipTerrain self)
- /**
Returns a new grayscale image containing the slope angles. A white pixel
value means a vertical slope, while a black pixel will mean that the
terrain is entirely flat at that pixel. You can translate it to degrees by
mapping the greyscale values from 0 to 90 degrees. The resulting image
will have the same size as the heightfield image. The scale will be taken
into respect – meaning, if you change the terrain scale, the slope image
will need to be regenerated in order to be correct.
*/
- setAutoFlatten()
C++ Interface: set_auto_flatten(const GeoMipTerrain self, int mode)
- /**
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()
C++ Interface: set_block_size(const GeoMipTerrain self, int newbs)
- /**
Sets the block size. If it is not a power of two, the closest power of two
is used.
*/
- setBorderStitching()
C++ Interface: set_border_stitching(const GeoMipTerrain self, bool stitching)
- /**
If this value is true, the LOD level at the borders of the terrain will be
This is useful if you have multiple terrains attached and you want to
stitch them together, to fix seams. This setting also has effect when
bruteforce is enabled, although in that case you are probably better off
with setting the minlevels to the same value.
*/
- setBruteforce()
C++ Interface: set_bruteforce(const GeoMipTerrain self, bool bf)
- /**
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()
C++ Interface: set_color_map(const GeoMipTerrain self, const Filename filename) set_color_map(const GeoMipTerrain self, const Texture image) set_color_map(const GeoMipTerrain self, const PNMImage image) set_color_map(const GeoMipTerrain self, str path)
- /**
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()
C++ Interface: set_factor(const GeoMipTerrain self, float factor)
- /**
DEPRECATED method. Use set_near/far instead. 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.
@deprecated use set_near/set_far instead
*/
- setFar()
C++ Interface: set_far(const GeoMipTerrain self, double input_far)
- /**
Sets the far LOD distance, at which the terrain will be rendered at lowest
quality. This distance is in the terrain’s coordinate space!
*/
- setFocalPoint()
C++ Interface: set_focal_point(const GeoMipTerrain self, const LPoint2d fp) set_focal_point(const GeoMipTerrain self, const LPoint2f fp) set_focal_point(const GeoMipTerrain self, const LPoint3d fp) set_focal_point(const GeoMipTerrain self, const LPoint3f fp) set_focal_point(const GeoMipTerrain self, NodePath fnp) set_focal_point(const GeoMipTerrain self, double x, double y)
// The focal point is the point at which the terrain will have the highest // quality (lowest level of detail). Parts farther away from the focal point // will have a lower quality (higher level of detail). The focal point is // not taken in respect if bruteforce is set true.
- /**
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()
C++ Interface: set_heightfield(const GeoMipTerrain self, const Filename filename) set_heightfield(const GeoMipTerrain self, const PNMImage image)
- /**
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.
*/
- /**
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()
C++ Interface: set_min_level(const GeoMipTerrain self, int minlevel)
- /**
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.
*/
- setNear()
C++ Interface: set_near(const GeoMipTerrain self, double input_near)
- /**
Sets the near LOD distance, at which the terrain will be rendered at
highest quality. This distance is in the terrain’s coordinate space!
*/
- setNearFar()
C++ Interface: set_near_far(const GeoMipTerrain self, double input_near, double input_far)
- /**
Sets the near and far LOD distances in one call.
*/
- set_auto_flatten()
C++ Interface: set_auto_flatten(const GeoMipTerrain self, int mode)
- /**
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.
*/
- set_block_size()
C++ Interface: set_block_size(const GeoMipTerrain self, int newbs)
- /**
Sets the block size. If it is not a power of two, the closest power of two
is used.
*/
- set_border_stitching()
C++ Interface: set_border_stitching(const GeoMipTerrain self, bool stitching)
- /**
If this value is true, the LOD level at the borders of the terrain will be
This is useful if you have multiple terrains attached and you want to
stitch them together, to fix seams. This setting also has effect when
bruteforce is enabled, although in that case you are probably better off
with setting the minlevels to the same value.
*/
- set_bruteforce()
C++ Interface: set_bruteforce(const GeoMipTerrain self, bool bf)
- /**
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.
*/
- set_color_map()
C++ Interface: set_color_map(const GeoMipTerrain self, const Filename filename) set_color_map(const GeoMipTerrain self, const Texture image) set_color_map(const GeoMipTerrain self, const PNMImage image) set_color_map(const GeoMipTerrain self, str path)
- /**
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.
*/
- set_factor()
C++ Interface: set_factor(const GeoMipTerrain self, float factor)
- /**
DEPRECATED method. Use set_near/far instead. 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.
@deprecated use set_near/set_far instead
*/
- set_far()
C++ Interface: set_far(const GeoMipTerrain self, double input_far)
- /**
Sets the far LOD distance, at which the terrain will be rendered at lowest
quality. This distance is in the terrain’s coordinate space!
*/
- set_focal_point()
C++ Interface: set_focal_point(const GeoMipTerrain self, const LPoint2d fp) set_focal_point(const GeoMipTerrain self, const LPoint2f fp) set_focal_point(const GeoMipTerrain self, const LPoint3d fp) set_focal_point(const GeoMipTerrain self, const LPoint3f fp) set_focal_point(const GeoMipTerrain self, NodePath fnp) set_focal_point(const GeoMipTerrain self, double x, double y)
// The focal point is the point at which the terrain will have the highest // quality (lowest level of detail). Parts farther away from the focal point // will have a lower quality (higher level of detail). The focal point is // not taken in respect if bruteforce is set true.
- /**
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.
*/
- set_heightfield()
C++ Interface: set_heightfield(const GeoMipTerrain self, const Filename filename) set_heightfield(const GeoMipTerrain self, const PNMImage image)
- /**
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.
*/
- /**
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.
*/
- set_min_level()
C++ Interface: set_min_level(const GeoMipTerrain self, int minlevel)
- /**
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.
*/
- set_near()
C++ Interface: set_near(const GeoMipTerrain self, double input_near)
- /**
Sets the near LOD distance, at which the terrain will be rendered at
highest quality. This distance is in the terrain’s coordinate space!
*/
- set_near_far()
C++ Interface: set_near_far(const GeoMipTerrain self, double input_near, double input_far)
- /**
Sets the near and far LOD distances in one call.
*/
- update()
C++ Interface: update(const GeoMipTerrain self)
- /**
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.
*/