Panda3D
|
Interfaces with the SpeedTree library to render SpeedTree objects, especially trees, within the Panda3D scene graph. More...
#include "speedTreeNode.h"
Classes | |
class | DrawCallback |
class | InstanceList |
class | ShadowInfo |
Public Member Functions | |
SpeedTreeNode (const string &name) | |
SpeedTreeNode (const SpeedTreeNode ©) | |
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, so that it will be drawn at render time. | |
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 instances of this node. | |
bool | add_from_stf (istream &in, const Filename &pathname, const LoaderOptions &options=LoaderOptions(), Loader *loader=NULL) |
Reads text data from the indicated stream, which is understood to represent the named STF (SpeedTree Forest) file, and adds the SRT files named within as instances of this node. | |
void | add_instance (const STTree *tree, const STTransform &transform) |
Adds a new instance of the indicated tree at the indicated transform. | |
void | add_instances (const NodePath &root, const TransformState *transform=TransformState::make_identity()) |
Walks the scene graph beginning at root, looking for nested SpeedTreeNodes. | |
void | add_instances_from (const SpeedTreeNode *other) |
Adds all of the instances defined within the indicated SpeedTreeNode as instances of this node. | |
void | add_instances_from (const SpeedTreeNode *other, const TransformState *transform) |
Adds all of the instances defined within the indicated SpeedTreeNode as instances of this node, after applying the indicated scene-graph transform. | |
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. | |
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 bitmask) to the vertices on this node, if appropriate. | |
void | clear_terrain () |
Removes the terrain associated with the node. | |
virtual PandaNode * | combine_with (PandaNode *other) |
Collapses this node with the other node, if possible, and returns a pointer to the combined node, or NULL if the two nodes cannot safely be combined. | |
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. | |
int | count_total_instances () const |
Returns the total number of trees that will be rendered by this node, counting all instances of all trees. | |
virtual bool | cull_callback (CullTraverser *trav, CullTraverserData &data) |
This function will be called during the cull traversal to perform any additional operations that should be performed at cull time. | |
virtual TypeHandle | force_init_type () |
const InstanceList & | get_instance_list (int n) const |
Returns a list of transforms that corresponds to the instances at which the nth tree appears. | |
const InstanceList & | get_instance_list (const STTree *tree) const |
Returns a list of transforms that corresponds to the instances at which the indicated tree appears. | |
int | get_num_trees () const |
Returns the number of unique tree objects that have been added to the node. | |
STTerrain * | get_terrain () const |
Returns the terrain associated with the node, or NULL if there is no terrain. | |
double | get_time_delta () const |
Returns an offset that is to be added each frame to the global clock's frame_time for the purpose of animating the trees in this particular node. | |
const STTree * | get_tree (int n) const |
Returns the STTree pointer for the nth tree. | |
virtual TypeHandle | get_type () const |
bool | has_instance_list (const STTree *tree) const |
Returns true if the indicated tree has any instances within this node, false otherwise. | |
bool | has_terrain () const |
Returns true if a valid terrain has been associated with the node, false otherwise. | |
virtual bool | is_renderable () const |
Returns true if there is some value to visiting this particular node during the cull traversal for any camera, false otherwise. | |
bool | is_valid () const |
Returns true if the node is valid and ready to render, false otherwise. | |
virtual PandaNode * | make_copy () const |
Returns a newly-allocated Node that is a shallow copy of this one. | |
MAKE_SEQ (get_trees, get_num_trees, get_tree) | |
MAKE_SEQ (get_instance_lists, get_num_trees, get_instance_list) | |
InstanceList & | modify_instance_list (const STTree *tree) |
Returns a modifiable list of transforms that corresponds to the instances of this tree. | |
STTree * | modify_tree (int n) |
Returns a modifiable STTree pointer for the nth tree instance. | |
virtual void | output (ostream &out) const |
Writes a brief description of the node to the indicated output stream. | |
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 render the scene properly with the indicated GSG. | |
void | reload_config () |
Re-reads the current setting of all of the relevant config variables and applies them to this node. | |
void | remove_all_trees () |
Removes all instances of all trees from the node. | |
int | remove_tree (const STTree *tree) |
Removes all instances of the indicated tree. | |
void | set_terrain (STTerrain *terrain) |
Associated a terrain with the node. | |
void | set_time_delta (double delta) |
Specifies an offset that is to be added each frame to the global clock's frame_time for the purpose of animating the trees in this particular node. | |
void | set_wind (double strength, const LVector3 &direction) |
Specifies the overall wind strength and direction. | |
bool | setup_terrain (const Filename &terrain_file) |
A convenience function to set up terrain geometry by reading a terrain.txt file as defined by SpeedTree. | |
void | snap_to_terrain () |
Adjusts all the trees in this node so that their Z position matches the height of the terrain at their X, Y position. | |
virtual void | write (ostream &out, int indent_level) const |
virtual void | write_datagram (BamWriter *manager, Datagram &dg) |
Writes the contents of this object to the datagram for shipping out to a Bam file. | |
Static Public Member Functions | |
static bool | authorize (const string &license="") |
Make this call to initialized the SpeedTree API and verify the license. | |
static TypeHandle | get_class_type () |
static double | get_global_time_delta () |
Returns an offset that is to be added each frame to the global clock's frame_time for the purpose of animating the trees in all SpeedTreeNodes. | |
static void | init_type () |
static void | register_with_read_factory () |
Tells the BamReader how to create objects of type SpeedTreeNode. | |
static void | set_global_time_delta (double delta) |
Specifies an offset that is to be added each frame to the global clock's frame_time for the purpose of animating the trees in all SpeedTreeNodes. | |
static void | write_error (ostream &out) |
Writes the current SpeedTree error message to the indicated stream. | |
Protected Member Functions | |
void | fillin (DatagramIterator &scan, BamReader *manager) |
This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new SpeedTreeNode. | |
void | set_transparent_texture_mode (SpeedTree::ETextureAlphaRenderMode eMode) const |
Uses SpeedTree::CRenderState to set the indicated transparency mode. | |
Static Protected Member Functions | |
static TypedWritable * | make_from_bam (const FactoryParams ¶ms) |
This function is called by the BamReader's factory when a new object of type SpeedTreeNode is encountered in the Bam file. | |
Friends | |
class | SpeedTreeNode::DrawCallback |
Interfaces with the SpeedTree library to render SpeedTree objects, especially trees, within the Panda3D scene graph.
SpeedTree also includes some support for a simple terrain system, which is available here as well. SpeedTree's rather lame grass system is not presently exposed.
Definition at line 54 of file speedTreeNode.h.
void SpeedTreeNode::add_for_draw | ( | CullTraverser * | trav, |
CullTraverserData & | data | ||
) | [virtual] |
Adds the node's contents to the CullResult we are building up during the cull traversal, so that it will be drawn at render time.
For most nodes other than GeomNodes, this is a do-nothing operation.
Reimplemented from PandaNode.
Definition at line 1116 of file speedTreeNode.cxx.
References CullTraverser::get_cull_handler(), CullTraverser::get_gsg(), CullHandler::record_object(), and CullableObject::set_draw_callback().
bool SpeedTreeNode::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 instances of this node.
Returns true on success, false on failure.
Definition at line 438 of file speedTreeNode.cxx.
References VirtualFileSystem::close_read_file(), VirtualFileSystem::exists(), VirtualFileSystem::get_global_ptr(), and VirtualFileSystem::resolve_filename().
bool SpeedTreeNode::add_from_stf | ( | istream & | in, |
const Filename & | pathname, | ||
const LoaderOptions & | options = LoaderOptions() , |
||
Loader * | loader = NULL |
||
) |
Reads text data from the indicated stream, which is understood to represent the named STF (SpeedTree Forest) file, and adds the SRT files named within as instances of this node.
Returns true on success, false on failure.
The pathname is used for reference only; if nonempty, it provides a search directory for named SRT files.
The Loader and LoaderOptions, if provided, are used to load the SRT files. If the Loader pointer is NULL, the default global Loader is used instead.
Definition at line 487 of file speedTreeNode.cxx.
References add_instance(), DSearchPath::append_directory(), NodePath::find(), Filename::from_os_specific(), Filename::get_dirname(), Loader::get_global_ptr(), get_num_trees(), get_tree(), NodePath::is_empty(), and NodePath::node().
void SpeedTreeNode::add_instance | ( | const STTree * | tree, |
const STTransform & | transform | ||
) |
Adds a new instance of the indicated tree at the indicated transform.
Definition at line 295 of file speedTreeNode.cxx.
References SpeedTreeNode::InstanceList::add_instance(), add_tree(), and has_terrain().
Referenced by add_from_stf().
void SpeedTreeNode::add_instances | ( | const NodePath & | root, |
const TransformState * | transform = TransformState::make_identity() |
||
) |
Walks the scene graph beginning at root, looking for nested SpeedTreeNodes.
For each SpeedTreeNode found, adds all of the instances defined within that SpeedTreeNode as instances of this node, after applying the indicated scene-graph transform.
Definition at line 315 of file speedTreeNode.cxx.
References Thread::get_current_thread(), NodePath::get_transform(), NodePath::is_empty(), and NodePath::node().
void SpeedTreeNode::add_instances_from | ( | const SpeedTreeNode * | other | ) |
Adds all of the instances defined within the indicated SpeedTreeNode as instances of this node.
Does not recurse to children.
Definition at line 329 of file speedTreeNode.cxx.
References SpeedTreeNode::InstanceList::add_instance(), add_tree(), SpeedTreeNode::InstanceList::get_instance(), get_instance_list(), SpeedTreeNode::InstanceList::get_num_instances(), get_num_trees(), and SpeedTreeNode::InstanceList::get_tree().
Referenced by combine_with().
void SpeedTreeNode::add_instances_from | ( | const SpeedTreeNode * | other, |
const TransformState * | transform | ||
) |
Adds all of the instances defined within the indicated SpeedTreeNode as instances of this node, after applying the indicated scene-graph transform.
Does not recurse to children.
Definition at line 353 of file speedTreeNode.cxx.
References SpeedTreeNode::InstanceList::add_instance(), add_tree(), SpeedTreeNode::InstanceList::get_instance(), get_instance_list(), SpeedTreeNode::InstanceList::get_num_instances(), get_num_trees(), SpeedTreeNode::InstanceList::get_tree(), and has_terrain().
void SpeedTreeNode::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.
If a terrain is present, height_min and height_max restrict trees to the (x, y) positions that fall within the indicated terrain, and slope_min and slope_max restrict trees to the (x, y) positions that have a matching slope. If a terrain is not present, height_min and height_max specify a random range of Z heights, and slope_min and slope_max are ignored.
Definition at line 391 of file speedTreeNode.cxx.
References SpeedTreeNode::InstanceList::add_instance(), add_tree(), has_terrain(), and Randomizer::random_real().
SpeedTreeNode::InstanceList & SpeedTreeNode::add_tree | ( | const STTree * | tree | ) |
Adds a new tree for rendering.
Returns the InstanceList which can be used to add to the instances for this tree. If the tree has previously been added, returns the existing InstanceList.
Definition at line 157 of file speedTreeNode.cxx.
References ordered_vector< Key, Compare >::end(), STTree::get_fullpath(), STTree::get_tree(), STTree::is_valid(), is_valid(), PandaNode::mark_internal_bounds_stale(), and write_error().
Referenced by add_instance(), add_instances_from(), add_random_instances(), and modify_instance_list().
void SpeedTreeNode::apply_attribs_to_vertices | ( | const AccumulatedAttribs & | attribs, |
int | attrib_types, | ||
GeomTransformer & | transformer | ||
) | [virtual] |
Applies whatever attributes are specified in the AccumulatedAttribs object (and by the attrib_types bitmask) to the vertices on this node, if appropriate.
If this node uses geom arrays like a GeomNode, the supplied GeomTransformer may be used to unify shared arrays across multiple different nodes.
This is a generalization of xform().
Reimplemented from PandaNode.
Definition at line 924 of file speedTreeNode.cxx.
References ordered_vector< Key, Compare >::begin(), ordered_vector< Key, Compare >::end(), PandaNode::mark_internal_bounds_stale(), and PandaNode::xform().
bool SpeedTreeNode::authorize | ( | const string & | license = "" | ) | [static] |
Make this call to initialized the SpeedTree API and verify the license.
If an empty string is passed for the license, the config variable speedtree-license is consulted. Returns true on success, false on failure. If this call is not made explicitly, it will be made implicitly the first time a SpeedTreeNode is created.
Definition at line 781 of file speedTreeNode.cxx.
Referenced by STTree::STTree().
void SpeedTreeNode::clear_terrain | ( | ) | [inline] |
Removes the terrain associated with the node.
Definition at line 88 of file speedTreeNode.I.
References set_terrain().
Collapses this node with the other node, if possible, and returns a pointer to the combined node, or NULL if the two nodes cannot safely be combined.
The return value may be this, other, or a new node altogether.
This function is called from GraphReducer::flatten(), and need not deal with children; its job is just to decide whether to collapse the two nodes and what the collapsed node should look like.
Reimplemented from PandaNode.
Definition at line 889 of file speedTreeNode.cxx.
References add_instances_from(), get_terrain(), has_terrain(), TypedObject::is_exact_type(), and set_terrain().
void SpeedTreeNode::compute_internal_bounds | ( | CPT(BoundingVolume)& | internal_bounds, |
int & | internal_vertices, | ||
int | pipeline_stage, | ||
Thread * | current_thread | ||
) | const [virtual] |
Returns a newly-allocated BoundingVolume that represents the internal contents of the node.
Should be overridden by PandaNode classes that contain something internally.
Reimplemented from PandaNode.
Definition at line 1163 of file speedTreeNode.cxx.
References ordered_vector< Key, Compare >::begin(), ordered_vector< Key, Compare >::end(), STTree::get_tree(), and SpeedTreeNode::InstanceList::get_tree().
int SpeedTreeNode::count_total_instances | ( | ) | const |
Returns the total number of trees that will be rendered by this node, counting all instances of all trees.
Definition at line 137 of file speedTreeNode.cxx.
References ordered_vector< Key, Compare >::begin(), ordered_vector< Key, Compare >::end(), and SpeedTreeNode::InstanceList::get_num_instances().
Referenced by output().
bool SpeedTreeNode::cull_callback | ( | CullTraverser * | trav, |
CullTraverserData & | data | ||
) | [virtual] |
This function will be called during the cull traversal to perform any additional operations that should be performed at cull time.
This may include additional manipulation of render state or additional visible/invisible decisions, or any other arbitrary operation.
Note that this function will *not* be called unless set_cull_callback() is called in the constructor of the derived class. It is necessary to call set_cull_callback() to indicated that we require cull_callback() to be called.
By the time this function is called, the node has already passed the bounding-volume test for the viewing frustum, and the node's transform and state have already been applied to the indicated CullTraverserData object.
The return value is true if this node should be visible, or false if it should be culled.
Reimplemented from PandaNode.
Definition at line 968 of file speedTreeNode.cxx.
References LMatrix4f::convert_mat(), RenderState::get_attrib(), Light::get_color(), Lens::get_coordinate_system(), GraphicsStateGuardian::get_cs_transform(), LMatrix4f::get_data(), DirectionalLight::get_direction(), Lens::get_far(), ClockObject::get_frame_time(), ClockObject::get_global_clock(), CullTraverser::get_gsg(), GraphicsStateGuardian::get_internal_coordinate_system(), SceneSetup::get_lens(), Lens::get_near(), LightAttrib::get_num_on_lights(), LightAttrib::get_on_light(), NodePath::get_parent(), Light::get_priority(), Lens::get_projection_mat(), CullTraverser::get_scene(), SceneSetup::get_scene_root(), NodePath::get_transform(), TextureAttrib::has_all_off(), NodePath::is_empty(), TypedObject::is_of_type(), NodePath::node(), and LVecBase3f::normalize().
void SpeedTreeNode::fillin | ( | DatagramIterator & | scan, |
BamReader * | manager | ||
) | [protected, virtual] |
This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new SpeedTreeNode.
Reimplemented from PandaNode.
Definition at line 1875 of file speedTreeNode.cxx.
References SpeedTreeNode::InstanceList::fillin(), SpeedTreeNode::InstanceList::get_tree(), DatagramIterator::get_uint32(), ordered_vector< Key, Compare >::push_back(), and ov_set< Key, Compare >::sort().
Referenced by make_from_bam().
double SpeedTreeNode::get_global_time_delta | ( | ) | [inline, static] |
Returns an offset that is to be added each frame to the global clock's frame_time for the purpose of animating the trees in all SpeedTreeNodes.
Also see get_time_delta().
Definition at line 162 of file speedTreeNode.I.
const SpeedTreeNode::InstanceList & SpeedTreeNode::get_instance_list | ( | int | n | ) | const [inline] |
Returns a list of transforms that corresponds to the instances at which the nth tree appears.
Definition at line 62 of file speedTreeNode.I.
References ordered_vector< Key, Compare >::size().
Referenced by add_instances_from().
const SpeedTreeNode::InstanceList & SpeedTreeNode::get_instance_list | ( | const STTree * | tree | ) | const |
Returns a list of transforms that corresponds to the instances at which the indicated tree appears.
You should ensure that has_instance_list() returns true before calling this method.
Definition at line 263 of file speedTreeNode.cxx.
References ordered_vector< Key, Compare >::end().
int SpeedTreeNode::get_num_trees | ( | ) | const [inline] |
Returns the number of unique tree objects that have been added to the node.
This count does not include multiple instances of the same tree that appear in different transforms.
Definition at line 38 of file speedTreeNode.I.
References ordered_vector< Key, Compare >::size().
Referenced by add_from_stf(), add_instances_from(), SpeedTreeNode::InstanceList::fillin(), and output().
STTerrain * SpeedTreeNode::get_terrain | ( | ) | const [inline] |
Returns the terrain associated with the node, or NULL if there is no terrain.
Definition at line 110 of file speedTreeNode.I.
Referenced by combine_with().
double SpeedTreeNode::get_time_delta | ( | ) | const [inline] |
Returns an offset that is to be added each frame to the global clock's frame_time for the purpose of animating the trees in this particular node.
Also see get_global_time_delta().
Definition at line 136 of file speedTreeNode.I.
const STTree * SpeedTreeNode::get_tree | ( | int | n | ) | const [inline] |
Returns the STTree pointer for the nth tree.
See get_num_trees().
Definition at line 49 of file speedTreeNode.I.
References ordered_vector< Key, Compare >::size().
Referenced by add_from_stf(), and SpeedTreeNode::InstanceList::fillin().
bool SpeedTreeNode::has_instance_list | ( | const STTree * | tree | ) | const |
Returns true if the indicated tree has any instances within this node, false otherwise.
Definition at line 248 of file speedTreeNode.cxx.
References ordered_vector< Key, Compare >::end().
bool SpeedTreeNode::has_terrain | ( | ) | const [inline] |
Returns true if a valid terrain has been associated with the node, false otherwise.
Definition at line 99 of file speedTreeNode.I.
Referenced by add_instance(), add_instances_from(), add_random_instances(), and combine_with().
bool SpeedTreeNode::is_renderable | ( | ) | const [virtual] |
Returns true if there is some value to visiting this particular node during the cull traversal for any camera, false otherwise.
This will be used to optimize the result of get_net_draw_show_mask(), so that any subtrees that contain only nodes for which is_renderable() is false need not be visited.
Reimplemented from PandaNode.
Definition at line 1103 of file speedTreeNode.cxx.
bool SpeedTreeNode::is_valid | ( | ) | const [inline] |
Returns true if the node is valid and ready to render, false otherwise.
Note that this might not become false until after the first time the node is rendered.
Definition at line 25 of file speedTreeNode.I.
Referenced by add_tree().
PandaNode * SpeedTreeNode::make_copy | ( | ) | const [virtual] |
TypedWritable * SpeedTreeNode::make_from_bam | ( | const FactoryParams & | params | ) | [static, protected] |
This function is called by the BamReader's factory when a new object of type SpeedTreeNode is encountered in the Bam file.
It should create the SpeedTreeNode and extract its information from the file.
Reimplemented from PandaNode.
Definition at line 1856 of file speedTreeNode.cxx.
References fillin().
Referenced by register_with_read_factory().
SpeedTreeNode::InstanceList & SpeedTreeNode::modify_instance_list | ( | const STTree * | tree | ) |
Returns a modifiable list of transforms that corresponds to the instances of this tree.
This is equivalent to add_tree().
Definition at line 284 of file speedTreeNode.cxx.
References add_tree().
STTree * SpeedTreeNode::modify_tree | ( | int | n | ) | [inline] |
Returns a modifiable STTree pointer for the nth tree instance.
Definition at line 75 of file speedTreeNode.I.
References ordered_vector< Key, Compare >::size().
void SpeedTreeNode::output | ( | ostream & | out | ) | const [virtual] |
Writes a brief description of the node to the indicated output stream.
This is invoked by the << operator. It may be overridden in derived classes to include some information relevant to the class.
Reimplemented from PandaNode.
Definition at line 1201 of file speedTreeNode.cxx.
References count_total_instances(), and get_num_trees().
void SpeedTreeNode::prepare_scene | ( | GraphicsStateGuardianBase * | gsgbase, |
const RenderState * | net_state | ||
) |
Walks through the scene graph beginning at this node, and does whatever initialization is required to render the scene properly with the indicated GSG.
It is not strictly necessary to call this, since the GSG will initialize itself when the scene is rendered, but this may take some of the overhead away from that process.
In particular, this will ensure that textures within the scene are loaded in texture memory, and display lists are built up from static geometry.
Reimplemented from PandaNode.
Definition at line 1147 of file speedTreeNode.cxx.
void SpeedTreeNode::register_with_read_factory | ( | ) | [static] |
Tells the BamReader how to create objects of type SpeedTreeNode.
Reimplemented from PandaNode.
Definition at line 1824 of file speedTreeNode.cxx.
References BamReader::get_factory(), make_from_bam(), and Factory< Type >::register_factory().
void SpeedTreeNode::reload_config | ( | ) |
Re-reads the current setting of all of the relevant config variables and applies them to this node.
This can be called after changing config settings, to make them apply to this particular node.
Definition at line 698 of file speedTreeNode.cxx.
References ConfigVariable::get_num_words().
void SpeedTreeNode::remove_all_trees | ( | ) |
Removes all instances of all trees from the node.
Definition at line 223 of file speedTreeNode.cxx.
References ordered_vector< Key, Compare >::begin(), ordered_vector< Key, Compare >::clear(), ordered_vector< Key, Compare >::end(), STTree::get_fullpath(), STTree::get_tree(), SpeedTreeNode::InstanceList::get_tree(), PandaNode::mark_internal_bounds_stale(), and write_error().
int SpeedTreeNode::remove_tree | ( | const STTree * | tree | ) |
Removes all instances of the indicated tree.
Returns the number of instances removed.
Definition at line 192 of file speedTreeNode.cxx.
References ordered_vector< Key, Compare >::end(), STTree::get_fullpath(), SpeedTreeNode::InstanceList::get_num_instances(), STTree::get_tree(), PandaNode::mark_internal_bounds_stale(), and write_error().
void SpeedTreeNode::set_global_time_delta | ( | double | delta | ) | [inline, static] |
Specifies an offset that is to be added each frame to the global clock's frame_time for the purpose of animating the trees in all SpeedTreeNodes.
Also see set_time_delta().
Definition at line 149 of file speedTreeNode.I.
void SpeedTreeNode::set_terrain | ( | STTerrain * | terrain | ) |
Associated a terrain with the node.
If the terrain has not already been loaded prior to this call, load_data() will be called immediately.
The terrain will be rendered using SpeedTree callbacks, and trees may be repositioned with a call to snap_to_terrain().
Definition at line 607 of file speedTreeNode.cxx.
References STTerrain::get_max_height(), STTerrain::get_min_height(), STTerrain::get_normal_map(), STTerrain::get_num_splat_layers(), STTerrain::get_splat_layer(), STTerrain::get_splat_layer_tiling(), STTerrain::get_splat_map(), STTerrain::is_valid(), STTerrain::load_data(), and snap_to_terrain().
Referenced by clear_terrain(), combine_with(), and setup_terrain().
void SpeedTreeNode::set_time_delta | ( | double | delta | ) | [inline] |
Specifies an offset that is to be added each frame to the global clock's frame_time for the purpose of animating the trees in this particular node.
Also see set_global_time_delta().
Definition at line 123 of file speedTreeNode.I.
void SpeedTreeNode::set_transparent_texture_mode | ( | SpeedTree::ETextureAlphaRenderMode | eMode | ) | const [protected] |
Uses SpeedTree::CRenderState to set the indicated transparency mode.
Definition at line 1251 of file speedTreeNode.cxx.
void SpeedTreeNode::set_wind | ( | double | strength, |
const LVector3 & | direction | ||
) |
Specifies the overall wind strength and direction.
Gusts are controlled internally.
Definition at line 764 of file speedTreeNode.cxx.
bool SpeedTreeNode::setup_terrain | ( | const Filename & | terrain_file | ) |
A convenience function to set up terrain geometry by reading a terrain.txt file as defined by SpeedTree.
This file names the various map files that define the terrain, as well as defining parameters size as its size and color.
This method implicitly creates a STBasicTerrain object and passes it to set_terrain().
Definition at line 585 of file speedTreeNode.cxx.
References set_terrain().
void SpeedTreeNode::snap_to_terrain | ( | ) |
Adjusts all the trees in this node so that their Z position matches the height of the terrain at their X, Y position.
Definition at line 661 of file speedTreeNode.cxx.
References ordered_vector< Key, Compare >::begin(), ordered_vector< Key, Compare >::end(), SpeedTreeNode::InstanceList::get_instance(), SpeedTreeNode::InstanceList::get_num_instances(), STTransform::get_pos(), SpeedTreeNode::InstanceList::set_instance(), and STTransform::set_pos().
Referenced by set_terrain().
Writes the contents of this object to the datagram for shipping out to a Bam file.
Reimplemented from PandaNode.
Definition at line 1835 of file speedTreeNode.cxx.
References Datagram::add_uint32(), ordered_vector< Key, Compare >::begin(), ordered_vector< Key, Compare >::end(), ordered_vector< Key, Compare >::size(), and SpeedTreeNode::InstanceList::write_datagram().
void SpeedTreeNode::write_error | ( | ostream & | out | ) | [static] |
Writes the current SpeedTree error message to the indicated stream.
Definition at line 1236 of file speedTreeNode.cxx.
Referenced by add_tree(), remove_all_trees(), remove_tree(), and STTree::STTree().