Commit 5ad374a6 authored by schurade's avatar schurade
Browse files

[FIX] dataset manipulator rotation and scaling

parent 0687a2a7
......@@ -1010,7 +1010,6 @@ void WGridRegular3D::stretch( wmath::WPosition str )
m_matrixInverse = wmath::invertMatrix4x4( m_matrix );
}
// TODO(all): compiler warning: warning: unused parameter 'center'
void WGridRegular3D::rotate( osg::Matrixf osgrot, wmath::WPosition center )
{
switch ( m_matrixActive )
......@@ -1033,6 +1032,20 @@ void WGridRegular3D::rotate( osg::Matrixf osgrot, wmath::WPosition center )
wmath::WMatrix<double> rotmat( 4, 4 );
rotmat.makeIdentity();
wmath::WMatrix<double> transTo( 4, 4 );
transTo.makeIdentity();
wmath::WMatrix<double> transFrom( 4, 4 );
transFrom.makeIdentity();
transTo( 0, 3 ) = -center.x();
transTo( 1, 3 ) = -center.y();
transTo( 2, 3 ) = -center.z();
transFrom( 0, 3 ) = center.x();
transFrom( 1, 3 ) = center.y();
transFrom( 2, 3 ) = center.z();
rotmat( 0, 0 ) = osgrot( 0, 0 );
rotmat( 1, 0 ) = osgrot( 1, 0 );
rotmat( 2, 0 ) = osgrot( 2, 0 );
......@@ -1045,7 +1058,9 @@ void WGridRegular3D::rotate( osg::Matrixf osgrot, wmath::WPosition center )
rotmat( 1, 2 ) = osgrot( 1, 2 );
rotmat( 2, 2 ) = osgrot( 2, 2 );
m_rotMatrix = m_rotMatrix * transFrom;
m_rotMatrix = m_rotMatrix * rotmat;
m_rotMatrix = m_rotMatrix * transTo;
m_matrix = m_matrix * m_translateMatrix;
m_matrix = m_matrix * m_stretchMatrix;
......
......@@ -283,17 +283,23 @@ void WMDatasetManipulator::manipulatorMoved()
wmath::WPosition stretch( 1.0, 1.0, 1.0 );
m_grid->translate( wmath::WPosition( m_grid->getTranslate().x() + m_knobx1->getPosition().x() - m_posx1.x(),
m_grid->getTranslate().y() + m_knoby1->getPosition().y() - m_posy1.y(),
m_grid->getTranslate().z() + m_knobz1->getPosition().z() - m_posz1.z() ) );
float orgsizex = static_cast<float>( ( m_posx2Orig - m_posx1Orig ).x() );
float orgsizey = static_cast<float>( ( m_posy2Orig - m_posy1Orig ).y() );
float orgsizez = static_cast<float>( ( m_posz2Orig - m_posz1Orig ).z() );
m_grid->translate( wmath::WPosition( m_grid->getTranslate().x() + ( m_knobx1->getPosition().x() - m_posx1.x() ) *
( static_cast<float>( m_grid->getNbCoordsX() / orgsizex ) ),
m_grid->getTranslate().y() + ( m_knoby1->getPosition().y() - m_posy1.y() ) *
( static_cast<float>( m_grid->getNbCoordsY() / orgsizey ) ),
m_grid->getTranslate().z() + ( m_knobz1->getPosition().z() - m_posz1.z() ) *
( static_cast<float>( m_grid->getNbCoordsZ() / orgsizez ) ) ) );
m_translationX->set( m_grid->getTranslate().x(), true );
m_translationY->set( m_grid->getTranslate().y(), true );
m_translationZ->set( m_grid->getTranslate().z(), true );
stretch.x() = ( m_knobx2->getPosition().x() - m_knobx1->getPosition().x() ) / static_cast<float>( m_grid->getNbCoordsX() );
stretch.y() = ( m_knoby2->getPosition().y() - m_knoby1->getPosition().y() ) / static_cast<float>( m_grid->getNbCoordsY() );
stretch.z() = ( m_knobz2->getPosition().z() - m_knobz1->getPosition().z() ) / static_cast<float>( m_grid->getNbCoordsZ() );
stretch.x() = ( m_knobx2->getPosition().x() - m_knobx1->getPosition().x() ) / orgsizex;
stretch.y() = ( m_knoby2->getPosition().y() - m_knoby1->getPosition().y() ) / orgsizey;
stretch.z() = ( m_knobz2->getPosition().z() - m_knobz1->getPosition().z() ) / orgsizez;
m_grid->stretch( stretch );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment