Updated Embree library to version 2.2

This commit is contained in:
schuellc
2015-01-28 16:07:34 +01:00
parent b930cfce27
commit 9b05283300
1941 changed files with 107083 additions and 242967 deletions
+156
View File
@@ -0,0 +1,156 @@
// ======================================================================== //
// Copyright 2009-2013 Intel Corporation //
// //
// Licensed under the Apache License, Version 2.0 (the "License"); //
// you may not use this file except in compliance with the License. //
// You may obtain a copy of the License at //
// //
// http://www.apache.org/licenses/LICENSE-2.0 //
// //
// Unless required by applicable law or agreed to in writing, software //
// distributed under the License is distributed on an "AS IS" BASIS, //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
// See the License for the specific language governing permissions and //
// limitations under the License. //
// ======================================================================== //
#include "tutorial/tutorial.h"
#include "tutorial/obj_loader.h"
#include "sys/taskscheduler.h"
namespace embree
{
/* name of the tutorial */
const char* tutorialName = "tutorial03";
/* configuration */
static std::string g_rtcore = "";
/* output settings */
static size_t g_width = 512;
static size_t g_height = 512;
static bool g_fullscreen = false;
static size_t g_numThreads = 0;
/* ISPC compatible mesh */
struct ISPCMesh
{
Vec3fa* positions; //!< vertex position array
Vec3fa* normals; //!< vertex normal array
Vec2f* texcoords; //!< vertex texcoord array
OBJScene::Triangle* triangles; //!< list of triangles
int numVertices;
int numTriangles;
};
/* ISPC compatible scene */
struct ISPCScene
{
ISPCMesh** meshes;
OBJScene::Material* materials; //!< material list
int numMeshes;
int numMaterials;
};
/* scene */
OBJScene g_obj_scene;
static FileName filename = "default.obj";
static void parseCommandLine(Ref<ParseStream> cin, const FileName& path)
{
while (true)
{
std::string tag = cin->getString();
if (tag == "") return;
/* parse command line parameters from a file */
else if (tag == "-c") {
FileName file = path + cin->getFileName();
parseCommandLine(new ParseStream(new LineCommentFilter(file, "#")), file.path());
}
/* load OBJ model*/
else if (tag == "-i") {
filename = path + cin->getFileName();
}
/* parse camera parameters */
else if (tag == "-vp") g_camera.from = cin->getVec3fa();
else if (tag == "-vi") g_camera.to = cin->getVec3fa();
else if (tag == "-vd") g_camera.to = g_camera.from + cin->getVec3fa();
else if (tag == "-vu") g_camera.up = cin->getVec3fa();
else if (tag == "-fov") g_camera.fov = cin->getFloat();
/* frame buffer size */
else if (tag == "-size") {
g_width = cin->getInt();
g_height = cin->getInt();
}
/* full screen mode */
else if (tag == "-fullscreen")
g_fullscreen = true;
/* rtcore configuration */
else if (tag == "-rtcore")
g_rtcore = cin->getString();
/* number of threads to use */
else if (tag == "-threads")
g_numThreads = cin->getInt();
/* skip unknown command line parameter */
else {
std::cerr << "unknown command line parameter: " << tag << " ";
while (cin->peek() != "" && cin->peek()[0] != '-') std::cerr << cin->getString() << " ";
std::cerr << std::endl;
}
}
}
/* 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);
/* initialize task scheduler */
#if !defined(__EXPORT_ALL_SYMBOLS__)
TaskScheduler::create(g_numThreads);
#endif
/* load scene */
loadOBJ(filename,g_obj_scene);
/* initialize ray tracing core */
init(g_rtcore.c_str());
/* send model */
set_scene(&g_obj_scene);
/* initialize GLUT */
initGlut(tutorialName,g_width,g_height,g_fullscreen,true);
return 0;
}
}
int main(int argc, char** argv)
{
try {
return embree::main(argc, argv);
}
catch (const std::exception& e) {
std::cout << "Error: " << e.what() << std::endl;
return 1;
}
catch (...) {
std::cout << "Error: unknown exception caught." << std::endl;
return 1;
}
}