Panda3D

bamToEgg.h

00001 // Filename: bamToEgg.h
00002 // Created by:  drose (25Jun01)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef BAMTOEGG_H
00016 #define BAMTOEGG_H
00017 
00018 #include "pandatoolbase.h"
00019 
00020 #include "somethingToEgg.h"
00021 #include "luse.h"
00022 #include "eggTextureCollection.h"
00023 #include "eggMaterialCollection.h"
00024 
00025 class WorkingNodePath;
00026 class EggGroup;
00027 class EggGroupNode;
00028 class EggVertexPool;
00029 class EggTexture;
00030 class LODNode;
00031 class SequenceNode;
00032 class SwitchNode;
00033 class AnimBundleNode;
00034 class AnimGroup;
00035 class Character;
00036 class PartGroup;
00037 class CollisionNode;
00038 class GeomNode;
00039 class GeomVertexData;
00040 class GeomPrimitive;
00041 class PandaNode;
00042 class RenderState;
00043 class Texture;
00044 class CharacterJoint;
00045 class EggVertex;
00046 
00047 typedef pmap<const CharacterJoint*, pvector<pair<EggVertex*,PN_stdfloat> > > CharacterJointMap;
00048 
00049 ////////////////////////////////////////////////////////////////////
00050 //       Class : BamToEgg
00051 // Description : This program reads a bam file, for instance as
00052 //               written out from a real-time interaction session, and
00053 //               generates a corresponding egg file.
00054 ////////////////////////////////////////////////////////////////////
00055 class BamToEgg : public SomethingToEgg {
00056 public:
00057   BamToEgg();
00058 
00059   void run();
00060 
00061 private:
00062   void convert_node(const WorkingNodePath &node_path, EggGroupNode *egg_parent,
00063                     bool has_decal);
00064   void convert_lod_node(LODNode *node, const WorkingNodePath &node_path,
00065                         EggGroupNode *egg_parent, bool has_decal);
00066   void convert_sequence_node(SequenceNode *node, const WorkingNodePath &node_path,
00067                         EggGroupNode *egg_parent, bool has_decal);
00068   void convert_switch_node(SwitchNode *node, const WorkingNodePath &node_path,
00069                         EggGroupNode *egg_parent, bool has_decal);
00070   EggGroupNode *convert_animGroup_node(AnimGroup *animGroup, double fps );
00071   void convert_anim_node(AnimBundleNode *node, const WorkingNodePath &node_path,
00072                         EggGroupNode *egg_parent, bool has_decal);
00073   void convert_character_node(Character *node, const WorkingNodePath &node_path,
00074                         EggGroupNode *egg_parent, bool has_decal);
00075   void convert_character_bundle(PartGroup *bundleNode, EggGroupNode *egg_parent, CharacterJointMap *jointMap);
00076   void convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path,
00077                         EggGroupNode *egg_parent, bool has_decal);
00078   void convert_geom_node(GeomNode *node, const WorkingNodePath &node_path, 
00079                          EggGroupNode *egg_parent, bool has_decal, CharacterJointMap *jointMap=NULL);
00080   void convert_primitive(const GeomVertexData *vertex_data,
00081                          const GeomPrimitive *primitive, 
00082                          const RenderState *net_state, 
00083                          const LMatrix4 &net_mat, EggGroupNode *egg_parent,
00084                          CharacterJointMap *jointMap);
00085 
00086   void recurse_nodes(const WorkingNodePath &node_path, EggGroupNode *egg_parent,
00087                      bool has_decal);
00088   bool apply_node_properties(EggGroup *egg_group, PandaNode *node, bool allow_backstage = true);
00089   bool apply_tags(EggGroup *egg_group, PandaNode *node);
00090   bool apply_tag(EggGroup *egg_group, PandaNode *node, const string &tag);
00091 
00092   EggTexture *get_egg_texture(Texture *tex);
00093 
00094   static EggPrimitive *make_egg_polygon();
00095   static EggPrimitive *make_egg_point();
00096   static EggPrimitive *make_egg_line();
00097 
00098   EggVertexPool *_vpool;
00099   EggTextureCollection _textures;
00100   EggMaterialCollection _materials;
00101 };
00102 
00103 #endif
 All Classes Functions Variables Enumerations