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
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
EggGroup * get_dart_node() const
Returns the root of the joint hierarchy, if _make_char is true, or NULL otherwise.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void close()
Finalizes and closes the file previously opened via convert_file().
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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:46
This is a collection of materials by MRef name.
Defines a texture map that may be applied to geometry.
Definition: eggTexture.h:30
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual std::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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
EggMaterial * create_unique_material(const EggMaterial &copy)
Returns an EggMaterial pointer whose properties match that of the the given EggMaterial,...
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
Definition: eggGroup.h:34
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:39
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual std::string get_extension() const
Returns the common extension of the file type this converter supports.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This represents an X file "material", which consists of a color, lighting, and/or texture specificati...
Definition: xFileMaterial.h:31
This is an abstract base class for an XFileNode which is also an XFileDataObject.
Definition: xFileDataNode.h:33
This represents the complete contents of an X file (file.x) in memory.
Definition: xFile.h:32
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–...
EggTexture * create_unique_texture(const EggTexture &copy)
Returns an EggTexture pointer whose properties match that of the the given EggTexture,...
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
An ordered list of data elements, formatted in memory for transmission over a socket or writing to a ...
Definition: datagram.h:38
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.