00001 //=========================================================================== 00002 /* 00003 This file is part of the CHAI 3D visualization and haptics libraries. 00004 Copyright (C) 2003-2009 by CHAI 3D. All rights reserved. 00005 00006 This library is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License("GPL") version 2 00008 as published by the Free Software Foundation. 00009 00010 For using the CHAI 3D libraries with software that can not be combined 00011 with the GNU GPL, and for taking advantage of the additional benefits 00012 of our support services, please contact CHAI 3D about acquiring a 00013 Professional Edition License. 00014 00015 \author <http://www.chai3d.org> 00016 \author Francois Conti 00017 \author Federico Barbagli 00018 \version 2.0.0 $Rev: 256 $ 00019 */ 00020 //=========================================================================== 00021 00022 //--------------------------------------------------------------------------- 00023 #ifndef CGeneric3dofPointerH 00024 #define CGeneric3dofPointerH 00025 //--------------------------------------------------------------------------- 00026 #include "tools/CGenericTool.h" 00027 #include "graphics/CColor.h" 00028 #include "scenegraph/CShapeSphere.h" 00029 #include "scenegraph/CMesh.h" 00030 #include "forces/CProxyPointForceAlgo.h" 00031 #include "forces/CPotentialFieldForceAlgo.h" 00032 //--------------------------------------------------------------------------- 00033 00034 //=========================================================================== 00042 //=========================================================================== 00043 00044 //=========================================================================== 00057 //=========================================================================== 00058 class cGeneric3dofPointer : public cGenericTool 00059 { 00060 public: 00061 00062 //----------------------------------------------------------------------- 00063 // CONSTRUCTOR & DESTRUCTOR: 00064 //----------------------------------------------------------------------- 00065 00067 cGeneric3dofPointer(cWorld* a_world); 00068 00070 virtual ~cGeneric3dofPointer(); 00071 00072 00073 //----------------------------------------------------------------------- 00074 // METHODS - TOOL COMMANDS 00075 //----------------------------------------------------------------------- 00076 00078 virtual int start(); 00079 00081 virtual int stop(); 00082 00084 virtual int initialize(const bool a_resetEncoders=false); 00085 00087 virtual int setForcesON(); 00088 00090 virtual int setForcesOFF(); 00091 00093 virtual void updatePose(); 00094 00096 virtual void computeInteractionForces(); 00097 00099 virtual void applyForces(); 00100 00102 virtual cProxyPointForceAlgo* getProxy() { return m_proxyPointForceModel; } 00103 00105 virtual bool isInContact(cGenericObject* a_object); 00106 00108 virtual cVector3d getProxyGlobalPos() { return (m_proxyPointForceModel->getProxyGlobalPosition()); } 00109 00111 virtual cMatrix3d getProxyGlobalRot() { return (m_deviceGlobalRot); } 00112 00114 virtual cVector3d getDeviceGlobalPos() { return (m_deviceGlobalPos); } 00115 00117 virtual cMatrix3d getDeviceGlobalRot() { return (m_deviceGlobalRot); } 00118 00120 virtual cVector3d getDeviceLocalPos() { return (m_deviceLocalPos); } 00121 00123 virtual cMatrix3d getDeviceLocalRot() { return (m_deviceLocalRot); } 00124 00125 00126 //----------------------------------------------------------------------- 00127 // METHODS - WORKSPACE SETTINGS 00128 //----------------------------------------------------------------------- 00129 00131 virtual void setRadius(const double& a_radius); 00132 00134 virtual void setWorkspaceRadius(const double& a_workspaceRadius); 00135 00137 double getWorkspaceRadius() { return(m_workspaceRadius); } 00138 00140 void setWorkspaceScaleFactor(const double& a_workspaceScaleFactor); 00141 00143 double getWorkspaceScaleFactor() { return (m_workspaceScaleFactor); } 00144 00145 00146 //----------------------------------------------------------------------- 00147 // METHODS - GRAPHICS 00148 //----------------------------------------------------------------------- 00149 00151 virtual void render(const int a_renderMode=0); 00152 00153 00154 //----------------------------------------------------------------------- 00155 // MEMBERS - GRAPHICS 00156 //----------------------------------------------------------------------- 00157 00159 cShapeSphere* m_deviceSphere; 00160 00162 cShapeSphere* m_proxySphere; 00163 00165 cMesh* m_deviceMesh; 00166 00168 cMesh* m_proxyMesh; 00169 00171 cColorf m_colorLine; 00172 00174 cMaterial m_materialProxy; 00175 00177 cMaterial m_materialProxyButtonPressed; 00178 00179 00180 //----------------------------------------------------------------------- 00181 // MEMBERS - FORCE MODELS 00182 //----------------------------------------------------------------------- 00183 00185 cProxyPointForceAlgo* m_proxyPointForceModel; 00186 00188 cPotentialFieldForceAlgo* m_potentialFieldsForceModel; 00189 00197 cVector3d m_lastComputedGlobalForce; 00198 00203 cVector3d m_lastComputedLocalForce; 00204 00205 00206 //----------------------------------------------------------------------- 00207 // MEMBERS - TOOL STATUS AND WORKSPACE SETTINGS 00208 //----------------------------------------------------------------------- 00209 00211 double m_workspaceRadius; 00212 00214 double m_workspaceScaleFactor; 00215 00217 cVector3d m_deviceLocalPos; 00218 00220 cVector3d m_deviceGlobalPos; 00221 00223 cVector3d m_deviceLocalVel; 00224 00226 cVector3d m_deviceGlobalVel; 00227 00229 cMatrix3d m_deviceLocalRot; 00230 00232 cMatrix3d m_deviceGlobalRot; 00233 00234 00235 protected: 00236 00237 //----------------------------------------------------------------------- 00238 // MEMBERS: 00239 //----------------------------------------------------------------------- 00240 00242 cWorld* m_world; 00243 00245 double m_displayRadius; 00246 00248 bool m_userSwitch0; 00249 00251 bool m_forceON; 00252 00254 bool m_forceStarted; 00255 00261 bool m_waitForSmallForce; 00262 }; 00263 00264 //--------------------------------------------------------------------------- 00265 #endif 00266 //--------------------------------------------------------------------------- 00267