Panda3D
softToEggConverter.h
1 // Filename: softToEggConverter.h
2 // Created by: masad (25Sep03)
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 SOFTTOEGGCONVERTER_H
16 #define SOFTTOEGGCONVERTER_H
17 
18 #include "pandatoolbase.h"
19 #include "somethingToEggConverter.h"
20 #include "softNodeTree.h"
21 
22 #include "eggTextureCollection.h"
23 #include "distanceUnit.h"
24 #include "coordinateSystem.h"
25 
26 #ifdef _MIN
27 #undef _MIN
28 #endif
29 #ifdef _MAX
30 #undef _MAX
31 #endif
32 
33 #include <SAA.h>
34 #include <SI_macros.h>
35 
36 class EggData;
37 class EggGroup;
38 class EggTable;
39 class EggVertexPool;
40 class EggNurbsCurve;
41 class EggPrimitive;
42 class EggXfmSAnim;
43 class EggSAnimData;
44 
45 
46 ////////////////////////////////////////////////////////////////////
47 // Class : SoftToEggConverter
48 // Description : This class supervises the construction of an EggData
49 // structure from a single Softimage file, or from the data
50 // already in th cout << "egg name = " << eggFilename << endl;e global Softimage model space.
51 //
52 ////////////////////////////////////////////////////////////////////
54 public:
55  SoftToEggConverter(const string &program_name = "");
57  virtual ~SoftToEggConverter();
58 
59  void Help();
60  void Usage();
61  void ShowOpts();
62 
63  bool HandleGetopts(int &idx, int argc, char **argv);
64  bool DoGetopts(int &argc, char **&argv);
65 
66  SoftNodeDesc *find_node(string name);
67  int *FindClosestTriVert( EggVertexPool *vpool, SAA_DVector *vertices, int numVert );
68 
70  virtual string get_name() const;
71  virtual string get_extension() const;
72 
73  virtual bool convert_file(const Filename &filename);
74  bool convert_soft(bool from_selection);
75  bool open_api();
76  void close_api();
77 
78 private:
79  bool convert_flip(double start_frame, double end_frame,
80  double frame_inc, double output_frame_rate);
81 
82  bool make_soft_skin();
83  bool cleanup_soft_skin();
84  bool convert_char_chan();
85  bool convert_char_model();
86  bool convert_hierarchy(EggGroupNode *egg_root);
87  bool process_model_node(SoftNodeDesc *node_desc);
88 
89  void make_polyset(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type);
90  void make_nurb_surface(SoftNodeDesc *node_desc, EggGroup *egg_group, SAA_ModelType type);
91  void add_knots( vector <double> &eggKnots, double *knots, int numKnots, SAA_Boolean closed, int degree );
92 
93  void set_shader_attributes(SoftNodeDesc *node_desc, EggPrimitive &primitive, int idx);
94  void apply_texture_properties(EggTexture &tex, int uRepeat, int vRepeat);
95 
96  bool reparent_decals(EggGroupNode *egg_parent);
97 
98  string _program_name;
99  bool _from_selection;
100 
101  SI_Error result;
102  SAA_Elem model;
103  SAA_Database database;
104 
105 public:
106 
107  SoftNodeTree _tree;
108 
109  SAA_Scene scene;
110 
111  char *_getopts;
112 
113  // This is argv[0].
114  const char *_commandName;
115 
116  // This is the entire command line.
117  char _commandLine[4096];
118 
119  char *rsrc_path;
120  char *database_name;
121  char *scene_name;
122  char *model_name;
123  char *eggFileName;
124  char *animFileName;
125  char *eggGroupName;
126  char *tex_path;
127  char *tex_filename;
128  char *search_prefix;
129 
130  int nurbs_step;
131  int anim_start;
132  int anim_end;
133  int anim_rate;
134  int pose_frame;
135  int verbose;
136  int flatten;
137  int shift_textures;
138  int ignore_tex_offsets;
139  int use_prefix;
140 
141  bool foundRoot;
142  bool geom_as_joint;
143  bool make_anim;
144  bool make_nurbs;
145  bool make_poly;
146  bool make_soft;
147  bool make_morph;
148  bool make_duv;
149  bool make_dart;
150  bool has_morph;
151  bool make_pose;
152 
153 
154  char *GetTextureName( SAA_Scene *scene, SAA_Elem *texture );
155 
156  EggTextureCollection _textures;
157 
158  bool _polygon_output;
159  double _polygon_tolerance;
160 
161  enum TransformType {
162  TT_invalid,
163  TT_all,
164  TT_model,
165  TT_dcs,
166  TT_none,
167  };
168  TransformType _transform_type;
169 
170  static TransformType string_transform_type(const string &arg);
171 
173  MorphTable _morph_table;
174 
175  EggTable *morph_node;
176  EggSAnimData *find_morph_table(char *name);
177 };
178 
179 extern const int TEX_PER_MAT;
180 
181 #endif
A base class for any of a number of kinds of geometry primitives: polygons, point lights...
Definition: eggPrimitive.h:51
virtual string get_extension() const
Returns the common extension of the file type this converter supports.
bool open_api()
Attempts to open the Soft API if it was not already open, and returns true if successful, or false if there is an error.
virtual bool convert_file(const Filename &filename)
Handles the reading of the input file and converting it to egg.
void close_api()
Closes the Soft API, if it was previously opened.
A base class for nodes in the hierarchy that are not leaf nodes.
Definition: eggGroupNode.h:51
Defines a texture map that may be applied to geometry.
Definition: eggTexture.h:33
Corresponding to an <S$Anim> entry, this stores a single column of numbers, for instance for a morph ...
Definition: eggSAnimData.h:28
This is a collection of textures by TRef name.
void Help()
Displays the "what is this program" message, along with the usage message.
This is the primary interface into all the egg data, and the root of the egg file structure...
Definition: eggData.h:41
bool HandleGetopts(int &idx, int argc, char **argv)
increment idx based on what kind of option parsed Supported options are as follows: r:d:s:m:t:P:b:e:f...
Describes a complete tree of soft nodes for conversion.
Definition: softNodeTree.h:35
char * GetTextureName(SAA_Scene *scene, SAA_Elem *texture)
Given a texture element, return texture name with given tex_path.
EggSAnimData * find_morph_table(char *name)
Given a tablename, it either creates a new eggSAnimData structure (if doesn&#39;t exist) or locates it...
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
Definition: eggGroup.h:36
void ShowOpts()
Displays the valid options.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
int * FindClosestTriVert(EggVertexPool *vpool, SAA_DVector *vertices, int numVert)
Given an egg vertex pool, map each vertex therein to a vertex within an array of SAA model vertices o...
This corresponds to an <Xfm$Anim_S$> entry, which is a collection of up to nine <S$Anim> entries that...
Definition: eggXfmSAnim.h:33
Describes a single instance of a node aka element in the Soft scene graph, relating it to the corresp...
Definition: softNodeDesc.h:46
A parametric NURBS curve.
Definition: eggNurbsCurve.h:28
This corresponds to a.
Definition: eggTable.h:31
This class supervises the construction of an EggData structure from a single Softimage file...
virtual SomethingToEggConverter * make_copy()
Allocates and returns a new copy of the converter.
void Usage()
Displays the usage message.
bool DoGetopts(int &argc, char **&argv)
Calls getopt() to parse the command-line switches.
SoftNodeDesc * find_node(string name)
Returns the English name of the file type this converter supports.
virtual string get_name() const
Returns the English name of the file type this converter supports.
bool convert_soft(bool from_selection)
Fills up the egg_data structure according to the global soft model data.
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
static TransformType string_transform_type(const string &arg)
Returns the TransformType value corresponding to the indicated string, or TT_invalid.