Panda3D
 All Classes Functions Variables Enumerations
fltToEggConverter.h
00001 // Filename: fltToEggConverter.h
00002 // Created by:  drose (17Apr01)
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 FLTTOEGGCONVERTER_H
00016 #define FLTTOEGGCONVERTER_H
00017 
00018 #include "pandatoolbase.h"
00019 
00020 #include "fltToEggLevelState.h"
00021 #include "somethingToEggConverter.h"
00022 #include "fltHeader.h"
00023 #include "eggVertex.h"
00024 #include "eggVertexPool.h"
00025 #include "eggTexture.h"
00026 #include "pt_EggTexture.h"
00027 #include "pt_EggVertex.h"
00028 #include "pointerTo.h"
00029 #include "distanceUnit.h"
00030 
00031 class FltRecord;
00032 class FltLOD;
00033 class FltGroup;
00034 class FltObject;
00035 class FltBeadID;
00036 class FltBead;
00037 class FltVertex;
00038 class FltGeometry;
00039 class FltFace;
00040 class FltExternalReference;
00041 class FltTexture;
00042 class EggGroupNode;
00043 class EggPrimitive;
00044 
00045 ////////////////////////////////////////////////////////////////////
00046 //       Class : FltToEggConverter
00047 // Description : This class supervises the construction of an EggData
00048 //               structure from the data represented by the FltHeader.
00049 //               Reading and writing the egg and flt structures is
00050 //               left to the user.
00051 ////////////////////////////////////////////////////////////////////
00052 class FltToEggConverter : public SomethingToEggConverter {
00053 public:
00054   FltToEggConverter();
00055   FltToEggConverter(const FltToEggConverter &copy);
00056   ~FltToEggConverter();
00057 
00058   virtual SomethingToEggConverter *make_copy();
00059 
00060   virtual string get_name() const;
00061   virtual string get_extension() const;
00062   virtual bool supports_compressed() const;
00063 
00064   virtual bool convert_file(const Filename &filename);
00065   virtual DistanceUnit get_input_units();
00066   bool convert_flt(const FltHeader *flt_header);
00067 
00068   // Set this true to store transforms in egg files as the fully
00069   // composed matrix, or false (the default) to keep them decomposed
00070   // into elemental operations.
00071   bool _compose_transforms;
00072 
00073 private:
00074   void cleanup();
00075 
00076   typedef pvector< PT_EggVertex > EggVertices;
00077 
00078   void convert_record(const FltRecord *flt_record, FltToEggLevelState &state);
00079   void dispatch_record(const FltRecord *flt_record, FltToEggLevelState &state);
00080   void convert_lod(const FltLOD *flt_lod, FltToEggLevelState &state);
00081   void convert_group(const FltGroup *flt_group, FltToEggLevelState &state);
00082   void convert_object(const FltObject *flt_object, FltToEggLevelState &state);
00083   void convert_bead_id(const FltBeadID *flt_bead, FltToEggLevelState &state);
00084   void convert_bead(const FltBead *flt_bead, FltToEggLevelState &state);
00085   void convert_face(const FltFace *flt_face, FltToEggLevelState &state);
00086   void convert_ext_ref(const FltExternalReference *flt_ext, FltToEggLevelState &state);
00087 
00088   void setup_geometry(const FltGeometry *flt_geom, FltToEggLevelState &state,
00089                       EggPrimitive *egg_prim, EggVertexPool *egg_vpool,
00090                       const EggVertices &vertices);
00091 
00092   void convert_subfaces(const FltRecord *flt_record, FltToEggLevelState &state);
00093 
00094   bool parse_comment(const FltBeadID *flt_bead, EggNode *egg_node);
00095   bool parse_comment(const FltBead *flt_bead, EggNode *egg_node);
00096   bool parse_comment(const FltTexture *flt_texture, EggNode *egg_node);
00097   bool parse_comment(const string &comment, const string &name,
00098                      EggNode *egg_node);
00099 
00100   PT_EggVertex make_egg_vertex(const FltVertex *flt_vertex);
00101   PT_EggTexture make_egg_texture(const FltTexture *flt_texture);
00102 
00103   CPT(FltHeader) _flt_header;
00104   DistanceUnit _flt_units;
00105 
00106   PT(EggVertexPool) _main_egg_vpool;
00107 
00108   typedef pmap<const FltTexture *, PT(EggTexture) > Textures;
00109   Textures _textures;
00110 };
00111 
00112 #include "fltToEggConverter.I"
00113 
00114 #endif
00115 
00116 
 All Classes Functions Variables Enumerations