ScummVM API documentation
SurfaceData.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_SURFACE_DATA_H
29 #define HPL_SURFACE_DATA_H
30 
31 #include "hpl1/engine/math/MathTypes.h"
32 #include "hpl1/engine/physics/PhysicsMaterial.h"
33 
34 namespace hpl {
35 
36 #define eRollAxisFlag_X 1
37 #define eRollAxisFlag_Y 2
38 #define eRollAxisFlag_Z 4
39 
40 class cPhysics;
41 class iPhysicsWorld;
42 class iPhysicsBody;
43 class cResources;
44 
45 //----------------------------------------
46 
48  friend class cSurfaceData;
49 
50 public:
51  float GetMinSpeed() { return mfMinSpeed; }
52 
53  const tString &GetSoundName() { return msSoundName; }
54  void SetSoundName(const tString &asName) { msSoundName = asName; }
55 
56  const tString &GetPSName() { return msPSName; }
57  void SetPSName(const tString &asName) { msPSName = asName; }
58 
59  int GetPSPrio() { return mlPSPrio; }
60  void SetPSPrio(int alPrio) { mlPSPrio = alPrio; }
61 
62 private:
63  float mfMinSpeed;
64  tString msSoundName;
65  tString msPSName;
66  int mlPSPrio;
67 };
68 
70 typedef tSurfaceImpactDataVec::iterator tSurfaceImpactDataVecIt;
71 
72 //----------------------------------------
73 
74 class cSurfaceData {
75 public:
76  cSurfaceData(const tString &asName, cPhysics *apPhysics, cResources *apResources);
77  ~cSurfaceData();
78 
79  const tString &GetName() const { return msName; }
80 
81  void OnImpact(float afSpeed, const cVector3f &avPos, int alContacts, iPhysicsBody *apBody);
82  void OnSlide(float afSpeed, const cVector3f &avPos, int alContacts, iPhysicsBody *apBody,
83  iPhysicsBody *apSlideAgainstBody);
84  void CreateImpactEffect(float afSpeed, const cVector3f &avPos, int alContacts,
85  cSurfaceData *apSecondSurface);
86 
87  void UpdateRollEffect(iPhysicsBody *apBody);
88 
89  void SetElasticity(float afElasticity);
90  float GetElasticity() const;
91  void SetStaticFriction(float afElasticity);
92  float GetStaticFriction() const;
93  void SetKineticFriction(float afElasticity);
94  float GetKineticFriction() const;
95 
96  void SetPriority(int alPriority);
97  int GetPriority() const;
98 
99  void SetFrictionCombMode(ePhysicsMaterialCombMode aMode);
100  ePhysicsMaterialCombMode GetFrictionCombMode() const;
101  void SetElasticityCombMode(ePhysicsMaterialCombMode aMode);
102  ePhysicsMaterialCombMode GetElasticityCombMode() const;
103 
104  const tString &GetStepType() { return msStepType; }
105  void GetStepType(const tString &asX) { msStepType = asX; }
106 
107  void SetMinScrapeSpeed(float afX) { mfMinScrapeSpeed = afX; }
108  void SetMinScrapeFreq(float afX) { mfMinScrapeFreq = afX; }
109  void SetMinScrapeFreqSpeed(float afX) { mfMinScrapeFreqSpeed = afX; }
110  void SetMaxScrapeFreq(float afX) { mfMaxScrapeFreq = afX; }
111  void SetMaxScrapeFreqSpeed(float afX) { mfMaxScrapeFreqSpeed = afX; }
112  void SetMiddleScrapeSpeed(float afX) { mfMiddleScrapeSpeed = afX; }
113  void SetMinScrapeContacts(int alX) { mlMinScrapeContacts = alX; }
114  void SetScrapeSoundName(const tString &asName) { msScrapeSoundName = asName; }
115 
116  void SetMinRollSpeed(float afX) { mfMinRollSpeed = afX; }
117  void SetMinRollFreq(float afX) { mfMinRollFreq = afX; }
118  void SetMinRollVolume(float afX) { mfMinRollVolume = afX; }
119  void SetMinRollFreqSpeed(float afX) { mfMinRollFreqSpeed = afX; }
120  void SetMaxRollFreq(float afX) { mfMaxRollFreq = afX; }
121  void SetMaxRollVolume(float afX) { mfMaxRollVolume = afX; }
122  void SetMaxRollFreqSpeed(float afX) { mfMaxRollFreqSpeed = afX; }
123  void SetMiddleRollSpeed(float afX) { mfMiddleRollSpeed = afX; }
124  void SetRollSoundName(const tString &asName) { msRollSoundName = asName; }
125  void SetRollAxisFlags(tFlag aAxisFlags) { mRollAxisFlags = aAxisFlags; }
126 
127  void PreloadData();
128 
129  iPhysicsMaterial *ToMaterial(iPhysicsWorld *apWorld);
130 
134  cSurfaceImpactData *CreateImpactData(float afMinSpeed);
135  cSurfaceImpactData *GetImpactData(int alIdx);
136  int GetImpactDataNum();
142  cSurfaceImpactData *GetImpactDataFromSpeed(float afSpeed);
143 
147  cSurfaceImpactData *CreateHitData(float afMinSpeed);
148  cSurfaceImpactData *GetHitData(int alIdx);
149  int GetHitDataNum();
155  cSurfaceImpactData *GetHitDataFromSpeed(float afSpeed);
156 
157 protected:
158  cResources *mpResources;
159  cPhysics *mpPhysics;
160  tString msName;
161 
162  // Properties
163  ePhysicsMaterialCombMode mFrictionMode;
164  ePhysicsMaterialCombMode mElasticityMode;
165 
166  float mfElasticity;
167  float mfStaticFriction;
168  float mfKineticFriction;
169 
170  int mlPriority;
171 
172  float mfMinScrapeSpeed;
173  float mfMinScrapeFreq;
174  float mfMinScrapeFreqSpeed;
175  float mfMaxScrapeFreq;
176  float mfMaxScrapeFreqSpeed;
177  float mfMiddleScrapeSpeed;
178  int mlMinScrapeContacts;
179  tString msScrapeSoundName;
180 
181  float mfMinRollSpeed;
182  float mfMinRollFreq;
183  float mfMinRollVolume;
184  float mfMinRollFreqSpeed;
185  float mfMaxRollFreq;
186  float mfMaxRollVolume;
187  float mfMaxRollFreqSpeed;
188  float mfMiddleRollSpeed;
189  int mlMinRollContacts;
190  tString msRollSoundName;
191  tFlag mRollAxisFlags;
192 
193  tString msStepType;
194 
195  tSurfaceImpactDataVec mvImpactData;
196 
197  tSurfaceImpactDataVec mvHitData;
198 };
199 
200 } // namespace hpl
201 
202 #endif // HPL_SURFACE_DATA_H
Definition: AI.h:36
Definition: str.h:59
Definition: PhysicsWorld.h:115
T * iterator
Definition: array.h:54
Definition: SurfaceData.h:74
Definition: PhysicsBody.h:117
Definition: Physics.h:67
Definition: SurfaceData.h:47
Definition: PhysicsMaterial.h:77
Definition: Resources.h:160