Panda3D

mayaNodeDesc.h

00001 // Filename: mayaNodeDesc.h
00002 // Created by:  drose (06Jun03)
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 MAYANODEDESC_H
00016 #define MAYANODEDESC_H
00017 
00018 #include "pandatoolbase.h"
00019 
00020 #include "mayaBlendDesc.h"
00021 #include "referenceCount.h"
00022 #include "pointerTo.h"
00023 #include "namable.h"
00024 
00025 #include "pre_maya_include.h"
00026 #include <maya/MDagPath.h>
00027 #include <maya/MFnDagNode.h>
00028 #include "post_maya_include.h"
00029 
00030 class MayaToEggConverter;
00031 class MayaNodeTree;
00032 class EggGroup;
00033 class EggTable;
00034 class EggXfmSAnim;
00035 
00036 ////////////////////////////////////////////////////////////////////
00037 //       Class : MayaNodeDesc
00038 // Description : Describes a single instance of a node in the Maya
00039 //               scene graph, relating it to the corresponding egg
00040 //               structures (e.g. node, group, or table entry) that
00041 //               will be created.
00042 ////////////////////////////////////////////////////////////////////
00043 class MayaNodeDesc : public ReferenceCount, public Namable {
00044 public:
00045   MayaNodeDesc(MayaNodeTree *tree,
00046                MayaNodeDesc *parent = NULL, const string &name = string());
00047   ~MayaNodeDesc();
00048 
00049   void from_dag_path(const MDagPath &dag_path, MayaToEggConverter *converter);
00050   bool has_dag_path() const;
00051   const MDagPath &get_dag_path() const;
00052 
00053   int get_num_blend_descs() const;
00054   MayaBlendDesc *get_blend_desc(int n) const;
00055 
00056   bool is_joint() const;
00057   bool is_joint_parent() const;
00058 
00059   bool is_tagged() const;
00060   bool is_joint_tagged() const;
00061   bool has_object_type(string object_type) const;
00062 
00063   MayaNodeTree *_tree;
00064   MayaNodeDesc *_parent;
00065   typedef pvector< PT(MayaNodeDesc) > Children;
00066   Children _children;
00067   
00068 private:
00069   void tag();
00070   void untag();
00071   void tag_recursively();
00072   void untag_recursively();
00073   void tag_joint();
00074   void tag_joint_recursively();
00075 
00076   void clear_egg();
00077   void mark_joint_parent();
00078   void check_pseudo_joints(bool joint_above);
00079   void check_blend_shapes(const MFnDagNode &node, 
00080                           const string &attrib_name);
00081   void check_lods();
00082 
00083   MDagPath *_dag_path;
00084 
00085   EggGroup *_egg_group;
00086   EggTable *_egg_table;
00087   EggXfmSAnim *_anim;
00088 
00089   typedef pvector< PT(MayaBlendDesc) > BlendDescs;
00090   BlendDescs _blend_descs;
00091 
00092   enum JointType {
00093     JT_none,         // Not a joint.
00094     JT_joint,        // An actual joint in Maya.
00095     JT_pseudo_joint, // Not a joint in Maya, but treated just like a
00096                      // joint for the purposes of the converter.
00097     JT_joint_parent, // A parent or ancestor of a joint or pseudo joint.
00098   };
00099   JointType _joint_type;
00100 
00101   bool _is_lod;
00102   double _switch_in, _switch_out;
00103 
00104   bool _tagged;
00105   bool _joint_tagged;
00106 
00107 public:
00108   static TypeHandle get_class_type() {
00109     return _type_handle;
00110   }
00111   static void init_type() {
00112     ReferenceCount::init_type();
00113     Namable::init_type();
00114     register_type(_type_handle, "MayaNodeDesc",
00115                   ReferenceCount::get_class_type(),
00116                   Namable::get_class_type());
00117   }
00118 
00119 private:
00120   static TypeHandle _type_handle;
00121 
00122   friend class MayaNodeTree;
00123 };
00124 
00125 #endif
 All Classes Functions Variables Enumerations