ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

skeleton.h

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef GRIM_SKELETON_H
00024 #define GRIM_SKELETON_H
00025 
00026 #include "common/hashmap.h"
00027 #include "common/hash-str.h"
00028 #include "math/mathfwd.h"
00029 #include "math/quat.h"
00030 #include "engines/grim/object.h"
00031 #include "engines/grim/actor.h"
00032 
00033 namespace Common {
00034 class SeekableReadStream;
00035 }
00036 
00037 namespace Grim {
00038 
00039 class AnimationStateEmi;
00040 class AnimationEmi;
00041 
00042 struct Joint {
00043     Common::String _name;
00044     Common::String _parent;
00045     Math::Vector3d _trans;
00046     Math::Quaternion _quat;
00047     int _parentIndex;
00048     Math::Matrix4 _absMatrix;
00049     Math::Matrix4 _relMatrix;
00050     Math::Matrix4 _animMatrix;
00051     Math::Quaternion _animQuat;
00052     Math::Matrix4 _finalMatrix;
00053     Math::Quaternion _finalQuat;
00054 };
00055 
00056 struct JointAnimation {
00057     Math::Vector3d _pos;
00058     Math::Quaternion _quat;
00059     float _transWeight;
00060     float _rotWeight;
00061 };
00062 
00063 struct AnimationLayer {
00064     JointAnimation* _jointAnims;
00065 };
00066 
00067 class Skeleton : public Object {
00068 
00069     void loadSkeleton(Common::SeekableReadStream *data);
00070     void initBone(int index);
00071     void initBones();
00072     void resetAnim();
00073 public:
00074     // Note: EMI uses priority 5 at most.
00075     static const int MAX_ANIMATION_LAYERS = 8;
00076 
00077     int _numJoints;
00078     Joint *_joints;
00079 
00080     typedef Common::HashMap<Common::String, int, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> JointMap;
00081     JointMap _jointsMap;
00082 
00083     Skeleton(const Common::String &filename, Common::SeekableReadStream *data);
00084     ~Skeleton();
00085     void animate();
00086     void commitAnim();
00087     void addAnimation(AnimationStateEmi *anim);
00088     void removeAnimation(AnimationStateEmi *anim);
00089     int findJointIndex(const Common::String &name) const;
00090     bool hasJoint(const Common::String &name) const;
00091     Joint *getJointNamed(const Common::String &name) const;
00092     Joint *getParentJoint(const Joint *j) const;
00093     int getJointIndex(const Joint *j) const;
00094     AnimationLayer* getLayer(int priority) const;
00095 private:
00096     AnimationLayer *_animLayers;
00097     Common::List<AnimationStateEmi*> _activeAnims;
00098 };
00099 
00100 } // end of namespace Grim
00101 
00102 #endif


Generated on Sat Dec 7 2019 05:00:31 for ResidualVM by doxygen 1.7.1
curved edge   curved edge