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
37namespace hpl {
38
39class iLowLevelPhysics;
40class iPhysicsWorld;
41class cSurfaceData;
42class cWorld3D;
43class cResources;
44
45//------------------------------------------------
46
47typedef Common::List<iPhysicsWorld *> tPhysicsWorldList;
48typedef tPhysicsWorldList::iterator tPhysicsWorldListIt;
49
50typedef Common::StableMap<tString, cSurfaceData *> tSurfaceDataMap;
51typedef tSurfaceDataMap::iterator tSurfaceDataMapIt;
52
53//------------------------------------------------
54
56public:
57 cPhysicsImpactCount() { mfCount = 0; }
58
59 float mfCount;
60};
61
64
65//------------------------------------------------
66
67class cPhysics : public iUpdateable {
68public:
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
101private:
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
size_type size() const
Definition: list.h:237
ListInternal::Iterator< iPhysicsWorld * > iterator
Definition: list.h:52
typename TreeT::BasicIterator iterator
Definition: stablemap.h:48
Definition: str.h:59
Definition: Physics.h:67
Definition: Physics.h:55
Definition: Resources.h:160
Definition: SurfaceData.h:74
Definition: World3D.h:179
Definition: LowLevelPhysics.h:38
Definition: PhysicsWorld.h:115
Definition: Updateable.h:35
Definition: list_intern.h:54