Panda3D
Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends

EggNode Class Reference

A base class for things that may be directly added into the egg hierarchy. More...

#include "eggNode.h"

Inheritance diagram for EggNode:
EggNamedObject EggObject Namable TypedReferenceCount MemoryBase TypedObject ReferenceCount MemoryBase MemoryBase EggAnimData EggAnimPreload EggComment EggCoordinateSystem EggFilenameNode EggGroupNode EggMaterial EggPrimitive EggVertexPool

List of all members.

Public Member Functions

 EggNode (const string &name="")
 EggNode (const EggNode &copy)
void apply_texmats ()
 Applies the texture matrices to the UV's of the vertices that reference them, and then removes the texture matrices from the textures themselves.
virtual EggRenderModedetermine_alpha_mode ()
 Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has an alpha_mode other than AM_unspecified.
virtual EggRenderModedetermine_bin ()
 Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has a bin specified.
virtual bool determine_decal ()
 Walks back up the hierarchy, looking for an EggGroup at this level or above that has the "decal" flag set.
virtual EggRenderModedetermine_depth_offset ()
 Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has a depth_offset specified.
virtual EggRenderModedetermine_depth_test_mode ()
 Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has a depth_test_mode other than DTM_unspecified.
virtual EggRenderModedetermine_depth_write_mode ()
 Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has a depth_write_mode other than DWM_unspecified.
virtual EggRenderModedetermine_draw_order ()
 Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has a draw_order specified.
virtual bool determine_indexed ()
 Walks back up the hierarchy, looking for an EggGroup at this level or above that has the "indexed" scalar set.
virtual EggRenderModedetermine_visibility_mode ()
 Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has a visibility_mode other than VM_unspecified.
void flatten_transforms ()
 Removes any transform and instance records from this node in the scene graph and below.
virtual TypeHandle force_init_type ()
int get_depth () const
 Returns the number of nodes above this node in the egg hierarchy.
const LMatrix4dget_node_frame () const
 Returns the coordinate frame of the node itself.
const LMatrix4dget_node_frame_inv () const
 Returns the inverse of the matrix returned by get_node_frame().
const LMatrix4dget_node_frame_inv_ptr () const
 Returns either a NULL pointer or a unique pointer shared by nodes with the same get_node_frame_inv() matrix.
const LMatrix4dget_node_frame_ptr () const
 Returns either a NULL pointer or a unique pointer shared by nodes with the same get_node_frame() matrix.
const LMatrix4dget_node_to_vertex () const
 Returns the transformation matrix suitable for converting vertices in the coordinate space of the node to the appropriate coordinate space for storing in the egg file.
const LMatrix4dget_node_to_vertex_ptr () const
 Returns either a NULL pointer or a unique pointer shared by nodes with the same get_node_to_vertex() matrix.
EggGroupNodeget_parent () const
virtual TypeHandle get_type () const
const LMatrix4dget_vertex_frame () const
 Returns the coordinate frame of the vertices referenced by primitives at or under this node.
const LMatrix4dget_vertex_frame_inv () const
 Returns the inverse of the matrix returned by get_vertex_frame().
const LMatrix4dget_vertex_frame_inv_ptr () const
 Returns either a NULL pointer or a unique pointer shared by nodes with the same get_vertex_frame_inv() matrix.
const LMatrix4dget_vertex_frame_ptr () const
 Returns either a NULL pointer or a unique pointer shared by nodes with the same get_vertex_frame() matrix.
const LMatrix4dget_vertex_to_node () const
 Returns the transformation matrix suitable for converting the vertices as read from the egg file into the coordinate space of the node.
const LMatrix4dget_vertex_to_node_ptr () const
 Returns either a NULL pointer or a unique pointer shared by nodes with the same get_vertex_to_node() matrix.
virtual bool is_anim_matrix () const
 Returns true if this node represents a table of animation transformation data, false otherwise.
virtual bool is_joint () const
 Returns true if this particular node represents a <Joint> entry or not.
bool is_local_coord () const
 Returns true if this node's vertices are not in the global coordinate space.
bool is_under_instance () const
 Returns true if there is an <Instance> node somewhere in the egg tree at or above this node, false otherwise.
bool is_under_transform () const
 Returns true if there is a <Transform> entry somewhere in the egg tree at or above this node, false otherwise.
EggNodeoperator= (const EggNode &copy)
bool parse_egg (const string &egg_syntax)
 Parses the egg syntax given in the indicate string as if it had been read from the egg file within this object's definition.
int rename_node (vector_string strip_prefix)
 Rename by stripping out the prefix.
