xFileAnimationSet.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // Filename: xFileAnimationSet.h
  2. // Created by: drose (02Oct04)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef XFILEANIMATIONSET_H
  19. #define XFILEANIMATIONSET_H
  20. #include "pandatoolbase.h"
  21. #include "pmap.h"
  22. #include "pvector.h"
  23. #include "luse.h"
  24. #include "namable.h"
  25. class XFileToEggConverter;
  26. class EggGroup;
  27. class EggTable;
  28. class EggXfmSAnim;
  29. ////////////////////////////////////////////////////////////////////
  30. // Class : XFileAnimationSet
  31. // Description : This represents a tree of EggTables, corresponding to
  32. // Animation entries in the X file. There is one
  33. // EggTable for each joint in the character's joint
  34. // set, and the whole tree is structured as a
  35. // mirror of the joint set.
  36. ////////////////////////////////////////////////////////////////////
  37. class XFileAnimationSet : public Namable {
  38. public:
  39. XFileAnimationSet();
  40. ~XFileAnimationSet();
  41. bool create_hierarchy(XFileToEggConverter *converter);
  42. EggXfmSAnim *get_table(const string &joint_name) const;
  43. enum FrameDataFlags {
  44. FDF_scale = 0x01,
  45. FDF_rot = 0x02,
  46. FDF_trans = 0x04,
  47. FDF_mat = 0x08,
  48. };
  49. class FrameEntry {
  50. public:
  51. INLINE FrameEntry();
  52. INLINE const LMatrix4d &get_mat(int flags) const;
  53. LVecBase3d _scale;
  54. LQuaterniond _rot;
  55. LVector3d _trans;
  56. LMatrix4d _mat;
  57. };
  58. typedef pvector<FrameEntry> FrameEntries;
  59. class FrameData {
  60. public:
  61. INLINE FrameData();
  62. FrameEntries _entries;
  63. int _flags;
  64. };
  65. FrameData &create_frame_data(const string &joint_name);
  66. private:
  67. void mirror_table(double frame_rate,
  68. EggGroup *model_node, EggTable *anim_node);
  69. typedef pmap<string, FrameData> JointData;
  70. JointData _joint_data;
  71. class TablePair {
  72. public:
  73. EggGroup *_joint;
  74. EggXfmSAnim *_table;
  75. };
  76. typedef pmap<string, TablePair> Tables;
  77. Tables _tables;
  78. };
  79. #include "xFileAnimationSet.I"
  80. #endif