Panda3D
fltToEggConverter.h
1 // Filename: fltToEggConverter.h
2 // Created by: drose (17Apr01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef FLTTOEGGCONVERTER_H
16 #define FLTTOEGGCONVERTER_H
17 
18 #include "pandatoolbase.h"
19 
20 #include "fltToEggLevelState.h"
21 #include "somethingToEggConverter.h"
22 #include "fltHeader.h"
23 #include "eggVertex.h"
24 #include "eggVertexPool.h"
25 #include "eggTexture.h"
26 #include "pt_EggTexture.h"
27 #include "pt_EggVertex.h"
28 #include "pointerTo.h"
29 #include "distanceUnit.h"
30 
31 class FltRecord;
32 class FltLOD;
33 class FltGroup;
34 class FltObject;
35 class FltBeadID;
36 class FltBead;
37 class FltVertex;
38 class FltGeometry;
39 class FltFace;
41 class FltTexture;
42 class EggGroupNode;
43 class EggPrimitive;
44 
45 ////////////////////////////////////////////////////////////////////
46 // Class : FltToEggConverter
47 // Description : This class supervises the construction of an EggData
48 // structure from the data represented by the FltHeader.
49 // Reading and writing the egg and flt structures is
50 // left to the user.
51 ////////////////////////////////////////////////////////////////////
53 public:
57 
59 
60  virtual string get_name() const;
61  virtual string get_extension() const;
62  virtual bool supports_compressed() const;
63 
64  virtual bool convert_file(const Filename &filename);
65  virtual DistanceUnit get_input_units();
66  bool convert_flt(const FltHeader *flt_header);
67 
68  // Set this true to store transforms in egg files as the fully
69  // composed matrix, or false (the default) to keep them decomposed
70  // into elemental operations.
71  bool _compose_transforms;
72 
73 private:
74  void cleanup();
75 
77 
78  void convert_record(const FltRecord *flt_record, FltToEggLevelState &state);
79  void dispatch_record(const FltRecord *flt_record, FltToEggLevelState &state);
80  void convert_lod(const FltLOD *flt_lod, FltToEggLevelState &state);
81  void convert_group(const FltGroup *flt_group, FltToEggLevelState &state);
82  void convert_object(const FltObject *flt_object, FltToEggLevelState &state);
83  void convert_bead_id(const FltBeadID *flt_bead, FltToEggLevelState &state);
84  void convert_bead(const FltBead *flt_bead, FltToEggLevelState &state);
85  void convert_face(const FltFace *flt_face, FltToEggLevelState &state);
86  void convert_ext_ref(const FltExternalReference *flt_ext, FltToEggLevelState &state);
87 
88  void setup_geometry(const FltGeometry *flt_geom, FltToEggLevelState &state,
89  EggPrimitive *egg_prim, EggVertexPool *egg_vpool,
90  const EggVertices &vertices);
91 
92  void convert_subfaces(const FltRecord *flt_record, FltToEggLevelState &state);
93 
94  bool parse_comment(const FltBeadID *flt_bead, EggNode *egg_node);
95  bool parse_comment(const FltBead *flt_bead, EggNode *egg_node);
96  bool parse_comment(const FltTexture *flt_texture, EggNode *egg_node);
97  bool parse_comment(const string &comment, const string &name,
98  EggNode *egg_node);
99 
100  PT_EggVertex make_egg_vertex(const FltVertex *flt_vertex);
101  PT_EggTexture make_egg_texture(const FltTexture *flt_texture);
102 
103  CPT(FltHeader) _flt_header;
104  DistanceUnit _flt_units;
105 
106  PT(EggVertexPool) _main_egg_vpool;
107 
109  Textures _textures;
110 };
111 
112 #include "fltToEggConverter.I"
113 
114 #endif
115 
116 
A base class for any of a number of kinds of geometry primitives: polygons, point lights...
Definition: eggPrimitive.h:51
virtual bool supports_compressed() const
Returns true if this file type can transparently load compressed files (with a .pz extension)...
A base class for any of a broad family of flt beads that include an ID.
Definition: fltBeadID.h:27
A base class for nodes in the hierarchy that are not leaf nodes.
Definition: eggGroupNode.h:51
The main grouping bead of the flt file.
Definition: fltGroup.h:26
A base class for any of a broad family of flt records that represent particular beads in the hierarch...
Definition: fltBead.h:33
A single face bead, e.g.
Definition: fltFace.h:26
This class supervises the construction of an EggData structure from the data represented by the FltHe...
This is a base class for both FltFace and FltMesh, which are two different kinds of geometric primiti...
Definition: fltGeometry.h:36
This is the first bead in the file, the top of the bead hierarchy, and the primary interface to readi...
Definition: fltHeader.h:48
virtual string get_name() const
Returns the English name of the file type this converter supports.
This keeps track of relevant things about the traversal as we walk through the flt hierarchy...
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:39
virtual DistanceUnit get_input_units()
This may be called after convert_file() has been called and returned true, indicating a successful co...
Represents a single texture in the texture palette.
Definition: fltTexture.h:29
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
The base class for all kinds of records in a MultiGen OpenFlight file.
Definition: fltRecord.h:40
Represents a single vertex in the vertex palette.
Definition: fltVertex.h:35
An external reference to another flt file (possibly to a specific bead within the flt file)...
virtual string get_extension() const
Returns the common extension of the file type this converter supports.
The main objecting bead of the flt file.
Definition: fltObject.h:26
bool convert_flt(const FltHeader *flt_header)
Fills up the egg_data structure according to the indicated lwo structure.
A base class for things that may be directly added into the egg hierarchy.
Definition: eggNode.h:38
virtual SomethingToEggConverter * make_copy()
Allocates and returns a new copy of the converter.
virtual bool convert_file(const Filename &filename)
Handles the reading of the input file and converting it to egg.
A Level-of-Detail record.
Definition: fltLOD.h:26
This is a base class for a family of converter classes that manage a conversion from some file type t...
A collection of vertices.
Definition: eggVertexPool.h:46