ScummVM API documentation
head.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_HEAD_H
23 #define GRIM_HEAD_H
24 
25 #include "math/matrix4.h"
26 
27 namespace Grim {
28 
29 class ModelNode;
30 class SaveGame;
31 
32 class BaseHead {
33 public:
34  virtual ~BaseHead() {}
35 
36  virtual void lookAt(bool entering, const Math::Vector3d &point, float rate, const Math::Matrix4 &matrix) = 0;
37  virtual void saveState(SaveGame *state) const = 0;
38  virtual void restoreState(SaveGame *state) = 0;
39  virtual void loadJoints(ModelNode *nodes) = 0;
40 };
41 
42 class Head : public BaseHead {
43 public:
44  class Joint {
45  public:
46  Joint();
47 
48  void init(ModelNode *node);
49 
50  void orientTowards(bool entering, const Math::Vector3d &point, float rate, const Math::Matrix4 &matrix,
51  float maxPitch, float maxYaw, float maxRoll, float constrain);
52 
53  void saveState(SaveGame *state) const;
54  void restoreState(SaveGame *state);
55 
56  private:
57  ModelNode *_node;
58 
59  Math::Angle _pitch;
60  Math::Angle _yaw;
61  Math::Angle _roll;
62  };
63 
64  Head();
65 
66  void setJoints(int joint1, int joint2, int joint3);
67  void loadJoints(ModelNode *nodes);
68  void setMaxAngles(float maxPitch, float maxYaw, float maxRoll);
69 
70  void lookAt(bool entering, const Math::Vector3d &point, float rate, const Math::Matrix4 &matrix);
71 
72  void saveState(SaveGame *state) const;
73  void restoreState(SaveGame *state);
74 
75  int getJoint1() const { return _joint1Node; }
76  int getJoint2() const { return _joint2Node; }
77  int getJoint3() const { return _joint3Node; }
78 
79 private:
80  int _joint1Node;
81  int _joint2Node;
82  int _joint3Node;
83  float _maxRoll;
84  float _maxPitch;
85  float _maxYaw;
86 
87  // Specifies the three head joint bones of this character.
88  // These joint bones are animated by the moveHead function to make
89  // the characters face different directions.
90  // Note that for some characters, these variables may all be equal.
91  Joint _joint1;
92  Joint _joint2;
93  Joint _joint3;
94 };
95 
96 } // end of namespace Grim
97 
98 #endif
Definition: head.h:32
Definition: savegame.h:33
Definition: actor.h:33
Definition: head.h:44
Definition: head.h:42
Definition: model.h:158