Пример #1
0
void
Scene::handleKeyDown(const int& key, const int& mod, bool& handled)
{


    if( key == 'a' ) {
        m_differential->setParam( dParamVel, m_differential->getParam( dParamVel ) + osg::PI * 1.0 ) ;
    }


    if( key == 'd' ) {
        m_differential->setParam( dParamVel, m_differential->getParam( dParamVel ) - osg::PI * 1.0 ) ;
    }


    if( key == 's' ) {
        m_differential->setParam( dParamVel, 0.0 ) ;
    }


    if( key == 'q' ) {
        m_left_slider->setParam( dParamVel, -1.0 ) ;
    }


    if( key == 'w' ) {
        m_left_slider->setParam( dParamVel, 1.0 ) ;
    }


    if( key == 'e' ) {
        m_right_slider->setParam( dParamVel, -1.0 ) ;
    }


    if( key == 'r' ) {
        m_right_slider->setParam( dParamVel, 1.0 ) ;
    }


    if( key == 'x' ) {
        ooReal  friction = osg::clampTo(m_differential->getFriction() + 0.05, 0.0, 1.0) ;

        m_differential->setFriction( friction ) ;
    }


    if( key == 'z' ) {
        ooReal  friction = osg::clampTo(m_differential->getFriction() - 0.05, 0.0, 1.0) ;

        m_differential->setFriction( friction ) ;
    }


    if( key == 'c' ) {
        const ooReal    ratio = m_differential->getRatio1() * 0.5 ;

        m_differential->setRatio1( ratio ) ;
        m_differential->setRatio2( 1.0 / ratio ) ;
    }


    if( key == 'v' ) {
        const ooReal    ratio = m_differential->getRatio1() * 2.0 ;

        m_differential->setRatio1( ratio ) ;
        m_differential->setRatio2( 1.0 / ratio ) ;
    }


}