Panda3D
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
ModelNode Class Reference

This node is placed at key points within the scene graph to indicate the roots of "models": subtrees that are conceptually to be treated as a single unit, like a car or a room, for instance. More...

#include "modelNode.h"

Inheritance diagram for ModelNode:
PandaNode TypedWritable Namable LinkedListNode ReferenceCount TypedObject MemoryBase MemoryBase MemoryBase ModelRoot

List of all members.

Public Types

enum  PreserveTransform {
  PT_none, PT_local, PT_net, PT_drop_node,
  PT_no_touch
}

Public Member Functions

 ModelNode (const string &name)
virtual PandaNodecombine_with (PandaNode *other)
 Collapses this PandaNode with the other PandaNode, if possible, and returns a pointer to the combined PandaNode, or NULL if the two PandaNodes cannot safely be combined.
virtual TypeHandle force_init_type ()
int get_preserve_attributes () const
 Returns the current setting of the preserve_attributes flag.
PreserveTransform get_preserve_transform () const
 Returns the current setting of the preserve_transform flag.
virtual TypeHandle get_type () const
virtual int get_unsafe_to_apply_attribs () const
 Returns the union of all attributes from SceneGraphReducer::AttribTypes that may not safely be applied to the vertices of this node.
virtual PandaNodemake_copy () const
 Returns a newly-allocated Node that is a shallow copy of this one.
virtual bool preserve_name () const
 Returns true if the node's name has extrinsic meaning and must be preserved across a flatten operation, false otherwise.
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 Node by duplicating instances, false otherwise (for instance, a Camera cannot be safely flattened, because the Camera pointer itself is meaningful).
virtual bool safe_to_flatten_below () const
 Returns true if a flatten operation may safely continue past this node, or false if nodes below this node may not be molested.
virtual bool safe_to_modify_transform () const
 Returns true if it is safe to automatically adjust the transform on this kind of node.
virtual bool safe_to_transform () const
 Returns true if it is generally safe to transform this particular kind of Node by calling the xform() method, false otherwise.
void set_preserve_attributes (int attrib_mask)
 Sets the preserve_attributes flag.
void set_preserve_transform (PreserveTransform preserve_transform)
 Sets the preserve_transform flag.
void set_transform_limit (PN_stdfloat limit)
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 ModelNode.

Protected Member Functions

 ModelNode (const ModelNode &copy)
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 ModelNode.
void test_transform (const TransformState *ts) const
 this tests the transform to make sure it's within the specified limits.
virtual void transform_changed ()
 node hook.

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 ModelNode is encountered in the Bam file.

Protected Attributes

PN_stdfloat _transform_limit

Detailed Description

This node is placed at key points within the scene graph to indicate the roots of "models": subtrees that are conceptually to be treated as a single unit, like a car or a room, for instance.

It doesn't affect rendering or any other operations; it's primarily useful as a high-level model indication.

ModelNodes are created in response to a <Model> { 1 } flag within an egg file.

Definition at line 34 of file modelNode.h.


Member Function Documentation

PandaNode * ModelNode::combine_with ( PandaNode other) [virtual]

Collapses this PandaNode with the other PandaNode, if possible, and returns a pointer to the combined PandaNode, or NULL if the two PandaNodes cannot safely be combined.

The return value may be this, other, or a new PandaNode 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 PandaNodes and what the collapsed PandaNode should look like.

Reimplemented from PandaNode.

Definition at line 54 of file modelNode.cxx.

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

Reimplemented from PandaNode.

Reimplemented in ModelRoot.

Definition at line 252 of file modelNode.cxx.

References DatagramIterator::get_uint16(), and DatagramIterator::get_uint8().

Referenced by make_from_bam().

int ModelNode::get_preserve_attributes ( ) const [inline]

Returns the current setting of the preserve_attributes flag.

See set_preserve_attributes().

Definition at line 103 of file modelNode.I.

ModelNode::PreserveTransform ModelNode::get_preserve_transform ( ) const [inline]

Returns the current setting of the preserve_transform flag.

See set_preserve_transform().

Definition at line 76 of file modelNode.I.

int ModelNode::get_unsafe_to_apply_attribs ( ) const [virtual]

Returns the union of all attributes from SceneGraphReducer::AttribTypes that may not safely be applied to the vertices of this node.

If this is nonzero, these attributes must be dropped at this node as a state change.

