36 _is_valid(copy._is_valid),
37 _normal_map(copy._normal_map),
38 _splat_layers(copy._splat_layers),
39 _min_height(copy._min_height),
40 _max_height(copy._max_height)
42 set_vertex_format(copy._vertex_format);
63 _splat_layers.clear();
65 set_vertex_format(
nullptr);
116 PN_stdfloat height_min, PN_stdfloat height_max,
117 PN_stdfloat slope_min, PN_stdfloat slope_max) {
119 if (height < height_min || height > height_max) {
124 if (slope < slope_min || slope > slope_max) {
144 PN_stdfloat start_x, PN_stdfloat start_y,
145 PN_stdfloat size_xy,
int num_xy)
const {
152 output(std::ostream &out)
const {
160 write(std::ostream &out,
int indent_level)
const {
172 nassertr(!_st_vertex_attribs.empty(),
nullptr);
174 return &_st_vertex_attribs[0];
184 if (format ==
nullptr) {
185 _vertex_format =
nullptr;
186 _st_vertex_attribs.clear();
191 _vertex_format = GeomVertexFormat::register_format(format);
192 if (!convert_vertex_format(_st_vertex_attribs, _vertex_format)) {
208 st_vertex_attribs.clear();
211 speedtree_cat.error()
212 <<
"Cannot represent multi-array vertex format in SpeedTree.\n";
219 for (
int ci = 0; ci < num_columns; ++ci) {
221 st_vertex_attribs.push_back(SpeedTree::SVertexAttribDesc());
222 SpeedTree::SVertexAttribDesc &attrib = st_vertex_attribs.back();
223 if (!convert_vertex_column(attrib, column)) {
224 st_vertex_attribs.clear();
229 st_vertex_attribs.push_back(SpeedTree::st_attrib_end);
240 convert_vertex_column(SpeedTree::SVertexAttribDesc &st_attrib,
243 case GeomEnums::NT_stdfloat:
244 st_attrib.m_eDataType = SpeedTree::VERTEX_ATTRIB_TYPE_FLOAT;
248 speedtree_cat.error()
249 <<
"Unsupported vertex numeric type for " << *column <<
"\n";
255 if (column->
get_name() == InternalName::get_vertex()) {
256 st_attrib.m_eSemantic = SpeedTree::VERTEX_ATTRIB_SEMANTIC_POS;
258 }
else if (column->
get_name() == InternalName::get_texcoord()) {
259 st_attrib.m_eSemantic = SpeedTree::VERTEX_ATTRIB_SEMANTIC_TEXCOORD0;
262 speedtree_cat.error()
263 <<
"Unsupported vertex semantic name for " << *column <<
"\n";
267 nassertr(st_attrib.SizeOfAttrib() == column->
get_total_bytes(),
false);
NumericType get_numeric_type() const
Returns the token representing the numeric type of the data storage.
const SpeedTree::SVertexAttribDesc * get_st_vertex_format() const
Returns a pointer to the SpeedTree array of vertex attribs that defines the vertex format for SpeedTr...
A base class for things which need to inherit from both TypedObject and from ReferenceCount.
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...
This defines how a single column is interleaved within a vertex array stored within a Geom.
void output(std::ostream &out) const
Outputs the Namable.
A base class for all things which can have a name.
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...
std::ostream & indent(std::ostream &out, int indent_level)
A handy function for doing text formatting.
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.
const InternalName * get_name() const
Returns the name of this particular data field, e.g.
int get_total_bytes() const
Returns the number of bytes used by each element of the column: component_bytes * num_components.
TypeHandle is the identifier used to differentiate C++ class types.
int get_num_components() const
Returns the number of components of the column: the number of instances of the NumericType in each el...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool placement_is_acceptable(PN_stdfloat x, PN_stdfloat y, PN_stdfloat height_min, PN_stdfloat height_max, PN_stdfloat slope_min, PN_stdfloat slope_max)
Returns true if the elevation and slope of point (x, y) fall within the requested limits,...