Пример #1
0
bool ModelController::handle(const osgGA::GUIEventAdapter &ea,
                                   osgGA::GUIActionAdapter &aa)
{
    if ( !_model ) return false;
    osg::Matrix matrix = _model->getMatrix();

    switch ( ea.getEventType() )
    {
        case osgGA::GUIEventAdapter::KEYDOWN:
        switch ( ea.getKey() )
        {
        case 'a': case 'A':
            matrix *= osg::Matrix::rotate( -0.1f, osg::Z_AXIS );
            break;
        case 'd': case 'D':
            matrix *= osg::Matrix::rotate(  0.1f, osg::Z_AXIS );
            break;
        case 'w': case 'W':
            matrix *= osg::Matrix::rotate( -0.1f, osg::X_AXIS );
            break;
        case 's': case 'S':
            matrix *= osg::Matrix::rotate(  0.1f, osg::X_AXIS );
            break;
        default:
            break;
        }
        _model->setMatrix( matrix );
        break;
    default:
        break;
    }
    return false;
}
Пример #2
0
void SlideEventHandler::rotateImage(float rx,float ry)
{
    const float scale = 0.5f;
    _texmatLeft->setMatrix(_texmatLeft->getMatrix()*osg::Matrix::translate(-rx*scale,-ry*scale,0.0f));
    _texmatRight->setMatrix(_texmatRight->getMatrix()*osg::Matrix::translate(-rx*scale,-ry*scale,0.0f));
}
Пример #3
0
void SlideEventHandler::scaleImage(float s)
{
    _texmatLeft->setMatrix(_texmatLeft->getMatrix()*osg::Matrix::translate(-0.5f,-0.5f,0.0f)*osg::Matrix::scale(s,s,1.0f)*osg::Matrix::translate(0.5f,0.5f,0.0f));
    _texmatRight->setMatrix(_texmatRight->getMatrix()*osg::Matrix::translate(-0.5f,-0.5f,0.0f)*osg::Matrix::scale(s,s,1.0f)*osg::Matrix::translate(0.5f,0.5f,0.0f));
}
Пример #4
0
void updateTransform()
{
	osg::Matrix m = mt->getMatrix();
	m.setTrans( pos );
	mt->setMatrix( m );
}