Panda3D
|
00001 // Filename: xFileAnimationSet.h 00002 // Created by: drose (02Oct04) 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 XFILEANIMATIONSET_H 00016 #define XFILEANIMATIONSET_H 00017 00018 #include "pandatoolbase.h" 00019 #include "pmap.h" 00020 #include "pvector.h" 00021 #include "luse.h" 00022 #include "namable.h" 00023 00024 class XFileToEggConverter; 00025 class EggGroup; 00026 class EggTable; 00027 class EggXfmSAnim; 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Class : XFileAnimationSet 00031 // Description : This represents a tree of EggTables, corresponding to 00032 // Animation entries in the X file. There is one 00033 // EggTable for each joint in the character's joint 00034 // set, and the whole tree is structured as a 00035 // mirror of the joint set. 00036 //////////////////////////////////////////////////////////////////// 00037 class XFileAnimationSet : public Namable { 00038 public: 00039 XFileAnimationSet(); 00040 ~XFileAnimationSet(); 00041 00042 bool create_hierarchy(XFileToEggConverter *converter); 00043 EggXfmSAnim *get_table(const string &joint_name) const; 00044 00045 enum FrameDataFlags { 00046 FDF_scale = 0x01, 00047 FDF_rot = 0x02, 00048 FDF_trans = 0x04, 00049 FDF_mat = 0x08, 00050 }; 00051 00052 class FrameEntry { 00053 public: 00054 INLINE FrameEntry(); 00055 INLINE const LMatrix4d &get_mat(int flags) const; 00056 00057 LVecBase3d _scale; 00058 LQuaterniond _rot; 00059 LVector3d _trans; 00060 LMatrix4d _mat; 00061 }; 00062 00063 typedef epvector<FrameEntry> FrameEntries; 00064 00065 class FrameData { 00066 public: 00067 INLINE FrameData(); 00068 FrameEntries _entries; 00069 int _flags; 00070 }; 00071 00072 FrameData &create_frame_data(const string &joint_name); 00073 00074 public: 00075 double _frame_rate; 00076 00077 private: 00078 void mirror_table(XFileToEggConverter *converter, 00079 EggGroup *model_node, EggTable *anim_node); 00080 00081 typedef pmap<string, FrameData> JointData; 00082 JointData _joint_data; 00083 00084 class TablePair { 00085 public: 00086 EggGroup *_joint; 00087 EggXfmSAnim *_table; 00088 }; 00089 00090 typedef pmap<string, TablePair> Tables; 00091 Tables _tables; 00092 }; 00093 00094 #include "xFileAnimationSet.I" 00095 00096 #endif 00097