00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef EGGLOADER_H
00020 #define EGGLOADER_H
00021
00022 #include "pandabase.h"
00023
00024 #include "deferredNodeProperty.h"
00025 #include "eggData.h"
00026 #include "eggTexture.h"
00027 #include "pt_EggTexture.h"
00028 #include "eggGroup.h"
00029 #include "eggMaterial.h"
00030 #include "pt_EggMaterial.h"
00031 #include "texture.h"
00032 #include "pandaNode.h"
00033 #include "pointerTo.h"
00034 #include "builder.h"
00035 #include "lmatrix.h"
00036 #include "indirectCompareTo.h"
00037 #include "textureAttrib.h"
00038 #include "eggTransform3d.h"
00039
00040 class EggNode;
00041 class EggBin;
00042 class EggTable;
00043 class EggNurbsCurve;
00044 class EggPrimitive;
00045 class EggPolygon;
00046 class EggMaterial;
00047 class ComputedVerticesMaker;
00048 class RenderRelation;
00049 class CollisionSolid;
00050 class CollisionNode;
00051 class CollisionPlane;
00052 class CollisionPolygon;
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 class EggLoader {
00063 public:
00064 EggLoader();
00065 EggLoader(const EggData &data);
00066
00067 void build_graph();
00068 void reparent_decals();
00069
00070 void make_nonindexed_primitive(EggPrimitive *egg_prim, PandaNode *parent,
00071 const LMatrix4d *transform = NULL);
00072
00073 void make_indexed_primitive(EggPrimitive *egg_prim, PandaNode *parent,
00074 const LMatrix4d *transform,
00075 ComputedVerticesMaker &_comp_verts_maker);
00076
00077 private:
00078 class TextureDef {
00079 public:
00080 CPT(RenderAttrib) _texture;
00081 CPT(RenderAttrib) _apply;
00082 };
00083
00084 void load_textures();
00085 bool load_texture(TextureDef &def, const EggTexture *egg_tex);
00086 void apply_texture_attributes(Texture *tex, const EggTexture *egg_tex);
00087 CPT(RenderAttrib) get_texture_apply_attributes(const EggTexture *egg_tex);
00088
00089 CPT(RenderAttrib) get_material_attrib(const EggMaterial *egg_mat,
00090 bool bface);
00091
00092 void setup_bucket(BuilderBucket &bucket, PandaNode *parent,
00093 EggPrimitive *egg_prim);
00094
00095 PandaNode *make_node(EggNode *egg_node, PandaNode *parent);
00096 PandaNode *make_node(EggNurbsCurve *egg_curve, PandaNode *parent);
00097 PandaNode *make_node(EggPrimitive *egg_prim, PandaNode *parent);
00098 PandaNode *make_node(EggBin *egg_bin, PandaNode *parent);
00099 PandaNode *make_node(EggGroup *egg_group, PandaNode *parent);
00100 PandaNode *create_group_arc(EggGroup *egg_group, PandaNode *parent,
00101 PandaNode *node);
00102 PandaNode *make_node(EggTable *egg_table, PandaNode *parent);
00103 PandaNode *make_node(EggGroupNode *egg_group, PandaNode *parent);
00104
00105 void make_collision_solids(EggGroup *start_group, EggGroup *egg_group,
00106 CollisionNode *cnode);
00107 void make_collision_plane(EggGroup *egg_group, CollisionNode *cnode,
00108 EggGroup::CollideFlags flags);
00109 void make_collision_polygon(EggGroup *egg_group, CollisionNode *cnode,
00110 EggGroup::CollideFlags flags);
00111 void make_collision_polyset(EggGroup *egg_group, CollisionNode *cnode,
00112 EggGroup::CollideFlags flags);
00113 void make_collision_sphere(EggGroup *egg_group, CollisionNode *cnode,
00114 EggGroup::CollideFlags flags);
00115 void apply_collision_flags(CollisionSolid *solid,
00116 EggGroup::CollideFlags flags);
00117 EggGroup *find_collision_geometry(EggGroup *egg_group);
00118 CollisionPlane *create_collision_plane(EggPolygon *egg_poly,
00119 EggGroup *parent_group);
00120 void create_collision_polygons(CollisionNode *cnode, EggPolygon *egg_poly,
00121 EggGroup *parent_group,
00122 EggGroup::CollideFlags flags);
00123
00124 void apply_deferred_nodes(PandaNode *node, const DeferredNodeProperty &prop);
00125 bool expand_object_types(EggGroup *egg_group, const pset<string> &expanded,
00126 const pvector<string> &expanded_history);
00127 bool do_expand_object_type(EggGroup *egg_group, const pset<string> &expanded,
00128 const pvector<string> &expanded_history,
00129 const string &object_type);
00130
00131 CPT(TransformState) make_transform(const EggTransform3d *egg_transform);
00132
00133 Builder _builder;
00134
00135 typedef pmap<PT_EggTexture, TextureDef> Textures;
00136 Textures _textures;
00137
00138 typedef pmap<CPT_EggMaterial, CPT(RenderAttrib) > Materials;
00139 Materials _materials;
00140 Materials _materials_bface;
00141
00142 typedef pset<PandaNode *> Decals;
00143 Decals _decals;
00144
00145 DeferredNodes _deferred_nodes;
00146
00147 public:
00148 PT(PandaNode) _root;
00149 EggData _data;
00150 bool _error;
00151 };
00152
00153
00154 #endif