Panda3D

eggOptchar.h

00001 // Filename: eggOptchar.h
00002 // Created by:  drose (18Jul03)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef EGGOPTCHAR_H
00016 #define EGGOPTCHAR_H
00017 
00018 #include "pandatoolbase.h"
00019 
00020 #include "eggCharacterFilter.h"
00021 #include "luse.h"
00022 
00023 #include "pvector.h"
00024 #include "vector_string.h"
00025 #include "globPattern.h"
00026 
00027 class EggCharacterData;
00028 class EggComponentData;
00029 class EggJointData;
00030 class EggSliderData;
00031 class EggGroupNode;
00032 
00033 ////////////////////////////////////////////////////////////////////
00034 //       Class : EggOptchar
00035 // Description : Performs basic optimizations of a character model and
00036 //               its associated animations, by analyzing the animation
00037 //               tables and removing unneeded joints and/or morphs.
00038 //               Can also be used to restructure the character
00039 //               hierarchy.
00040 ////////////////////////////////////////////////////////////////////
00041 class EggOptchar : public EggCharacterFilter {
00042 public:
00043   EggOptchar();
00044 
00045   void run();
00046 
00047 protected:
00048   virtual bool handle_args(Args &args);
00049 
00050 private:
00051   static bool dispatch_vector_string_pair(const string &opt, const string &arg, void *var);
00052   static bool dispatch_name_components(const string &opt, const string &arg, void *var);
00053   static bool dispatch_double_components(const string &opt, const string &arg, void *var);
00054   static bool dispatch_flag_groups(const string &opt, const string &arg, void *var);
00055 
00056   void determine_removed_components();
00057   void move_vertices();
00058   bool process_joints();
00059   EggJointData *find_best_parent(EggJointData *joint_data) const;
00060   EggJointData *find_best_vertex_joint(EggJointData *joint_data) const;
00061 
00062   bool apply_user_reparents();
00063   bool zero_channels();
00064   bool quantize_channels();
00065   void analyze_joints(EggJointData *joint_data, int level);
00066   void analyze_sliders(EggCharacterData *char_data);
00067   void list_joints(EggJointData *joint_data, int indent_level, bool verbose);
00068   void list_joints_p(EggJointData *joint_data, int &col);
00069   void list_scalars(EggCharacterData *char_data, bool verbose);
00070   void describe_component(EggComponentData *comp_data, int indent_level,
00071                           bool verbose);
00072   void do_reparent();
00073 
00074   void quantize_vertices();
00075   void quantize_vertices(EggNode *egg_node);
00076   void quantize_vertex(EggVertex *egg_vertex);
00077 
00078   void do_flag_groups(EggGroupNode *egg_group);
00079   void rename_joints();
00080   void rename_primitives(EggGroupNode *egg_group, const string &name);
00081   void change_dart_type(EggGroupNode *egg_group, const string &new_dart_type);
00082   void do_preload();
00083   void do_defpose();
00084 
00085   bool _list_hierarchy;
00086   bool _list_hierarchy_v;
00087   bool _list_hierarchy_p;
00088   bool _preload;
00089   bool _keep_all;
00090 
00091   class StringPair {
00092   public:
00093     string _a;
00094     string _b;
00095   };
00096   typedef pvector<StringPair> StringPairs;
00097   StringPairs _new_joints;
00098   StringPairs _reparent_joints;
00099   StringPairs _zero_channels;
00100   StringPairs _rename_joints;
00101 
00102   vector_string _keep_components;
00103   vector_string _drop_components;
00104   vector_string _expose_components;
00105   vector_string _suppress_components;
00106 
00107   string _dart_type;
00108 
00109   class DoubleString {
00110   public:
00111     double _a;
00112     string _b;
00113   };
00114   typedef pvector<DoubleString> DoubleStrings;
00115   DoubleStrings _quantize_anims;
00116 
00117   typedef pvector<GlobPattern> Globs;
00118 
00119   class FlagGroupsEntry {
00120   public:
00121     Globs _groups;
00122     string _name;
00123   };
00124   typedef pvector<FlagGroupsEntry> FlagGroups;
00125   FlagGroups _flag_groups;
00126 
00127   string _defpose;
00128 
00129   bool _optimal_hierarchy;
00130   double _vref_quantum;
00131 };
00132 
00133 #endif
00134 
 All Classes Functions Variables Enumerations