|
|
|
A node that holds Geom objects, renderable pieces of geometry.
More...
#include "geomNode.h"
List of all members.
Classes |
| class | BamAuxData |
| class | CData |
| class | GeomEntry |
| class | Geoms |
Public Types |
typedef CopyOnWriteObj
< pvector< GeomEntry > > | GeomList |
Public Member Functions |
|
| GeomNode (const string &name) |
| 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.
|
| void | add_geom (Geom *geom, const RenderState *state=RenderState::make_empty()) |
| | Adds a new Geom to the node.
|
| void | add_geoms_from (const GeomNode *other) |
| | Copies the Geoms (and their associated RenderStates) from the indicated GeomNode into this one.
|
| 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.
|
| bool | check_valid () const |
| | Verifies that the each Geom within the GeomNode reference vertices that actually exist within its GeomVertexData.
|
| 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.
|
|
| CPT (Geom) get_geom(int n) const |
|
virtual | CPT (TransformState) calc_tight_bounds(LPoint3 &min_point |
| void | decompose () |
| | Calls decompose() on each Geom with the GeomNode.
|
| void | do_premunge (GraphicsStateGuardianBase *gsg, const RenderState *node_state, GeomTransformer &transformer) |
| | Uses the indicated GSG to premunge the Geoms in this node to optimize them for eventual rendering.
|
| virtual void | finalize (BamReader *manager) |
| | Called by the BamReader to perform any final actions needed for setting up the object after all objects have been read and all pointers have been completed.
|
|
virtual TypeHandle | force_init_type () |
| const RenderState * | get_geom_state (int n) const |
| | Returns the RenderState associated with the nth geom of the node.
|
| Geoms | get_geoms (Thread *current_thread=Thread::get_current_thread()) const |
| | Returns an object that can be used to walk through the list of geoms of the node.
|
| virtual CollideMask | get_legal_collide_mask () const |
| | Returns the subset of CollideMask bits that may be set for this particular type of PandaNode.
|
| int | get_num_geoms () const |
| | Returns the number of geoms in the node.
|
| bool | get_preserved () const |
| | Returns the "preserved" flag.
|
|
virtual TypeHandle | get_type () const |
| virtual bool | is_geom_node () const |
| | A simple downcast check.
|
| 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.
|
| virtual PandaNode * | make_copy () const |
| | Returns a newly-allocated PandaNode that is a shallow copy of this one.
|
|
| MAKE_SEQ (get_geom_states, get_num_geoms, get_geom_state) |
|
| MAKE_SEQ (get_geoms, get_num_geoms, get_geom) |
| virtual void | output (ostream &out) const |
| | Outputs the Namable.
|
|
| PT (Geom) modify_geom(int n) |
| virtual void | r_prepare_scene (GraphicsStateGuardianBase *gsg, const RenderState *node_state, GeomTransformer &transformer, Thread *current_thread) |
| | The recursive implementation of prepare_scene().
|
| void | remove_all_geoms () |
| | Removes all the geoms from the node at once.
|
| void | remove_geom (int n) |
| | Removes the nth geom from the node.
|
| virtual bool | safe_to_combine () const |
| | Returns true if it is generally safe to combine this particular kind of PandaNode with other kinds of PandaNodes of compatible type, adding children or whatever.
|
| virtual bool | safe_to_flatten () const |
| | Returns true if it is generally safe to flatten out this particular kind of PandaNode by duplicating instances (by calling dupe_for_flatten()), false otherwise (for instance, a Camera cannot be safely flattened, because the Camera pointer itself is meaningful).
|
| void | set_geom (int n, Geom *geom) |
| | Replaces the nth Geom of the node with a new pointer.
|
| void | set_geom_state (int n, const RenderState *state) |
| | Changes the RenderState associated with the nth geom of the node.
|
| void | set_preserved (bool value) |
| | Sets the "preserved" flag.
|
| void | unify (int max_indices, bool preserve_order) |
| | Attempts to unify all of the Geoms contained within this node into a single Geom, or at least as few Geoms as possible.
|
| virtual void | write_datagram (BamWriter *manager, Datagram &dg) |
| | Writes the contents of this object to the datagram for shipping out to a Bam file.
|
| void | write_geoms (ostream &out, int indent_level) const |
| | Writes a short description of all the Geoms in the node.
|
| void | write_verbose (ostream &out, int indent_level) const |
| | Writes a detailed description of all the Geoms in the node.
|
| virtual void | xform (const LMatrix4 &mat) |
| | Transforms the contents of this node by the indicated matrix, if it means anything to do so.
|
Static Public Member Functions |
|
static TypeHandle | get_class_type () |
| static CollideMask | get_default_collide_mask () |
| | Returns the default into_collide_mask assigned to new GeomNodes.
|
|
static void | init_type () |
| static void | register_with_read_factory () |
| | Tells the BamReader how to create objects of type GeomNode.
|
Public Attributes |
virtual LPoint3 bool const
TransformState Thread
*current_thread | const |
|
virtual LPoint3 bool & | found_any |
|
virtual LPoint3 & | max_point |
virtual LPoint3 bool const
TransformState * | transform |
Protected Member Functions |
|
| GeomNode (const GeomNode ©) |
| 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.
|
| 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 GeomNode.
|
| virtual void | r_mark_geom_bounds_stale (Thread *current_thread) |
| | Recursively calls Geom::mark_bounds_stale() on every Geom at this node and below.
|
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 GeomNode is encountered in the Bam file.
|
Friends |
|
class | GeomTransformer |
Detailed Description
A node that holds Geom objects, renderable pieces of geometry.
This is the primary kind of leaf node in the scene graph; almost all visible objects will be contained in a GeomNode somewhere.
Definition at line 37 of file geomNode.h.
Member Function Documentation
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 531 of file geomNode.cxx.
References CullTraverser::get_cull_handler(), CullTraverser::get_current_thread(), GeomNode::Geoms::get_geom_state(), get_geoms(), CullTraverser::get_gsg(), CullTraverserData::get_net_transform(), GeomNode::Geoms::get_num_geoms(), Geom::is_empty(), and CullHandler::record_object().
| void GeomNode::add_geom |
( |
Geom * |
geom, |
|
|
const RenderState * |
state = RenderState::make_empty() |
|
) |
| |
| void GeomNode::add_geoms_from |
( |
const GeomNode * |
other | ) |
|
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 106 of file geomNode.cxx.
References GeomTransformer::apply_texture_colors(), AccumulatedAttribs::collect(), Thread::get_current_thread(), CullFaceAttrib::get_effective_mode(), TexMatrixAttrib::get_mat(), TextureAttrib::get_num_on_stages(), TexMatrixAttrib::get_num_stages(), TextureAttrib::get_on_stage(), TexMatrixAttrib::get_stage(), TextureStage::get_texcoord_name(), GeomTransformer::register_vertices(), GeomTransformer::remove_column(), GeomTransformer::reverse_normals(), GeomTransformer::set_color(), GeomTransformer::transform_colors(), GeomTransformer::transform_texcoords(), and GeomTransformer::transform_vertices().
| bool GeomNode::check_valid |
( |
| ) |
const |
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 456 of file geomNode.cxx.
References add_geoms_from(), and TypedObject::is_exact_type().
| void GeomNode::compute_internal_bounds |
( |
CPT(BoundingVolume)& |
internal_bounds, |
|
|
int & |
internal_vertices, |
|
|
int |
pipeline_stage, |
|
|
Thread * |
current_thread |
|
) |
| const [protected, virtual] |
| void GeomNode::decompose |
( |
| ) |
|
| void GeomNode::finalize |
( |
BamReader * |
manager | ) |
[virtual] |
| CollideMask GeomNode::get_default_collide_mask |
( |
| ) |
[inline, static] |
Returns the default into_collide_mask assigned to new GeomNodes.
Definition at line 172 of file geomNode.I.
| const RenderState * GeomNode::get_geom_state |
( |
int |
n | ) |
const [inline] |
| GeomNode::Geoms GeomNode::get_geoms |
( |
Thread * |
current_thread = Thread::get_current_thread() | ) |
const [inline] |
Returns an object that can be used to walk through the list of geoms of the node.
When you intend to visit multiple geoms, using this is slightly faster than calling get_geom() directly on the GeomNode, since this object avoids reopening the PipelineCycler each time.
This object also protects you from self-modifying loops (e.g. adding or removing geoms during traversal), since a virtual copy of the geoms is made ahead of time. The virtual copy is fast--it is a form of copy-on-write, so the list is not actually copied unless it is modified during the traversal.
Definition at line 223 of file geomNode.I.
Referenced by add_for_draw().
| CollideMask GeomNode::get_legal_collide_mask |
( |
| ) |
const [virtual] |
| int GeomNode::get_num_geoms |
( |
| ) |
const [inline] |
| bool GeomNode::get_preserved |
( |
| ) |
const [inline] |
Returns the "preserved" flag.
When this is true, the GeomNode will be left untouched by any flatten operations.
Definition at line 36 of file geomNode.I.
| bool GeomNode::is_geom_node |
( |
| ) |
const [virtual] |
A simple downcast check.
Returns true if this kind of node happens to inherit from GeomNode, false otherwise.
This is provided as a a faster alternative to calling is_of_type(GeomNode::get_class_type()), since this test is so important to rendering.
Reimplemented from PandaNode.
Definition at line 925 of file geomNode.cxx.
| bool GeomNode::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 518 of file geomNode.cxx.
| PandaNode * GeomNode::make_copy |
( |
| ) |
const [virtual] |
Returns a newly-allocated PandaNode that is a shallow copy of this one.
It will be a different pointer, but its internal data may or may not be shared with that of the original PandaNode. No children will be copied.
Reimplemented from PandaNode.
Definition at line 89 of file geomNode.cxx.
| void GeomNode::output |
( |
ostream & |
out | ) |
const [virtual] |
Outputs the Namable.
This function simply writes the name to the output stream; most Namable derivatives will probably redefine this.
Reimplemented from PandaNode.
Definition at line 884 of file geomNode.cxx.
| void GeomNode::r_mark_geom_bounds_stale |
( |
Thread * |
current_thread | ) |
[protected, virtual] |
| void GeomNode::register_with_read_factory |
( |
| ) |
[static] |
| void GeomNode::remove_all_geoms |
( |
| ) |
[inline] |
| void GeomNode::remove_geom |
( |
int |
n | ) |
[inline] |
| bool GeomNode::safe_to_combine |
( |
| ) |
const [virtual] |
Returns true if it is generally safe to combine this particular kind of PandaNode with other kinds of PandaNodes of compatible type, adding children or whatever.
For instance, an LODNode should not be combined with any other PandaNode, because its set of children is meaningful.
Reimplemented from PandaNode.
Reimplemented in BulletDebugNode.
Definition at line 370 of file geomNode.cxx.
| bool GeomNode::safe_to_flatten |
( |
| ) |
const [virtual] |
| void GeomNode::set_geom |
( |
int |
n, |
|
|
Geom * |
geom |
|
) |
| |
Replaces the nth Geom of the node with a new pointer.
There must already be a Geom in this slot.
Note that if this method is called in a downstream stage (for instance, during cull or draw), then it will propagate the new list of Geoms upstream all the way to pipeline stage 0, which may step on changes that were made independently in pipeline stage 0. Use with caution.
Definition at line 681 of file geomNode.cxx.
References Geom::check_valid(), and PandaNode::mark_internal_bounds_stale().
| void GeomNode::set_geom_state |
( |
int |
n, |
|
|
const RenderState * |
state |
|
) |
| [inline] |
Changes the RenderState associated with the nth geom of the node.
This is just the RenderState directly associated with the Geom; the actual state in which the Geom is rendered will also be affected by RenderStates that appear on the scene graph in nodes above this GeomNode.
Note that if this method is called in a downstream stage (for instance, during cull or draw), then it will propagate the new list of Geoms upstream all the way to pipeline stage 0, which may step on changes that were made independently in pipeline stage 0. Use with caution.
Definition at line 131 of file geomNode.I.
| void GeomNode::set_preserved |
( |
bool |
value | ) |
[inline] |
Sets the "preserved" flag.
When this is true, the GeomNode will be left untouched by any flatten operations.
Definition at line 24 of file geomNode.I.
| void GeomNode::unify |
( |
int |
max_indices, |
|
|
bool |
preserve_order |
|
) |
| |
Attempts to unify all of the Geoms contained within this node into a single Geom, or at least as few Geoms as possible.
In turn, the individual GeomPrimitives contained within each resulting Geom are also unified. The goal is to reduce the number of GeomPrimitives within the node as far as possible. This may result in composite primitives, such as triangle strips and triangle fans, being decomposed into triangles. See also Geom::unify().
max_indices represents the maximum number of indices that will be put in any one GeomPrimitive. If preserve_order is true, then the primitives will not be reordered during the operation, even if this results in a suboptimal result.
In order for this to be successful, the primitives must reference the same GeomVertexData, have the same fundamental primitive type, and have compatible shade models.
Definition at line 771 of file geomNode.cxx.
References Thread::get_current_thread(), and PandaNode::mark_internal_bounds_stale().
Referenced by SceneGraphReducer::r_unify().
| void GeomNode::write_geoms |
( |
ostream & |
out, |
|
|
int |
indent_level |
|
) |
| const |
Writes a short description of all the Geoms in the node.
Definition at line 845 of file geomNode.cxx.
| void GeomNode::write_verbose |
( |
ostream & |
out, |
|
|
int |
indent_level |
|
) |
| const |
Writes a detailed description of all the Geoms in the node.
Definition at line 864 of file geomNode.cxx.
| void GeomNode::xform |
( |
const LMatrix4 & |
mat | ) |
[virtual] |
Transforms the contents of this node by the indicated matrix, if it means anything to do so.
For most kinds of nodes, this does nothing.
For a GeomNode, this does the right thing, but it is better to use a GeomTransformer instead, since it will share the new arrays properly between different GeomNodes.
Reimplemented from PandaNode.
Definition at line 334 of file geomNode.cxx.
References GeomTransformer::transform_vertices().
The documentation for this class was generated from the following files:
| | |