Panda3D
xFileToEggConverter.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file xFileToEggConverter.h
10  * @author drose
11  * @date 2001-06-21
12  */
13 
14 #ifndef XFILETOEGGCONVERTER_H
15 #define XFILETOEGGCONVERTER_H
16 
17 #include "pandatoolbase.h"
18 #include "xFileAnimationSet.h"
19 #include "xFile.h"
21 #include "eggTextureCollection.h"
22 #include "eggMaterialCollection.h"
23 #include "pvector.h"
24 #include "pmap.h"
25 #include "luse.h"
26 #include "pointerTo.h"
27 
28 class Datagram;
29 class XFileMesh;
30 class XFileMaterial;
31 class EggGroup;
32 class EggGroupNode;
33 class EggTexture;
34 class EggMaterial;
35 class XFileDataObject;
36 
37 /**
38  *
39  */
41 public:
45 
47 
48  virtual std::string get_name() const;
49  virtual std::string get_extension() const;
50  virtual bool supports_compressed() const;
51 
52  virtual bool convert_file(const Filename &filename);
53  void close();
54 
55  EggGroup *get_dart_node() const;
56 
59  EggGroup *find_joint(const std::string &joint_name);
60  void strip_nodes(TypeHandle t);
61 
62 public:
63  bool _make_char;
64  std::string _char_name;
65  double _frame_rate;
66  bool _keep_model;
67  bool _keep_animation;
68 
69 private:
71 
72  bool get_toplevel();
73  bool convert_toplevel_object(XFileDataNode *obj, EggGroupNode *egg_parent);
74  bool convert_object(XFileDataNode *obj, EggGroupNode *egg_parent);
75  bool convert_frame(XFileDataNode *obj, EggGroupNode *egg_parent);
76  bool convert_transform(XFileDataNode *obj, EggGroupNode *egg_parent);
77  bool convert_animation_set(XFileDataNode *obj);
78  bool convert_animation_set_object(XFileDataNode *obj,
79  XFileAnimationSet &animation_set);
80  bool convert_animation(XFileDataNode *obj,
81  XFileAnimationSet &animation_set);
82  bool convert_animation_object(XFileDataNode *obj,
83  const std::string &joint_name, FrameData &table);
84  bool convert_animation_key(XFileDataNode *obj, const std::string &joint_name,
85  FrameData &table);
86  bool set_animation_frame(const std::string &joint_name, FrameData &table,
87  int frame, int key_type,
88  const XFileDataObject &values);
89  bool convert_mesh(XFileDataNode *obj, EggGroupNode *egg_parent);
90 
91  bool create_polygons();
92  bool create_hierarchy();
93 
94  PT(XFile) _x_file;
95 
96  bool _any_frames;
97  bool _any_animation;
98  int _ticks_per_second;
99  int _total_tick_deltas;
100  int _num_ticks;
101 
103  Meshes _meshes;
104 
106  AnimationSets _animation_sets;
107 
109  Joints _joints;
110 
111  EggGroup *_dart_node;
112 
113  EggTextureCollection _textures;
114  EggMaterialCollection _materials;
115 };
116 
117 #endif
XFileToEggConverter
Definition: xFileToEggConverter.h:40
pvector< XFileMesh * >
XFileDataObject
The abstract base class for a number of different types of data elements that may be stored in the X ...
Definition: xFileDataObject.h:30
XFileToEggConverter::make_copy
virtual SomethingToEggConverter * make_copy()
Allocates and returns a new copy of the converter.
Definition: xFileToEggConverter.cxx:67
EggMaterialCollection
This is a collection of materials by MRef name.
Definition: eggMaterialCollection.h:30
pvector.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
xFile.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pmap< std::string, EggGroup * >
EggMaterial
Definition: eggMaterial.h:26
EggGroupNode
A base class for nodes in the hierarchy that are not leaf nodes.
Definition: eggGroupNode.h:46
XFile
This represents the complete contents of an X file (file.x) in memory.
Definition: xFile.h:32
XFileMesh
This is a collection of polygons; i.e.
Definition: xFileMesh.h:45
XFileToEggConverter::convert_file
virtual bool convert_file(const Filename &filename)
Handles the reading of the input file and converting it to egg.
Definition: xFileToEggConverter.cxx:106
Datagram
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
pmap.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
eggTextureCollection.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
somethingToEggConverter.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
XFileToEggConverter::strip_nodes
void strip_nodes(TypeHandle t)
Removes all groups of the given type.
Definition: xFileToEggConverter.cxx:180
SomethingToEggConverter
This is a base class for a family of converter classes that manage a conversion from some file type t...
Definition: somethingToEggConverter.h:38
luse.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
XFileToEggConverter::close
void close()
Finalizes and closes the file previously opened via convert_file().
Definition: xFileToEggConverter.cxx:156
XFileToEggConverter::create_unique_texture
EggTexture * create_unique_texture(const EggTexture &copy)
Returns an EggTexture pointer whose properties match that of the the given EggTexture,...
Definition: xFileToEggConverter.cxx:208
XFileToEggConverter::find_joint
EggGroup * find_joint(const std::string &joint_name)
This is called by set_animation_frame, for the purposes of building the frame data for the animation–...
Definition: xFileToEggConverter.cxx:227
xFileAnimationSet.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
EggTexture
Defines a texture map that may be applied to geometry.
Definition: eggTexture.h:30
XFileAnimationSet::FrameData
Definition: xFileAnimationSet.h:61
pandatoolbase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
XFileToEggConverter::get_name
virtual std::string get_name() const
Returns the English name of the file type this converter supports.
Definition: xFileToEggConverter.cxx:76
XFileDataNode
This is an abstract base class for an XFileNode which is also an XFileDataObject.
Definition: xFileDataNode.h:33
XFileAnimationSet
This represents a tree of EggTables, corresponding to Animation entries in the X file.
Definition: xFileAnimationSet.h:33
XFileToEggConverter::create_unique_material
EggMaterial * create_unique_material(const EggMaterial &copy)
Returns an EggMaterial pointer whose properties match that of the the given EggMaterial,...
Definition: xFileToEggConverter.cxx:217
XFileMaterial
This represents an X file "material", which consists of a color, lighting, and/or texture specificati...
Definition: xFileMaterial.h:31
EggGroup
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
Definition: eggGroup.h:34
eggMaterialCollection.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
EggTextureCollection
This is a collection of textures by TRef name.
Definition: eggTextureCollection.h:30
XFileToEggConverter::supports_compressed
virtual bool supports_compressed() const
Returns true if this file type can transparently load compressed files (with a .pz extension),...
Definition: xFileToEggConverter.cxx:93
XFileToEggConverter::get_extension
virtual std::string get_extension() const
Returns the common extension of the file type this converter supports.
Definition: xFileToEggConverter.cxx:84
Filename
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
XFileToEggConverter::get_dart_node
EggGroup * get_dart_node() const
Returns the root of the joint hierarchy, if _make_char is true, or NULL otherwise.
Definition: xFileToEggConverter.cxx:199