void test_under_integrity () const
void transform (const LMatrix4d &mat)
 Applies the indicated transformation to the node and all of its descendants.
void transform_vertices_only (const LMatrix4d &mat)
 Applies the indicated transformation only to vertices that appear in global space within vertex pools at this node and below.
virtual void write (ostream &out, int indent_level) const =0

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96.

Protected Types

typedef RefCountObj< LMatrix4dMatrixFrame
enum  UnderFlags { UF_under_instance = 0x001, UF_under_transform = 0x002, UF_local_coord = 0x004 }

Protected Member Functions

virtual void adjust_under ()
 This is called within update_under() after all the various under settings have been inherited directly from the parent node.
virtual bool egg_start_parse_body ()
 This function is called within parse_egg().
virtual bool has_normals () const
 Returns true if any of the primitives (e.g.
virtual bool has_primitives () const
 Returns true if there are any primitives (e.g.
virtual bool joint_has_primitives () const
 Returns true if there are any primitives (e.g.
 PT (MatrixFrame) _vertex_to_node
 PT (MatrixFrame) _node_to_vertex
 PT (MatrixFrame) _node_frame_inv
 PT (MatrixFrame) _vertex_frame
 PT (MatrixFrame) _node_frame
 PT (MatrixFrame) _vertex_frame_inv
virtual void r_apply_texmats (EggTextureCollection &textures)
 The recursive implementation of apply_texmats().
virtual void r_flatten_transforms ()
 The recursive implementation of flatten_transforms().
virtual void r_mark_coordsys (CoordinateSystem cs)
 This is only called immediately after loading an egg file from disk, to propagate the value found in the CoordinateSystem entry (or the default Y-up coordinate system) to all nodes that care about what the coordinate system is.
virtual void r_transform (const LMatrix4d &mat, const LMatrix4d &inv, CoordinateSystem to_cs)
 This is called from within the egg code by transform().
virtual void r_transform_vertices (const LMatrix4d &mat)
 This is called from within the egg code by transform_vertices_only()().
virtual void update_under (int depth_offset)
 This function is called from within EggGroupNode whenever the parentage of the node has changed.

Protected Attributes

int _depth
EggGroupNode_parent
int _under_flags

Friends

class EggGroupNode
class EggTable

Detailed Description

A base class for things that may be directly added into the egg hierarchy.

This includes groups, joints, polygons, vertex pools, etc., but does not include things like vertices.

Definition at line 38 of file eggNode.h.


Member Function Documentation

void EggNode::adjust_under ( ) [protected, virtual]

This is called within update_under() after all the various under settings have been inherited directly from the parent node.

It is responsible for adjusting these settings to reflect states local to the current node; for instance, an <Instance> node will force the UF_under_instance bit on.

Reimplemented in EggGroup.

Definition at line 401 of file eggNode.cxx.

Referenced by update_under().

void EggNode::apply_texmats ( )

Applies the texture matrices to the UV's of the vertices that reference them, and then removes the texture matrices from the textures themselves.

Definition at line 58 of file eggNode.cxx.

References EggTextureCollection::find_used_textures(), and r_apply_texmats().

EggRenderMode * EggNode::determine_alpha_mode ( ) [virtual]

Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has an alpha_mode other than AM_unspecified.

Returns a valid EggRenderMode pointer if one is found, or NULL otherwise.

Reimplemented in EggGroup, and EggPrimitive.

Definition at line 99 of file eggNode.cxx.

References determine_alpha_mode().

Referenced by determine_alpha_mode().

EggRenderMode * EggNode::determine_bin ( ) [virtual]

Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has a bin specified.

Returns a valid EggRenderMode pointer if one is found, or NULL otherwise.

Reimplemented in EggGroup, and EggPrimitive.

Definition at line 207 of file eggNode.cxx.

References determine_bin().

Referenced by determine_bin().

bool EggNode::determine_decal ( ) [virtual]

Walks back up the hierarchy, looking for an EggGroup at this level or above that has the "decal" flag set.

Returns the value of the decal flag if it is found, or false if it is not.

In other words, returns true if the "decal" flag is in effect for the indicated node, false otherwise.

Reimplemented in EggGroup.

Definition at line 247 of file eggNode.cxx.

References determine_decal().

Referenced by determine_decal().

EggRenderMode * EggNode::determine_depth_offset ( ) [virtual]

Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has a depth_offset specified.

Returns a valid EggRenderMode pointer if one is found, or NULL otherwise.

Reimplemented in EggGroup, and EggPrimitive.

Definition at line 171 of file eggNode.cxx.

References determine_depth_offset().

Referenced by determine_depth_offset().

EggRenderMode * EggNode::determine_depth_test_mode ( ) [virtual]

Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has a depth_test_mode other than DTM_unspecified.

Returns a valid EggRenderMode pointer if one is found, or NULL otherwise.

Reimplemented in EggGroup, and EggPrimitive.

Definition at line 135 of file eggNode.cxx.

References determine_depth_test_mode().

Referenced by determine_depth_test_mode().

EggRenderMode * EggNode::determine_depth_write_mode ( ) [virtual]

Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has a depth_write_mode other than DWM_unspecified.

Returns a valid EggRenderMode pointer if one is found, or NULL otherwise.

Reimplemented in EggGroup, and EggPrimitive.

Definition at line 117 of file eggNode.cxx.

References determine_depth_write_mode().

Referenced by determine_depth_write_mode().

EggRenderMode * EggNode::determine_draw_order ( ) [virtual]

Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has a draw_order specified.

Returns a valid EggRenderMode pointer if one is found, or NULL otherwise.

Reimplemented in EggGroup, and EggPrimitive.

Definition at line 189 of file eggNode.cxx.

References determine_draw_order().

Referenced by determine_draw_order().

bool EggNode::determine_indexed ( ) [virtual]

Walks back up the hierarchy, looking for an EggGroup at this level or above that has the "indexed" scalar set.

Returns the value of the indexed scalar if it is found, or false if it is not.

In other words, returns true if the "indexed" flag is in effect for the indicated node, false otherwise.

Reimplemented in EggGroup.

Definition at line 227 of file eggNode.cxx.

References determine_indexed().

Referenced by determine_indexed().

EggRenderMode * EggNode::determine_visibility_mode ( ) [virtual]

Walks back up the hierarchy, looking for an EggGroup or EggPrimitive or some such object at this level or above this node that has a visibility_mode other than VM_unspecified.

Returns a valid EggRenderMode pointer if one is found, or NULL otherwise.

Reimplemented in EggGroup, and EggPrimitive.

Definition at line 153 of file eggNode.cxx.

References determine_visibility_mode().

Referenced by determine_visibility_mode().

bool EggNode::egg_start_parse_body ( ) [protected, virtual]

This function is called within parse_egg().

It should call the appropriate function on the lexer to initialize the parser into the state associated with this object. If the object cannot be parsed into directly, it should return false.

Reimplemented in EggGroup, EggPrimitive, and EggTexture.

Definition at line 340 of file eggNode.cxx.

Referenced by parse_egg().

void EggNode::flatten_transforms ( ) [inline]

Removes any transform and instance records from this node in the scene graph and below.

If an instance node is encountered, removes the instance and applies the transform to its vertices, duplicating vertices if necessary.

Since this function may result in duplicated vertices, it may be a good idea to call remove_unused_vertices() after calling this.

Definition at line 351 of file eggNode.I.

References r_flatten_transforms(), and update_under().

int EggNode::get_depth ( ) const [inline]

Returns the number of nodes above this node in the egg hierarchy.

Definition at line 71 of file eggNode.I.

const LMatrix4d & EggNode::get_node_frame ( ) const [inline]

Returns the coordinate frame of the node itself.

This is simply the net product of all transformations up to the root.

Definition at line 152 of file eggNode.I.

References LMatrix4d::ident_mat().

Referenced by EggGroup::adjust_under().

const LMatrix4d & EggNode::get_node_frame_inv ( ) const [inline]

Returns the inverse of the matrix returned by get_node_frame().

See get_node_frame().

Definition at line 183 of file eggNode.I.

References LMatrix4d::ident_mat().

Referenced by EggGroup::adjust_under().

const LMatrix4d * EggNode::get_node_frame_inv_ptr ( ) const [inline]

Returns either a NULL pointer or a unique pointer shared by nodes with the same get_node_frame_inv() matrix.

Definition at line 277 of file eggNode.I.

const LMatrix4d * EggNode::get_node_frame_ptr ( ) const [inline]

Returns either a NULL pointer or a unique pointer shared by nodes with the same get_node_frame() matrix.

Definition at line 252 of file eggNode.I.

const LMatrix4d & EggNode::get_node_to_vertex ( ) const [inline]

Returns the transformation matrix suitable for converting vertices in the coordinate space of the node to the appropriate coordinate space for storing in the egg file.

This is the same thing as:

get_node_frame() * get_vertex_frame_inv()

Definition at line 223 of file eggNode.I.

References LMatrix4d::ident_mat().

Referenced by XFileMesh::create_polygons().

const LMatrix4d * EggNode::get_node_to_vertex_ptr ( ) const [inline]

Returns either a NULL pointer or a unique pointer shared by nodes with the same get_node_to_vertex() matrix.

Definition at line 301 of file eggNode.I.

const LMatrix4d & EggNode::get_vertex_frame ( ) const [inline]

Returns the coordinate frame of the vertices referenced by primitives at or under this node.

This is not the same as get_node_frame().

Generally, vertices in an egg file are stored in the global coordinate space, regardless of the transforms defined at each node. Thus, get_vertex_frame() will usually return the identity transform (global coordinate space). However, primitives under an <Instance> entry reference their vertices in the coordinate system under effect at the time of the <Instance>. Thus, nodes under an <Instance> entry may return this non-identity matrix.

Specifically, this may return a non-identity matrix only if is_local_coord() is true.

Definition at line 135 of file eggNode.I.

References LMatrix4d::ident_mat().

Referenced by EggGroup::adjust_under(), EggPrimitive::r_flatten_transforms(), EggGroup::r_flatten_transforms(), XFileVertex::set_from_egg(), XFileNormal::set_from_egg(), EggToDXFLayer::write_3d_face(), and EggToDXFLayer::write_polyline().

const LMatrix4d & EggNode::get_vertex_frame_inv ( ) const [inline]

Returns the inverse of the matrix returned by get_vertex_frame().

See get_vertex_frame().

Definition at line 167 of file eggNode.I.

References LMatrix4d::ident_mat().

Referenced by EggGroup::adjust_under().

const LMatrix4d * EggNode::get_vertex_frame_inv_ptr ( ) const [inline]

Returns either a NULL pointer or a unique pointer shared by nodes with the same get_vertex_frame_inv() matrix.

Definition at line 264 of file eggNode.I.

const LMatrix4d * EggNode::get_vertex_frame_ptr ( ) const [inline]

Returns either a NULL pointer or a unique pointer shared by nodes with the same get_vertex_frame() matrix.

Definition at line 239 of file eggNode.I.

const LMatrix4d & EggNode::get_vertex_to_node ( ) const [inline]

Returns the transformation matrix suitable for converting the vertices as read from the egg file into the coordinate space of the node.

This is the same thing as:

get_vertex_frame() * get_node_frame_inv()

Definition at line 203 of file eggNode.I.

References LMatrix4d::ident_mat().

Referenced by EggLoader::make_polyset(), XFileVertex::set_from_egg(), and XFileNormal::set_from_egg().

const LMatrix4d * EggNode::get_vertex_to_node_ptr ( ) const [inline]

Returns either a NULL pointer or a unique pointer shared by nodes with the same get_vertex_to_node() matrix.

Definition at line 289 of file eggNode.I.

bool EggNode::has_normals ( ) const [protected, virtual]

Returns true if any of the primitives (e.g.

polygons) defined within this group or below have either face or vertex normals defined, false otherwise.

Reimplemented in EggGroupNode, EggPrimitive, and EggVertexPool.

Definition at line 436 of file eggNode.cxx.

bool EggNode::has_primitives ( ) const [protected, virtual]

Returns true if there are any primitives (e.g.

polygons) defined within this group or below, false otherwise.

Reimplemented in EggGroupNode, and EggPrimitive.

Definition at line 412 of file eggNode.cxx.

static void EggNode::init_type ( ) [inline, static]
bool EggNode::is_anim_matrix ( ) const [virtual]

Returns true if this node represents a table of animation transformation data, false otherwise.

Reimplemented in EggXfmAnimData, and EggXfmSAnim.

Definition at line 85 of file eggNode.cxx.

Referenced by EggTable::has_transform(), and EggTable::r_transform().

bool EggNode::is_joint ( ) const [virtual]

Returns true if this particular node represents a <Joint> entry or not.

This is a handy thing to know since Joints are sorted to the end of their sibling list when writing an egg file. See EggGroupNode::write().

Reimplemented in EggGroup.

Definition at line 74 of file eggNode.cxx.

Referenced by EggGroupNode::joint_has_primitives().

bool EggNode::is_local_coord ( ) const [inline]

Returns true if this node's vertices are not in the global coordinate space.

This will be the case if there was an <Instance> node under a transform at or above this node.

Definition at line 109 of file eggNode.I.

Referenced by EggVertex::get_num_global_coord(), EggVertex::get_num_local_coord(), EggPrimitive::r_flatten_transforms(), and EggGroup::r_flatten_transforms().

bool EggNode::is_under_instance ( ) const [inline]

Returns true if there is an <Instance> node somewhere in the egg tree at or above this node, false otherwise.

Definition at line 84 of file eggNode.I.

bool EggNode::is_under_transform ( ) const [inline]

Returns true if there is a <Transform> entry somewhere in the egg tree at or above this node, false otherwise.

Definition at line 96 of file eggNode.I.

bool EggNode::joint_has_primitives ( ) const [protected, virtual]

Returns true if there are any primitives (e.g.

polygons) defined within this group or below, but the search does not include nested joints.

Reimplemented in EggGroupNode, and EggPrimitive.

Definition at line 424 of file eggNode.cxx.

Referenced by EggGroupNode::joint_has_primitives().

bool EggNode::parse_egg ( const string &  egg_syntax)

Parses the egg syntax given in the indicate string as if it had been read from the egg file within this object's definition.

Updates the object accordingly. Returns true if successful, false if there was some parse error or if the object does not support this functionality.

Definition at line 267 of file eggNode.cxx.

References egg_start_parse_body(), and TypedObject::is_of_type().

void EggNode::r_apply_texmats ( EggTextureCollection textures) [protected, virtual]

The recursive implementation of apply_texmats().

Reimplemented in EggGroupNode, EggNurbsSurface, and EggPrimitive.

Definition at line 499 of file eggNode.cxx.

Referenced by apply_texmats().

void EggNode::r_flatten_transforms ( ) [protected, virtual]

The recursive implementation of flatten_transforms().

Reimplemented in EggGroup, EggGroupNode, and EggPrimitive.

Definition at line 490 of file eggNode.cxx.

Referenced by flatten_transforms().

void EggNode::r_mark_coordsys ( CoordinateSystem  cs) [protected, virtual]

This is only called immediately after loading an egg file from disk, to propagate the value found in the CoordinateSystem entry (or the default Y-up coordinate system) to all nodes that care about what the coordinate system is.

Reimplemented in EggGroupNode, EggXfmAnimData, and EggXfmSAnim.

Definition at line 481 of file eggNode.cxx.

void EggNode::r_transform ( const LMatrix4d mat,
const LMatrix4d inv,
CoordinateSystem  to_cs 
) [protected, virtual]

This is called from within the egg code by transform().

It applies a transformation matrix to the current node in some sensible way, then continues down the tree.

The first matrix is the transformation to apply; the second is its inverse. The third parameter is the coordinate system we are changing to, or CS_default if we are not changing coordinate systems.

Reimplemented in EggGroup, EggGroupNode, EggPrimitive, EggTable, EggVertexPool, EggXfmAnimData, and EggXfmSAnim.

Definition at line 455 of file eggNode.cxx.

Referenced by EggTable::r_transform(), and transform().

void EggNode::r_transform_vertices ( const LMatrix4d mat) [protected, virtual]

This is called from within the egg code by transform_vertices_only()().

It applies a transformation matrix to the current node in some sensible way (if the current node is a vertex pool with vertices), then continues down the tree.

Reimplemented in EggGroupNode, and EggVertexPool.

Definition at line 468 of file eggNode.cxx.

Referenced by transform(), and transform_vertices_only().

int EggNode::rename_node ( vector_string  strip_prefix)

Rename by stripping out the prefix.

Definition at line 36 of file eggNode.cxx.

Referenced by EggGroupNode::rename_nodes().

void EggNode::transform ( const LMatrix4d mat) [inline]

Applies the indicated transformation to the node and all of its descendants.

Reimplemented in EggVertexPool.

Definition at line 313 of file eggNode.I.

References r_transform(), r_transform_vertices(), and update_under().

Referenced by SomethingToEgg::apply_units_scale(), EggToSomething::apply_units_scale(), and EggGroup::set_default_pose().

void EggNode::transform_vertices_only ( const LMatrix4d mat) [inline]

Applies the indicated transformation only to vertices that appear in global space within vertex pools at this node and below.

Joints and other transforms are not affected, nor are local vertices.

Definition at line 333 of file eggNode.I.

References r_transform_vertices().

Referenced by EggTopstrip::strip_anim_vertices().

void EggNode::update_under ( int  depth_offset) [protected, virtual]

This function is called from within EggGroupNode whenever the parentage of the node has changed.

It should update the depth and under_instance flags accordingly.

depth_offset is the difference between the old depth value and the new value. It should be consistent with the supplied depth value. If it is not, we have some error.

Reimplemented in EggGroupNode.

Definition at line 358 of file eggNode.cxx.

References adjust_under(), and ReferenceCount::test_ref_count_integrity().

Referenced by flatten_transforms(), and transform().


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