15 #ifndef STBASICTERRAIN_H 16 #define STBASICTERRAIN_H 18 #include "pandabase.h" 19 #include "stTerrain.h" 38 bool setup_terrain(
const Filename &terrain_filename);
39 bool setup_terrain(istream &in,
const Filename &pathname);
41 INLINE
void set_height_map(
const Filename &height_map);
42 INLINE
const Filename &get_height_map()
const;
46 INLINE PN_stdfloat get_size()
const;
47 virtual PN_stdfloat
get_height(PN_stdfloat x, PN_stdfloat y)
const;
48 virtual PN_stdfloat
get_smooth_height(PN_stdfloat x, PN_stdfloat y, PN_stdfloat radius)
const;
49 virtual PN_stdfloat
get_slope(PN_stdfloat x, PN_stdfloat y)
const;
52 PN_stdfloat start_x, PN_stdfloat start_y,
53 PN_stdfloat size_xy,
int num_xy)
const;
55 virtual void output(ostream &out)
const;
56 virtual void write(ostream &out,
int indent_level = 0)
const;
59 bool read_height_map();
60 void compute_slope(PN_stdfloat smoothing);
62 INLINE PN_stdfloat interpolate(PN_stdfloat a, PN_stdfloat b, PN_stdfloat t);
65 static void read_quoted_filename(
Filename &result, istream &in,
69 template<
class ValueType>
70 class InterpolationData {
73 void reset(
int width,
int height);
75 ValueType get_nearest_neighbor(PN_stdfloat u, PN_stdfloat v)
const;
76 ValueType calc_bilinear_interpolation(PN_stdfloat u, PN_stdfloat v)
const;
77 ValueType calc_smooth(PN_stdfloat u, PN_stdfloat v, PN_stdfloat radius)
const;
78 bool is_present()
const;
88 PN_stdfloat _height_scale;
90 InterpolationData<PN_stdfloat> _height_data;
92 InterpolationData<PN_stdfloat> _slope_data;
99 static void init_type() {
100 STTerrain::init_type();
101 register_type(_type_handle,
"STBasicTerrain",
102 STTerrain::get_class_type());
105 return get_class_type();
107 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
113 #include "stBasicTerrain.I" A specific implementation of STTerrain that supports basic heightmaps loaded from an image file...
This is the abstract base class that defines the interface needed to describe a terrain for rendering...
virtual PN_stdfloat get_slope(PN_stdfloat x, PN_stdfloat y) const
After load_data() has been called, this should return the directionless slope at point (x...
virtual void fill_vertices(GeomVertexData *data, PN_stdfloat start_x, PN_stdfloat start_y, PN_stdfloat size_xy, int num_xy) const
After load_data() has been called, this will be called occasionally to populate the vertices for a te...
virtual PN_stdfloat get_smooth_height(PN_stdfloat x, PN_stdfloat y, PN_stdfloat radius) const
After load_data() has been called, this should return the approximate average height value over a cir...
The name of a file, such as a texture file or an Egg file.
This defines the actual numeric vertex data stored in a Geom, in the structure defined by a particula...
virtual void clear()
Resets the terrain to its initial, unloaded state.
virtual PN_stdfloat get_height(PN_stdfloat x, PN_stdfloat y) const =0
After load_data() has been called, this should return the computed height value at point (x...
virtual void load_data()=0
This will be called at some point after initialization.
TypeHandle is the identifier used to differentiate C++ class types.