/* main function in embree namespace */ int main(int argc, char** argv) { /* for best performance set FTZ and DAZ flags in MXCSR control and status register */ _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); /* set default camera */ g_camera.from = Vec3fa(2.5f,2.5f,2.5f); g_camera.to = Vec3fa(0.0f,0.0f,0.0f); /* create stream for parsing */ Ref<ParseStream> stream = new ParseStream(new CommandLineStream(argc, argv)); /* parse command line */ parseCommandLine(stream, FileName()); if (g_numThreads) g_rtcore += ",threads=" + toString(g_numThreads); /* initialize ray tracing core */ init(g_rtcore.c_str()); /* render to disk */ if (outFilename.str() != "") { renderToFile(outFilename); return 0; } /* initialize GLUT */ initWindowState(argc,argv,tutorialName, g_width, g_height, g_fullscreen); /* enter the GLUT run loop */ enterWindowRunLoop(); return 0; }
void main(int argc, char **argv) { std::cout << " === Possible cmd line options: -lazy, -pregenerate, -cache === " << std::endl; /* set default camera */ g_camera.from = Vec3fa(1.5f,1.5f,-1.5f); g_camera.to = Vec3fa(0.0f,0.0f,0.0f); /*! Parse command line options. */ parseCommandLine(new ParseStream(new CommandLineStream(argc, argv)), FileName()); /*! Set the thread count in the Embree configuration string. */ if (g_numThreads) g_rtcore += ",threads=" + std::stringOf(g_numThreads); g_rtcore += g_subdiv_mode; /*! Initialize the task scheduler. */ #if !defined(RTCORE_EXPORT_ALL_SYMBOLS) TaskScheduler::create(g_numThreads); #endif /*! Initialize Embree state. */ init(g_rtcore.c_str()); /* render to disk */ if (outFilename.str() != "") renderToFile(outFilename); /* interactive mode */ if (g_interactive) { initWindowState(argc,argv,tutorialName, g_width, g_height, g_fullscreen); enterWindowRunLoop(); } }
int main(int argc, char **argv) { /* for best performance set FTZ and DAZ flags in MXCSR control and status register */ _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); std::cout << " === Possible cmd line options: -pregenerate, -cache === " << std::endl; /* set default camera */ g_camera.from = Vec3fa(1.5f,1.5f,-1.5f); g_camera.to = Vec3fa(0.0f,0.0f,0.0f); /*! Parse command line options. */ parseCommandLine(new ParseStream(new CommandLineStream(argc, argv)), FileName()); /*! Set the thread count in the Embree configuration string. */ if (g_numThreads) g_rtcore += ",threads=" + std::to_string((long long)g_numThreads); g_rtcore += g_subdiv_mode; /*! Initialize Embree state. */ init(g_rtcore.c_str()); /* render to disk */ if (outFilename.str() != "") renderToFile(outFilename); /* interactive mode */ if (g_interactive) { initWindowState(argc,argv,tutorialName, g_width, g_height, g_fullscreen); enterWindowRunLoop(); } return 0; }
/* main function in embree namespace */ int main(int argc, char** argv) { /* set default camera */ g_camera.from = Vec3fa(2.5f,2.5f,2.5f); g_camera.to = Vec3fa(0.0f,0.0f,0.0f); /* create stream for parsing */ Ref<ParseStream> stream = new ParseStream(new CommandLineStream(argc, argv)); /* parse command line */ parseCommandLine(stream, FileName()); if (g_numThreads) g_rtcore += ",threads=" + std::stringOf(g_numThreads); /* initialize ray tracing core */ init(g_rtcore.c_str()); /* render to disk */ if (outFilename.str() != "") { renderToFile(outFilename); return 0; } /* initialize GLUT */ initWindowState(argc,argv,tutorialName, g_width, g_height, g_fullscreen); /* enter the GLUT run loop */ enterWindowRunLoop(); return 0; }
/* main function in embree namespace */ int main(int argc, char** argv) { /* for best performance set FTZ and DAZ flags in MXCSR control and status register */ _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); /* create stream for parsing */ Ref<ParseStream> stream = new ParseStream(new CommandLineStream(argc, argv)); /* parse command line */ parseCommandLine(stream, FileName()); /* load default scene if none specified */ if (filename.ext() == "") { FileName file = FileName::executableFolder() + FileName("models/cornell_box.ecs"); parseCommandLine(new ParseStream(new LineCommentFilter(file, "#")), file.path()); } /* configure number of threads */ if (g_numThreads) g_rtcore += ",threads=" + std::to_string((long long)g_numThreads); if (g_numBenchmarkFrames) g_rtcore += ",benchmark=1"; g_rtcore += g_subdiv_mode; /* load scene */ if (strlwr(filename.ext()) == std::string("obj")) { g_scene->add(loadOBJ(filename,g_subdiv_mode != "")); } else if (strlwr(filename.ext()) == std::string("xml")) { g_scene->add(loadXML(filename,one)); } else if (filename.ext() != "") THROW_RUNTIME_ERROR("invalid scene type: "+strlwr(filename.ext())); /* initialize ray tracing core */ init(g_rtcore.c_str()); /* send model */ g_obj_scene.add(g_scene.dynamicCast<SceneGraph::Node>(),g_instancing_mode); g_scene = nullptr; set_scene(&g_obj_scene); /* benchmark mode */ if (g_numBenchmarkFrames) renderBenchmark(outFilename); /* render to disk */ if (outFilename.str() != "") renderToFile(outFilename); /* interactive mode */ if (g_interactive) { initWindowState(argc,argv,tutorialName, g_width, g_height, g_fullscreen); enterWindowRunLoop(g_anim_mode); } return 0; }
/* main function in embree namespace */ int main(int argc, char** argv) { /* create stream for parsing */ Ref<ParseStream> stream = new ParseStream(new CommandLineStream(argc, argv)); /* parse command line */ parseCommandLine(stream, FileName()); if (g_numThreads) g_rtcore += ",threads=" + std::stringOf(g_numThreads); if (g_numBenchmarkFrames) g_rtcore += ",benchmark=1"; g_rtcore += g_subdiv_mode; /* load scene */ if (strlwr(filename.ext()) == std::string("obj")) { if (g_subdiv_mode != "") { std::cout << "enabling subdiv mode" << std::endl; loadOBJ(filename,one,g_obj_scene,true); } else loadOBJ(filename,one,g_obj_scene); } else if (strlwr(filename.ext()) == std::string("xml")) loadXML(filename,one,g_obj_scene); else if (filename.ext() != "") THROW_RUNTIME_ERROR("invalid scene type: "+strlwr(filename.ext())); /* initialize ray tracing core */ init(g_rtcore.c_str()); /* convert triangle meshes to subdiv meshes */ if (g_only_subdivs) g_obj_scene.convert_to_subdiv(); /* send model */ set_scene(&g_obj_scene); /* benchmark mode */ if (g_numBenchmarkFrames) renderBenchmark(outFilename); /* render to disk */ if (outFilename.str() != "") renderToFile(outFilename); /* interactive mode */ if (g_interactive) { initWindowState(argc,argv,tutorialName, g_width, g_height, g_fullscreen); enterWindowRunLoop(g_anim_mode); } return 0; }
void PageRunner::reallyFinished() { int latency = time.restart(); // err << latency << " " << changed << " " << nam->hasOutstandingRequests() << endl; if (changed || latency >= 152 || nam->hasOutstandingRequests()) { QTimer::singleShot(150, this, SLOT(reallyFinished())); changed = false; return; } if (!exportpdf.isEmpty() || !exportpng.isEmpty()) { setViewportSize(mainFrame()->contentsSize()); } if (!exportpng.isEmpty()) { renderToFile(exportpng); } if (!exportpdf.isEmpty()) { printToFile(exportpdf); } qApp->exit(sawJSError); }
/* main function in embree namespace */ int main(int argc, char** argv) { /* create stream for parsing */ Ref<ParseStream> stream = new ParseStream(new CommandLineStream(argc, argv)); /* parse command line */ parseCommandLine(stream, FileName()); if (g_numThreads) g_rtcore += ",threads=" + std::stringOf(g_numThreads); if (g_numBenchmarkFrames) g_rtcore += ",benchmark=1"; /* initialize task scheduler */ #if !defined(__EXPORT_ALL_SYMBOLS__) TaskScheduler::create(g_numThreads); #endif /* load scene */ if (filename.str() != "") loadOBJ(filename,one,g_obj_scene); /* initialize ray tracing core */ init(g_rtcore.c_str()); /* send model */ set_scene(&g_obj_scene); /* benchmark mode */ if (g_numBenchmarkFrames) renderBenchmark(outFilename); /* render to disk */ if (outFilename.str() != "") renderToFile(outFilename); /* interactive mode */ if (g_interactive) { initWindowState(argc,argv,tutorialName, g_width, g_height, g_fullscreen); enterWindowRunLoop(); } return 0; }
void Engine::input(sf::Event *event) { bool a = sf::Keyboard::isKeyPressed(sf::Keyboard::A); bool b = sf::Keyboard::isKeyPressed(sf::Keyboard::S); if (a && !b) setMode(EDITOR_1); else if (!a && b) setMode(EDITOR_2); else setMode(DEFAULT); bool n1 = false; bool n2 = false; if (event->type == sf::Event::KeyReleased) { if (event->key.code == sf::Keyboard::Num1) n1 = true; if (event->key.code == sf::Keyboard::Num2) n2 = true; if (event->key.code == sf::Keyboard::Z) Undo(); if (event->key.code == sf::Keyboard::Y) Redo(); if (event->key.code == sf::Keyboard::Space) saveConfig(); if (event->key.code == sf::Keyboard::Return) renderToFile(); if (event->key.code == sf::Keyboard::P) fullOrWindowScreen(); } if (a && !b) setMode(EDITOR_1); else if (!a && b) setMode(EDITOR_2); else setMode(DEFAULT); if (n1 && !n2) setTool(LINE); else if (!n1 && n2) setTool(CIRCLE); if (mode == EDITOR_1) editor1->input(event, window); if (mode == EDITOR_2) editor2->input(event, window); }
int main (int argc, char *argv[]) { Params p; int obj = -1, reader = -1, writer = -1; int i = 0; char number[100]; char outfilename[4096]; const char *id; p.width = p.height = p.bond = p.mode = -1; p.id = p.string_to_load = p.file_to_load = NULL; p.hydro_set = p.query_set = p.smarts_set = 0; p.aromatization = NONE; p.comment_field = NULL; p.comment = NULL; p.comment_name = 0; if (argc <= 2) USAGE(); indigoSetErrorHandler(onError, 0); indigoSetOption("ignore-stereochemistry-errors", "on"); if (parseParams(&p, argc, argv) < 0) return -1; p.out_ext = OEXT_OTHER; if (strcmp(p.outfile_ext, "mol") == 0) p.out_ext = OEXT_MOL; else if (strcmp(p.outfile_ext, "sdf") == 0) p.out_ext = OEXT_SDF; else if (strcmp(p.outfile_ext, "rxn") == 0) p.out_ext = OEXT_RXN; else if (strcmp(p.outfile_ext, "rdf") == 0) p.out_ext = OEXT_RDF; else if (strcmp(p.outfile_ext, "cml") == 0) p.out_ext = OEXT_CML; // guess whether to layout or render by extension p.action = ACTION_LAYOUT; if (p.out_ext == OEXT_OTHER) { indigoSetOption("render-output-format", p.outfile_ext); p.action = ACTION_RENDER; } // read in the input reader = (p.file_to_load != NULL) ? indigoReadFile(p.file_to_load) : indigoReadString(p.string_to_load); if (p.mode == MODE_SINGLE_MOLECULE) { if (p.id != NULL) ERROR("on single input, setting '-id' is not allowed\n"); if (p.out_ext == OEXT_RXN) ERROR("reaction output specified for molecule input\n"); if (p.smarts_set) obj = indigoLoadSmarts(reader); else if (p.query_set) obj = indigoLoadQueryMolecule(reader); else obj = indigoLoadMolecule(reader); _prepare(obj, p.aromatization); if (p.action == ACTION_LAYOUT) { indigoLayout(obj); if (p.out_ext == OEXT_MOL) indigoSaveMolfileToFile(obj, p.outfile); else indigoSaveCmlToFile(obj, p.outfile); } else { _setComment(obj, &p); renderToFile(obj, p.outfile); } } else if (p.mode == MODE_SINGLE_REACTION) { if (p.id != NULL) ERROR("on single input, setting '-id' is not allowed\n"); if (p.out_ext == OEXT_MOL) ERROR("molecule output specified for reaction input\n"); if (p.smarts_set) obj = indigoLoadReactionSmarts(reader); else if (p.query_set) obj = indigoLoadQueryReaction(reader); else obj = indigoLoadReaction(reader); _prepare(obj, p.aromatization); if (p.action == ACTION_LAYOUT) { indigoLayout(obj); if (p.out_ext == OEXT_CML) indigoSaveCmlToFile(obj, p.outfile); else indigoSaveRxnfileToFile(obj, p.outfile); } else { _setComment(obj, &p); renderToFile(obj, p.outfile); } } else { int item; int have_percent_s = (strstr(p.outfile, "%s") != NULL); if (p.mode == MODE_MULTILINE_SMILES) obj = indigoIterateSmiles(reader); else if (p.mode == MODE_SDF) obj = indigoIterateSDF(reader); else if (p.mode == MODE_MULTIPLE_CML) obj = indigoIterateCML(reader); else if (p.mode == MODE_RDF) obj = indigoIterateRDF(reader); else { fprintf(stderr, "internal error: wrong branch\n"); return -1; } if ((p.out_ext == OEXT_MOL || p.out_ext == OEXT_RXN || p.out_ext == OEXT_OTHER) && !have_percent_s) ERROR("on multiple output, output file name must have '%%s'\n"); if (p.out_ext == OEXT_SDF || p.out_ext == OEXT_RDF || (p.out_ext == OEXT_CML && !have_percent_s)) { writer = indigoWriteFile(p.outfile); if (p.out_ext == OEXT_RDF) indigoRdfHeader(writer); if (p.out_ext == OEXT_CML) indigoCmlHeader(writer); } i = -1; while ((item = indigoNext(obj))) { int rc; ++i; if (writer > 0) printf("saving item #%d... ", i); else { if (p.id) { if (!indigoHasProperty(item, p.id)) { fprintf(stderr, "item #%d does not have %s, skipping\n", i, p.id); continue; } id = indigoGetProperty(item, p.id); snprintf(outfilename, sizeof(outfilename), p.outfile, id); } else { snprintf(number, sizeof(number), "%d", i); snprintf(outfilename, sizeof(outfilename), p.outfile, number); } printf("saving %s... ", outfilename); } indigoSetErrorHandler(0, 0); if (_prepare(item, p.aromatization) < 0) { printf("%s\n", indigoGetLastError()); indigoSetErrorHandler(onError, 0); continue; } if (p.action == ACTION_LAYOUT) { if (indigoLayout(item) < 0) { printf("%s\n", indigoGetLastError()); indigoSetErrorHandler(onError, 0); continue; } } if (writer > 0) { if (p.out_ext == OEXT_SDF) rc = indigoSdfAppend(writer, item); else if (p.out_ext == OEXT_RDF) rc = indigoRdfAppend(writer, item); else rc = indigoCmlAppend(writer, item); } else { if (p.action == ACTION_LAYOUT) { if (p.out_ext == OEXT_MOL) rc = indigoSaveMolfileToFile(item, outfilename); else if (p.out_ext == OEXT_RXN) rc = indigoSaveRxnfileToFile(item, outfilename); else ERROR("extension unexpected"); } else { _setComment(item, &p); rc = indigoRenderToFile(item, outfilename); } } if (rc < 0) { printf("%s\n", indigoGetLastError()); indigoSetErrorHandler(onError, 0); continue; } indigoFree(item); indigoSetErrorHandler(onError, 0); printf("\n"); } if (writer > 0) { if (p.out_ext == OEXT_CML) indigoCmlFooter(writer); indigoFree(writer); } } indigoFree(reader); indigoFree(obj); return 0; }
/* main function in embree namespace */ int main(int argc, char** argv) { /* for best performance set FTZ and DAZ flags in MXCSR control and status register */ _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); /* create stream for parsing */ Ref<ParseStream> stream = new ParseStream(new CommandLineStream(argc, argv)); /* parse command line */ parseCommandLine(stream, FileName()); /* load default scene if none specified */ if (filename.ext() == "") { FileName file = FileName::executableFolder() + FileName("models/cornell_box.ecs"); parseCommandLine(new ParseStream(new LineCommentFilter(file, "#")), file.path()); } /* configure number of threads */ if (g_numThreads) g_rtcore += ",threads=" + std::to_string((long long)g_numThreads); if (g_numBenchmarkFrames) g_rtcore += ",benchmark=1"; g_rtcore += g_subdiv_mode; /* load scene */ if (strlwr(filename.ext()) == std::string("obj")) { if (g_subdiv_mode != "") { std::cout << "enabling subdiv mode" << std::endl; loadOBJ(filename,one,g_obj_scene,true); } else loadOBJ(filename,one,g_obj_scene); } else if (strlwr(filename.ext()) == std::string("xml")) loadXML(filename,one,g_obj_scene); else if (filename.ext() != "") THROW_RUNTIME_ERROR("invalid scene type: "+strlwr(filename.ext())); /* load keyframes */ if (keyframeList.str() != "") loadKeyFrameAnimation(keyframeList); /* initialize ray tracing core */ init(g_rtcore.c_str()); /* set shader mode */ switch (g_shader) { case SHADER_EYELIGHT: key_pressed(GLUT_KEY_F2); break; case SHADER_UV : key_pressed(GLUT_KEY_F4); break; case SHADER_NG : key_pressed(GLUT_KEY_F5); break; case SHADER_GEOMID : key_pressed(GLUT_KEY_F6); break; case SHADER_GEOMID_PRIMID: key_pressed(GLUT_KEY_F7); break; }; /* convert triangle meshes to subdiv meshes */ if (g_only_subdivs) g_obj_scene.convert_to_subdiv(); /* send model */ set_scene(&g_obj_scene); /* send keyframes */ if (g_keyframes.size()) set_scene_keyframes(&*g_keyframes.begin(),g_keyframes.size()); /* benchmark mode */ if (g_numBenchmarkFrames) renderBenchmark(outFilename); /* render to disk */ if (outFilename.str() != "") renderToFile(outFilename); /* interactive mode */ if (g_interactive) { initWindowState(argc,argv,tutorialName, g_width, g_height, g_fullscreen); enterWindowRunLoop(g_anim_mode); } return 0; }