void Scene02::InitializeSubScene() { SceneLoader sceneLoader; if (!sceneLoader.LoadFromFile(this, "Scene02")) { assert(false); return; } }
void initialize() { logMsg("initialize\n"); // Create view if (!m_view) { m_view = std::make_shared<View>(); } // Create a scene object if (!m_scene) { m_scene = std::make_shared<Scene>(); m_skybox = std::shared_ptr<Skybox>(new Skybox("cubemap.png")); m_skybox->init(); } // Create a tileManager if (!m_tileManager) { m_tileManager = TileManager::GetInstance(); // Pass references to the view and scene into the tile manager m_tileManager->setView(m_view); m_tileManager->setScene(m_scene); } // Hard-coded setup for stuff that isn't loaded through the config file yet m_ftContext = std::make_shared<FontContext>(); m_ftContext->addFont("FiraSans-Medium.ttf", "FiraSans"); m_labels = Labels::GetInstance(); m_labels->setFontContext(m_ftContext); m_labels->setView(m_view); SceneLoader loader; loader.loadScene("config.yaml", *m_scene, *m_tileManager, *m_view); // Set up openGL state glDisable(GL_BLEND); glDisable(GL_STENCIL_TEST); glEnable(GL_DEPTH_TEST); glClearDepthf(1.0); glDepthRangef(0.0, 1.0); glDepthMask(GL_TRUE); glDepthFunc(GL_LEQUAL); glEnable(GL_CULL_FACE); glFrontFace(GL_CCW); glCullFace(GL_BACK); glClearColor(0.3f, 0.3f, 0.3f, 1.0f); while (Error::hadGlError("Tangram::initialize()")) {} logMsg("finish initialize\n"); }
/// Load a scene from a file Node::SPtr Simulation::load ( const char *filename ) { if( sofa::helper::system::SetDirectory::GetFileName(filename).empty() || // no filename sofa::helper::system::SetDirectory::GetExtension(filename).empty() ) // filename with no extension return NULL; SceneLoader *loader = SceneLoaderFactory::getInstance()->getEntryFileName(filename); if (loader) return loader->load(filename); // unable to load file serr << "extension ("<<sofa::helper::system::SetDirectory::GetExtension(filename)<<") not handled" << sendl; return NULL; }
void NetworkRenderer::run() { while(!serv.is_connected() && serv.get_failed_connections()<MAX_FAILED_CONNECTIONS) { Logger::log()<<"Waiting for server"<<std::endl; sleep(1); } if(!serv.is_connected()) { Logger::log()<<"Connection timeout. Closing client"<<std::endl; serv.stop(); return; } string login_string="LOGIN "; char ptr[40]=""; gethostname(ptr,40); login_string.append(ptr); serv.send_message(login_string); SceneLoader sceneLoader; Scene *scene; int global_width,global_height; Renderer renderer(scene,NULL); int numOfCPUs = sysconf(_SC_NPROCESSORS_ONLN); while(serv.is_connected()) { if(!serv.has_messages()) { serv.wait_for_message(); } string mes = ""; if(serv.has_messages()) { mes=serv.unstack_message(); } stringstream mes_ss(stringstream::in | stringstream::out); mes_ss<<mes; string head; mes_ss>>head; /*message parsing*/ if(head=="SETSCENE") { string filexml; mes_ss>>filexml; Logger::log(LOG_INFO)<<"Set scene file: <"<<filexml<<">"<<std::endl; sceneLoader.load(filexml,&scene,global_width,global_height); renderer.set_scene(scene); } else if(head=="CALCULATE") {
/// Load a scene Node::SPtr Simulation::load ( const char *filename ) { SceneLoader *loader = SceneLoaderFactory::getInstance()->getEntryFileName(filename); if (loader) { sRoot = loader->load(filename); return sRoot; } // unable to load file std::cerr << "Simulation : Error : extension not handled" << std::endl; return NULL; }
/// Print all object in the graph void Simulation::exportGraph ( Node* root, const char* filename ) { if ( !root ) return; SceneLoader *exporter = SceneLoaderFactory::getInstance()->getExporterEntryFileName(filename); if (exporter) { exporter->write(root,filename); } else { // unable to write the file serr << "exportGraph: extension ("<<sofa::helper::system::SetDirectory::GetExtension(filename)<<") not handled for export" << sendl; } }
int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); if (app.arguments().size() == 2 && app.arguments().at(1) == "--help") { printUsage(); return 0; } InputParametersParser paramatersParser; InputParametersPointer inputParameters = paramatersParser.parseInputParameters(app.arguments()); if (inputParameters == NULL) { std::cout << "Invalid arguments passed to application" << std::endl; printUsage(); return -1; } // std::cout << *inputParameters; std::cout << "Loading scene..." << std::endl; SceneLoader sceneLoader; ScenePointer scene = sceneLoader.loadScene(inputParameters->sceneFilePath); if (scene == NULL) { std::cout << "Scene loading failed" << std::endl; return -1; } std::cout << "Loading scene is finished" << std::endl; RadiosityEngine radiosityEngine; radiosityEngine.setScene(scene); radiosityEngine.setImageResolution(inputParameters->xResolution, inputParameters->yResolution); std::cout << "Calculating illumination..." << std::endl; radiosityEngine.calculateIllumination(inputParameters->iterationsNumber, inputParameters->patchSize, inputParameters->raysNumberPerPatch); std::cout << "Calculating illumination is finished" << std::endl; std::cout << "Rendering scene..." << std::endl; radiosityEngine.renderScene(); std::cout << "Rendering scene is finished" << std::endl; std::cout << "Saving image to file '" << inputParameters->outputFilePath.toUtf8().constData() << "'..." << std::endl; radiosityEngine.saveRenderedImageToFile(inputParameters->outputFilePath); std::cout << "Image is saved" << std::endl; return 0; }
int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); if (app.arguments().size() == 2 && app.arguments().at(1) == "--help") { printUsage(); return 0; } InputParametersParser paramatersParser; InputParametersPointer inputParameters = paramatersParser.parseInputParameters(app.arguments()); if (inputParameters == NULL) { std::cout << "Invalid arguments passed to application" << std::endl; printUsage(); return -1; } std::cout << "Loading scene..." << std::endl; SceneLoader sceneLoader; ScenePointer scene = sceneLoader.loadScene(inputParameters->sceneFilePath); if (scene == NULL) { std::cout << "Scene loading failed" << std::endl; return -1; } std::cout << "Loading scene finished" << std::endl; RayTracer rayTracer; rayTracer.setScene(scene); rayTracer.setImageResolution(inputParameters->xResolution, inputParameters->yResolution); std::cout << "Rendering scene..." << std::endl; rayTracer.renderScene(); std::cout << "Rendering scene finished" << std::endl; std::cout << "Saving image to file '" << inputParameters->outputFilePath.toUtf8().constData() << "'" << std::endl; rayTracer.saveRenderedImageToFile(inputParameters->outputFilePath); std::cout << "Image is saved" << std::endl; return 0; }
bool Scene::Load(Rid rid) { SceneLoader sl; return sl.Load(rid, this->root); }
// loads an object into the scene from a file void loadObjectFromFile(string filename) { // declare current object struct ObjectInstance curObject; // load object SceneLoader sceneLoader; int objId = sceneLoader.loadAndAddObject(filename); int NumVertices = sceneLoader.objects[objId].faces.size(); NumVertices = NumVertices * 3; cout << NumVertices << endl; curObject.points = new point4[NumVertices]; curObject.normals = new vec4[NumVertices]; Index = 0; for (unsigned int j = 0; j < sceneLoader.objects[objId].faces.size(); j++) { myFunc(sceneLoader.objects[objId], sceneLoader.objects[objId].faces[j], curObject); } // Create a vertex array object GLuint vao; glGenVertexArrays(1, &vao); glBindVertexArray(vao); // fill in rest of details for object and add to list curObject.vaoID = vao; curObject.numVertices = NumVertices; curObject.selectionR = idcount; ///Really only using red component to store unique id! printf("Set red component to %d\n", curObject.selectionR); curObject.selectionG = 0; curObject.selectionB = 0; curObject.selectionA = 255; curObject.translate = Translate(0, 0, 0); curObject.rotate = RotateX(0); curObject.scale = Scale(1, 1, 1); myObjects.push_back(curObject); counter++; idcount++; // Create and initialize a buffer object GLuint buffer; glGenBuffers(1, &buffer); glBindBuffer( GL_ARRAY_BUFFER, buffer); int pointsSize = NumVertices * sizeof(point4); int normalzSize = NumVertices * sizeof(vec4); glBufferData( GL_ARRAY_BUFFER, pointsSize + normalzSize, NULL, GL_STATIC_DRAW); glBufferSubData( GL_ARRAY_BUFFER, 0, pointsSize, curObject.points); glBufferSubData( GL_ARRAY_BUFFER, pointsSize, normalzSize, curObject.normals); // set up vertex arrays GLuint vPosition = glGetAttribLocation(mainShaderProgram, "vPosition"); glEnableVertexAttribArray(vPosition); glVertexAttribPointer(vPosition, 4, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0)); GLuint vNormal = glGetAttribLocation(mainShaderProgram, "vNormal"); glEnableVertexAttribArray(vNormal); glVertexAttribPointer(vNormal, 4, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(pointsSize)); display(); }
void initialize() { logMsg("initialize\n"); // Create view if (!m_view) { m_view = std::make_shared<View>(); } // Create a scene object if (!m_scene) { m_scene = std::make_shared<Scene>(); m_skybox = std::shared_ptr<Skybox>(new Skybox("cubemap.png")); m_skybox->init(); } // Create a tileManager if (!m_tileManager) { m_tileManager = TileManager::GetInstance(); // Pass references to the view and scene into the tile manager m_tileManager->setView(m_view); m_tileManager->setScene(m_scene); } SceneLoader loader; loader.loadScene("config.yaml", *m_scene, *m_tileManager, *m_view); // Hard-coded setup for stuff that isn't loaded through the config file yet m_ftContext = std::make_shared<FontContext>(); m_ftContext->addFont("FiraSans-Medium.ttf", "FiraSans"); m_ftContext->addFont("FuturaStd-Condensed.ttf", "Futura"); m_labelContainer = LabelContainer::GetInstance(); m_labelContainer->setFontContext(m_ftContext); m_labelContainer->setView(m_view); std::unique_ptr<Style> textStyle0(new TextStyle("FiraSans", "Textstyle0", 15.0f, 0xF7F0E1, true, true)); StyleParamMap emptyParamMap; textStyle0->addLayer({ "roads", std::move(emptyParamMap)}); textStyle0->addLayer({ "places", std::move(emptyParamMap)}); textStyle0->addLayer({ "pois", std::move(emptyParamMap)}); m_scene->addStyle(std::move(textStyle0)); std::unique_ptr<Style> textStyle1(new TextStyle("Futura", "Textstyle1", 18.0f, 0x26241F, true, true)); textStyle1->addLayer({ "landuse", std::move(emptyParamMap)}); m_scene->addStyle(std::move(textStyle1)); std::unique_ptr<Style> debugTextStyle(new DebugTextStyle("FiraSans", "DebugTextStyle", 30.0f, 0xDC3522, true)); m_scene->addStyle(std::move(debugTextStyle)); // Set up openGL state glDisable(GL_BLEND); glDisable(GL_STENCIL_TEST); glEnable(GL_DEPTH_TEST); glClearDepthf(1.0); glDepthRangef(0.0, 1.0); glDepthMask(GL_TRUE); glDepthFunc(GL_LEQUAL); glEnable(GL_CULL_FACE); glFrontFace(GL_CCW); glCullFace(GL_BACK); glClearColor(0.3f, 0.3f, 0.3f, 1.0f); while (Error::hadGlError("Tangram::initialize()")) {} logMsg("finish initialize\n"); }