Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Translator::mouseMove( int xP, int yP, double x, double y, double z )
- {
- if( !m_clicked ) { m_xPStartTranslate = xP; m_yPStartTranslate = yP; return; }
- if( m_action == TYPE_TRANSLATE_NONE ) return;
- double xDelta = 0, yDelta = 0, zDelta = 0;
- double metrInGl = m_sceneManager->storer()->pasport()->metrInGl();
- if( m_modeTranslate || ( m_action == TYPE_TRANSLATE_ANGLE ) || ( m_action == TYPE_FIGURE_CREATE_STAGE2 ))
- {
- m_sceneManager->intersect()->doIntersect( m_xPosObjects / metrInGl, m_yPosObjects / metrInGl, m_zPosObjects / metrInGl, &x, &y, &z );
- x *= metrInGl; y *= metrInGl; z *= metrInGl;
- }
- xDelta = x - m_xStartTranslate;
- yDelta = y - m_yStartTranslate;
- zDelta = z - m_zStartTranslate;
- int countStep;
- double stepMove;
- if( m_action == TYPE_TRANSLATE_ANGLE )
- {
- zDelta = ( m_modeTranslate ) ? m_yPStartTranslate - yP : xP - m_xPStartTranslate;
- }
- else if (m_action == TYPE_FIGURE_CREATE_STAGE2) {
- // вот тут подумать надо, наверно, что-то такое:
- if( fabs( stepMove ) > GLHDL_EPSILON )
- {
- countStep = xDelta / stepMove; xDelta = stepMove * countStep;
- countStep = yDelta / stepMove; yDelta = stepMove * countStep;
- countStep = zDelta / stepMove; zDelta = stepMove * countStep;
- }
- }
- else
- {
- stepMove = m_sceneManager->storer()->pasport()->stepMove() * metrInGl;
- if( fabs( stepMove ) > GLHDL_EPSILON )
- {
- countStep = xDelta / stepMove; xDelta = stepMove * countStep;
- countStep = yDelta / stepMove; yDelta = stepMove * countStep;
- countStep = zDelta / stepMove; zDelta = stepMove * countStep;
- }
- }
- for( uint i = 0; i < m_idObject.count(); i++ )
- {
- SPtr<BaseObject> baseObject = m_sceneManager->storer()->object()->idToSPtr( *m_idObject.at( i ) );
- if( m_action == TYPE_TRANSLATE_ANGLE )
- {
- baseObject->position()->setPivotXYZ( m_xPosObjects, m_yPosObjects, m_zPosObjects );
- baseObject->position()->enablePivot( true );
- if( m_modeTranslate )
- baseObject->position()->setRotatePlusX( zDelta );
- else
- baseObject->position()->setRotatePlusZ( zDelta );
- baseObject->position()->enablePivot( false );
- }
- else
- {
- baseObject->position()->setTranslateX( m_basePositionOld[i * 6 + 0] + xDelta );
- baseObject->position()->setTranslateY( m_basePositionOld[i * 6 + 1] + yDelta );
- baseObject->position()->setTranslateZ( m_basePositionOld[i * 6 + 2] + zDelta );
- }
- }
- m_xPStartTranslate = xP;
- m_yPStartTranslate = yP;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement