Panda3D
eggOptchar.h
1 // Filename: eggOptchar.h
2 // Created by: drose (18Jul03)
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 EGGOPTCHAR_H
16 #define EGGOPTCHAR_H
17 
18 #include "pandatoolbase.h"
19 
20 #include "eggCharacterFilter.h"
21 #include "luse.h"
22 
23 #include "pvector.h"
24 #include "vector_string.h"
25 #include "globPattern.h"
26 
27 class EggCharacterData;
28 class EggComponentData;
29 class EggJointData;
30 class EggSliderData;
31 class EggGroupNode;
32 
33 ////////////////////////////////////////////////////////////////////
34 // Class : EggOptchar
35 // Description : Performs basic optimizations of a character model and
36 // its associated animations, by analyzing the animation
37 // tables and removing unneeded joints and/or morphs.
38 // Can also be used to restructure the character
39 // hierarchy.
40 ////////////////////////////////////////////////////////////////////
42 public:
43  EggOptchar();
44 
45  void run();
46 
47 protected:
48  virtual bool handle_args(Args &args);
49 
50 private:
51  static bool dispatch_vector_string_pair(const string &opt, const string &arg, void *var);
52  static bool dispatch_name_components(const string &opt, const string &arg, void *var);
53  static bool dispatch_double_components(const string &opt, const string &arg, void *var);
54  static bool dispatch_flag_groups(const string &opt, const string &arg, void *var);
55 
56  void determine_removed_components();
57  void move_vertices();
58  bool process_joints();
59  EggJointData *find_best_parent(EggJointData *joint_data) const;
60  EggJointData *find_best_vertex_joint(EggJointData *joint_data) const;
61 
62  bool apply_user_reparents();
63  bool zero_channels();
64  bool quantize_channels();
65  void analyze_joints(EggJointData *joint_data, int level);
66  void analyze_sliders(EggCharacterData *char_data);
67  void list_joints(EggJointData *joint_data, int indent_level, bool verbose);
68  void list_joints_p(EggJointData *joint_data, int &col);
69  void list_scalars(EggCharacterData *char_data, bool verbose);
70  void describe_component(EggComponentData *comp_data, int indent_level,
71  bool verbose);
72  void do_reparent();
73 
74  void quantize_vertices();
75  void quantize_vertices(EggNode *egg_node);
76  void quantize_vertex(EggVertex *egg_vertex);
77 
78  void do_flag_groups(EggGroupNode *egg_group);
79  void rename_joints();
80  void rename_primitives(EggGroupNode *egg_group, const string &name);
81  void change_dart_type(EggGroupNode *egg_group, const string &new_dart_type);
82  void do_preload();
83  void do_defpose();
84 
85  bool _list_hierarchy;
86  bool _list_hierarchy_v;
87  bool _list_hierarchy_p;
88  bool _preload;
89  bool _keep_all;
90 
91  class StringPair {
92  public:
93  string _a;
94  string _b;
95  };
97  StringPairs _new_joints;
98  StringPairs _reparent_joints;
99  StringPairs _zero_channels;
100  StringPairs _rename_joints;
101 
102  vector_string _keep_components;
103  vector_string _drop_components;
104  vector_string _expose_components;
105  vector_string _suppress_components;
106 
107  string _dart_type;
108 
109  class DoubleString {
110  public:
111  double _a;
112  string _b;
113  };
115  DoubleStrings _quantize_anims;
116 
117  typedef pvector<GlobPattern> Globs;
118 
119  class FlagGroupsEntry {
120  public:
121  Globs _groups;
122  string _name;
123  };
125  FlagGroups _flag_groups;
126 
127  string _defpose;
128 
129  bool _optimal_hierarchy;
130  double _vref_quantum;
131 };
132 
133 #endif
134 
A base class for nodes in the hierarchy that are not leaf nodes.
Definition: eggGroupNode.h:51
This corresponds to a single morph slider control.
Definition: eggSliderData.h:31
This is the base class of both EggJointData and EggSliderData.
Any one-, two-, three-, or four-component vertex, possibly with attributes such as a normal...
Definition: eggVertex.h:41
Performs basic optimizations of a character model and its associated animations, by analyzing the ani...
Definition: eggOptchar.h:41
This is the base class for a family of programs that operate on a number of character models and thei...
Represents a single character, as read and collected from several models and animation files...
This is one node of a hierarchy of EggJointData nodes, each of which represents a single joint of the...
Definition: eggJointData.h:34
A base class for things that may be directly added into the egg hierarchy.
Definition: eggNode.h:38