Advertisement
4da

Untitled

4da
Aug 19th, 2012
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.83 KB | None | 0 0
  1. void Translator::mouseMove( int xP, int yP, double x, double y, double z )
  2. {
  3.  
  4.     if( !m_clicked ) { m_xPStartTranslate = xP; m_yPStartTranslate = yP; return; }
  5.     if( m_action == TYPE_TRANSLATE_NONE ) return;
  6.    
  7.     double xDelta = 0, yDelta = 0, zDelta = 0;
  8.     double metrInGl = m_sceneManager->storer()->pasport()->metrInGl();
  9.    
  10.     if( m_modeTranslate || ( m_action == TYPE_TRANSLATE_ANGLE ) || ( m_action == TYPE_FIGURE_CREATE_STAGE2 ))
  11.     {
  12.         m_sceneManager->intersect()->doIntersect( m_xPosObjects / metrInGl, m_yPosObjects / metrInGl, m_zPosObjects / metrInGl, &x, &y, &z );
  13.         x *= metrInGl; y *= metrInGl; z *= metrInGl;
  14.     }
  15.    
  16.     xDelta = x - m_xStartTranslate;
  17.     yDelta = y - m_yStartTranslate;
  18.     zDelta = z - m_zStartTranslate;
  19.    
  20.     int countStep;
  21.     double stepMove;
  22.     if( m_action == TYPE_TRANSLATE_ANGLE )
  23.     {
  24.         zDelta = ( m_modeTranslate ) ? m_yPStartTranslate - yP : xP - m_xPStartTranslate;
  25.     }
  26. else if (m_action == TYPE_FIGURE_CREATE_STAGE2) {
  27. // вот тут подумать надо, наверно, что-то такое:
  28.         if( fabs( stepMove ) > GLHDL_EPSILON )
  29.         {
  30.             countStep = xDelta / stepMove; xDelta = stepMove * countStep;
  31.             countStep = yDelta / stepMove; yDelta = stepMove * countStep;
  32.             countStep = zDelta / stepMove; zDelta = stepMove * countStep;
  33.         }
  34. }
  35.     else
  36.     {
  37.         stepMove = m_sceneManager->storer()->pasport()->stepMove() * metrInGl;
  38.         if( fabs( stepMove ) > GLHDL_EPSILON )
  39.         {
  40.             countStep = xDelta / stepMove; xDelta = stepMove * countStep;
  41.             countStep = yDelta / stepMove; yDelta = stepMove * countStep;
  42.             countStep = zDelta / stepMove; zDelta = stepMove * countStep;
  43.         }
  44.     }
  45.    
  46.     for( uint i = 0; i < m_idObject.count(); i++ )
  47.     {
  48.         SPtr<BaseObject> baseObject = m_sceneManager->storer()->object()->idToSPtr( *m_idObject.at( i ) );
  49.         if( m_action == TYPE_TRANSLATE_ANGLE )
  50.         {
  51.             baseObject->position()->setPivotXYZ( m_xPosObjects, m_yPosObjects, m_zPosObjects );
  52.             baseObject->position()->enablePivot( true );
  53.            
  54.             if( m_modeTranslate )
  55.                 baseObject->position()->setRotatePlusX( zDelta );
  56.             else
  57.                 baseObject->position()->setRotatePlusZ( zDelta );
  58.                
  59.             baseObject->position()->enablePivot( false );
  60.            
  61.         }
  62.         else
  63.         {
  64.             baseObject->position()->setTranslateX( m_basePositionOld[i * 6 + 0] + xDelta );
  65.             baseObject->position()->setTranslateY( m_basePositionOld[i * 6 + 1] + yDelta );
  66.             baseObject->position()->setTranslateZ( m_basePositionOld[i * 6 + 2] + zDelta );
  67.         }
  68.     }
  69.    
  70.     m_xPStartTranslate = xP;
  71.     m_yPStartTranslate = yP;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement