Improved support for keyboard/mouse events in osgcluster.

This commit is contained in:
Robert Osfield
2005-08-29 14:05:30 +00:00
parent 2e84f10b21
commit 9f740f7397
3 changed files with 13 additions and 20 deletions

View File

@@ -99,7 +99,7 @@ class PackedEvent
double _time;
};
const unsigned int MAX_NUM_EVENTS = 0;
const unsigned int MAX_NUM_EVENTS = 10;
class CameraPacket {
public:
@@ -180,12 +180,12 @@ void CameraPacket::readEventQueue(osgProducer::Viewer& viewer)
osgProducer::EventAdapter* event = itr->get();
_events[_numEvents].set(*event);
}
std::cout<<"written events = "<<_numEvents<<std::endl;
osg::notify(osg::INFO)<<"written events = "<<_numEvents<<std::endl;
}
void CameraPacket::writeEventQueue(osgProducer::Viewer& viewer)
{
std::cout<<"recieved events = "<<_numEvents<<std::endl;
osg::notify(osg::INFO)<<"recieved events = "<<_numEvents<<std::endl;
// copy the packed events to osgProducer style events.
osgProducer::KeyboardMouseCallback::EventQueue queue;
@@ -211,6 +211,10 @@ enum ViewerMode
int main( int argc, char **argv )
{
osg::notify(osg::INFO)<<"FrameStamp "<<sizeof(osg::FrameStamp)<<std::endl;
osg::notify(osg::INFO)<<"osg::Matrix "<<sizeof(osg::Matrix)<<std::endl;
osg::notify(osg::INFO)<<"PackedEvent "<<sizeof(PackedEvent)<<std::endl;
// use an ArgumentParser object to manage the program arguments.
osg::ArgumentParser arguments(&argc,argv);
@@ -304,7 +308,7 @@ int main( int argc, char **argv )
Receiver rc;
bc.setPort(static_cast<short int>(socketNumber));
rc.setPort(static_cast<short int>(socketNumber+1));
rc.setPort(static_cast<short int>(socketNumber));
bool masterKilled = false;
@@ -341,19 +345,17 @@ int main( int argc, char **argv )
rc.setBuffer(cp, sizeof( CameraPacket ));
std::cout << "rc.sync()"<<sizeof( CameraPacket )<<std::endl;
osg::notify(osg::INFO) << "rc.sync()"<<sizeof( CameraPacket )<<std::endl;
rc.sync();
std::cout << "done"<<std::endl;
cp->checkByteOrder();
// cp->writeEventQueue(viewer);
cp->writeEventQueue(viewer);
if (cp->getMasterKilled())
{
std::cout << "received master killed"<<std::endl;
std::cout << "Received master killed."<<std::endl;
// break out of while (!done) loop since we've now want to shut down.
masterKilled = true;
}
@@ -366,7 +368,7 @@ int main( int argc, char **argv )
osg::Timer_t endTick = osg::Timer::instance()->tick();
osg::notify(osg::NOTICE)<<"Time to do sync "<<osg::Timer::instance()->delta_m(startTick,endTick)<<std::endl;
osg::notify(osg::INFO)<<"Time to do cluster sync "<<osg::Timer::instance()->delta_m(startTick,endTick)<<std::endl;
// update the scene by traversing it with the the update visitor which will
// call all node update callbacks and animations.
@@ -399,7 +401,7 @@ int main( int argc, char **argv )
bc.setBuffer(cp, sizeof( CameraPacket ));
bc.sync();
std::cout << "broadcasting death"<<std::endl;
std::cout << "Broadcasting death."<<std::endl;
}

View File

@@ -134,21 +134,14 @@ void Receiver::sync( void )
}
}
#else
std::cout<<"A"<<std::endl;
recvfrom( _so, (caddr_t)_buffer, _buffer_size, 0, 0, &size );
std::cout<<" B"<<std::endl;
while( select( _so+1, &fdset, 0L, 0L, &tv ) )
{
std::cout<<" C"<<std::endl;
if( FD_ISSET( _so, &fdset ) )
{
std::cout<<" D"<<std::endl;
recvfrom( _so, (caddr_t)_buffer, _buffer_size, 0, 0, &size );
}
}
std::cout<<" E"<<std::endl;
#endif
}

View File

@@ -190,7 +190,6 @@ double KeyboardMouseCallback::setEventQueue(EventQueue& queue)
{
double swapTime;
queue.clear();
_eventQueueMutex.lock();
_eventQueue = queue;
swapTime = getTime();
@@ -203,7 +202,6 @@ double KeyboardMouseCallback::appendEventQueue(EventQueue& queue)
{
double swapTime;
queue.clear();
_eventQueueMutex.lock();
_eventQueue.insert(_eventQueue.end(),queue.begin(),queue.end());
swapTime = getTime();