My Project
Loading...
Searching...
No Matches
CHapticPoint.h
Go to the documentation of this file.
1//==============================================================================
2/*
3 Software License Agreement (BSD License)
4 Copyright (c) 2003-2024, CHAI3D
5 (www.chai3d.org)
6
7 All rights reserved.
8
9 Redistribution and use in source and binary forms, with or without
10 modification, are permitted provided that the following conditions
11 are met:
12
13 * Redistributions of source code must retain the above copyright
14 notice, this list of conditions and the following disclaimer.
15
16 * Redistributions in binary form must reproduce the above
17 copyright notice, this list of conditions and the following
18 disclaimer in the documentation and/or other materials provided
19 with the distribution.
20
21 * Neither the name of CHAI3D nor the names of its contributors may
22 be used to endorse or promote products derived from this software
23 without specific prior written permission.
24
25 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 POSSIBILITY OF SUCH DAMAGE.
37
38 \author <http://www.chai3d.org>
39 \author Francois Conti
40 \version 3.3.0
41*/
42//==============================================================================
43
44//------------------------------------------------------------------------------
45#ifndef cHapticPointH
46#define cHapticPointH
47//------------------------------------------------------------------------------
48#include "audio/CAudioDevice.h"
52#include "world/CShapeSphere.h"
53//------------------------------------------------------------------------------
54
55//------------------------------------------------------------------------------
56namespace chai3d {
57//------------------------------------------------------------------------------
58
59//------------------------------------------------------------------------------
60class cGenericTool;
61//------------------------------------------------------------------------------
62
63//==============================================================================
70//==============================================================================
71
72//==============================================================================
96//==============================================================================
98{
99 //--------------------------------------------------------------------------
100 // CONSTRUCTOR & DESTRUCTOR:
101 //--------------------------------------------------------------------------
102
103public:
104
106 cHapticPoint(cGenericTool* a_parentTool);
107
109 virtual ~cHapticPoint();
110
111
112 //--------------------------------------------------------------------------
113 // PUBLIC METHODS - GENERAL:
114 //--------------------------------------------------------------------------
115
116public:
117
119 virtual std::string getClassName() { return ("HapticPoint"); }
120
121
122 //--------------------------------------------------------------------------
123 // PUBLIC METHODS - POSITION COMMANDS
124 //--------------------------------------------------------------------------
125
126public:
127
129 void initialize();
130
132 void initialize(cVector3d a_globalPos);
133
136
139
142
145
148
149
150 //--------------------------------------------------------------------------
151 // PUBLIC METHODS - GENERAL SETTINGS
152 //--------------------------------------------------------------------------
153
154public:
155
157 void setRadius(double a_radius);
158
160 void setRadius(double a_radiusDisplay,
161 double a_radiusContact);
162
164 void setRadiusContact(double a_radiusContact);
165
167 double getRadiusContact() { return (m_radiusContact); }
168
170 void setRadiusDisplay(double a_radiusDisplay);
171
173 double getRadiusDisplay() { return (m_radiusDisplay); }
174
176 void setShow(bool a_showProxy = true,
177 bool a_showGoal = false,
178 cColorf a_colorLine = cColorf(0.5, 0.5, 0.5));
179
181 bool createAudioSource(cAudioDevice* a_audioDevice);
182
183
184 //--------------------------------------------------------------------------
185 // PUBLIC METHODS - COLLISION EVENTS (MESH OBJECTS)
186 //--------------------------------------------------------------------------
187
188public:
189
190 // This method returns the current number of collision events between this haptic point and the environment.
192
193 // This method returns the i'th collision collision event for this haptic point.
194 inline cCollisionEvent* getCollisionEvent(const int a_index) { return (m_algorithmFingerProxy->m_collisionEvents[a_index]); }
195
196
197 //--------------------------------------------------------------------------
198 // PUBLIC METHODS - INTERACTION EVENTS (POTENTIAL FIELDS)
199 //--------------------------------------------------------------------------
200
201public:
202
203 // This method returns the number of interaction events between this haptic point and the environment.
205
206 // This method returns the i'th interaction events between this haptic point and the environment.
208
209
210 //--------------------------------------------------------------------------
211 // PUBLIC METHODS - FORCE COMPUTATIONS
212 //--------------------------------------------------------------------------
213
214public:
215
218 cMatrix3d& a_globalRot,
219 cVector3d& a_globalLinVel,
220 cVector3d& a_globalAngVel);
221
224
226 bool isInContact(cGenericObject* a_object);
227
228
229 //--------------------------------------------------------------------------
230 // PUBLIC MEMBERS - FORCE RENDERING ALGORITHMS
231 //--------------------------------------------------------------------------
232
233public:
234
237
240
241
242 //--------------------------------------------------------------------------
243 // PUBLIC MEMBERS - GRAPHIC MODEL
244 //--------------------------------------------------------------------------
245
246public:
247
250
253
256
257
258 //--------------------------------------------------------------------------
259 // PUBLIC METHODS
260 //--------------------------------------------------------------------------
261
262public:
263
265 void render(cRenderOptions& a_options);
266
267
268 //--------------------------------------------------------------------------
269 // PROTECTED METHODS
270 //--------------------------------------------------------------------------
271
272protected:
273
276
277
278 //--------------------------------------------------------------------------
279 // PROTECTED MEMBERS
280 //--------------------------------------------------------------------------
281
282protected:
283
286
289
292
295
298
299
300 //--------------------------------------------------------------------------
301 // PROTECTED MEMBERS - AUDIO
302 //--------------------------------------------------------------------------
303
304protected:
305
308
311
314
317
318};
319
320//------------------------------------------------------------------------------
321} // namespace chai3d
322//------------------------------------------------------------------------------
323
324//------------------------------------------------------------------------------
325#endif
326//------------------------------------------------------------------------------
Implements a finger-proxy force rendering algorithm.
Implements a force algorithm for modeling haptic effects.
Implements an audio device for listening to audio sources.
Implements a base class for all objects.
Implementation of a 3D shape sphere object.
This class implements a finger-proxy force rendering algorithm.
Definition CAlgorithmFingerProxy.h:87
int getNumCollisionEvents()
This method return the number of collision events (0, 1, 2 or 3):
Definition CAlgorithmFingerProxy.h:151
cCollisionEvent * m_collisionEvents[3]
Table of collision events (0-3). Call getNumCollisionEvents() to see how many are actually valid.
Definition CAlgorithmFingerProxy.h:161
This class implements a force algorithms for handling all haptic effects associated with objects.
Definition CAlgorithmPotentialField.h:80
cInteractionRecorder m_interactionRecorder
Interaction recorder.
Definition CAlgorithmPotentialField.h:114
This class implements an audio device context.
Definition CAudioDevice.h:82
This class implements an audio source.
Definition CAudioSource.h:79
This class implements a base class for all 2D or 3D objects in CHAI3D.
Definition CGenericObject.h:113
This class implements a base class for modeling haptic tools.
Definition CGenericTool.h:86
This class implements a haptic point on a tool.
Definition CHapticPoint.h:98
cShapeSphere * m_sphereProxy
Sphere object used for rendering the proxy position.
Definition CHapticPoint.h:249
cAudioSource * m_audioSourceFriction[3]
Optional audio source for rendering sound friction.
Definition CHapticPoint.h:310
cAlgorithmFingerProxy * m_algorithmFingerProxy
Finger-proxy algorithm used for modeling contacts with cMesh objects.
Definition CHapticPoint.h:236
void setRadiusContact(double a_radiusContact)
This method sets the radius size of the physical proxy.
Definition CHapticPoint.cpp:309
bool isInContact(cGenericObject *a_object)
This method checks if the tool is touching a particular object.
Definition CHapticPoint.cpp:584
cInteractionEvent * getInteractionEvent(const int a_index)
Definition CHapticPoint.h:207
virtual ~cHapticPoint()
Destructor of cHapticPoint.
Definition CHapticPoint.cpp:116
void updateSpherePositions()
This method updates the position of the spheres (proxy and goal) in local tool coordinates.
Definition CHapticPoint.cpp:697
void setShow(bool a_showProxy=true, bool a_showGoal=false, cColorf a_colorLine=cColorf(0.5, 0.5, 0.5))
This method sets the display options of the goal and proxy spheres.
Definition CHapticPoint.cpp:347
double m_radiusContact
Radius used to model the physical radius of the proxy.
Definition CHapticPoint.h:294
void initialize()
This method resets the haptic point to the current position of the haptic device.
Definition CHapticPoint.cpp:220
void render(cRenderOptions &a_options)
This method renders the haptic point graphically using OpenGL.
Definition CHapticPoint.cpp:640
cVector3d getLocalPosProxy()
This method returns the current proxy position of the haptic point in local tool coordinates.
Definition CHapticPoint.cpp:199
double m_radiusDisplay
Radius used for rendering the proxy and goal spheres.
Definition CHapticPoint.h:291
cAudioSource * m_audioSourceImpact[3]
Optional audio source for rendering sound impacts with environment.
Definition CHapticPoint.h:307
int getNumCollisionEvents()
Definition CHapticPoint.h:191
cVector3d getGlobalPosGoal()
This method returns the current desired goal position of the haptic point in world coordinates.
Definition CHapticPoint.cpp:148
int getNumInteractionEvents()
Definition CHapticPoint.h:204
cVector3d getLocalPosGoal()
This method returns the current desired goal position of the haptic point in local tool coordinates.
Definition CHapticPoint.cpp:176
cVector3d m_lastComputedGlobalForce
Last computed interaction force [N] in world global coordinates.
Definition CHapticPoint.h:288
void setRadiusDisplay(double a_radiusDisplay)
This method sets the radius size of the sphere used to display the proxy and goal position.
Definition CHapticPoint.cpp:326
virtual std::string getClassName()
This method returns the name of the object class.
Definition CHapticPoint.h:119
cAlgorithmPotentialField * m_algorithmPotentialField
Potential field algorithm used for modeling interaction forces with objects that have haptic effects ...
Definition CHapticPoint.h:239
cColorf m_colorLine
Color of the display line that connects both spheres (proxy and goal).
Definition CHapticPoint.h:255
bool m_useAudioSources
If true then audio sources are enabled.
Definition CHapticPoint.h:313
double getRadiusContact()
This method returns the radius size of the physical proxy.
Definition CHapticPoint.h:167
cGenericTool * m_parentTool
Parent tool.
Definition CHapticPoint.h:285
cGenericObject * m_audioProxyContacts[3]
Pointers to mesh objects for which the proxy was last in contact with.
Definition CHapticPoint.h:316
cShapeSphere * m_sphereGoal
Sphere object used for rendering the goal position.
Definition CHapticPoint.h:252
cCollisionEvent * getCollisionEvent(const int a_index)
Definition CHapticPoint.h:194
cVector3d getGlobalPosProxy()
This method returns the the current proxy position of the haptic point in world coordinates.
Definition CHapticPoint.cpp:162
cVector3d getLastComputedForce()
This method returns the last computed force in global world coordinates.
Definition CHapticPoint.h:223
double getRadiusDisplay()
This method returns the display radius size of the proxy and goal spheres.
Definition CHapticPoint.h:173
void setRadius(double a_radius)
This method sets the radius size of the haptic point.
Definition CHapticPoint.cpp:260
bool createAudioSource(cAudioDevice *a_audioDevice)
This method Create an audio source for this haptic point.
Definition CHapticPoint.cpp:365
cVector3d computeInteractionForces(cVector3d &a_globalPos, cMatrix3d &a_globalRot, cVector3d &a_globalLinVel, cVector3d &a_globalAngVel)
This method computes all interaction forces between the haptic point and the virtual environment.
Definition CHapticPoint.cpp:407
cGenericTool * getParentTool()
This method returns a pointer to the parent tool.
Definition CHapticPoint.h:135
cGenericObject * m_meshProxyContacts[3]
Pointer to mesh objects for which the proxy is in contact with.
Definition CHapticPoint.h:297
std::vector< cInteractionEvent > m_interactions
List of interaction events stored in recorder.
Definition CInteractionBasics.h:168
This class implements a 3D shape sphere.
Definition CShapeSphere.h:87
Definition CAudioBuffer.cpp:57
This structure stores the data related to a collision event.
Definition CCollisionBasics.h:92
This class defines a color using a GLfloat representation for each component.
Definition CColor.h:139
This structure stores information associated with the interaction of a haptic tool with a shape primi...
Definition CInteractionBasics.h:88
This class implements a 3D matrix.
Definition CMatrix3d.h:98
This structures provide a containers for storing rendering options that are passed through the sceneg...
Definition CRenderOptions.h:83
This class implements a 3D vector.
Definition CVector3d.h:89