void InteractiveWidget::MouseRelease( const Camera &in_camera, const ScreenPoint &in_pt ) { m_matTrans = m_matTrans * m_matTransDelta; m_matTransDelta = Matrix4::identity(); m_matRot = m_matRot * m_matRotDelta; m_matRotDelta = Matrix4::identity(); const double dScale = ( m_matScale(0,0) * m_matScaleDelta(0,0) + m_matScale(1,1) * m_matScaleDelta(1,1) + m_matScale(2,2) * m_matScaleDelta(2,2) ) / 3.0; m_matScale = Matrix4::scaling( dScale, dScale, dScale ); m_matScaleDelta = Matrix4::identity(); m_typeTransform = NONE; m_iAxis = -1; }
void CEntity::SetScale(const float& fScaleX, const float& fScaleY, const float& fScaleZ) { m_fScale[AT_X] = fScaleX; m_fScale[AT_Y] = fScaleY; m_fScale[AT_Z] = fScaleZ; for(int i = 0 ; i < AT_MAX; ++i) m_matScale(i, i) = m_fScale[i]; }
void InteractiveWidget::DrawWidget() const { glPushAttrib( GL_LIGHTING_BIT | GL_ENABLE_BIT ); glEnable( GL_LIGHTING ); glPushMatrix(); glMultMatrixd( &m_matTrans(0,0) ); glMultMatrixd( &m_matTransDelta(0,0) ); glMultMatrixd( &m_matRot(0,0) ); glMultMatrixd( &m_matRotDelta(0,0) ); glMultMatrixd( &m_matScale(0,0) ); glMultMatrixd( &m_matScaleDelta(0,0) ); // ToDo: use sphere class to draw widget center //static Sphere sphere(2); SetSelectColor( TRANS ); glPushMatrix(); glScaled(0.1, 0.1, 0.1); //sphere.draw(); glPopMatrix(); if ( m_typeTransform == NONE || m_typeTransform == TRANS_X ) { SetSelectColor( TRANS_X ); glPushMatrix(); glRotated( -90, 0,0,1 ); DrawArrow( 1.0, 0.075, 10 ); glPopMatrix(); } if ( m_typeTransform == NONE || m_typeTransform == TRANS_Y ) { SetSelectColor( TRANS_Y ); DrawArrow( 1.0, 0.075, 10 ); } if ( m_typeTransform == NONE || m_typeTransform == TRANS_Z ) { SetSelectColor( TRANS_Z ); glPushMatrix(); glRotated( 90, 1,0,0 ); DrawArrow( 1.0, 0.075, 10 ); glPopMatrix(); } if ( m_typeTransform == NONE || m_typeTransform == SCALE_X ) { SetSelectColor( SCALE_X ); glPushMatrix(); glRotated( -90, 0,0,1 ); DrawSceptre( 0.5, 0.1, 10, 4 ); glPopMatrix(); } if ( m_typeTransform == NONE || m_typeTransform == SCALE_Y ) { SetSelectColor( SCALE_Y ); DrawSceptre( 0.5, 0.1, 10, 4 ); } if ( m_typeTransform == NONE || m_typeTransform == SCALE_Z ) { SetSelectColor( SCALE_Z ); glPushMatrix(); glRotated( 90, 1,0,0 ); DrawSceptre( 0.5, 0.1, 10, 4 ); glPopMatrix(); } SetSelectColor( ROTATE_X ); glPushMatrix(); glRotated( -90, 0,0,1 ); DrawSceptre(1.5, 0.05, 10, 4 ); if ( m_typeMove == ROTATE_X ) { glRotated( 90, 0,0,1 ); SetSelectColor( ROTATE_X, 1 ); DrawCylinderOpen( Point3(0,-0.1,0), 0.2, 1.5, 40 ); glRotated( 90, 1,0,0 ); SetSelectColor( ROTATE_X, 2 ); DrawCylinderOpen( Point3(0,-0.1,0), 0.2, 1.5, 40 ); } glPopMatrix(); glPushMatrix(); SetSelectColor( ROTATE_Y ); DrawSceptre( 1.5, 0.05, 10, 4 ); if ( m_typeMove == ROTATE_Y ) { glRotated( 90, 0,0,1 ); SetSelectColor( ROTATE_Y, 0 ); DrawCylinderOpen( Point3(0,-0.1,0), 0.2, 1.5, 40 ); glRotated( 90, 1,0,0 ); SetSelectColor( ROTATE_Y, 2 ); DrawCylinderOpen( Point3(0,-0.1,0), 0.2, 1.5, 40 ); } glPopMatrix(); SetSelectColor( ROTATE_Z ); glPushMatrix(); glRotated( 90, 1,0,0 ); DrawSceptre( 1.5, 0.05, 10, 4 ); if ( m_typeMove == ROTATE_Z ) { glRotated( 90, 0,0,1 ); SetSelectColor( ROTATE_Z, 0 ); DrawCylinderOpen( Point3(0,-0.1,0), 0.2, 1.5, 40 ); glRotated( 90, 1,0,0 ); SetSelectColor( ROTATE_Z, 1 ); DrawCylinderOpen( Point3(0,-0.1,0), 0.2, 1.5, 40 ); } glPopMatrix(); if ( m_typeTransform == NONE || m_typeTransform == SCALE ) { SetSelectColor( SCALE ); glPushMatrix(); glRotated( 90, 0,0,1 ); glRotated( -45, 1,0,0 ); DrawSceptre( sqrt(2.0) * 0.5, 0.075, 10, 4 ); glPopMatrix(); } glPopMatrix(); glPopAttrib(); }