Panda3D
maxToEggConverter.h
1 // Filename: maxToEggConverter.h
2 // Created by Corey Revilla and Ken Strickland (6/22/03)
3 // from mayaToEggConverter.cxx created by drose (10Nov99)
4 //
5 ////////////////////////////////////////////////////////////////////
6 //
7 // PANDA 3D SOFTWARE
8 // Copyright (c) Carnegie Mellon University. All rights reserved.
9 //
10 // All use of this software is subject to the terms of the revised BSD
11 // license. You should have received a copy of this license along
12 // with this source code in a file named "LICENSE."
13 //
14 ////////////////////////////////////////////////////////////////////
15 
16 #ifndef __maxToEggConverter__H
17 #define __maxToEggConverter__H
18 
19 #pragma conform(forScope, off)
20 
21 /* Error-Reporting Includes
22  */
23 #define MTEC Logger::ST_MAP_ME_TO_APP_SPECIFIC_SYSTEM4
24 
25 /* Helpful Defintions and Casts
26  */
27 #define null 0
28 #define PHYSIQUE_CLASSID Class_ID(PHYSIQUE_CLASS_ID_A, PHYSIQUE_CLASS_ID_B)
29 
30 /* External Helper Functions for UI
31  */
32 // *** Figure out why this is causing link errors
33 //DWORD WINAPI ProgressBarFunction(LPVOID arg);
34 
35 ////////////////////////////////////////////////////////////////////
36 // Class : MaxToEggConverter
37 // Description : This class supervises the construction of an EggData
38 // structure from a Max model
39 ////////////////////////////////////////////////////////////////////
41  public:
44 
45  bool convert(MaxEggOptions *options);
46 
47  private:
48  struct PandaMaterial {
49  std::vector<PT(EggTexture)> _texture_list;
50  LColor _color;
51  std::vector<int> _map_channels;
52  bool _any_diffuse;
53  bool _any_opacity;
54  bool _any_gloss;
55  bool _any_normal;
56  };
57  typedef std::map<Mtl*,PandaMaterial> MaterialMap;
58  MaxEggOptions *_options;
59  int _current_frame;
60  PT(EggData) _egg_data;
61  string _program_name;
62  MaxNodeTree _tree;
63  int _cur_tref;
64  EggTextureCollection _textures;
65  MaterialMap _material_map;
66 
67  void reset();
68 
69  bool convert_char_model();
70  bool convert_char_chan(double start_frame, double end_frame,
71  double frame_inc, double output_frame_rate);
72  bool convert_hierarchy(EggGroupNode *egg_root);
73  bool process_model_node(MaxNodeDesc *node_desc);
74 
75  void get_transform(INode *max_node, EggGroup *egg_group);
76  LMatrix4d get_object_transform(INode *max_node);
77  void get_joint_transform(INode *max_node, EggGroup *egg_group);
78  void get_joint_transform(INode *max_node, INode *parent_node,
79  EggGroup *egg_group);
80 
81  bool make_nurbs_curve(INode *max_node, NURBSCVCurve *curve,
82  TimeValue time, EggGroup *egg_group);
83  void make_polyset(INode *max_node,
84  Mesh *mesh,
85  EggGroup *egg_group,
86  Shader *default_shader = NULL);
87 
88  Point3 get_max_vertex_normal(Mesh *mesh, int faceNo, int vertNo);
89  VertColor get_max_vertex_color(Mesh *mesh, int FaceNo, int VertexNo);
90  VertColor get_max_vertex_color(Mesh *mesh,int FaceNo,int VertexNo, int channel);
91  UVVert get_max_vertex_texcoord(Mesh *mesh, int faceNo, int vertNo, int channel);
92 
93  void get_vertex_weights(INode *max_node, EggVertexPool *vpool);
94 
95  const PandaMaterial &get_panda_material(Mtl *mtl, MtlID id);
96  void analyze_diffuse_maps(PandaMaterial &pandaMat, Texmap *m);
97  void analyze_opacity_maps(PandaMaterial &pandaMat, Texmap *m);
98  void analyze_gloss_maps(PandaMaterial &pandaMat, Texmap *m);
99  void analyze_glow_maps(PandaMaterial &pandaMat, Texmap *m);
100  void analyze_normal_maps(PandaMaterial &pandaMat, Texmap *m);
101  void add_map_channel(PandaMaterial &pandaMat, int channel);
102  void apply_texture_properties(EggTexture &tex, int channel);
103  std::string generate_tex_name();
104  std::string get_uv_name(int n);
105  bool reparent_decals(EggGroupNode *egg_parent);
106 
107  public:
108 
109  Modifier* FindSkinModifier (INode* node, const Class_ID &type);
110 };
111 
112 
113 #endif
bool convert(MaxEggOptions *options)
Fills up the egg_data structure according to the global Max model data.
This is a 4-by-4 transform matrix.
Definition: lmatrix.h:4716
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
Definition: shader.h:50
This is a collection of textures by TRef name.
This is the primary interface into all the egg data, and the root of the egg file structure...
Definition: eggData.h:41
The main glue of the egg hierarchy, this corresponds to the <Group>, <Instance>, and <Joint> type nod...
Definition: eggGroup.h:36
Describes a single instance of a node in the Max scene graph, relating it to the corresponding egg st...
Definition: maxNodeDesc.h:26
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
This class supervises the construction of an EggData structure from a Max model.
A collection of vertices.
Definition: eggVertexPool.h:46
Describes a complete tree of max nodes for conversion.
Definition: maxNodeTree.h:27