This is a generalization of safe_to_transform().

Reimplemented from PandaNode.

Definition at line 158 of file modelNode.cxx.

PandaNode * ModelNode::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.

Reimplemented in ModelRoot.

Definition at line 33 of file modelNode.cxx.

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

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

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

Reimplemented from PandaNode.

Reimplemented in ModelRoot.

Definition at line 233 of file modelNode.cxx.

References fillin().

Referenced by register_with_read_factory().

bool ModelNode::preserve_name ( ) const [virtual]

Returns true if the node's name has extrinsic meaning and must be preserved across a flatten operation, false otherwise.

Reimplemented from PandaNode.

Definition at line 142 of file modelNode.cxx.

Tells the BamReader how to create objects of type ModelNode.

Reimplemented from PandaNode.

Reimplemented in ModelRoot.

Definition at line 169 of file modelNode.cxx.

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

bool ModelNode::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 130 of file modelNode.cxx.

bool ModelNode::safe_to_flatten ( ) const [virtual]

Returns true if it is generally safe to flatten out this particular kind of Node by duplicating instances, false otherwise (for instance, a Camera cannot be safely flattened, because the Camera pointer itself is meaningful).

Reimplemented from PandaNode.

Definition at line 73 of file modelNode.cxx.

bool ModelNode::safe_to_flatten_below ( ) const [virtual]

Returns true if a flatten operation may safely continue past this node, or false if nodes below this node may not be molested.

Reimplemented from PandaNode.

Definition at line 85 of file modelNode.cxx.

bool ModelNode::safe_to_modify_transform ( ) const [virtual]

Returns true if it is safe to automatically adjust the transform on this kind of node.

Usually, this is only a bad idea if the user expects to find a particular transform on the node.

ModelNodes with the preserve_transform flag set are presently the only kinds of nodes that should not have their transform even adjusted.

Reimplemented from PandaNode.

Definition at line 115 of file modelNode.cxx.

bool ModelNode::safe_to_transform ( ) const [virtual]

Returns true if it is generally safe to transform this particular kind of Node by calling the xform() method, false otherwise.

For instance, it's usually a bad idea to attempt to xform a Character.

Reimplemented from PandaNode.

Definition at line 98 of file modelNode.cxx.

void ModelNode::set_preserve_attributes ( int  preserve_attributes) [inline]

Sets the preserve_attributes flag.

This restricts the ability of a flatten operation to affect the render attributes stored on this node.

The value should be the union of bits from SceneGraphReducer::AttribTypes that represent the attributes that should *not* be changed.

Definition at line 92 of file modelNode.I.

void ModelNode::set_preserve_transform ( ModelNode::PreserveTransform  preserve_transform) [inline]

Sets the preserve_transform flag.

This restricts the ability of a flatten operation to affect the transform stored on this node, and/or the node itself. In the order from weakest to strongest restrictions, the possible flags are:

PT_drop_node - This node should be removed at the next flatten call.

PT_none - The transform may be adjusted at will. The node itself will not be removed. This is the default.

PT_net - Preserve the net transform from the root, but it's acceptable to modify the local transform stored on this particular node if necessary, so long as the net transform is not changed. This eliminates the need to drop an extra transform on the node above.

PT_local - The local (and net) transform should not be changed in any way. If necessary, an extra transform will be left on the node above to guarantee this. This is a stronger restriction than PT_net.

PT_no_touch - The local transform will not be changed, the node will not be removed, and furthermore any flatten operation will not continue below this node--this node and all descendents are protected from the effects of flatten.

Definition at line 65 of file modelNode.I.

void ModelNode::test_transform ( const TransformState ts) const [protected]

this tests the transform to make sure it's within the specified limits.

It's done so we can assert to see when an invalid transform is being applied.

Definition at line 181 of file modelNode.cxx.

References TransformState::get_pos().

Referenced by transform_changed().

void ModelNode::transform_changed ( ) [protected, virtual]

node hook.

This function handles outside (non-physics) actions on the actor and updates the internal representation of the node. i.e. copy from PandaNode to PhysicsObject

Reimplemented from PandaNode.

Definition at line 200 of file modelNode.cxx.

References PandaNode::get_transform(), and test_transform().

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

Reimplemented in ModelRoot.

Definition at line 218 of file modelNode.cxx.

References Datagram::add_uint16(), and Datagram::add_uint8().


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