ScummVM API documentation
skeleton.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef GRIM_SKELETON_H
23 #define GRIM_SKELETON_H
24 
25 #include "common/hashmap.h"
26 #include "common/hash-str.h"
27 
28 #include "math/mathfwd.h"
29 #include "math/quat.h"
30 
31 #include "engines/grim/object.h"
32 #include "engines/grim/actor.h"
33 
34 namespace Common {
35 class SeekableReadStream;
36 }
37 
38 namespace Grim {
39 
40 class AnimationStateEmi;
41 class AnimationEmi;
42 
43 struct Joint {
44  Common::String _name;
45  Common::String _parent;
46  Math::Vector3d _trans;
47  Math::Quaternion _quat;
48  int _parentIndex;
49  Math::Matrix4 _absMatrix;
50  Math::Matrix4 _relMatrix;
51  Math::Matrix4 _animMatrix;
52  Math::Quaternion _animQuat;
53  Math::Matrix4 _finalMatrix;
54  Math::Quaternion _finalQuat;
55 };
56 
58  Math::Vector3d _pos;
59  Math::Quaternion _quat;
60  float _transWeight;
61  float _rotWeight;
62 };
63 
65  JointAnimation* _jointAnims;
66 };
67 
68 class Skeleton : public Object {
69 
70  void loadSkeleton(Common::SeekableReadStream *data);
71  void initBone(int index);
72  void initBones();
73  void resetAnim();
74 public:
75  // Note: EMI uses priority 5 at most.
76  static const int MAX_ANIMATION_LAYERS = 8;
77 
78  int _numJoints;
79  Joint *_joints;
80 
82  JointMap _jointsMap;
83 
84  Skeleton(const Common::String &filename, Common::SeekableReadStream *data);
85  ~Skeleton();
86  void animate();
87  void commitAnim();
88  void addAnimation(AnimationStateEmi *anim);
89  void removeAnimation(AnimationStateEmi *anim);
90  int findJointIndex(const Common::String &name) const;
91  bool hasJoint(const Common::String &name) const;
92  Joint *getJointNamed(const Common::String &name) const;
93  Joint *getParentJoint(const Joint *j) const;
94  int getJointIndex(const Joint *j) const;
95  AnimationLayer* getLayer(int priority) const;
96 private:
97  AnimationLayer *_animLayers;
99 };
100 
101 } // end of namespace Grim
102 
103 #endif
Definition: str.h:59
Definition: animationemi.h:74
Definition: list.h:44
Definition: stream.h:745
Definition: actor.h:33
Definition: skeleton.h:68
Definition: skeleton.h:64
Definition: algorithm.h:29
Definition: skeleton.h:57
Definition: object.h:32
Definition: skeleton.h:43