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

head.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_HEAD_H
00024 #define GRIM_HEAD_H
00025 
00026 #include "math/matrix4.h"
00027 
00028 namespace Grim {
00029 
00030 class ModelNode;
00031 class SaveGame;
00032 
00033 class BaseHead {
00034 public:
00035     virtual ~BaseHead() {}
00036 
00037     virtual void lookAt(bool entering, const Math::Vector3d &point, float rate, const Math::Matrix4 &matrix) = 0;
00038     virtual void saveState(SaveGame *state) const = 0;
00039     virtual void restoreState(SaveGame *state) = 0;
00040     virtual void loadJoints(ModelNode *nodes) = 0;
00041 };
00042 
00043 class Head : public BaseHead {
00044 public:
00045     class Joint {
00046     public:
00047         Joint();
00048 
00049         void init(ModelNode *node);
00050 
00051         void orientTowards(bool entering, const Math::Vector3d &point, float rate, const Math::Matrix4 &matrix,
00052                            float maxPitch, float maxYaw, float maxRoll, float constrain);
00053 
00054         void saveState(SaveGame *state) const;
00055         void restoreState(SaveGame *state);
00056 
00057     private:
00058         ModelNode *_node;
00059 
00060         Math::Angle _pitch;
00061         Math::Angle _yaw;
00062         Math::Angle _roll;
00063     };
00064 
00065     Head();
00066 
00067     void setJoints(int joint1, int joint2, int joint3);
00068     void loadJoints(ModelNode *nodes);
00069     void setMaxAngles(float maxPitch, float maxYaw, float maxRoll);
00070 
00071     void lookAt(bool entering, const Math::Vector3d &point, float rate, const Math::Matrix4 &matrix);
00072 
00073     void saveState(SaveGame *state) const;
00074     void restoreState(SaveGame *state);
00075 
00076     int getJoint1() const { return _joint1Node; }
00077     int getJoint2() const { return _joint2Node; }
00078     int getJoint3() const { return _joint3Node; }
00079 
00080 private:
00081     int _joint1Node;
00082     int _joint2Node;
00083     int _joint3Node;
00084     float _maxRoll;
00085     float _maxPitch;
00086     float _maxYaw;
00087 
00088     // Specifies the three head joint bones of this character.
00089     // These joint bones are animated by the moveHead function to make
00090     // the characters face different directions.
00091     // Note that for some characters, these variables may all be equal.
00092     Joint _joint1;
00093     Joint _joint2;
00094     Joint _joint3;
00095 };
00096 
00097 } // end of namespace Grim
00098 
00099 #endif


Generated on Sat Dec 14 2019 05:00:35 for ResidualVM by doxygen 1.7.1
curved edge   curved edge