예제 #1
0
            Openni2Helper()
            {
                openni::OpenNI::initialize();
                openni::OpenNI::enumerateDevices( &_deviceInfos );

                _camInfos.resize( _deviceInfos.getSize() );
                for( size_t i = 0; i < _deviceInfos.getSize(); ++i ){
                    CameraInfo& c = _camInfos[ i ];
                    const openni::DeviceInfo& devInfo = _deviceInfos[ i ];
                    c.setName(  devInfo.getName() );
                    c.setIndex( i );
                    c.setType( CAMERATYPE_OPENNI2 );
                    String id;
                    id.sprintf( "%s_%s", devInfo.getVendor(), devInfo.getUri() );
                    c.setIdentifier( id );

                    // add the supported modes
                    openni::Device d;
                    d.open( devInfo.getUri() );
                    const openni::SensorInfo* sinfo = d.getSensorInfo( openni::SENSOR_COLOR );
                    const openni::Array<openni::VideoMode>& vmodes = sinfo->getSupportedVideoModes();
                    for( size_t i = 0; i < vmodes.getSize(); ++i ){
                        const openni::VideoMode& vm = vmodes[ i ];
                        try {
                            c.addMode( CameraMode( vm.getResolutionX(), vm.getResolutionY(), vm.getFps(), toIFormat( vm.getPixelFormat() ) ) );
                        } catch( const cvt::Exception& e ){}
                    }
                    d.close();
                }
            }
예제 #2
0
파일: ingamestate.cpp 프로젝트: aap/openrw
void IngameState::handleEvent(const SDL_Event& event)
{
	auto player = game->getPlayer();

	switch(event.type) {
	case SDL_KEYDOWN:
		switch(event.key.keysym.sym) {
		case SDLK_ESCAPE:
			StateManager::get().enter(new PauseState(game));
			break;
		case SDLK_m:
			StateManager::get().enter(new DebugState(game, _look.position, _look.rotation));
			break;
		case SDLK_SPACE:
			if( getWorld()->state->currentCutscene )
			{
				getWorld()->state->skipCutscene = true;
			}
			break;
		case SDLK_c:
			camMode = CameraMode((camMode+(CameraMode)1)%CAMERA_MAX);
			break;
		case SDLK_w:
			_movement.x = 1.f;
			break;
		case SDLK_s:
			_movement.x =-1.f;
			break;
		case SDLK_a:
			_movement.y = 1.f;
			break;
		case SDLK_d:
			_movement.y =-1.f;
			break;
		default: break;
		}
		break;

	case SDL_KEYUP:
		switch(event.key.keysym.sym) {
		case SDLK_w:
		case SDLK_s:
			_movement.x = 0.f;
			break;
		case SDLK_a:
		case SDLK_d:
			_movement.y = 0.f;
			break;
		default: break;
		}
		break;
	default: break;
	}
	
	if( player && player->isInputEnabled() )
	{
		handlePlayerInput(event);
	}
	State::handleEvent(event);
}
예제 #3
0
void IngameState::handleEvent(const sf::Event &event)
{
	auto player = game->getPlayer();

	switch(event.type) {
	case sf::Event::KeyPressed:
		switch(event.key.code) {
		case sf::Keyboard::Escape:
			StateManager::get().enter(new PauseState(game));
			break;
		case sf::Keyboard::M:
			StateManager::get().enter(new DebugState(game, _look.position, _look.rotation));
			break;
		case sf::Keyboard::Space:
			if( getWorld()->state->currentCutscene )
			{
				getWorld()->state->skipCutscene = true;
			}
			break;
		case sf::Keyboard::C:
			camMode = CameraMode((camMode+(CameraMode)1)%CAMERA_MAX);
			break;
		case sf::Keyboard::W:
			_movement.x = 1.f;
			break;
		case sf::Keyboard::S:
			_movement.x =-1.f;
			break;
		case sf::Keyboard::A:
			_movement.y = 1.f;
			break;
		case sf::Keyboard::D:
			_movement.y =-1.f;
			break;
		default: break;
		}
		break;
	case sf::Event::KeyReleased:
		switch(event.key.code) {
		case sf::Keyboard::W:
		case sf::Keyboard::S:
			_movement.x = 0.f;
			break;
		case sf::Keyboard::A:
		case sf::Keyboard::D:
			_movement.y = 0.f;
			break;
		default: break;
		}
		break;
	default: break;
	}
	
	if( player && player->isInputEnabled() )
	{
		handlePlayerInput(event);
	}
	State::handleEvent(event);
}