Panda3D
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions
SwitchNode Class Reference

A node that renders only one of its children, according to the user's indication. More...

#include "switchNode.h"

Inheritance diagram for SwitchNode:
SelectiveChildNode PandaNode TypedWritable Namable LinkedListNode ReferenceCount TypedObject MemoryBase MemoryBase MemoryBase

List of all members.

Classes

class  CData

Public Member Functions

 SwitchNode (const string &name)
 SwitchNode (const SwitchNode &copy)
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 ()
virtual int get_first_visible_child () const
 Returns the index number of the first visible child of this node, or a number >= get_num_children() if there are no visible children of this node.
virtual TypeHandle get_type () const
virtual int get_visible_child () const
 Returns the index of the child that should be visible.
virtual bool has_single_child_visibility () const
 Should be overridden by derived classes to return true if this kind of node has the special property that just one of its children is visible at any given time, and furthermore that the particular visible child can be determined without reference to any external information (such as a camera).
virtual PandaNodemake_copy () const
 Returns a newly-allocated Node that is a shallow copy of this one.
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_combine_children () const
 Returns true if it is generally safe to combine the children of this PandaNode with each other.
void set_visible_child (int index)
 Specifies the particular child of this node, by index, that will be visible.
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 TypeHandle get_class_type ()
static void init_type ()
static void register_with_read_factory ()
 Tells the BamReader how to create objects of type SwitchNode.

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 SwitchNode.

Static Protected Member Functions

static TypedWritablemake_from_bam (const FactoryParams &params)
 This function is called by the BamReader's factory when a new object of type SwitchNode is encountered in the Bam file.

Detailed Description

A node that renders only one of its children, according to the user's indication.

Definition at line 27 of file switchNode.h.


Member Function Documentation

bool SwitchNode::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 134 of file switchNode.cxx.

References get_visible_child(), and SelectiveChildNode::select_child().

void SwitchNode::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 SwitchNode.

Reimplemented from PandaNode.

Definition at line 237 of file switchNode.cxx.

References BamReader::read_cdata().

Referenced by make_from_bam().

int SwitchNode::get_first_visible_child ( ) const [virtual]

Returns the index number of the first visible child of this node, or a number >= get_num_children() if there are no visible children of this node.

This is called during the cull traversal, but only if has_selective_visibility() has already returned true. See has_selective_visibility().

Reimplemented from SelectiveChildNode.

Definition at line 150 of file switchNode.cxx.

References get_visible_child().

int SwitchNode::get_visible_child ( ) const [virtual]

Returns the index of the child that should be visible.

Reimplemented from PandaNode.

Definition at line 181 of file switchNode.cxx.

Referenced by cull_callback(), and get_first_visible_child().

bool SwitchNode::has_single_child_visibility ( ) const [virtual]

Should be overridden by derived classes to return true if this kind of node has the special property that just one of its children is visible at any given time, and furthermore that the particular visible child can be determined without reference to any external information (such as a camera).

At present, only SequenceNodes and SwitchNodes fall into this category.

If this function returns true, get_visible_child() can be called to return the index of the currently-visible child.

Reimplemented from PandaNode.

Definition at line 171 of file switchNode.cxx.

PandaNode * SwitchNode::make_copy ( ) const [virtual]

Returns a newly-allocated Node that is a shallow copy of this one.

It will be a different Node pointer, but its internal data may or may not be shared with that of the original Node.

Reimplemented from PandaNode.

Definition at line 104 of file switchNode.cxx.

TypedWritable * SwitchNode::make_from_bam ( const FactoryParams params) [static, protected]

This function is called by the BamReader's factory when a new object of type SwitchNode is encountered in the Bam file.

It should create the SwitchNode and extract its information from the file.

Reimplemented from PandaNode.

Definition at line 218 of file switchNode.cxx.

References fillin().

Referenced by register_with_read_factory().

Tells the BamReader how to create objects of type SwitchNode.

Reimplemented from PandaNode.

Definition at line 193 of file switchNode.cxx.

References BamReader::get_factory(), make_from_bam(), and Factory< Type >::register_factory().

bool SwitchNode::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.

Definition at line 42 of file switchNode.cxx.

bool SwitchNode::safe_to_combine_children ( ) const [virtual]

Returns true if it is generally safe to combine the children of this PandaNode with each other.

For instance, an LODNode's children should not be combined with each other, because the set of children is meaningful.

Reimplemented from PandaNode.

Definition at line 56 of file switchNode.cxx.

void SwitchNode::set_visible_child ( int  index) [inline]

Specifies the particular child of this node, by index, that will be visible.

Definition at line 56 of file switchNode.I.

void SwitchNode::write_datagram ( BamWriter manager,
Datagram dg 
) [virtual]

Writes the contents of this object to the datagram for shipping out to a Bam file.

Reimplemented from PandaNode.

Definition at line 204 of file switchNode.cxx.

References BamWriter::write_cdata().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations