forked from FrictionalGames/HPL1Engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LowLevelHaptic.h
203 lines (148 loc) · 6.84 KB
/
LowLevelHaptic.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/*
* Copyright (C) 2006-2010 - Frictional Games
*
* This file is part of HPL1 Engine.
*
* HPL1 Engine is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HPL1 Engine is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HPL1 Engine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HPL_LOW_LEVEL_HAPTIC_H
#define HPL_LOW_LEVEL_HAPTIC_H
#include "math/MathTypes.h"
#include "haptic/HapticTypes.h"
namespace hpl {
class iHapticShape;
class iHapticForce;
class iHapticSurface;
class iVertexBuffer;
class cCamera3D;
class cResources;
class iPhysicsBody;
class iLowLevelHaptic
{
public:
iLowLevelHaptic();
virtual ~iLowLevelHaptic();
//########################################################################################
//! \name General
//########################################################################################
//! @{
void Update(float afTimeStep);
bool Init(cResources *apResources);
void DestroyAllShapes();
void DestroyAll();
virtual float GetMaxForce()=0;
virtual void SetWorldScale(float afScale)=0;
virtual float GetWorldScale()=0;
virtual void SetRenderingActive(bool abX)=0;
virtual bool IsRenderingActive()=0;
virtual bool ShapeIsInContact(iHapticShape *apShape)=0;
void SetCamera(cCamera3D *apCamera){ mpCamera = apCamera;}
cCamera3D* GetCamera(){ return mpCamera;}
void SetCameraOffset(const cVector3f &avOffset){ mvCameraOffset = avOffset;}
cVector3f GetCameraOffset(){ return mvCameraOffset; }
void SetUpdateShapes(bool abX){ mbUpdateShapes = abX;}
bool GetUpdateShapes(){ return mbUpdateShapes;}
void SetForceMul(float afX) {mfForceMul = afX;}
float GetForceMul() {return mfForceMul;}
//! @}
//########################################################################################
//! \name Input
//########################################################################################
//! @{
virtual bool ButtonIsPressed(int alNum)=0;
virtual cVector3f GetHardwarePosition()=0;
virtual cVector3f GetHardwareRotation()=0;
cVector3f GetHardwarePosDelta();
cVector2f GetProxyScreenPos(const cVector2f& avScreenSize);
cVector2f GetProxyScreenDeltaPos(const cVector2f& avScreenSize);
cVector2f GetRelativeVirtualMousePos();
cVector2f GetVirtualMousePos();
void SetVirtualMousePosBounds( const cVector2f &avMin,const cVector2f &avMax,
const cVector2f &avScreenSize);
virtual cVector3f GetProxyPosition()=0;
virtual void SetProxyRadius(float afRadius)=0;
virtual float GetProxyRadius()=0;
virtual int GetNumberOfButtons()=0;
//! @}
//########################################################################################
//! \name Surfaces
//########################################################################################
//! @{
virtual iHapticSurface* CreateSimpleSurface(const tString &asName,
float afDamping=0.0f, float afStiffness=0.9f)=0;
virtual iHapticSurface* CreateFrictionalSurface(const tString &asName,
float afDamping=0.0f, float afStiffness=0.9f,
float afDynamicFriction=0.2f, float afStartingFriction=0.3f,
float afTangentStiffness=0.7f, float afStoppingFriction=0.1f)=0;
virtual iHapticSurface* CreateRoughSurface(const tString &asName,
float afDeviation=0.1f, float afMean=0.5f,
float afDamping=0.0f, float afStiffness=0.9f,
float afDynamicFriction=0.2f, float afStartingFriction=0.3f,
float afTangentStiffness=0.7f, float afStoppingFriction=0.1f)=0;
virtual iHapticSurface* CreateStickySurface(const tString &asName,
float afDeadHeight=0.004f, float afStickyStiffness=0.6f,
float afDamping=0.0f, float afStiffness=0.9f,
float afDynamicFriction=0.2f, float afStartingFriction=0.3f,
float afTangentStiffness=0.7f, float afStoppingFriction=0.1f)=0;
iHapticSurface* GetSurfaceFromName(const tString &asName);
//! @}
//########################################################################################
//! \name Shapes
//########################################################################################
//! @{
virtual iHapticShape* CreateBoxShape(const tString &asName, const cVector3f &avSize, cMatrixf* apOffsetMtx)=0;
virtual iHapticShape* CreateSphereShape(const tString &asName, const cVector3f &avRadii, cMatrixf* apOffsetMtx)=0;
virtual iHapticShape* CreateCylinderShape(const tString &asName, float afRadius, float afHeight, cMatrixf* apOffsetMtx)=0;
virtual iHapticShape* CreateCapsuleShape(const tString &asName, float afRadius, float afHeight, cMatrixf* apOffsetMtx)=0;
virtual iHapticShape* CreateMeshShape(const tString &asName, iVertexBuffer *apVtxBuffer)=0;
virtual iHapticShape* CreateCompundShape(const tString &asName, tHapticShapeVec &avShapes)=0;
virtual iHapticShape* CreateShapeFromPhysicsBody(const tString &asName, iPhysicsBody *apBody)=0;
void DestroyShape(iHapticShape* apShape);
bool ShapeExists(iHapticShape* apShape);
cHapticShapeIterator GetShapeIterator();
//! @}
//########################################################################################
//! \name Forces
//########################################################################################
//! @{
virtual iHapticForce* CreateImpulseForce(const cVector3f& avForce)=0;
virtual iHapticForce* CreateSinusWaveForce(const cVector3f& avDirection, float afAmp, float afFreq)=0;
virtual iHapticForce* CreateSawWaveForce(const cVector3f& avDirection, float afAmp, float afFreq)=0;
virtual iHapticForce* CreateSpringForce(const cVector3f& avPostition, float afStiffness, float afDamping)=0;
virtual iHapticForce* CreateViscosityForce(const cVector3f& avVelocity,float afMass, float afStiffness, float afDamping)=0;
void DestroyForce(iHapticForce* apForce);
void StopAllForces();
//! @}
protected:
virtual bool InitLowLevel()=0;
virtual void UpdateLowLevel(float afTimeStep)=0;
cResources *mpResources;
cCamera3D *mpCamera;
cVector3f mvCameraOffset;
tHapticSurfaceMap m_mapSurfaces;
tHapticForceList mlstForces;
tHapticShapeList mlstShapes;
float mfForceMul;
cVector3f mvPreviousHardwarePos;
cVector3f mvCurrentHardwarePos;
cVector2f mvPreviousScreenPos;
cVector2f mvCurrentScreenPos;
bool mbScreenPosFirstTime;
cVector2f mvMinMousePos;
cVector2f mvMaxMousePos;
cVector2f mvScreenSize;
bool mbUpdateShapes;
};
};
#endif // HPL_LOW_LEVEL_HAPTIC_H