CHapticPoint.h
Go to the documentation of this file.
1 //==============================================================================
2 /*
3  Software License Agreement (BSD License)
4  Copyright (c) 2003-2016, 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.2.0 $Rev: 1869 $
41 */
42 //==============================================================================
43 
44 //------------------------------------------------------------------------------
45 #ifndef cHapticPointH
46 #define cHapticPointH
47 //------------------------------------------------------------------------------
48 #include "audio/CAudioDevice.h"
51 #include "world/CGenericObject.h"
52 #include "world/CShapeSphere.h"
53 //------------------------------------------------------------------------------
54 
55 //------------------------------------------------------------------------------
56 namespace chai3d {
57 //------------------------------------------------------------------------------
58 
59 //------------------------------------------------------------------------------
60 class cGenericTool;
61 //------------------------------------------------------------------------------
62 
63 //==============================================================================
70 //==============================================================================
71 
72 //==============================================================================
96 //==============================================================================
98 {
99  //--------------------------------------------------------------------------
100  // CONSTRUCTOR & DESTRUCTOR:
101  //--------------------------------------------------------------------------
102 
103 public:
104 
106  cHapticPoint(cGenericTool* a_parentTool);
107 
109  virtual ~cHapticPoint();
110 
111 
112  //--------------------------------------------------------------------------
113  // PUBLIC METHODS - POSITION COMMANDS
114  //--------------------------------------------------------------------------
115 
116 public:
117 
119  void initialize();
120 
122  void initialize(cVector3d a_globalPos);
123 
125  inline cGenericTool* getParentTool() { return (m_parentTool); }
126 
129 
132 
135 
138 
139 
140  //--------------------------------------------------------------------------
141  // PUBLIC METHODS - GENERAL SETTINGS
142  //--------------------------------------------------------------------------
143 
144 public:
145 
147  void setRadius(double a_radius);
148 
150  void setRadius(double a_radiusDisplay,
151  double a_radiusContact);
152 
154  void setRadiusContact(double a_radiusContact);
155 
157  double getRadiusContact() { return (m_radiusContact); }
158 
160  void setRadiusDisplay(double a_radiusDisplay);
161 
163  double getRadiusDisplay() { return (m_radiusDisplay); }
164 
166  void setShow(bool a_showProxy = true,
167  bool a_showGoal = false,
168  cColorf a_colorLine = cColorf(0.5, 0.5, 0.5));
169 
171  bool createAudioSource(cAudioDevice* a_audioDevice);
172 
173 
174  //--------------------------------------------------------------------------
175  // PUBLIC METHODS - COLLISION EVENTS (MESH OBJECTS)
176  //--------------------------------------------------------------------------
177 
178 public:
179 
180  // This method returns the current number of collision events between this haptic point and the environment.
182 
183  // This method returns the i'th collision collision event for this haptic point.
184  inline cCollisionEvent* getCollisionEvent(const int a_index) { return (m_algorithmFingerProxy->m_collisionEvents[a_index]); }
185 
186 
187  //--------------------------------------------------------------------------
188  // PUBLIC METHODS - INTERACTION EVENTS (POTENTIAL FIELDS)
189  //--------------------------------------------------------------------------
190 
191 public:
192 
193  // This method returns the number of interaction events between this haptic point and the environment.
195 
196  // This method returns the i'th interaction events between this haptic point and the environment.
198 
199 
200  //--------------------------------------------------------------------------
201  // PUBLIC METHODS - FORCE COMPUTATIONS
202  //--------------------------------------------------------------------------
203 
204 public:
205 
208  cMatrix3d& a_globalRot,
209  cVector3d& a_globalLinVel,
210  cVector3d& a_globalAngVel);
211 
214 
216  bool isInContact(cGenericObject* a_object);
217 
218 
219  //--------------------------------------------------------------------------
220  // PUBLIC MEMBERS - FORCE RENDERING ALGORITHMS
221  //--------------------------------------------------------------------------
222 
223 public:
224 
227 
230 
231 
232  //--------------------------------------------------------------------------
233  // PUBLIC MEMBERS - GRAPHIC MODEL
234  //--------------------------------------------------------------------------
235 
236 public:
237 
240 
243 
246 
247 
248  //--------------------------------------------------------------------------
249  // PUBLIC METHODS
250  //--------------------------------------------------------------------------
251 
252 public:
253 
255  void render(cRenderOptions& a_options);
256 
257 
258  //--------------------------------------------------------------------------
259  // PROTECTED METHODS
260  //--------------------------------------------------------------------------
261 
262 protected:
263 
265  void updateSpherePositions();
266 
267 
268  //--------------------------------------------------------------------------
269  // PROTECTED MEMBERS
270  //--------------------------------------------------------------------------
271 
272 protected:
273 
276 
279 
282 
285 
288 
289 
290  //--------------------------------------------------------------------------
291  // PROTECTED MEMBERS - AUDIO
292  //--------------------------------------------------------------------------
293 
294 protected:
295 
298 
301 
304 
307 };
308 
309 //------------------------------------------------------------------------------
310 } // namespace chai3d
311 //------------------------------------------------------------------------------
312 
313 //------------------------------------------------------------------------------
314 #endif
315 //------------------------------------------------------------------------------
This class implements a 3D vector.
Definition: CVector3d.h:88
This structures provide a containers for storing rendering options that are passed through the sceneg...
Definition: CRenderOptions.h:82
cVector3d getLocalPosProxy()
This method returns the current proxy position of the haptic point in local tool coordinates.
Definition: CHapticPoint.cpp:205
This class implements a haptic point on a tool.
Definition: CHapticPoint.h:97
Implementation of a 3D shape sphere object.
cVector3d m_lastComputedGlobalForce
Last computed interaction force [N] in world global coordinates.
Definition: CHapticPoint.h:278
cGenericObject * m_meshProxyContacts[3]
Pointer to mesh objects for which the proxy is in contact with.
Definition: CHapticPoint.h:287
cGenericTool * getParentTool()
This method returns a pointer to the parent tool.
Definition: CHapticPoint.h:125
cAudioSource * m_audioSourceFriction[3]
Optional audio source for rendering sound friction.
Definition: CHapticPoint.h:300
cVector3d getLocalPosGoal()
This method returns the current desired goal position of the haptic point in local tool coordinates...
Definition: CHapticPoint.cpp:182
double getRadiusDisplay()
This method returns the display radius size of the proxy and goal spheres.
Definition: CHapticPoint.h:163
This class implements a force algorithms for handling all haptic effects associated with objects...
Definition: CAlgorithmPotentialField.h:79
This class implements an audio source.
Definition: CAudioSource.h:78
This structure stores the data related to a collision event.
Definition: CCollisionBasics.h:91
cColorf m_colorLine
Color of the display line that connects both spheres (proxy and goal).
Definition: CHapticPoint.h:245
virtual ~cHapticPoint()
Destructor of cHapticPoint.
Definition: CHapticPoint.cpp:116
cShapeSphere * m_sphereGoal
Sphere object used for rendering the goal position.
Definition: CHapticPoint.h:242
cVector3d getGlobalPosGoal()
This method returns the current desired goal position of the haptic point in world coordinates...
Definition: CHapticPoint.cpp:154
double m_radiusDisplay
Radius used for rendering the proxy and goal spheres.
Definition: CHapticPoint.h:281
cAlgorithmPotentialField * m_algorithmPotentialField
Potential field algorithm used for modeling interaction forces with objects that have haptic effects ...
Definition: CHapticPoint.h:229
void setRadius(double a_radius)
This method sets the radius size of the haptic point.
Definition: CHapticPoint.cpp:266
This class implements a base class for modeling haptic tools.
Definition: CGenericTool.h:85
cVector3d getGlobalPosProxy()
This method returns the the current proxy position of the haptic point in world coordinates.
Definition: CHapticPoint.cpp:168
This structure stores information associated with the interaction of a haptic tool with a shape primi...
Definition: CInteractionBasics.h:87
This class implements a base class for all 2D or 3D objects in CHAI3D.
Definition: CGenericObject.h:112
int getNumInteractionEvents()
Definition: CHapticPoint.h:194
This class implements a 3D matrix.
Definition: CMatrix3d.h:97
cVector3d getLastComputedForce()
This method returns the last computed force in global world coordinates.
Definition: CHapticPoint.h:213
cGenericObject * m_audioProxyContacts[3]
Pointers to mesh objects for which the proxy was last in contact with.
Definition: CHapticPoint.h:306
Implements a finger-proxy force rendering algorithm.
int getNumCollisionEvents()
This method return the number of collision events (0, 1, 2 or 3):
Definition: CAlgorithmFingerProxy.h:151
Implements a base class for all objects.
void render(cRenderOptions &a_options)
This method renders the haptic point graphically using OpenGL.
Definition: CHapticPoint.cpp:640
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 3D shape sphere.
Definition: CShapeSphere.h:86
bool m_useAudioSources
If true then audio sources are enabled.
Definition: CHapticPoint.h:303
int getNumCollisionEvents()
Definition: CHapticPoint.h:181
This class defines a color using a GLfloat representation for each component.
Definition: CColor.h:138
void updateSpherePositions()
This method updates the position of the spheres (proxy and goal) in local tool coordinates.
Definition: CHapticPoint.cpp:697
This class implements an audio device context.
Definition: CAudioDevice.h:81
std::vector< cInteractionEvent > m_interactions
List of interaction events stored in recorder.
Definition: CInteractionBasics.h:168
This class implements a finger-proxy force rendering algorithm.
Definition: CAlgorithmFingerProxy.h:86
cGenericTool * m_parentTool
Parent tool.
Definition: CHapticPoint.h:275
cInteractionEvent * getInteractionEvent(const int a_index)
Definition: CHapticPoint.h:197
bool createAudioSource(cAudioDevice *a_audioDevice)
This method Create an audio source for this haptic point.
Definition: CHapticPoint.cpp:371
double m_radiusContact
Radius used to model the physical radius of the proxy.
Definition: CHapticPoint.h:284
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:409
bool isInContact(cGenericObject *a_object)
This method checks if the tool is touching a particular object.
Definition: CHapticPoint.cpp:584
double getRadiusContact()
This method returns the radius size of the physical proxy.
Definition: CHapticPoint.h:157
cCollisionEvent * getCollisionEvent(const int a_index)
Definition: CHapticPoint.h:184
Implements an audio device for listening to audio sources.
void setRadiusContact(double a_radiusContact)
This method sets the radius size of the physical proxy.
Definition: CHapticPoint.cpp:315
Definition: CAudioBuffer.cpp:56
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:353
cShapeSphere * m_sphereProxy
Sphere object used for rendering the proxy position.
Definition: CHapticPoint.h:239
Implements a force algorithm for modeling haptic effects.
cInteractionRecorder m_interactionRecorder
Interaction recorder.
Definition: CAlgorithmPotentialField.h:114
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:332
cAlgorithmFingerProxy * m_algorithmFingerProxy
Finger-proxy algorithm used for modeling contacts with cMesh objects.
Definition: CHapticPoint.h:226
void initialize()
This method resets the haptic point to the current position of the haptic device. ...
Definition: CHapticPoint.cpp:226
cHapticPoint(cGenericTool *a_parentTool)
Constructor of cHapticPoint.
Definition: CHapticPoint.cpp:60
cAudioSource * m_audioSourceImpact[3]
Optional audio source for rendering sound impacts with environment.
Definition: CHapticPoint.h:297