ScummVM API documentation
PlayerHands.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 /*
23  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of Penumbra Overture.
26  */
27 
28 #ifndef GAME_PLAYER_HANDS_H
29 #define GAME_PLAYER_HANDS_H
30 
31 #include "hpl1/engine/engine.h"
32 #include "hpl1/penumbra-overture/GameTypes.h"
33 
34 using namespace hpl;
35 
36 class cInit;
37 
38 //------------------------------------------------
39 
41 public:
42  cHudModelPose() {}
43  cHudModelPose(const cVector3f &avPos, const cVector3f &avRot) {
44  mvPos = avPos;
45  mvRot = avRot;
46  }
47 
48  cMatrixf ToMatrix() {
49  cMatrixf mtxPose = cMath::MatrixRotate(mvRot, eEulerRotationOrder_XYZ);
50  mtxPose.SetTranslation(mvPos);
51  return mtxPose;
52  }
53 
54  cVector3f mvPos;
55  cVector3f mvRot;
56 };
57 
58 //------------------------------------------------
59 
60 enum eHudModelState {
61  eHudModelState_Idle,
62  eHudModelState_Equip,
63  eHudModelState_Unequip
64 };
65 
66 //------------------------------------------------
67 
68 cHudModelPose GetPoseFromElem(const tString &asName, TiXmlElement *apElem);
69 
70 cMatrixf InterpolatePosesToMatrix(float afT, const cHudModelPose &aPoseA, const cHudModelPose &aPoseB);
71 
72 //------------------------------------------------
73 
74 class iHudModel {
75  friend class cPlayerHands;
76 
77 public:
78  iHudModel(ePlayerHandType aType);
79  virtual ~iHudModel() = default;
80 
81  cMeshEntity *GetEntity() { return mpEntity; }
82 
83  void LoadEntities();
84  void DestroyEntities();
85 
86  void EquipEffect(bool abJustCreated);
87  void UnequipEffect();
88 
89  void Reset();
90 
91  tString msName;
92  tString msModelFile;
93 
94  cHudModelPose mEquipPose;
95  cHudModelPose mUnequipPose;
96 
97  tString msEquipSound;
98  tString msUnequipSound;
99 
100  float mfEquipTime;
101  float mfUnequipTime;
102 
103  eHudModelState GetState() { return mState; }
104 
105  Common::Array<cParticleSystem3D *> mvParticleSystems;
106  Common::Array<cBillboard *> mvBillboards;
107  Common::Array<iLight3D *> mvLights;
108  Common::Array<cColor> mvLightColors;
109  Common::Array<float> mvLightRadii;
110  Common::Array<cSoundEntity *> mvSoundEntities;
111 
112  virtual void LoadData(TiXmlElement *apRootElem) = 0;
113 
114 protected:
115  virtual void ResetExtraData() = 0;
116 
117  virtual bool UpdatePoseMatrix(cMatrixf &aPoseMtx, float afTimeStep) { return false; }
118 
119  virtual void LoadExtraEntites() {}
120  virtual void DestroyExtraEntities() {}
121 
122  virtual void PostSceneDraw() {}
123 
124  ePlayerHandType mType;
125 
126  cInit *mpInit;
127 
128  cMesh *mpMesh;
129  cMeshEntity *mpEntity;
130 
131  eHudModelState mState;
132 
133  float mfTime;
134 
135  tString msNextModel;
136 };
137 
138 //------------------------------------------------
139 
141  friend class cPlayerHands;
142 
143 public:
144  cHudModel_Normal() : iHudModel(ePlayerHandType_Normal) {}
145  virtual ~cHudModel_Normal() = default;
146 
147  void LoadData(TiXmlElement *apRootElem) {}
148 
149  void ResetExtraData() {}
150 };
151 
152 //------------------------------------------------
153 
155 typedef tHudModelMap::iterator tHudModelMapIt;
156 
157 //------------------------------------------------
158 
159 class cPlayerHands : public iUpdateable {
160 public:
161  cPlayerHands(cInit *apInit);
162  ~cPlayerHands();
163 
164  void OnStart();
165  void Update(float afTimeStep);
166  void Reset();
167  void OnDraw();
168 
169  void OnWorldExit();
170  void OnWorldLoad();
171 
172  void AddHudModel(iHudModel *apHudModel);
173  bool AddModelFromFile(const tString &asFile);
174 
175  iHudModel *GetModel(const tString &asName);
176 
177  void SetCurrentModel(int alNum, const tString &asName);
178  iHudModel *GetCurrentModel(int alNum) { return mvCurrentHudModels[alNum]; }
179 
180 private:
181  void UpdatePrevPositions();
182 
183  cInit *mpInit;
184  cMeshManager *mpMeshManager;
185 
186  tVector3fList mlstPositions;
187  tVector3fList mlstRotations;
188  int mlMaxPositions;
189  int mlMaxRotations;
190 
191  cVector3f mvSmoothCameraPos;
192  cVector3f mvSmoothCameraRot;
193 
194  tHudModelMap m_mapHudModels;
195  iHudModel *mvCurrentHudModels[2];
196  int mlCurrentModelNum;
197 };
198 
199 #endif // GAME_PLAYER_HANDS_H
Definition: AI.h:36
Definition: str.h:59
static cMatrixf MatrixRotate(cVector3f avRot, eEulerRotationOrder aOrder)
Definition: array.h:52
Definition: PlayerHands.h:40
Definition: Mesh.h:215
typename TreeT::BasicIterator iterator
Definition: stablemap.h:48
Definition: PlayerHands.h:140
Definition: Updateable.h:35
Definition: PlayerHands.h:74
Definition: tinyxml.h:864
Definition: MeshEntity.h:96
Definition: MeshManager.h:39
Definition: PlayerHands.h:159
Definition: Init.h:70