14#ifndef STBASICTERRAIN_H
15#define STBASICTERRAIN_H
35 bool setup_terrain(
const Filename &terrain_filename);
36 bool setup_terrain(std::istream &in,
const Filename &pathname);
38 INLINE
void set_height_map(
const Filename &height_map);
39 INLINE
const Filename &get_height_map()
const;
43 INLINE PN_stdfloat get_size()
const;
44 virtual PN_stdfloat
get_height(PN_stdfloat x, PN_stdfloat y)
const;
45 virtual PN_stdfloat
get_smooth_height(PN_stdfloat x, PN_stdfloat y, PN_stdfloat radius)
const;
46 virtual PN_stdfloat
get_slope(PN_stdfloat x, PN_stdfloat y)
const;
49 PN_stdfloat start_x, PN_stdfloat start_y,
50 PN_stdfloat size_xy,
int num_xy)
const;
52 virtual void output(std::ostream &out)
const;
53 virtual void write(std::ostream &out,
int indent_level = 0)
const;
56 bool read_height_map();
57 void compute_slope(PN_stdfloat smoothing);
59 INLINE PN_stdfloat interpolate(PN_stdfloat a, PN_stdfloat b, PN_stdfloat t);
62 static void read_quoted_filename(
Filename &result, std::istream &in,
66 template<
class ValueType>
67 class InterpolationData {
70 void reset(
int width,
int height);
72 ValueType get_nearest_neighbor(PN_stdfloat u, PN_stdfloat v)
const;
73 ValueType calc_bilinear_interpolation(PN_stdfloat u, PN_stdfloat v)
const;
74 ValueType calc_smooth(PN_stdfloat u, PN_stdfloat v, PN_stdfloat radius)
const;
75 bool is_present()
const;
85 PN_stdfloat _height_scale;
87 InterpolationData<PN_stdfloat> _height_data;
89 InterpolationData<PN_stdfloat> _slope_data;
96 static void init_type() {
97 STTerrain::init_type();
99 STTerrain::get_class_type());
102 return get_class_type();
104 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
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...
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 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...
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 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 load_data()=0
This will be called at some point after initialization.
TypeHandle is the identifier used to differentiate C++ class types.
This is our own Panda specialization on the default STL vector.
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.