Parent Directory | Revision Log
Cleanup namespace usage in eqPly [ ] May break build [ ] Breaks existing applications [ ] Bugfix [ ] New Feature [x] Cleanup [ ] Optimization [ ] Documentation
/* Copyright (c) 2006-2007, Stefan Eilemann <[email protected]> All rights reserved. */ #include "config.h" using namespace std; namespace eqPly { Config::Config() : _running( false ), _spinX( 5 ), _spinY( 5 ) { } Config::~Config() { } bool Config::init() { // init distributed objects _frameData.data.color = _initData.useColor(); registerObject( &_frameData ); _initData.setFrameDataID( _frameData.getID( )); registerObject( &_initData ); // init config _running = eq::Config::init( _initData.getID( )); if( !_running ) return false; // init tracker if( !_initData.getTrackerPort().empty( )) { if( !_tracker.init( _initData.getTrackerPort() )) EQWARN << "Failed to initialise tracker" << endl; else { // Set up position of tracking system in world space // Note: this depends on the physical installation. vmml::Matrix4f m( vmml::Matrix4f::IDENTITY ); m.scale( 1.f, 1.f, -1.f ); //m.x = .5; _tracker.setWorldToEmitter( m ); m = vmml::Matrix4f::IDENTITY; m.rotateZ( -M_PI_2 ); _tracker.setSensorToObject( m ); EQLOG( eq::LOG_CUSTOM ) << "Tracker initialised" << endl; } } return true; } bool Config::exit() { _running = false; const bool ret = eq::Config::exit(); _initData.setFrameDataID( EQ_ID_INVALID ); deregisterObject( &_initData ); deregisterObject( &_frameData ); return ret; } uint32_t Config::startFrame() { // update head position if( _tracker.isRunning() ) { _tracker.update(); const vmml::Matrix4f& headMatrix = _tracker.getMatrix(); setHeadMatrix( headMatrix ); } // update database _frameData.data.rotation.preRotateX( -0.001f * _spinX ); _frameData.data.rotation.preRotateY( -0.001f * _spinY ); const uint32_t version = _frameData.commit(); return eq::Config::startFrame( version ); } bool Config::handleEvent( const eq::ConfigEvent* event ) { switch( event->type ) { case eq::ConfigEvent::WINDOW_CLOSE: _running = false; return true; case eq::ConfigEvent::KEY_PRESS: switch( event->keyPress.key ) { case 'q': case eq::KC_ESCAPE: _running = false; return true; case 'r': case ' ': _spinX = 0; _spinY = 0; _frameData.reset(); return true; } break; case eq::ConfigEvent::POINTER_BUTTON_PRESS: if( event->pointerButtonPress.buttons == ( eq::PTR_BUTTON1 | eq::PTR_BUTTON2 | eq::PTR_BUTTON3 )) { _running = false; return true; } break; case eq::ConfigEvent::POINTER_BUTTON_RELEASE: if( event->pointerButtonRelease.buttons == eq::PTR_BUTTON_NONE && event->pointerButtonRelease.button == eq::PTR_BUTTON1 ) { _spinX = event->pointerButtonRelease.dx; _spinY = event->pointerButtonRelease.dy; } return true; case eq::ConfigEvent::POINTER_MOTION: if( event->pointerMotion.buttons == eq::PTR_BUTTON_NONE ) return true; if( event->pointerMotion.buttons == eq::PTR_BUTTON1 ) { _spinX = 0; _spinY = 0; _frameData.data.rotation.preRotateX( -0.005f * event->pointerMotion.dx ); _frameData.data.rotation.preRotateY( -0.005f * event->pointerMotion.dy ); } else if( event->pointerMotion.buttons == eq::PTR_BUTTON2 || event->pointerMotion.buttons == ( eq::PTR_BUTTON1 | eq::PTR_BUTTON3 )) { _frameData.data.translation.z += .005f * event->pointerMotion.dy; } else if( event->pointerMotion.buttons == eq::PTR_BUTTON3 ) { _frameData.data.translation.x += .0005f * event->pointerMotion.dx; _frameData.data.translation.y -= .0005f * event->pointerMotion.dy; } return true; default: break; } return eq::Config::handleEvent( event ); } }
Back to Equalizer website | ViewVC Help |
Powered by ViewVC 1.0.3 |