bool Scene::load(const ofBuffer& buffer, bool optimize, Handedness handness, const char* extension) { unload(); unsigned int flags = aiProcessPreset_TargetRealtime_MaxQuality; if (optimize) { flags |= aiProcess_ImproveCacheLocality | aiProcess_JoinIdenticalVertices | aiProcess_RemoveRedundantMaterials; } if (handness == LEFT_HANDED) { flags |= aiProcess_ConvertToLeftHanded; } scene = aiImportFileFromMemory(buffer.getBinaryBuffer(), buffer.size(), flags, extension); string err_str = aiGetErrorString(); if (!err_str.empty()) { ofLogError("ofxAssimp::Scene::load") << err_str; } assert(scene); setupResources(); setupNodes(); setupAnimations(); return true; }
void SortLastWindow::clientRender(RenderActionBase *action) { UInt32 p; UInt32 groupId = getMFServers()->size32(); if(getMFServers()->size()) { if(getClientWindow() != NULL) { setupNodes(groupId); /* getClientWindow()->activate(); getClientWindow()->frameInit(); */ action->setWindow(getClientWindow()); if(getComposer() != NULL) getComposer()->startFrame(); DrawEnv oEnv; oEnv.setWindow(action->getWindow()); // render all viewports for(p = 0; p < getMFPort()->size() ; ++p) { Viewport *vp=getPort(p); oEnv.setViewportDimension(vp->calcPixelLeft (), vp->calcPixelBottom (), vp->calcPixelRight (), vp->calcPixelTop (), vp->calcIsFullWindow()); if(getComposer() != NULL) { getComposer()->startViewport(vp); action->setCamera (vp->getCamera ()); action->setBackground(vp->getBackground()); action->setViewarea (vp ); action->setTravMask (vp->getTravMask ()); action->apply(vp->getRoot()); for(UInt16 i=0; i < vp->getMFForegrounds()->size(); i++) { if(dynamic_cast<StatisticsForeground *>( vp->getForegrounds(i)) == NULL) { vp->getForegrounds(i)->draw(&oEnv); } } getComposer()->composeViewport(vp); for(UInt16 i=0; i < vp->getMFForegrounds()->size(); i++) { if(dynamic_cast<StatisticsForeground *>( vp->getForegrounds(i)) != NULL) { vp->getForegrounds(i)->draw(&oEnv); } } } else { vp->render(action); } } // compose whole window if(getComposer() != NULL) getComposer()->composeWindow(); } } }
/*! client rendering */ void SortLastWindow::clientRender(DrawActionBase *action) { UInt32 p; UInt32 groupId = getServers().size(); UInt32 l,b,r,t; UInt32 front,back; SortLastWindow *clusterWindow(this); if(getServers().size()) { Connection *srcConnection= getNetwork()->getConnection(groupId); if(getClientWindow() != NULL) { setupNodes(groupId); /* getClientWindow()->activate(); getClientWindow()->frameInit(); */ action->setWindow(getClientWindow()); if(getComposer() != NULL) getComposer()->startFrame(); DrawEnv oEnv; oEnv.setWindow(action->getWindow()); // render all viewports for(p = 0; p < getPort().size() ; ++p) { Viewport *vp=getPort()[p]; if(getComposer() != NULL) { getComposer()->startViewport(vp); action->setCamera (vp->getCamera ()); action->setBackground(vp->getBackground()); action->setViewport (vp ); action->setTravMask (vp->getTravMask ()); action->apply(vp->getRoot()); for(UInt16 i=0; i < vp->getForegrounds().size(); i++) { if(dynamic_cast<StatisticsForeground *>( vp->getForegrounds(i)) == NULL) { vp->getForegrounds(i)->draw(&oEnv, vp); } } getComposer()->composeViewport(vp); for(UInt16 i=0; i < vp->getForegrounds().size(); i++) { if(dynamic_cast<StatisticsForeground *>( vp->getForegrounds(i)) != NULL) { vp->getForegrounds(i)->draw(&oEnv, vp); } } } else { vp->render(action); } } // compose whole window if(getComposer() != NULL) getComposer()->composeWindow(); } } }
void SortLastWindow::serverRender(Window *serverWindow, UInt32 id, RenderActionBase *action ) { ViewportUnrecPtr serverPort = NULL; Viewport *clientPort = NULL; UInt32 sv = 0; UInt32 cv = 0; // duplicate viewports for(cv = 0, sv = 0; cv < getMFPort()->size(); ++cv) { clientPort = getPort(cv); if(serverWindow->getMFPort()->size() <= sv) { // create new port serverPort = Viewport::create(); serverWindow->addPort(serverPort); } else { serverPort = serverWindow->getPort(sv); } // duplicate values if(getWidth() && getHeight()) { serverPort->setSize(clientPort->calcPixelLeft (), clientPort->calcPixelBottom(), clientPort->calcPixelRight (), clientPort->calcPixelTop ()); } else { serverPort->setSize(0,0,0,0); } serverPort->setCamera (clientPort->getCamera ()); serverPort->setRoot (clientPort->getRoot ()); serverPort->setBackground(clientPort->getBackground()); // ignore statistics foreground serverPort->clearForegrounds(); for(UInt32 f = 0 ; f < serverPort->getMFForegrounds()->size(); ++f) { Foreground *fg = clientPort->getForegrounds(f); StatisticsForeground *sfg = dynamic_cast<StatisticsForeground *>(fg); if(sfg == NULL) { serverPort->addForeground(fg); } } serverPort->setTravMask(clientPort->getTravMask()); sv++; } // remove unused ports while(serverWindow->getMFPort()->size() > sv) { serverWindow->subPort(sv); } // setup visible nodes setupNodes(id); // render the viewports serverWindow->activate(); serverWindow->frameInit(); action->setWindow(serverWindow); if(getComposer() != NULL) getComposer()->startFrame(); for(sv = 0; sv < serverWindow->getMFPort()->size(); ++sv) { Viewport *vp = serverWindow->getPort(sv); if(getComposer() != NULL) getComposer()->startViewport(vp); // render vp->render(action); // compose single viewport if(getComposer() != NULL) getComposer()->composeViewport(vp); } // compose whole window if(getComposer() != NULL) getComposer()->composeWindow(); }
/// @brief Constructor Player::Player (Ogre::SceneManager* sceneManager) : mPlayerAimHeight(100) { setupNodes(sceneManager); setupTargettingSystem(sceneManager); }