Bone.h

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #if !defined(__INCLUDE_Boneh_INCLUDE__)
00022 #define __INCLUDE_Boneh_INCLUDE__
00023 
00024 #include <string>
00025 #include <vector>
00026 #include <common/Vector.h>
00027 
00028 typedef float BoneMatrixType[3][4];
00029 class BoneType
00030 {
00031 public:
00032         BoneType();
00033 
00034         BoneMatrixType relative_;
00035         BoneMatrixType absolute_;
00036         BoneMatrixType relativeFinal_;
00037         BoneMatrixType final_;
00038         int parent_;
00039 };
00040 
00041 class BonePositionKey
00042 {
00043 public:
00044         BonePositionKey(float time, Vector &pos);
00045 
00046         float time;
00047         Vector position;
00048 };
00049 
00050 class BoneRotationKey
00051 {
00052 public:
00053         BoneRotationKey(float time, Vector &rot);
00054 
00055         float time;
00056         Vector rotation;
00057 };
00058 
00059 class Bone
00060 {
00061 public:
00062         Bone(const char *name);
00063         virtual ~Bone();
00064 
00065         const char *getName() { return name_.c_str(); }
00066         const char *getParentName() { return parentName_.c_str(); }
00067         Vector &getPosition() { return position_; }
00068         Vector &getRotation() { return rotation_; }
00069         std::vector<BonePositionKey *> &getPositionKeys() 
00070                 { return  positionKeys_; }
00071         std::vector<BoneRotationKey *> &getRotationKeys()
00072                 { return rotationKeys_; }
00073 
00074         Vector &getPositionAtTime(float currentTime);
00075         void getRotationAtTime(float currentTime, BoneMatrixType &m);
00076 
00077         void addPositionKey(BonePositionKey *key) 
00078                 { positionKeys_.push_back(key); }
00079         void addRotationKey(BoneRotationKey *key) 
00080                 { rotationKeys_.push_back(key); }
00081         void setParentName(const char *parentName) 
00082                 { parentName_ = parentName; }
00083         void setPosition(Vector &pos)
00084                 { position_ = pos; }    
00085         void setRotation(Vector &rot)
00086                 { rotation_ = rot; }    
00087 
00088 protected:
00089         std::string name_;
00090         std::string parentName_;
00091         Vector position_, rotation_;
00092         std::vector<BonePositionKey *> positionKeys_;
00093         std::vector<BoneRotationKey *> rotationKeys_;
00094 
00095 };
00096 
00097 #endif // __INCLUDE_Boneh_INCLUDE__

Generated on Mon Feb 16 15:14:48 2009 for Scorched3D by  doxygen 1.5.3