14 #ifndef SPEEDTREENODE_H 15 #define SPEEDTREENODE_H 36 #if SPEEDTREE_VERSION_MAJOR > 5 || (SPEEDTREE_VERSION_MAJOR == 5 && SPEEDTREE_VERSION_MINOR >= 3) 37 #undef ST_DELETE_FOREST_HACK 39 #define ST_DELETE_FOREST_HACK 61 INLINE
bool operator < (
const InstanceList &other)
const;
64 INLINE
const STTree *get_tree()
const;
66 INLINE
int get_num_instances()
const;
68 MAKE_SEQ(get_instances, get_num_instances, get_instance);
69 INLINE
void set_instance(
int n,
const STTransform &transform);
71 INLINE
int add_instance(
const STTransform &transform);
72 INLINE
void remove_instance(
int n);
74 void output(std::ostream &out)
const;
75 void write(std::ostream &out,
int indent_level = 0)
const;
93 INLINE
int get_num_trees()
const;
115 PN_stdfloat x_min, PN_stdfloat x_max,
116 PN_stdfloat y_min, PN_stdfloat y_max,
117 PN_stdfloat scale_min, PN_stdfloat scale_max,
118 PN_stdfloat height_min, PN_stdfloat height_max,
119 PN_stdfloat slope_min, PN_stdfloat slope_max,
126 Loader *loader =
nullptr);
138 void set_wind(
double strength,
const LVector3 &direction);
141 INLINE
double get_time_delta()
const;
143 INLINE
static double get_global_time_delta();
145 MAKE_PROPERTY(global_time_delta, get_global_time_delta,
148 static bool authorize(
const std::string &license =
"");
166 int &internal_vertices,
168 Thread *current_thread)
const;
170 virtual void output(std::ostream &out)
const;
171 virtual void write(std::ostream &out,
int indent_level)
const;
176 void set_transparent_texture_mode(SpeedTree::ETextureAlphaRenderMode eMode)
const;
184 void update_terrain_cells();
187 void render_forest_into_shadow_maps();
191 void print_forest_stats(
const SpeedTree::CForest::SPopulationStats &forest_stats)
const;
196 ALLOC_DELETED_CHAIN(DrawCallback);
207 static void init_type() {
208 CallbackObject::init_type();
210 CallbackObject::get_class_type());
213 return get_class_type();
215 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
222 std::string _os_shaders_dir;
228 #ifdef ST_DELETE_FOREST_HACK 229 SpeedTree::CForestRender &_forest_render;
231 SpeedTree::CForestRender _forest_render;
232 #endif // ST_DELETE_FOREST_HACK 233 SpeedTree::CView _view;
234 SpeedTree::SForestCullResultsRender _visible_trees;
235 SpeedTree::CForest::SPopulationStats _population_stats;
236 bool _needs_repopulate;
240 SpeedTree::CTerrainRender _terrain_render;
241 SpeedTree::STerrainCullResults _visible_terrain;
243 SpeedTree::Vec3 _light_dir;
249 SpeedTree::CView _light_view;
250 SpeedTree::SForestCullResultsRender _light_cull;
251 PN_stdfloat _shadow_split;
254 ShadowInfos _shadow_infos;
257 static double _global_time_delta;
259 static bool _authorized;
260 static bool _done_first_init;
284 static void init_type() {
285 PandaNode::init_type();
287 PandaNode::get_class_type());
288 DrawCallback::init_type();
291 return get_class_type();
293 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
298 friend class SpeedTreeNode::DrawCallback;
302 instances.output(out);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A basic node of the scene graph or data graph.
STTerrain * get_terrain() const
Returns the terrain associated with the node, or NULL if there is no terrain.
bool has_terrain() const
Returns true if a valid terrain has been associated with the node, false otherwise.
virtual void write_datagram(BamWriter *manager, Datagram &dg)
Writes the contents of this object to the datagram for shipping out to a Bam file.
virtual void apply_attribs_to_vertices(const AccumulatedAttribs &attribs, int attrib_types, GeomTransformer &transformer)
Applies whatever attributes are specified in the AccumulatedAttribs object (and by the attrib_types b...
static void write_error(std::ostream &out)
Writes the current SpeedTree error message to the indicated stream.
int count_total_instances() const
Returns the total number of trees that will be rendered by this node, counting all instances of all t...
This is the fundamental interface for extracting binary objects from a Bam file, as generated by a Ba...
virtual PandaNode * combine_with(PandaNode *other)
Collapses this PandaNode with the other PandaNode, if possible, and returns a pointer to the combined...
Specifies parameters that may be passed to the loader.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void output(std::ostream &out) const
Writes a brief description of the node to the indicated output stream.
void add_instances(const NodePath &root, const TransformState *transform=TransformState::make_identity())
Walks the scene graph beginning at root, looking for nested SpeedTreeNodes.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Base class for objects that can be written to and read from Bam files.
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.
bool has_instance_list(const STTree *tree) const
Returns true if the indicated tree has any instances within this node, false otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A convenient class for loading models from disk, in bam or egg format (or any of a number of other fo...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void clear_terrain()
Removes the terrain associated with the node.
This collects together the pieces of data that are accumulated for each node while walking the scene ...
bool setup_terrain(const Filename &terrain_file)
A convenience function to set up terrain geometry by reading a terrain.txt file as defined by SpeedTr...
bool is_valid() const
Returns true if the node is valid and ready to render, false otherwise.
int remove_tree(const STTree *tree)
Removes all instances of the indicated tree.
This is the abstract base class that defines the interface needed to describe a terrain for rendering...
This is the fundamental interface for writing binary objects to a Bam file, to be extracted later by ...
This is a generic data block that is passed along to a CallbackObject when a callback is made.
virtual bool cull_callback(CullTraverser *trav, CullTraverserData &data)
This function will be called during the cull traversal to perform any additional operations that shou...
static void register_with_read_factory()
Tells the BamReader how to create objects of type PandaNode.
STTree * modify_tree(int n)
Returns a modifiable STTree pointer for the nth tree instance.
A specialization of ordered_vector that emulates a standard STL set: one copy of each element is allo...
void snap_to_terrain()
Adjusts all the trees in this node so that their Z position matches the height of the terrain at thei...
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
A lightweight class that represents a single element that may be timed and/or counted via stats.
void set_terrain(STTerrain *terrain)
Associated a terrain with the node.
get_instance_list
Returns a list of transforms that corresponds to the instances at which the indicated tree appears.
The name of a file, such as a texture file or an Egg file.
This class is used by the SceneGraphReducer to maintain and accumulate the set of attributes we have ...
void add_instance(const STTree *tree, const STTransform &transform)
Adds a new instance of the indicated tree at the indicated transform.
void remove_all_trees()
Removes all instances of all trees from the node.
An instance of this class is passed to the Factory when requesting it to do its business and construc...
virtual void add_for_draw(CullTraverser *trav, CullTraverserData &data)
Adds the node's contents to the CullResult we are building up during the cull traversal,...
Interfaces with the SpeedTree library to render SpeedTree objects, especially trees,...
void prepare_scene(GraphicsStateGuardianBase *gsgbase, const RenderState *net_state)
Walks through the scene graph beginning at this node, and does whatever initialization is required to...
virtual PandaNode * make_copy() const
Returns a newly-allocated PandaNode that is a shallow copy of this one.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
bool add_from_stf(const Filename &stf_filename, const LoaderOptions &options=LoaderOptions())
Opens and reads the named STF (SpeedTree Forest) file, and adds the SRT files named within as instanc...
set_global_time_delta
Specifies an offset that is to be added each frame to the global clock's frame_time for the purpose o...
This is a generic object that can be assigned to a callback at various points in the rendering proces...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void reload_config()
Re-reads the current setting of all of the relevant config variables and applies them to this node.
virtual void compute_internal_bounds(CPT(BoundingVolume) &internal_bounds, int &internal_vertices, int pipeline_stage, Thread *current_thread) const
Returns a newly-allocated BoundingVolume that represents the internal contents of the node.
This is a base class for the GraphicsStateGuardian class, which is itself a base class for the variou...
A thread; that is, a lightweight process.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A handy class to return random numbers.
Encapsulates all the communication with a particular instance of a given rendering backend.
get_tree
Returns the STTree pointer for the nth tree.
void add_instances_from(const SpeedTreeNode *other)
Adds all of the instances defined within the indicated SpeedTreeNode as instances of this node.
A class to retrieve the individual data elements previously stored in a Datagram.
static bool authorize(const std::string &license="")
Make this call to initialized the SpeedTree API and verify the license.
InstanceList & modify_instance_list(const STTree *tree)
Returns a modifiable list of transforms that corresponds to the instances of this tree.
TypeHandle is the identifier used to differentiate C++ class types.
void add_random_instances(const STTree *tree, int quantity, PN_stdfloat x_min, PN_stdfloat x_max, PN_stdfloat y_min, PN_stdfloat y_max, PN_stdfloat scale_min, PN_stdfloat scale_max, PN_stdfloat height_min, PN_stdfloat height_max, PN_stdfloat slope_min, PN_stdfloat slope_max, Randomizer &randomizer=Randomizer())
Creates a number of random instances of the indicated true, within the indicated range.
InstanceList & add_tree(const STTree *tree)
Adds a new tree for rendering.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual bool is_renderable() const
Returns true if there is some value to visiting this particular node during the cull traversal for an...
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
This object performs a depth-first traversal of the scene graph, with optional view-frustum culling,...
Encapsulates a single tree model in the SpeedTree library, as loaded from an SRT file.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_wind(double strength, const LVector3 &direction)
Specifies the overall wind strength and direction.
set_time_delta
Specifies an offset that is to be added each frame to the global clock's frame_time for the purpose o...