void display(void) { /* std::cout << "FH timeStamp: " << FrameHandler::the()->getTimeStamp() << std::endl; std::cout << "xform0.translation: " << gXForm->getTranslation() << "\nxform0.rotation: " << gXForm->getRotation() << std::endl; */ FrameHandler::the()->frame(); commitChangesAndClear(); #if 0 for(UInt32 i = 0; i < g_anim.size(); ++i) { g_anim[i].anim->getTimeSensor()->dump(); } #endif mgr->redraw(); osgSleep(100); }
void Linux3AxisEventInterface::workProc(void) { while(_bRunning == true) { getRawData(); if(_uiNapTime > 0) osgSleep(_uiNapTime); } }
void SceneFileHandlerBase::readProgress(void * OSG_CHECK_ARG(data)) { SceneFileHandlerBase *the = SceneFileHandler::the(); if(the->_readProgressFP == NULL || the->_progressData.is == NULL) return; UInt32 p = 0; while(p < 100 && !the->_readReady) { if(!the->_progressData.is->eof() && !the->_progressData.is->bad()) { UInt64 pos = the->_progressData.is->tellg(); p = UInt32((pos * 100) / the->_progressData.length); if(p > 100) p = 100; } else { p = 100; } the->_readProgressFP(p); if(the->_useProgressThread) { osgSleep(100); } else { break; } } if(the->_useProgressThread && p < 100) { the->_readProgressFP(100); } }
void FCFileHandlerBase::readProgress(void *data) { UInt32 p = 0; while(p < 100 && !FCFileHandler::the()->_ReadReady) { if(!FCFileHandler::the()->_ProgressData.is->eof() && !FCFileHandler::the()->_ProgressData.is->bad()) { UInt64 pos = FCFileHandler::the()->_ProgressData.is->tellg(); p = UInt32((pos * 100) / FCFileHandler::the()->_ProgressData.length); if(p > 100) p = 100; } else { p = 100; } FCFileHandler::the()->_ReadProgressFP(p); osgSleep(100); } if(p < 100) FCFileHandler::the()->_ReadProgressFP(100); }
void CSMNativeWindow::xMainLoop(void) { XEvent event; char buffer[31]; KeySym keysym; // Sleep 2 sec to open the window; //sleep(_uiCreateNapTime); //sleep(1); osgSleep(100); while(_bRun == true) { WindowListIt winIt = _vWindowList.begin(); WindowListConstIt winEnd = _vWindowList.end (); while(winIt != winEnd) { Display *pDisplay = (*winIt)->getDisplay(); while(XPending(pDisplay)) { XNextEvent(pDisplay, &event); switch(event.type) { case KeyPress: XLookupString(&event.xkey, buffer, 30, &keysym, NULL); #if 0 fprintf(stderr, "%x %x %x\n", keysym, XK_F12, XK_Home); #endif if(keysym == XK_Escape) { _bRun = false; } else if(keysym == XK_End) { fprintf(stderr, "Dump\n"); (*winIt)->getWindow()->getShaderCache()->dump(); } else if(keysym == XK_F12) { FieldContainerFactory::the()->dump(); } else if(keysym == XK_F11) { fprintf(stderr, "dump vp[0] root\n"); Window *pWin = (*winIt)->getWindow(); if(pWin != NULL) { Viewport *pPort = pWin->getPort(0); if(pPort != NULL) { fprintf(stderr, "root %p\n", static_cast<void *>( pPort->getRoot())); DotFileGeneratorGraphOpRefPtr pGO = DotFileGeneratorGraphOp::create(); pGO->traverse(pPort->getRoot()); } else { fprintf(stderr, "viewport NULL\n"); } } else { fprintf(stderr, "win NULL\n"); } } else if(keysym == XK_F10) { fprintf(stderr, "osg dump vp[0] root\n"); Window *pWin = (*winIt)->getWindow(); if(pWin != NULL) { Viewport *pPort = pWin->getPort(0); if(pPort != NULL) { fprintf(stderr, "root %p\n", static_cast<void *>( pPort->getRoot())); SceneFileHandler::the()->write( pPort->getRoot(), "/tmp/csm.osg"); } else { fprintf(stderr, "viewport NULL\n"); } } else { fprintf(stderr, "win NULL\n"); } } else if(keysym == XK_F8) { fprintf(stderr, "pass mask pool\n"); fprintf(stderr, "================\n"); PassMaskPool::the()->dump(); fprintf(stderr, "render prop pool\n"); fprintf(stderr, "================\n"); RenderPropertiesPool::the()->dump(); } else if(keysym == XK_Home) { ComplexSceneManager::the()->resetScene(); } else if((XK_space <= keysym) && (XK_asciitilde >= keysym)) { ComplexSceneManager::the()->key( event.xkey.x, event.xkey.y, CSMKeyData::ButtonDown, Char8(keysym)); } break; case KeyRelease: XLookupString(&event.xkey, buffer, 30, &keysym, NULL); //fprintf(stderr, "%x\n", keysym); if(keysym == XK_Escape) { } else if((XK_space <= keysym) && (XK_asciitilde >= keysym)) { ComplexSceneManager::the()->key( event.xkey.x, event.xkey.y, CSMKeyData::ButtonUp, Char8(keysym)); } break; case ButtonPress: (*winIt)->mouse(event.xbutton.button - 1, MouseData::ButtonDown, mapModifier(event.xbutton.state), event.xbutton.x, event.xbutton.y); break; case ButtonRelease: (*winIt)->mouse(event.xbutton.button - 1, MouseData::ButtonUp, mapModifier(event.xbutton.state), event.xbutton.x, event.xbutton.y); break; case MotionNotify: (*winIt)->motion(event.xbutton.x, event.xbutton.y, mapModifier(event.xbutton.state)); break; case ConfigureNotify: { (*winIt)->reshape(event.xconfigure.width, event.xconfigure.height); } break; default: break; } } ++winIt; } ComplexSceneManager::the()->frame(); Thread::getCurrentChangeList()->commitChangesAndClear(); } ComplexSceneManager::the()->terminate(); }