Panda3D
xFileToEggConverter.h
1 // Filename: xFileToEggConverter.h
2 // Created by: drose (21Jun01)
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 XFILETOEGGCONVERTER_H
16 #define XFILETOEGGCONVERTER_H
17 
18 #include "pandatoolbase.h"
19 #include "xFileAnimationSet.h"
20 #include "xFile.h"
21 #include "somethingToEggConverter.h"
22 #include "eggTextureCollection.h"
23 #include "eggMaterialCollection.h"
24 #include "pvector.h"
25 #include "pmap.h"
26 #include "luse.h"
27 #include "pointerTo.h"
28 
29 class Datagram;
30 class XFileMesh;
31 class XFileMaterial;
32 class EggGroup;
33 class EggGroupNode;
34 class EggTexture;
35 class EggMaterial;
36 class XFileDataObject;
37 
38 ////////////////////////////////////////////////////////////////////
39 // Class : XFileToEggConverter
40 // Description :
41 ////////////////////////////////////////////////////////////////////
43 public:
47 
49 
50  virtual string get_name() const;
51  virtual string get_extension() const;
52  virtual bool supports_compressed() const;
53 
54  virtual bool convert_file(const Filename &filename);
55  void close();
56 
57  EggGroup *get_dart_node() const;
58 
61  EggGroup *find_joint(const string &joint_name);
62  void strip_nodes(TypeHandle t);
63 
64 public:
65  bool _make_char;
66  string _char_name;
67  double _frame_rate;
68  bool _keep_model;
69  bool _keep_animation;
70 
71 private:
73 
74  bool get_toplevel();
75  bool convert_toplevel_object(XFileDataNode *obj, EggGroupNode *egg_parent);
76  bool convert_object(XFileDataNode *obj, EggGroupNode *egg_parent);
77  bool convert_frame(XFileDataNode *obj, EggGroupNode *egg_parent);
78  bool convert_transform(XFileDataNode *obj, EggGroupNode *egg_parent);
79  bool convert_animation_set(XFileDataNode *obj);
80  bool convert_animation_set_object(XFileDataNode *obj,
81  XFileAnimationSet &animation_set);
82  bool convert_animation(XFileDataNode *obj,
83  XFileAnimationSet &animation_set);
84  bool convert_animation_object(XFileDataNode *obj,
85  const string &joint_name, FrameData &table);
86  bool convert_animation_key(XFileDataNode *obj, const string &joint_name,
87  FrameData &table);
88  bool set_animation_frame(const string &joint_name, FrameData &table,
89  int frame, int key_type,
90  const XFileDataObject &values);
91  bool convert_mesh(XFileDataNode *obj, EggGroupNode *egg_parent);
92 
93  bool create_polygons();
94  bool create_hierarchy();
95 
96  PT(XFile) _x_file;
97 
98  bool _any_frames;
99  bool _any_animation;
100  int _ticks_per_second;
101  int _total_tick_deltas;
102  int _num_ticks;
103 
105  Meshes _meshes;
106 
108  AnimationSets _animation_sets;
109 
111  Joints _joints;
112 
113  EggGroup *_dart_node;
114 
115  EggTextureCollection _textures;
116  EggMaterialCollection _materials;
117 };
118 
119 #endif
EggGroup * get_dart_node() const
Returns the root of the joint hierarchy, if _make_char is true, or NULL otherwise.
EggGroup * find_joint(const string &joint_name)
This is called by set_animation_frame, for the purposes of building the frame data for the animationâ€...
void close()
Finalizes and closes the file previously opened via convert_file().
This is a collection of polygons; i.e.
Definition: xFileMesh.h:45
virtual bool supports_compressed() const
Returns true if this file type can transparently load compressed files (with a .pz extension)...
A base class for nodes in the hierarchy that are not leaf nodes.
Definition: eggGroupNode.h:51
This is a collection of materials by MRef name.
Defines a texture map that may be applied to geometry.
Definition: eggTexture.h:33
virtual string get_name() const
Returns the English name of the file type this converter supports.
This represents a tree of EggTables, corresponding to Animation entries in the X file.
This is a collection of textures by TRef name.
EggMaterial * create_unique_material(const EggMaterial &copy)
Returns an EggMaterial pointer whose properties match that of the the given EggMaterial, except for the mref name.
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
Definition: eggGroup.h:36
void strip_nodes(TypeHandle t)
Removes all groups of the given type.
virtual bool convert_file(const Filename &filename)
Handles the reading of the input file and converting it to egg.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
virtual string get_extension() const
Returns the common extension of the file type this converter supports.
This represents an X file "material", which consists of a color, lighting, and/or texture specificati...
Definition: xFileMaterial.h:33
This is an abstract base class for an XFileNode which is also an XFileDataObject. ...
Definition: xFileDataNode.h:36
This represents the complete contents of an X file (file.x) in memory.
Definition: xFile.h:35
EggTexture * create_unique_texture(const EggTexture &copy)
Returns an EggTexture pointer whose properties match that of the the given EggTexture, except for the tref name.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:43
This is a base class for a family of converter classes that manage a conversion from some file type t...
The abstract base class for a number of different types of data elements that may be stored in the X ...
virtual SomethingToEggConverter * make_copy()
Allocates and returns a new copy of the converter.