Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

EggLoader Class Reference

Converts an egg data structure, possibly read from an egg file but not necessarily, into a scene graph suitable for rendering. More...

#include <eggLoader.h>

List of all members.

Public Member Functions

 EggLoader ()
 EggLoader (const EggData &data)
void build_graph ()
void reparent_decals ()
 For each node representing a decal base geometry (i.e.

void make_nonindexed_primitive (EggPrimitive *egg_prim, PandaNode *parent, const LMatrix4d *transform=NULL)
void make_indexed_primitive (EggPrimitive *egg_prim, PandaNode *parent, const LMatrix4d *transform, ComputedVerticesMaker &_comp_verts_maker)

Public Attributes

PointerTo< PandaNode > _root
EggData _data
bool _error

Private Types

typedef pmap< PT_EggTexture,
TextureDef > 
Textures
typedef pmap< CPT_EggMaterial,
ConstPointerTo< RenderAttrib > > 
Materials
typedef pset< PandaNode * > Decals

Private Member Functions

void load_textures ()
bool load_texture (TextureDef &def, const EggTexture *egg_tex)
void apply_texture_attributes (Texture *tex, const EggTexture *egg_tex)
ConstPointerTo< RenderAttrib > get_texture_apply_attributes (const EggTexture *egg_tex)
ConstPointerTo< RenderAttrib > get_material_attrib (const EggMaterial *egg_mat, bool bface)
 Returns a RenderAttrib suitable for enabling the material indicated by the given EggMaterial, and with the indicated backface flag.

void setup_bucket (BuilderBucket &bucket, PandaNode *parent, EggPrimitive *egg_prim)
PandaNode * make_node (EggNode *egg_node, PandaNode *parent)
PandaNode * make_node (EggNurbsCurve *egg_curve, PandaNode *parent)
PandaNode * make_node (EggPrimitive *egg_prim, PandaNode *parent)
PandaNode * make_node (EggBin *egg_bin, PandaNode *parent)
PandaNode * make_node (EggGroup *egg_group, PandaNode *parent)
PandaNode * create_group_arc (EggGroup *egg_group, PandaNode *parent, PandaNode *node)
 Creates the arc parenting a new group to the scene graph, and applies any relevant attribs to the arc according to the EggGroup node that inspired the group.

PandaNode * make_node (EggTable *egg_table, PandaNode *parent)
PandaNode * make_node (EggGroupNode *egg_group, PandaNode *parent)
void make_collision_solids (EggGroup *start_group, EggGroup *egg_group, CollisionNode *cnode)
 Creates CollisionSolids corresponding to the collision geometry indicated at the given node and below.

void make_collision_plane (EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags)
 Creates a single CollisionPlane corresponding to the first polygon associated with this group.

void make_collision_polygon (EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags)
 Creates a single CollisionPolygon corresponding to the first polygon associated with this group.

void make_collision_polyset (EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags)
 Creates a series of CollisionPolygons corresponding to the polygons associated with this group.

void make_collision_sphere (EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags)
 Creates a single CollisionSphere corresponding to the polygons associated with this group.

void apply_collision_flags (CollisionSolid *solid, EggGroup::CollideFlags flags)
 Does funny stuff to the CollisionSolid as appropriate, based on the settings of the given CollideFlags.

EggGroup * find_collision_geometry (EggGroup *egg_group)
 Looks for the node, at or below the indicated node, that contains the associated collision geometry.

CollisionPlane * create_collision_plane (EggPolygon *egg_poly, EggGroup *parent_group)
 Creates a single CollisionPlane from the indicated EggPolygon.

void create_collision_polygons (CollisionNode *cnode, EggPolygon *egg_poly, EggGroup *parent_group, EggGroup::CollideFlags flags)
 Creates one or more CollisionPolygons from the indicated EggPolygon, and adds them to the indicated CollisionNode.

void apply_deferred_nodes (PandaNode *node, const DeferredNodeProperty &prop)
 Walks back over the tree and applies the DeferredNodeProperties that were saved up along the way.

bool expand_object_types (EggGroup *egg_group, const pset< string > &expanded, const pvector< string > &expanded_history)
 Recursively expands the group's ObjectType string(s).

bool do_expand_object_type (EggGroup *egg_group, const pset< string > &expanded, const pvector< string > &expanded_history, const string &object_type)
 Further implementation of expand_object_types().

ConstPointerTo< TransformState > make_transform (const EggTransform3d *egg_transform)
 Walks back over the tree and applies the DeferredNodeProperties that were saved up along the way.


Private Attributes

Builder _builder
Textures _textures
Materials _materials
Materials _materials_bface
Decals _decals
DeferredNodes _deferred_nodes


Detailed Description

Converts an egg data structure, possibly read from an egg file but not necessarily, into a scene graph suitable for rendering.

This class isn't exported from this package.

Definition at line 72 of file eggLoader.h.


Member Typedef Documentation

typedef pset<PandaNode *> EggLoader::Decals [private]
 

Definition at line 152 of file eggLoader.h.

typedef pmap<CPT_EggMaterial, ConstPointerTo< RenderAttrib > > EggLoader::Materials [private]
 

Definition at line 148 of file eggLoader.h.

typedef pmap<PT_EggTexture, TextureDef> EggLoader::Textures [private]
 

Definition at line 145 of file eggLoader.h.


Constructor & Destructor Documentation

EggLoader::EggLoader (   ) 
 

Definition at line 114 of file eggLoader.cxx.

References _error.

EggLoader::EggLoader (  const EggData &  data  ) 
 

Definition at line 128 of file eggLoader.cxx.

References _data, _deferred_nodes, load_textures(), and EggBinMaker::make_bins().


Member Function Documentation

void EggLoader::apply_collision_flags (  CollisionSolid *  solid,
EggGroup::CollideFlags  flags
)  [private]
 

Does funny stuff to the CollisionSolid as appropriate, based on the settings of the given CollideFlags.

Definition at line 1829 of file eggLoader.cxx.

void EggLoader::apply_deferred_nodes (  PandaNode *  node,
const DeferredNodeProperty &  prop
)  [private]
 

Walks back over the tree and applies the DeferredNodeProperties that were saved up along the way.

Definition at line 2013 of file eggLoader.cxx.

void EggLoader::apply_texture_attributes (  Texture *  tex,
const EggTexture *  egg_tex
)  [private]
 

Definition at line 585 of file eggLoader.cxx.

References EggTexture::determine_wrap_v(), Texture::set_wrapv(), tex, Texture::WM_clamp, EggTexture::WM_clamp, Texture::WM_repeat, EggTexture::WM_repeat, and EggTexture::WM_unspecified.

void EggLoader::build_graph (   ) 
 

Definition at line 143 of file eggLoader.cxx.

References _builder, _data, and _root.

CollisionPlane * EggLoader::create_collision_plane (  EggPolygon *  egg_poly,
EggGroup *  parent_group
)  [private]
 

Creates a single CollisionPlane from the indicated EggPolygon.

Definition at line 1889 of file eggLoader.cxx.

void EggLoader::create_collision_polygons (  CollisionNode *  cnode,
EggPolygon *  egg_poly,
EggGroup *  parent_group,
EggGroup::CollideFlags  flags
)  [private]
 

Creates one or more CollisionPolygons from the indicated EggPolygon, and adds them to the indicated CollisionNode.

Definition at line 1941 of file eggLoader.cxx.

References _error, EggGroup::clear_object_types(), do_expand_object_type(), EggGroup::get_num_object_types(), and EggGroup::get_object_type().

PandaNode * EggLoader::create_group_arc (  EggGroup *  egg_group,
PandaNode *  parent,
PandaNode *  node
)  [private]
 

Creates the arc parenting a new group to the scene graph, and applies any relevant attribs to the arc according to the EggGroup node that inspired the group.

Definition at line 1480 of file eggLoader.cxx.

Referenced by make_node().

bool EggLoader::do_expand_object_type (  EggGroup *  egg_group,
const pset< string > &  expanded,
const pvector< string > &  expanded_history,
const string &  object_type
)  [private]
 

Further implementation of expand_object_types().

Definition at line 2113 of file eggLoader.cxx.

Referenced by create_collision_polygons().

bool EggLoader::expand_object_types (  EggGroup *  egg_group,
const pset< string > &  expanded,
const pvector< string > &  expanded_history
)  [private]
 

Recursively expands the group's ObjectType string(s).

It's recursive because an ObjectType string might itself expand to another ObjectType string, which is allowed; but we don't want to get caught in a cycle.

The return value is true if the object type is expanded and the node is valid, or false if the node should be ignored (e.g. ObjectType "backstage").

Definition at line 2057 of file eggLoader.cxx.

Referenced by make_node().

EggGroup * EggLoader::find_collision_geometry (  EggGroup *  egg_group  )  [private]
 

Looks for the node, at or below the indicated node, that contains the associated collision geometry.

Definition at line 1847 of file eggLoader.cxx.

References _error, EggPrimitive::begin(), EggPrimitive::const_iterator, DCAST, EggPrimitive::empty(), EggPrimitive::end(), Namable::get_name(), EggNode::get_vertex_to_node(), EggGroupNode::iterator, LCAST, PT, EggPolygon::triangulate_into(), and Vertexd.

Referenced by make_collision_plane().

ConstPointerTo< RenderAttrib > EggLoader::get_material_attrib (  const EggMaterial *  egg_mat,
bool  bface
)  [private]
 

Returns a RenderAttrib suitable for enabling the material indicated by the given EggMaterial, and with the indicated backface flag.

Definition at line 918 of file eggLoader.cxx.

ConstPointerTo< RenderAttrib > EggLoader::get_texture_apply_attributes (  const EggTexture *  egg_tex  )  [private]
 

Definition at line 877 of file eggLoader.cxx.

References _materials, _materials_bface, EggMaterial::get_amb(), EggMaterial::get_diff(), EggMaterial::get_emit(), EggMaterial::get_shininess(), EggMaterial::get_spec(), EggMaterial::has_amb(), EggMaterial::has_diff(), EggMaterial::has_emit(), EggMaterial::has_local(), EggMaterial::has_shininess(), EggMaterial::has_spec(), and PT.

bool EggLoader::load_texture (  TextureDef &  def,
const EggTexture *  egg_tex
)  [private]
 

Definition at line 501 of file eggLoader.cxx.

References EggTexture::F_rgb332, EggTexture::F_rgb5, EggTexture::F_rgb8, EggTexture::F_rgba, EggTexture::F_rgba12, EggTexture::F_rgba4, EggTexture::F_rgba5, EggTexture::F_rgba8, EggTexture::F_rgbm, and EggTexture::F_unspecified.

void EggLoader::load_textures (   )  [private]
 

Definition at line 458 of file eggLoader.cxx.

Referenced by EggLoader().

void EggLoader::make_collision_plane (  EggGroup *  egg_group,
CollisionNode *  cnode,
EggGroup::CollideFlags  flags
)  [private]
 

Creates a single CollisionPlane corresponding to the first polygon associated with this group.

Definition at line 1663 of file eggLoader.cxx.

References EggPrimitive::begin(), EggGroupNode::begin(), EggPrimitive::const_iterator, EggGroupNode::const_iterator, DCAST, EggPrimitive::end(), EggGroupNode::end(), find_collision_geometry(), EggPrimitive::get_class_type(), and NULL.

void EggLoader::make_collision_polygon (  EggGroup *  egg_group,
CollisionNode *  cnode,
EggGroup::CollideFlags  flags
)  [private]
 

Creates a single CollisionPolygon corresponding to the first polygon associated with this group.

Definition at line 1693 of file eggLoader.cxx.

References EggVertex::get_pos3().

void EggLoader::make_collision_polyset (  EggGroup *  egg_group,
CollisionNode *  cnode,
EggGroup::CollideFlags  flags
)  [private]
 

Creates a series of CollisionPolygons corresponding to the polygons associated with this group.

Definition at line 1719 of file eggLoader.cxx.

void EggLoader::make_collision_solids (  EggGroup *  start_group,
EggGroup *  egg_group,
CollisionNode *  cnode
)  [private]
 

Creates CollisionSolids corresponding to the collision geometry indicated at the given node and below.

Definition at line 1604 of file eggLoader.cxx.

References EggGroupNode::const_iterator, and NULL.

Referenced by make_node().

void EggLoader::make_collision_sphere (  EggGroup *  egg_group,
CollisionNode *  cnode,
EggGroup::CollideFlags  flags
)  [private]
 

Creates a single CollisionSphere corresponding to the polygons associated with this group.

Definition at line 1744 of file eggLoader.cxx.

References EggGroup::CF_intangible, and CollisionSolid::set_tangible().

void EggLoader::make_indexed_primitive (  EggPrimitive *  egg_prim,
PandaNode *  parent,
const LMatrix4d *  transform,
ComputedVerticesMaker &  _comp_verts_maker
) 
 

Definition at line 326 of file eggLoader.cxx.

PandaNode * EggLoader::make_node (  EggGroupNode *  egg_group,
PandaNode *  parent
)  [private]
 

Definition at line 1579 of file eggLoader.cxx.

PandaNode * EggLoader::make_node (  EggTable *  egg_table,
PandaNode *  parent
)  [private]
 

Definition at line 1555 of file eggLoader.cxx.

References _error, EggGroup::CST_inverse_sphere, EggGroup::CST_plane, EggGroup::CST_polygon, EggGroup::CST_polyset, and EggGroup::CST_sphere.

PandaNode * EggLoader::make_node (  EggGroup *  egg_group,
PandaNode *  parent
)  [private]
 

Definition at line 1373 of file eggLoader.cxx.

PandaNode * EggLoader::make_node (  EggBin *  egg_bin,
PandaNode *  parent
)  [private]
 

Definition at line 1321 of file eggLoader.cxx.

References EggGroupNode::begin(), EggGroup::CF_keep, EggGroupNode::const_iterator, create_group_arc(), EggGroup::CST_geode, EggGroup::CST_none, EggGroup::DT_none, egg_show_collision_solids, EggGroupNode::end(), expand_object_types(), EggGroup::get_collide_flags(), EggGroup::get_cs_type(), EggGroup::get_dart_type(), Namable::get_name(), EggGroup::get_num_object_types(), EggGroup::get_switch_flag(), EggGroup::get_switch_fps(), make_collision_solids(), make_node(), CharacterMaker::make_node(), NULL, PT, and PandaNode::set_draw_mask().

PandaNode * EggLoader::make_node (  EggPrimitive *  egg_prim,
PandaNode *  parent
)  [private]
 

Definition at line 1289 of file eggLoader.cxx.

References EggGroupNode::const_iterator.

PandaNode * EggLoader::make_node (  EggNurbsCurve *  egg_curve,
PandaNode *  parent
)  [private]
 

Definition at line 1208 of file eggLoader.cxx.

PandaNode * EggLoader::make_node (  EggNode *  egg_node,
PandaNode *  parent
)  [private]
 

Definition at line 1182 of file eggLoader.cxx.

References _error, and NULL.

Referenced by make_node().

void EggLoader::make_nonindexed_primitive (  EggPrimitive *  egg_prim,
PandaNode *  parent,
const LMatrix4d *  transform = NULL
) 
 

Definition at line 243 of file eggLoader.cxx.

ConstPointerTo< TransformState > EggLoader::make_transform (  const EggTransform3d *  egg_transform  )  [private]
 

Walks back over the tree and applies the DeferredNodeProperties that were saved up along the way.

Definition at line 2204 of file eggLoader.cxx.

void EggLoader::reparent_decals (   ) 
 

For each node representing a decal base geometry (i.e.

a node corresponding to an EggGroup with the decal flag set), move all of its nested geometry directly below the GeomNode representing the group.

Definition at line 179 of file eggLoader.cxx.

References _error, Namable::get_name(), NodePath::is_empty(), and NodePath::node().

void EggLoader::setup_bucket (  BuilderBucket &  bucket,
PandaNode *  parent,
EggPrimitive *  egg_prim
)  [private]
 

Definition at line 974 of file eggLoader.cxx.

References EggRenderMode::DepthTestMode, EggRenderMode::DTM_unspecified, and NULL.


Member Data Documentation

Builder EggLoader::_builder [private]
 

Definition at line 143 of file eggLoader.h.

Referenced by build_graph().

EggData EggLoader::_data
 

Definition at line 159 of file eggLoader.h.

Referenced by build_graph(), and EggLoader().

Decals EggLoader::_decals [private]
 

Definition at line 153 of file eggLoader.h.

DeferredNodes EggLoader::_deferred_nodes [private]
 

Definition at line 155 of file eggLoader.h.

Referenced by EggLoader().

bool EggLoader::_error
 

Definition at line 160 of file eggLoader.h.

Referenced by create_collision_polygons(), EggLoader(), find_collision_geometry(), make_node(), and reparent_decals().

Materials EggLoader::_materials [private]
 

Definition at line 149 of file eggLoader.h.

Referenced by get_texture_apply_attributes().

Materials EggLoader::_materials_bface [private]
 

Definition at line 150 of file eggLoader.h.

Referenced by get_texture_apply_attributes().

PointerTo< PandaNode > EggLoader::_root
 

Definition at line 158 of file eggLoader.h.

Referenced by build_graph().

Textures EggLoader::_textures [private]
 

Definition at line 146 of file eggLoader.h.


The documentation for this class was generated from the following files:
Generated on Fri May 2 00:50:05 2003 for Panda by doxygen1.3