14#ifndef GEOMIPTERRAIN_H
15#define GEOMIPTERRAIN_H
36class EXPCL_PANDA_GRUTIL GeoMipTerrain :
public TypedObject {
38 INLINE
explicit GeoMipTerrain(
const std::string &name);
39 INLINE ~GeoMipTerrain();
52 void calc_ambient_occlusion(PN_stdfloat radius = 32, PN_stdfloat contrast = 2.0f, PN_stdfloat brightness = 0.75f);
55 INLINE LVector3
get_normal(
unsigned short mx,
unsigned short my,
62 enum AutoFlattenMode {
79 INLINE
void set_focal_point(
const LPoint2d &fp);
80 INLINE
void set_focal_point(
const LPoint2f &fp);
81 INLINE
void set_focal_point(
const LPoint3d &fp);
82 INLINE
void set_focal_point(
const LPoint3f &fp);
83 INLINE
void set_focal_point(
double x,
double y);
84 INLINE
void set_focal_point(
NodePath fnp);
95 INLINE
void set_near_far(
double input_near,
double input_far);
96 INLINE
void set_near(
double input_near);
97 INLINE
void set_far(
double input_far);
113 PT(
GeomNode) generate_block(
unsigned short mx,
unsigned short my,
unsigned short level);
114 bool update_block(
unsigned short mx,
unsigned short my,
115 signed short level = -1,
bool forced =
false);
118 bool root_flattened();
120 INLINE
bool is_power_of_two(
unsigned int i);
121 INLINE
float f_part(
float i);
122 INLINE
double f_part(
double i);
123 INLINE
int sfav(
int n,
int powlevel,
int mypowlevel);
124 INLINE
double get_pixel_value(
int x,
int y);
125 INLINE
double get_pixel_value(
unsigned short mx,
unsigned short my,
int x,
int y);
126 INLINE
unsigned short lod_decide(
unsigned short mx,
unsigned short my);
127 unsigned short get_neighbor_level(
unsigned short mx,
unsigned short my,
short dmx,
short dmy);
131 bool _root_flattened;
142 unsigned short _block_size;
143 unsigned short _max_level;
146 bool _focal_is_temporary;
147 unsigned short _min_level;
149 pvector<pvector<NodePath> > _blocks;
150 pvector<pvector<unsigned short> > _levels;
151 pvector<pvector<unsigned short> > _old_levels;
160 TypedObject::get_class_type());
163 return get_class_type();
The name of a file, such as a texture file or an Egg file.
double get_elevation(double x, double y)
Fetches the elevation at (x, y), where the input coordinate is specified in pixels.
bool update()
Loops through all of the terrain blocks, and checks whether they need to be updated.
PNMImage & color_map()
Returns a reference to the color map (a PNMImage) contained inside GeoMipTerrain.
const NodePath get_block_node_path(unsigned short mx, unsigned short my)
Returns the NodePath of the specified block.
bool is_dirty()
Returns a bool indicating whether the terrain is marked 'dirty', that means the terrain has to be reg...
void set_min_level(unsigned short minlevel)
Sets the minimum level of detail at which blocks may be generated by generate() or update().
bool set_color_map(const Filename &filename, PNMFileType *type=nullptr)
Loads the specified image as color map.
bool set_heightfield(const Filename &filename, PNMFileType *type=nullptr)
Loads the specified heightmap image file into the heightfield.
void set_near(double input_near)
Sets the near LOD distance, at which the terrain will be rendered at highest quality.
void set_bruteforce(bool bf)
Sets a boolean specifying whether the terrain will be rendered bruteforce.
PNMImage make_slope_image()
Returns a new grayscale image containing the slope angles.
unsigned short get_max_level()
Returns the highest level possible for this block size.
void set_auto_flatten(int mode)
The terrain can be automatically flattened (using flatten_light, flatten_medium, or flatten_strong) a...
unsigned short get_block_size()
Gets the block size.
double get_far()
Returns the far LOD distance in the terrain coordinate space.
LVector3 get_normal(int x, int y)
Fetches the terrain normal at (x, y), where the input coordinate is specified in pixels.
void calc_ambient_occlusion(PN_stdfloat radius=32, PN_stdfloat contrast=2.0f, PN_stdfloat brightness=0.75f)
Calculates an approximate for the ambient occlusion and stores it in the color map,...
void set_near_far(double input_near, double input_far)
Sets the near and far LOD distances in one call.
void set_block_size(unsigned short newbs)
Sets the block size.
void clear_color_map()
Clears the color map.
void set_far(double input_far)
Sets the far LOD distance, at which the terrain will be rendered at lowest quality.
unsigned short get_min_level()
Gets the minimum level of detail at which blocks may be generated by generate() or update().
void set_border_stitching(bool stitching)
If this value is true, the LOD level at the borders of the terrain will be 0.
NodePath get_root() const
Returns the root of the terrain.
void set_factor(PN_stdfloat factor)
DEPRECATED method.
PNMImage & heightfield()
Returns a reference to the heightfield (a PNMImage) contained inside GeoMipTerrain.
int get_flatten_mode()
Returns the automatic-flatten mode (e.g., off, flatten_light, flatten_medium, or flatten_strong)
bool get_bruteforce()
Returns a boolean whether the terrain is rendered bruteforce or not.
bool get_border_stitching()
Returns the current stitching setting.
double get_near()
Returns the near LOD distance in the terrain coordinate space.
NodePath get_focal_point() const
Returns the focal point, as a NodePath.
void generate()
(Re)generates the entire terrain, erasing the current.
bool has_color_map() const
Returns whether a color map has been set.
LVecBase2 get_block_from_pos(double x, double y)
Gets the coordinates of the block at the specified position.
A node that holds Geom objects, renderable pieces of geometry.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
This is the base class of a family of classes that represent particular image file types that PNMImag...
The name of this class derives from the fact that we originally implemented it as a layer on top of t...
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
TypeHandle is the identifier used to differentiate C++ class types.
static void init_type()
This function is declared non-inline to work around a compiler bug in g++ 2.96.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.