Use new cgi source.
This commit is contained in:
parent
57ae058d9a
commit
20cc279b72
158 changed files with 157 additions and 92879 deletions
|
|
@ -27,17 +27,27 @@ struct Scene {
|
|||
if (embree::Ref<embree::SceneGraph::LightNode> lightNode = node.dynamicCast<
|
||||
embree::SceneGraph::LightNode>()) {
|
||||
lights.push_back(lightNode);
|
||||
lightNode->id = unsigned(lights.size()-1);
|
||||
} else {
|
||||
geometries.push_back(node);
|
||||
if (embree::Ref<embree::SceneGraph::TriangleMeshNode> triangleMesh = node.dynamicCast<
|
||||
embree::SceneGraph::TriangleMeshNode>()) {
|
||||
materialID(triangleMesh->material);
|
||||
|
||||
if(triangleMesh->material)
|
||||
materialID(triangleMesh->material);
|
||||
|
||||
if(triangleMesh->light)
|
||||
lightID(triangleMesh->light);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsigned materialID(embree::Ref<embree::SceneGraph::MaterialNode> material) {
|
||||
if (!material)
|
||||
return unsigned(-1);
|
||||
|
||||
if (material->id == -1) {
|
||||
materials.push_back(material);
|
||||
material->id = unsigned(materials.size() - 1);
|
||||
|
|
@ -45,21 +55,33 @@ struct Scene {
|
|||
return material->id;
|
||||
}
|
||||
|
||||
unsigned lightID(embree::Ref<embree::SceneGraph::LightNode> light) {
|
||||
if (!light)
|
||||
return unsigned(-1);
|
||||
|
||||
if (light->id == -1) {
|
||||
lights.push_back(light);
|
||||
light->id = unsigned(lights.size() - 1);
|
||||
}
|
||||
return light->id;
|
||||
}
|
||||
|
||||
std::vector<embree::Ref<embree::SceneGraph::MaterialNode> > materials; //!< list of materials
|
||||
std::vector<embree::Ref<embree::SceneGraph::Node> > geometries; //!< list of geometries
|
||||
std::vector<embree::Ref<embree::SceneGraph::LightNode> > lights; //!< list of lights
|
||||
};
|
||||
|
||||
enum Type { TRIANGLE_MESH, SUBDIV_MESH, CURVES, INSTANCE, INSTANCE_ARRAY, GROUP, QUAD_MESH, GRID_MESH, POINTS };
|
||||
enum Type { TRIANGLE_MESH, SUBDIV_MESH, CURVES, INSTANCE, INSTANCE_ARRAY, GROUP, QUAD_MESH, GRID_MESH /*, POINTS */}; // fast compilation fix!
|
||||
|
||||
struct Geometry {
|
||||
Geometry(Type type) : type(type), geometry(nullptr), materialID(-1), visited(false) {
|
||||
Geometry(Type type) : type(type), geometry(nullptr), materialID(-1), lightID(-1), visited(false) {
|
||||
}
|
||||
|
||||
~Geometry() { if (geometry) rtcReleaseGeometry(geometry); }
|
||||
Type type;
|
||||
RTCGeometry geometry;
|
||||
unsigned int materialID;
|
||||
unsigned int lightID;
|
||||
bool visited;
|
||||
};
|
||||
|
||||
|
|
@ -98,6 +120,7 @@ struct TriangleMesh {
|
|||
texcoords = in->texcoords;
|
||||
|
||||
geom.materialID = scene_in->materialID(in->material);
|
||||
geom.lightID = scene_in->lightID(in->light);
|
||||
|
||||
triangles = in->triangles;
|
||||
}
|
||||
|
|
@ -139,6 +162,13 @@ struct RenderScene {
|
|||
}
|
||||
|
||||
RenderScene(RTCDevice device, Scene* in): scene(rtcNewScene(device)), dataScene(in) {
|
||||
|
||||
lights = std::vector<Light*>(0);
|
||||
for (size_t i = 0; i < in->lights.size(); i++) {
|
||||
Light* light = convertLight(in->lights[i]->get(0.0f));
|
||||
if (light)
|
||||
lights.push_back(light);
|
||||
}
|
||||
geometries = std::vector<Geometry *>(in->geometries.size());
|
||||
for (size_t i = 0; i < in->geometries.size(); i++)
|
||||
geometries[i] = convertGeometry(device, in, in->geometries[i]);
|
||||
|
|
@ -159,12 +189,7 @@ struct RenderScene {
|
|||
|
||||
auto test = (OBJMaterial*) materials[0];
|
||||
|
||||
lights = std::vector<Light *>(0);
|
||||
for (size_t i = 0; i < in->lights.size(); i++) {
|
||||
Light* light = convertLight(in->lights[i]->get(0.0f));
|
||||
if (light)
|
||||
lights.push_back(light);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
~RenderScene() {
|
||||
|
|
@ -188,6 +213,7 @@ struct RenderScene {
|
|||
return (Geometry *) in->geometry;
|
||||
else if (Ref<SceneGraph::TriangleMeshNode> mesh = in.dynamicCast<SceneGraph::TriangleMeshNode>())
|
||||
geom = (Geometry *) new TriangleMesh(device, scene, mesh);
|
||||
|
||||
else
|
||||
THROW_RUNTIME_ERROR("unknown geometry type");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue