#include <OSGTrackball.h>
Definition at line 52 of file OSGTrackball.h.
|
|
Definition at line 56 of file OSGTrackball.h. 00057 { 00058 OSGOrientedTranslation = 0x01, 00059 OSGAbsoluteTranslation = 0x02 00060 };
|
|
|
Definition at line 62 of file OSGTrackball.h.
|
|
|
Definition at line 68 of file OSGTrackball.h.
|
|
|
Definition at line 58 of file OSGTrackball.cpp. 00058 : 00059 _bSum(false), 00060 _bAutoPosition(false), 00061 _gMode(OSGCamera), 00062 _gTransMode(OSGFixedZ), 00063 _gTransGen (OSGAbsoluteTranslation), 00064 _rAutoPositionStep(1.), 00065 _rAutoPositionIncrement(1.), 00066 _rTrackballSize(rSize), 00067 _rTranslationScale(1.), 00068 _qVal(), 00069 _pVal(), 00070 _qValStart(), 00071 _pValStart(), 00072 _pRotationCenter() 00073 { 00074 }
|
|
|
Definition at line 76 of file OSGTrackball.cpp.
|
|
|
|
|
|
Definition at line 78 of file OSGTrackball.h.
|
|
|
Definition at line 109 of file OSGTrackball.cpp. References _bSum. 00110 { 00111 _bSum = bVal; 00112 }
|
|
||||||||||||||||||||
|
Definition at line 114 of file OSGTrackball.cpp. References _bSum, _gMode, _qVal, _rTrackballSize, osg::VectorInterface< ValueTypeT, StorageInterfaceT >::crossThis(), osg::Eps, osg::VectorInterface< ValueTypeT, StorageInterfaceT >::length(), osg::osgabs(), osg::osgasin(), OSGObject, projectToSphere(), osg::QuaternionBase< ValueTypeT >::setValueAsAxisRad(), and osg::VecStorage3< ValueTypeT >::setValues(). 00116 { 00117 Quaternion qCurrVal; 00118 00119 Vec3f gAxis; /* Axis of rotation */ 00120 Real32 rPhi = 0; /* how much to rotate about axis */ 00121 Vec3f gP1; 00122 Vec3f gP2; 00123 Vec3f gDiff; 00124 Real32 rTmp; 00125 00126 if( (osgabs(rLastX - rCurrentX) > Eps) || 00127 (osgabs(rLastY - rCurrentY) > Eps)) 00128 { 00129 /* 00130 * First, figure out z-coordinates for projection of P1 and P2 to 00131 * deformed sphere 00132 */ 00133 00134 gP1.setValues( rLastX, 00135 rLastY, 00136 projectToSphere(_rTrackballSize, rLastX, rLastY)); 00137 00138 gP2.setValues( rCurrentX, 00139 rCurrentY, 00140 projectToSphere(_rTrackballSize, rCurrentX, rCurrentY)); 00141 00142 /* 00143 * Now, we want the cross product of P1 and P2 00144 */ 00145 00146 gAxis = gP2; 00147 gAxis.crossThis(gP1); 00148 00149 /* 00150 * Figure out how much to rotate around that axis. 00151 */ 00152 00153 gDiff = gP2; 00154 gDiff -= gP1; 00155 00156 rTmp = gDiff.length() / (2.0f * _rTrackballSize); 00157 00158 00159 /* 00160 * Avoid problems with out-of-control values... 00161 */ 00162 00163 if(rTmp > 1.0) 00164 rTmp = 1.0; 00165 00166 if(rTmp < -1.0) 00167 rTmp = -1.0; 00168 00169 if(_gMode == OSGObject) 00170 rPhi = (Real32) -2.0 * osgasin(rTmp); 00171 else 00172 rPhi = (Real32) 2.0 * osgasin(rTmp); 00173 00174 } 00175 00176 if(_bSum == false) 00177 { 00178 _qVal.setValueAsAxisRad(gAxis, rPhi); 00179 } 00180 else 00181 { 00182 qCurrVal.setValueAsAxisRad(gAxis, rPhi); 00183 _qVal *= qCurrVal; 00184 // _qVal.multLeft(qCurrVal); 00185 } 00186 }
|
|
||||||||||||||||||||
|
Definition at line 188 of file OSGTrackball.cpp. References _gTransGen, _gTransMode, _pVal, _rTranslationScale, getRotation(), osg::TransformationMatrix< ValueTypeT >::mult(), OSGAbsoluteTranslation, OSGFree, and osg::TransformationMatrix< ValueTypeT >::setRotate(). 00190 { 00191 if(_gTransMode == OSGFree) 00192 { 00193 if(_gTransGen == OSGAbsoluteTranslation) 00194 { 00195 _pVal[0] += (rLastX - rCurrentX) * -_rTranslationScale; 00196 _pVal[1] += (rLastY - rCurrentY) * -_rTranslationScale; 00197 } 00198 else 00199 { 00200 Vec3f tmpVec((rLastX - rCurrentX) * -_rTranslationScale, 00201 (rLastY - rCurrentY) * -_rTranslationScale, 00202 0.); 00203 00204 Matrix m1; 00205 00206 m1.setRotate(getRotation()); 00207 00208 m1.mult(tmpVec); 00209 00210 _pVal[0] += tmpVec[0]; 00211 _pVal[1] += tmpVec[1]; 00212 _pVal[2] += tmpVec[2]; 00213 } 00214 } 00215 }
|
|
||||||||||||||||||||
|
Definition at line 217 of file OSGTrackball.cpp. References _gTransGen, _gTransMode, _pVal, _rTranslationScale, getRotation(), osg::TransformationMatrix< ValueTypeT >::mult(), OSGAbsoluteTranslation, OSGFree, and osg::TransformationMatrix< ValueTypeT >::setRotate(). 00219 { 00220 if(_gTransMode == OSGFree) 00221 { 00222 if(_gTransGen == OSGAbsoluteTranslation) 00223 { 00224 _pVal[2] += (rLastY - rCurrentY) * -_rTranslationScale; 00225 } 00226 else 00227 { 00228 Vec3f tmpVec(0., 00229 0., 00230 (rLastY - rCurrentY) * -_rTranslationScale); 00231 00232 Matrix m1; 00233 00234 m1.setRotate(getRotation()); 00235 00236 m1.mult(tmpVec); 00237 00238 _pVal[0] += tmpVec[0]; 00239 _pVal[1] += tmpVec[1]; 00240 _pVal[2] += tmpVec[2]; 00241 } 00242 } 00243 }
|
|
|
Definition at line 245 of file OSGTrackball.cpp. References _rAutoPositionIncrement. 00246 { 00247 _rAutoPositionIncrement = rVal; 00248 }
|
|
|
Definition at line 250 of file OSGTrackball.cpp. References _bAutoPosition, _rAutoPositionIncrement, and _rAutoPositionStep. 00251 { 00252 _bAutoPosition = bVal; 00253 _rAutoPositionStep = -_rAutoPositionIncrement; 00254 }
|
|
|
Definition at line 256 of file OSGTrackball.cpp. References _bAutoPosition, _rAutoPositionIncrement, and _rAutoPositionStep. 00257 { 00258 _bAutoPosition = bVal; 00259 _rAutoPositionStep = _rAutoPositionIncrement; 00260 }
|
|
|
Definition at line 262 of file OSGTrackball.cpp. References _gMode. 00263 { 00264 _gMode = gMode; 00265 }
|
|
|
Definition at line 267 of file OSGTrackball.cpp. References _gTransMode. 00268 { 00269 _gTransMode = gMode; 00270 }
|
|
|
Definition at line 272 of file OSGTrackball.cpp. References _rTranslationScale. 00273 { 00274 _rTranslationScale = rTranslationScale; 00275 }
|
|
|
Definition at line 277 of file OSGTrackball.cpp. References _gTransGen, _pVal, getFullTrackballMatrix(), OSGAbsoluteTranslation, and OSGOrientedTranslation. 00278 { 00279 if(_gTransGen == OSGAbsoluteTranslation && 00280 gMode == OSGOrientedTranslation) 00281 { 00282 Matrix tmpMat = getFullTrackballMatrix(); 00283 00284 _pVal[0] = tmpMat[3][0]; 00285 _pVal[1] = tmpMat[3][1]; 00286 _pVal[2] = tmpMat[3][2]; 00287 } 00288 00289 _gTransGen = gMode; 00290 }
|
|
|
Definition at line 292 of file OSGTrackball.cpp. References _pVal, _pValStart, _qVal, and _qValStart. 00293 { 00294 _qVal = _qValStart; 00295 _pVal = _pValStart; 00296 }
|
|
||||||||||||||||||||
|
Definition at line 298 of file OSGTrackball.cpp. References _pVal, _pValStart, and osg::VecStorage3< ValueTypeT >::setValues(). 00300 { 00301 _pValStart.setValues(rX, rY, rZ); 00302 00303 if(bUpdate == true) 00304 _pVal = _pValStart; 00305 }
|
|
||||||||||||
|
Definition at line 307 of file OSGTrackball.cpp. References _pVal, and _pValStart. 00308 { 00309 _pValStart = gStartPos; 00310 00311 if(bUpdate == true) 00312 _pVal = _pValStart; 00313 }
|
|
|
Definition at line 315 of file OSGTrackball.cpp. References _bAutoPosition, _gTransMode, _pVal, _rAutoPositionStep, OSGFixedX, OSGFixedY, and OSGFixedZ. Referenced by getFullExamineMatrix(), and getFullTrackballMatrix(). 00316 { 00317 /* 00318 if(_bAutoPosition == true) 00319 _pVal[2] += _rAutoPositionStep; 00320 00321 return _pVal; 00322 */ 00323 if(_bAutoPosition == true) 00324 { 00325 switch(_gTransMode) 00326 { 00327 case OSGFixedX: 00328 _pVal[0] += _rAutoPositionStep; 00329 break; 00330 00331 case OSGFixedY: 00332 _pVal[1] += _rAutoPositionStep; 00333 break; 00334 00335 case OSGFixedZ: 00336 _pVal[2] += _rAutoPositionStep; 00337 break; 00338 00339 default: 00340 break; 00341 } 00342 } 00343 00344 return _pVal; 00345 }
|
|
||||||||||||||||||||||||
|
Definition at line 347 of file OSGTrackball.cpp. References _qVal, _qValStart, and osg::QuaternionBase< ValueTypeT >::setValueAsAxisDeg(). 00349 { 00350 _qValStart.setValueAsAxisDeg(rX, rY, rZ, rW); 00351 00352 if(bUpdate == true) 00353 _qVal = _qValStart; 00354 }
|
|
||||||||||||
|
Definition at line 356 of file OSGTrackball.cpp. References _qVal, and _qValStart. 00357 { 00358 _qValStart = gStartRot; 00359 00360 if(bUpdate == true) 00361 _qVal = _qValStart; 00362 }
|
|
|
Definition at line 364 of file OSGTrackball.cpp. References _pRotationCenter. 00365 { 00366 _pRotationCenter = pRotationCenter; 00367 }
|
|
|
Definition at line 369 of file OSGTrackball.cpp. References _qVal. Referenced by getFullExamineMatrix(), getFullTrackballMatrix(), updatePosition(), and updatePositionNeg(). 00370 { 00371 return _qVal; 00372 }
|
|
|
Definition at line 374 of file OSGTrackball.cpp. References _fullMatrix, _pVal, getPosition(), getRotation(), osg::TransformationMatrix< ValueTypeT >::mult(), and osg::TransformationMatrix< ValueTypeT >::setIdentity(). 00375 { 00376 OSG::Matrix m1; 00377 00378 _fullMatrix.setIdentity(); 00379 00380 _fullMatrix[3][0] = _pVal[0]; 00381 _fullMatrix[3][1] = _pVal[1]; 00382 _fullMatrix[3][2] = _pVal[2]; 00383 00384 m1.setRotate (getRotation()); 00385 _fullMatrix.mult(m1); 00386 00387 m1.setIdentity (); 00388 m1.setTranslate(getPosition()); 00389 00390 _fullMatrix.mult(m1); 00391 00392 m1.setIdentity(); 00393 00394 m1[3][0] = -_pVal[0]; 00395 m1[3][1] = -_pVal[1]; 00396 m1[3][2] = -_pVal[2]; 00397 00398 _fullMatrix.mult(m1); 00399 00400 return _fullMatrix; 00401 }
|
|
|
Definition at line 403 of file OSGTrackball.cpp. References _fullMatrix, _pRotationCenter, getPosition(), getRotation(), osg::TransformationMatrix< ValueTypeT >::mult(), and osg::TransformationMatrix< ValueTypeT >::setIdentity(). Referenced by setTranslationGen(). 00404 { 00405 OSG::Matrix m1; 00406 00407 _fullMatrix.setIdentity(); 00408 00409 _fullMatrix[3][0] = _pRotationCenter[0]; 00410 _fullMatrix[3][1] = _pRotationCenter[1]; 00411 _fullMatrix[3][2] = _pRotationCenter[2]; 00412 00413 m1.setRotate (getRotation()); 00414 _fullMatrix.mult(m1); 00415 00416 m1.setIdentity (); 00417 m1.setTranslate(getPosition()); 00418 00419 _fullMatrix.mult(m1); 00420 00421 m1.setIdentity(); 00422 00423 m1[3][0] = -_pRotationCenter[0]; 00424 m1[3][1] = -_pRotationCenter[1]; 00425 m1[3][2] = -_pRotationCenter[2]; 00426 00427 _fullMatrix.mult(m1); 00428 00429 return _fullMatrix; 00430 }
|
|
|
Definition at line 80 of file OSGTrackball.cpp. References _rTrackballSize. 00081 { 00082 _rTrackballSize = s; 00083 }
|
|
|
Definition at line 85 of file OSGTrackball.cpp. References _rTrackballSize. 00086 { 00087 return _rTrackballSize; 00088 }
|
|
|
|
|
||||||||||||||||
|
Definition at line 90 of file OSGTrackball.cpp. Referenced by updateRotation(). 00091 { 00092 Real32 d, t, z; 00093 00094 d = sqrt(rX * rX + rY * rY); 00095 00096 if (d < rRadius * 0.70710678118654752440f) 00097 { /* Inside sphere */ 00098 z = sqrt(rRadius * rRadius - d * d); 00099 } 00100 else 00101 { /* On hyperbola */ 00102 t = rRadius / 1.41421356237309504880f; 00103 z = t * t / d; 00104 } 00105 00106 return z; 00107 }
|
|
|
Definition at line 126 of file OSGTrackball.h. Referenced by setSum(), and updateRotation(). |
|
|
Definition at line 127 of file OSGTrackball.h. Referenced by getPosition(), setAutoPosition(), and setAutoPositionNeg(). |
|
|
Definition at line 129 of file OSGTrackball.h. Referenced by setMode(), and updateRotation(). |
|
|
Definition at line 130 of file OSGTrackball.h. Referenced by getPosition(), setTranslationMode(), updatePosition(), and updatePositionNeg(). |
|
|
Definition at line 131 of file OSGTrackball.h. Referenced by setTranslationGen(), updatePosition(), and updatePositionNeg(). |
|
|
Definition at line 133 of file OSGTrackball.h. Referenced by getPosition(), setAutoPosition(), and setAutoPositionNeg(). |
|
|
Definition at line 134 of file OSGTrackball.h. Referenced by setAutoPosition(), setAutoPositionIncrement(), and setAutoPositionNeg(). |
|
|
Definition at line 136 of file OSGTrackball.h. Referenced by getSize(), setSize(), and updateRotation(). |
|
|
Definition at line 137 of file OSGTrackball.h. Referenced by setTranslationScale(), updatePosition(), and updatePositionNeg(). |
|
|
Definition at line 139 of file OSGTrackball.h. Referenced by getRotation(), reset(), setStartRotation(), and updateRotation(). |
|
|
Definition at line 140 of file OSGTrackball.h. Referenced by getFullExamineMatrix(), getPosition(), reset(), setStartPosition(), setTranslationGen(), updatePosition(), and updatePositionNeg(). |
|
|
Definition at line 142 of file OSGTrackball.h. Referenced by reset(), and setStartRotation(). |
|
|
Definition at line 143 of file OSGTrackball.h. Referenced by reset(), and setStartPosition(). |
|
|
Definition at line 145 of file OSGTrackball.h. Referenced by getFullTrackballMatrix(), and setRotationCenter(). |
|
|
Definition at line 147 of file OSGTrackball.h. Referenced by getFullExamineMatrix(), and getFullTrackballMatrix(). |
1.4.3