ScummVM API documentation
Physics.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 HPL1 Engine.
26  */
27 
28 #ifndef HPL_Physics_H
29 #define HPL_Physics_H
30 
31 #include "common/list.h"
32 #include "hpl1/engine/game/Updateable.h"
33 #include "hpl1/engine/physics/PhysicsMaterial.h"
34 #include "hpl1/engine/system/SystemTypes.h"
35 #include "common/stablemap.h"
36 
37 namespace hpl {
38 
39 class iLowLevelPhysics;
40 class iPhysicsWorld;
41 class cSurfaceData;
42 class cWorld3D;
43 class cResources;
44 
45 //------------------------------------------------
46 
47 typedef Common::List<iPhysicsWorld *> tPhysicsWorldList;
48 typedef tPhysicsWorldList::iterator tPhysicsWorldListIt;
49 
50 typedef Common::StableMap<tString, cSurfaceData *> tSurfaceDataMap;
51 typedef tSurfaceDataMap::iterator tSurfaceDataMapIt;
52 
53 //------------------------------------------------
54 
56 public:
57  cPhysicsImpactCount() { mfCount = 0; }
58 
59  float mfCount;
60 };
61 
64 
65 //------------------------------------------------
66 
67 class cPhysics : public iUpdateable {
68 public:
69  cPhysics(iLowLevelPhysics *apLowLevelPhysics);
70  ~cPhysics();
71 
72  void Init(cResources *apResources);
73 
74  void Update(float afTimeStep);
75 
76  iPhysicsWorld *CreateWorld(bool abAddSurfaceData);
77  void DestroyWorld(iPhysicsWorld *apWorld);
78 
79  cSurfaceData *CreateSurfaceData(const tString &asName);
80  cSurfaceData *GetSurfaceData(const tString &asName);
81  bool LoadSurfaceData(const tString &asFile);
82 
83  iLowLevelPhysics *GetLowLevel() { return mpLowLevelPhysics; }
84 
85  void SetGameWorld(cWorld3D *apWorld) { mpGameWorld = apWorld; }
86  cWorld3D *GetGameWorld() { return mpGameWorld; }
87 
88  void SetImpactDuration(float afX) { mfImpactDuration = afX; }
89  float GetImpactDuration() { return mfImpactDuration; }
90 
91  void SetMaxImpacts(int alX) { mlMaxImpacts = alX; }
92  int GetMaxImpacts() { return mlMaxImpacts; }
93  int GetNumOfImpacts() { return (int)mlstImpactCounts.size(); }
94 
95  bool CanPlayImpact();
96  void AddImpact();
97 
98  void SetDebugLog(bool abX) { mbLog = abX; }
99  bool GetDebugLog() { return mbLog; }
100 
101 private:
102  ePhysicsMaterialCombMode GetCombMode(const char *apName);
103 
104  void UpdateImpactCounts(float afTimeStep);
105 
106  iLowLevelPhysics *mpLowLevelPhysics;
107  cResources *mpResources;
108 
109  cWorld3D *mpGameWorld;
110 
111  tPhysicsWorldList mlstWorlds;
112  tSurfaceDataMap m_mapSurfaceData;
113 
114  tPhysicsImpactCountList mlstImpactCounts;
115  float mfImpactDuration;
116  int mlMaxImpacts;
117  bool mbLog;
118 };
119 
120 } // namespace hpl
121 
122 #endif // HPL_Physics_H
Definition: AI.h:36
Definition: str.h:59
Definition: LowLevelPhysics.h:38
Definition: Physics.h:55
Definition: PhysicsWorld.h:115
Definition: SurfaceData.h:74
typename TreeT::BasicIterator iterator
Definition: stablemap.h:48
Definition: World3D.h:179
Definition: Physics.h:67
ListInternal::Iterator< t_T > iterator
Definition: list.h:52
Definition: Updateable.h:35
Definition: Resources.h:160
Definition: list_intern.h:51