Text archives Help
- From: boulos@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r959 - trunk/scenes
- Date: Fri, 24 Feb 2006 00:44:24 -0700 (MST)
Author: boulos
Date: Fri Feb 24 00:44:23 2006
New Revision: 959
Modified:
trunk/scenes/objviewer.cc
Log:
Changing the objviewer to take -DynBVH as a
parameter (similar to the -BVH) to control
which build to use.
Modified: trunk/scenes/objviewer.cc
==============================================================================
--- trunk/scenes/objviewer.cc (original)
+++ trunk/scenes/objviewer.cc Fri Feb 24 00:44:23 2006
@@ -104,9 +104,9 @@
bool center_object = true;
enum {
- RealisticBvh_Build,
- DynBVH_Build,
- BVH_Build
+ RealisticBvh_Build,
+ DynBVH_Build,
+ BVH_Build
};
int which_BVH = RealisticBvh_Build;
vector<string> BVH_args;
@@ -117,124 +117,128 @@
extern "C"
Scene* make_scene(const ReadContext& context, const vector<string>& args) {
- // Check the arguments.
- for (int i=0;i<args.size();++i) {
+ // Check the arguments.
+ for (int i=0;i<args.size();++i) {
- if (args[i] == "-file") {
- // Read in the file name.
- if (!getStringArg(i, args, file_name))
- throw IllegalArgument("objviewer -file
<filename>", i, args);
- }
- else if (args[i] == "-single") {
- use_single_bvh = true;
- }
- else if (args[i] == "-bounds") {
- display_bounds = true;
- }
- else if (args[i] == "-lambertian") {
- use_lambertian = true;
- }
- else if (args[i] == "-fixnormals") {
- fix_normals = true;
-
- getIntArg( i, args, fix_normals_degrees );
- }
- else if (args[i] == "-flip") {
- flip_faces = true;
- }
- else if (args[i] == "-BVH") {
- std::cout << "Doing BVH build\n";
- which_BVH = BVH_Build;
- }
- else if (args[i] == "-bvh-build") {
- string build;
- if (!getStringArg(i, args, build))
- throw IllegalArgument("objviewer -bvh_build
<type:naive,table>",
- i, args);
- BVH_args.push_back("-build");
- BVH_args.push_back(build);
- }
- else if (args[i] == "-nocentering") {
- center_object = false;
- }
+ if (args[i] == "-file") {
+ // Read in the file name.
+ if (!getStringArg(i, args, file_name))
+ throw IllegalArgument("objviewer -file <filename>", i, args);
}
-
-
/////////////////////////////////////////////////////////////////////////////
- // Load in the file using glm.
- GLMmodel *model = glmReadOBJ( file_name.c_str() );
- if (model == 0) {
- std::cout << "Error cannot read model from file." <<
std::endl;
- return 0;
+ else if (args[i] == "-single") {
+ use_single_bvh = true;
}
+ else if (args[i] == "-bounds") {
+ display_bounds = true;
+ }
+ else if (args[i] == "-lambertian") {
+ use_lambertian = true;
+ }
+ else if (args[i] == "-fixnormals") {
+ fix_normals = true;
- // Flip the face winding.
- if (flip_faces) {
- glmReverseWinding( model );
- }
-
- // Compute vertex normals.
- if (fix_normals) {
- glmFacetNormals( model );
- glmVertexNormals( model, fix_normals_degrees );
- }
-
- // Compute model bounds
- Vectorf bmax, bmin;
- glmBoundingBox( model, (float *)&bmin, (float *)&bmax );
-
-
/////////////////////////////////////////////////////////////////////////////
- // Center the model
- if (center_object) {
- Vector translate = ((Vector(bmax) + Vector(bmin)) * 0.5);
+ getIntArg( i, args, fix_normals_degrees );
+ }
+ else if (args[i] == "-flip") {
+ flip_faces = true;
+ }
+ else if (args[i] == "-BVH") {
+ std::cout << "Doing BVH build\n";
+ which_BVH = BVH_Build;
+ }
+ else if (args[i] == "-DynBVH") {
+ std::cout << "Doing DynBVH build\n";
+ which_BVH = DynBVH_Build;
+ }
+ else if (args[i] == "-bvh-build") {
+ string build;
+ if (!getStringArg(i, args, build))
+ throw IllegalArgument("objviewer -bvh_build
<type:naive,table>",
+ i, args);
+ BVH_args.push_back("-build");
+ BVH_args.push_back(build);
+ }
+ else if (args[i] == "-nocentering") {
+ center_object = false;
+ }
+ }
- std::cerr << "Min: " << bmin << " Max: " << bmax << " translate: " <<
translate << std::endl;
+
/////////////////////////////////////////////////////////////////////////////
+ // Load in the file using glm.
+ GLMmodel *model = glmReadOBJ( file_name.c_str() );
+ if (model == 0) {
+ std::cout << "Error cannot read model from file." << std::endl;
+ return 0;
+ }
- Vectorf *vertex;
- for (int i=0;i<model->numvertices;++i) {
- vertex = (Vectorf *)&model->vertices[i*3];
+ // Flip the face winding.
+ if (flip_faces) {
+ glmReverseWinding( model );
+ }
- (*vertex) = (*vertex) - translate;
+ // Compute vertex normals.
+ if (fix_normals) {
+ glmFacetNormals( model );
+ glmVertexNormals( model, fix_normals_degrees );
}
- }
-
/////////////////////////////////////////////////////////////////////////////
- // Create the bvh.
- Object *bvh = create_single_bvh( model );
+ // Compute model bounds
+ Vectorf bmax, bmin;
+ glmBoundingBox( model, (float *)&bmin, (float *)&bmax );
+
/////////////////////////////////////////////////////////////////////////////
+ // Center the model
+ if (center_object) {
+ Vector translate = ((Vector(bmax) + Vector(bmin)) * 0.5);
-
/////////////////////////////////////////////////////////////////////////////
- // Create the scene.
- Scene *scene = new Scene();
+ std::cerr << "Min: " << bmin << " Max: " << bmax << " translate: "
<< translate << std::endl;
- // Add a head light.
- LightSet *lights = new LightSet();
- lights->add( new HeadLight( 0.0, Color(RGB(1.0,1.0,1.0)) ));
- lights->setAmbientLight( new ConstantAmbient( Color(RGB(0.4,0.4,0.4)
) ));
- scene->setLights( lights );
+ Vectorf *vertex;
+ for (int i=0;i<model->numvertices;++i) {
+ vertex = (Vectorf *)&model->vertices[i*3];
- Material* red=new Lambertian(Color(RGBColor(.6,0,0)));
- Material* yellow=new Lambertian(Color(RGBColor(.6,.6,0)));
+ (*vertex) = (*vertex) - translate;
+ }
+ }
- // Add a floor.
- Parallelogram* floor = new Parallelogram(yellow,
Vector(-20,-20,bounds[0][2]),
-
Vector(40,0,0), Vector(0,40,0));
- Group *manta_group = new Group();
- // manta_group->add( floor );
+
/////////////////////////////////////////////////////////////////////////////
+ // Create the bvh.
+ Object *bvh = create_single_bvh( model );
+
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Create the scene.
+ Scene *scene = new Scene();
+
+ // Add a head light.
+ LightSet *lights = new LightSet();
+ lights->add( new HeadLight( 0.0, Color(RGB(1.0,1.0,1.0)) ));
+ lights->setAmbientLight( new ConstantAmbient( Color(RGB(0.4,0.4,0.4) )
));
+ scene->setLights( lights );
+
+ Material* red=new Lambertian(Color(RGBColor(.6,0,0)));
+ Material* yellow=new Lambertian(Color(RGBColor(.6,.6,0)));
+
+ // Add a floor.
+ Parallelogram* floor = new Parallelogram(yellow,
Vector(-20,-20,bounds[0][2]),
+ Vector(40,0,0), Vector(0,40,0));
+ Group *manta_group = new Group();
+ // manta_group->add( floor );
- if (display_bounds) {
- manta_group->add( new Cube( red, bounds[0], bounds[1] ) );
- }
- else {
- manta_group->add( bvh );
- }
+ if (display_bounds) {
+ manta_group->add( new Cube( red, bounds[0], bounds[1] ) );
+ }
+ else {
+ manta_group->add( bvh );
+ }
- // Add the bvh to the scene.
- scene->setObject( manta_group );
+ // Add the bvh to the scene.
+ scene->setObject( manta_group );
- // Background.
- scene->setBackground( new ConstantBackground( Color(RGB(0.8, 0.8,
0.8)) ) );
+ // Background.
+ scene->setBackground( new ConstantBackground( Color(RGB(0.8, 0.8, 0.8))
) );
- return scene;
+ return scene;
}
///////////////////////////////////////////////////////////////////////////////
@@ -247,52 +251,52 @@
template<>
ImageTexture<Color> *load_image_texture<Color>( const string& file_name ) {
- Image *image = 0;
+ Image *image = 0;
- // Load the image.
- if (file_name.rfind(".tga") == (file_name.size()-4)) {
- // Try to read a tga file.
- image = readTGA( file_name );
- }
- else {
- // Try reading the image using teem.
- image = readNRRD( file_name );
- }
+ // Load the image.
+ if (file_name.rfind(".tga") == (file_name.size()-4)) {
+ // Try to read a tga file.
+ image = readTGA( file_name );
+ }
+ else {
+ // Try reading the image using teem.
+ image = readNRRD( file_name );
+ }
- // Create the texture.
- ImageTexture<Color> *texture = new ImageTexture<Color>( image );
+ // Create the texture.
+ ImageTexture<Color> *texture = new ImageTexture<Color>( image );
- // Free time image.
- delete image;
+ // Free time image.
+ delete image;
- return texture;
+ return texture;
}
// Check to see if the specified file can be loaded, otherwise use the
specified color.
Texture<Color> *check_for_texture( const string &path_name, const string
&file_name, const Color &constant_color ) {
- Texture<Color> *texture = 0;
+ Texture<Color> *texture = 0;
- if (file_name.size()) {
- // Load the image texture.
- try {
- texture = load_image_texture<Color>( path_name + file_name );
- // texture = new TexCoordTexture;
- }
- catch (SCIRun::Exception &e) {
- std::cerr << "Could not load diffuse map: "
- << file_name
- << ": " << e.message() << std::endl;
+ if (file_name.size()) {
+ // Load the image texture.
+ try {
+ texture = load_image_texture<Color>( path_name + file_name );
+ // texture = new TexCoordTexture;
+ }
+ catch (SCIRun::Exception &e) {
+ std::cerr << "Could not load diffuse map: "
+ << file_name
+ << ": " << e.message() << std::endl;
+ }
}
- }
- if (texture == 0) {
+ if (texture == 0) {
- // Otherwise use a constant color.
- texture = new Constant<Color>( constant_color );
- }
+ // Otherwise use a constant color.
+ texture = new Constant<Color>( constant_color );
+ }
- return texture;
+ return texture;
}
///////////////////////////////////////////////////////////////////////////////
@@ -302,259 +306,259 @@
///////////////////////////////////////////////////////////////////////////////
static void create_materials( GLMmodel *model ) {
-
/////////////////////////////////////////////////////////////////////////////
- // Path to the model for loading textures.
- string model_path = model->pathname;
+
/////////////////////////////////////////////////////////////////////////////
+ // Path to the model for loading textures.
+ string model_path = model->pathname;
- int pos = model_path.rfind( '/' );
- if (pos != string::npos) {
- model_path = model_path.substr( 0, pos+1 );
- }
-
- material_array = new Material *[ model->nummaterials ];
+ int pos = model_path.rfind( '/' );
+ if (pos != string::npos) {
+ model_path = model_path.substr( 0, pos+1 );
+ }
- // Read in the materials.
- for (int i=0;i<model->nummaterials;++i) {
+ material_array = new Material *[ model->nummaterials ];
-
///////////////////////////////////////////////////////////////////////////
- // Copy out material attributes.
- string mtl_name = model->materials[i].name;
+ // Read in the materials.
+ for (int i=0;i<model->nummaterials;++i) {
- // Color ambient (RGB( model->materials[i].ambient[0],
- // model->materials[i].ambient[1],
- // model->materials[i].ambient[2] ));
+
///////////////////////////////////////////////////////////////////////////
+ // Copy out material attributes.
+ string mtl_name = model->materials[i].name;
- Color diffuse (RGB( model->materials[i].diffuse[0],
- model->materials[i].diffuse[1],
- model->materials[i].diffuse[2] ));
- Color specular(RGB( model->materials[i].specular[0],
- model->materials[i].specular[1],
- model->materials[i].specular[2] ));
+ // Color ambient (RGB( model->materials[i].ambient[0],
+ // model->materials[i].ambient[1],
+ // model->materials[i].ambient[2] ));
- float Ns = model->materials[i].shininess;
- float Tr = model->materials[i].refraction;
- float alpha = model->materials[i].alpha;
- int shader = model->materials[i].shader;
+ Color diffuse (RGB( model->materials[i].diffuse[0],
+ model->materials[i].diffuse[1],
+ model->materials[i].diffuse[2] ));
+ Color specular(RGB( model->materials[i].specular[0],
+ model->materials[i].specular[1],
+ model->materials[i].specular[2] ));
- // Copy out texture names.
- // string ambient_map_name = (model->materials[i].ambient_map[0] !=
'\0') ?
- // model->materials[i].ambient_map : "";
- string diffuse_map_name = (model->materials[i].diffuse_map[0] != '\0')
?
- model->materials[i].diffuse_map : "";
- string specular_map_name = (model->materials[i].specular_map[0] != '\0')
?
- model->materials[i].specular_map : "";
+ float Ns = model->materials[i].shininess;
+ float Tr = model->materials[i].refraction;
+ float alpha = model->materials[i].alpha;
+ int shader = model->materials[i].shader;
- // Note that the first material added by blender is always an
- // unused default material..
- int index = i-1;
+ // Copy out texture names.
+ // string ambient_map_name = (model->materials[i].ambient_map[0]
!= '\0') ?
+ // model->materials[i].ambient_map : "";
+ string diffuse_map_name = (model->materials[i].diffuse_map[0] !=
'\0') ?
+ model->materials[i].diffuse_map : "";
+ string specular_map_name = (model->materials[i].specular_map[0] !=
'\0') ?
+ model->materials[i].specular_map : "";
- // Texture<Color> *diffuse_map = check_for_texture( model_path,
diffuse_map_name, diffuse );
+ // Note that the first material added by blender is always an
+ // unused default material..
+ int index = i-1;
- // Lambertian Shader.
- // material_array[index] = new Flat( diffuse_map );
+ // Texture<Color> *diffuse_map = check_for_texture( model_path,
diffuse_map_name, diffuse );
-
///////////////////////////////////////////////////////////////////////////
- // Check for a dielectric.
- if (Tr != 0) {
+ // Lambertian Shader.
+ // material_array[index] = new Flat( diffuse_map );
- std::cerr << "Material " << index << " dielectric" << std::endl;
+
///////////////////////////////////////////////////////////////////////////
+ // Check for a dielectric.
+ if (Tr != 0) {
- // Constant textures for refraction parameters.
- Texture<Real> *n = new Constant<Real>( 1.6 );
- Texture<Real> *nt = new Constant<Real>( 1.0 );
+ std::cerr << "Material " << index << " dielectric" << std::endl;
- Texture<Color> *diffuse_map = check_for_texture( model_path,
diffuse_map_name, diffuse );
- // Texture<Color> *diffuse_map = new Constant<Color>( Color(RGB(.9,
.8, .8)) );
+ // Constant textures for refraction parameters.
+ Texture<Real> *n = new Constant<Real>( 1.6 );
+ Texture<Real> *nt = new Constant<Real>( 1.0 );
- // Create a dielectric shader.
- // material_array[index] = new Dielectric( n, nt, diffuse_map );
- material_array[index] = new Dielectric(1.6, 1.0, Color(RGB(.9, .8,
.8)));
+ Texture<Color> *diffuse_map = check_for_texture( model_path,
diffuse_map_name, diffuse );
+ // Texture<Color> *diffuse_map = new Constant<Color>(
Color(RGB(.9, .8, .8)) );
- }
+ // Create a dielectric shader.
+ // material_array[index] = new Dielectric( n, nt, diffuse_map );
+ material_array[index] = new Dielectric(1.6, 1.0, Color(RGB(.9,
.8, .8)));
-
///////////////////////////////////////////////////////////////////////////
- // Check for a specular term.
- else if (Ns != 0) {
-
- std::cerr << "Material " << index << " Specular" << std::endl;
+ }
- Texture<Color> *diffuse_map = check_for_texture( model_path,
diffuse_map_name, diffuse );
- Texture<Color> *specular_map = check_for_texture( model_path,
specular_map_name, specular );
- Texture<ColorComponent> *reflection = new Constant<ColorComponent>(
0.0 );
+
///////////////////////////////////////////////////////////////////////////
+ // Check for a specular term.
+ else if (Ns != 0) {
+
+ std::cerr << "Material " << index << " Specular" << std::endl;
+
+ Texture<Color> *diffuse_map = check_for_texture( model_path,
diffuse_map_name, diffuse );
+ Texture<Color> *specular_map = check_for_texture( model_path,
specular_map_name, specular );
+ Texture<ColorComponent> *reflection = new
Constant<ColorComponent>( 0.0 );
+
+ // Phong shader.
+ material_array[index] = new Phong( diffuse_map, specular_map,
+ static_cast<int>(Ns),
reflection );
+ }
- // Phong shader.
- material_array[index] = new Phong( diffuse_map, specular_map,
- static_cast<int>(Ns), reflection );
- }
+
///////////////////////////////////////////////////////////////////////////
+ // Use a lambertian shader.
+ else {
-
///////////////////////////////////////////////////////////////////////////
- // Use a lambertian shader.
- else {
+ std::cerr << "Material " << index << " Lambertian" << std::endl;
- std::cerr << "Material " << index << " Lambertian" << std::endl;
+ Texture<Color> *diffuse_map = check_for_texture( model_path,
diffuse_map_name, diffuse );
- Texture<Color> *diffuse_map = check_for_texture( model_path,
diffuse_map_name, diffuse );
+ // Lambertian Shader.
+ material_array[index] = new Lambertian( diffuse_map );
+ }
- // Lambertian Shader.
- material_array[index] = new Lambertian( diffuse_map );
}
- }
-
}
///////////////////////////////////////////////////////////////////////////////
// Create a single bvh to contain the mesh.
Object *create_single_bvh( GLMmodel *model ) {
- TexTriangle **triangle_array = 0;
- Group* bvh_group = 0;
+ TexTriangle **triangle_array = 0;
+ Group* bvh_group = 0;
-
/////////////////////////////////////////////////////////////////////////////
- // Allocate storage for primitives and materials.
- int total_triangles = model->numtriangles;
- switch (which_BVH) {
- case RealisticBvh_Build:
- triangle_array = new TexTriangle *[ total_triangles ];
- break;
- case DynBVH_Build:
- bvh_group = new DynBVH();
- break;
- case BVH_Build:
- bvh_group = new BVH(BVH_args);
- break;
- }
+
/////////////////////////////////////////////////////////////////////////////
+ // Allocate storage for primitives and materials.
+ int total_triangles = model->numtriangles;
+ switch (which_BVH) {
+ case RealisticBvh_Build:
+ triangle_array = new TexTriangle *[ total_triangles ];
+ break;
+ case DynBVH_Build:
+ bvh_group = new DynBVH();
+ break;
+ case BVH_Build:
+ bvh_group = new BVH(BVH_args);
+ break;
+ }
- create_materials( model );
+ create_materials( model );
- int tri = 0;
- int mtl = 0;
+ int tri = 0;
+ int mtl = 0;
- Material *default_material = 0;
- if (use_lambertian) {
- default_material = new Lambertian( Color(RGB( 1.0, 0.0, 0.0 ) ) );
- }
- else {
- default_material = new Flat( new NormalTexture() );
- }
-
-
- // Read in the groups.
- GLMgroup *group = model->groups;
- while (group != 0) {
-
- // Determine the material for this group.
- Material *material;
- if ((group->material-1) < model->nummaterials) {
- material = material_array[group->material-1];
- }
- else {
- material = default_material;
- }
-
- // Copy out triangles.
- int total_faces = group->numtriangles;
- for (int i=0;i<total_faces;++i) {
-
- Vector vertex[3];
- Vector normal[3];
- Vector texcoord[3];
-
- for (int v=0;v<3;++v) {
- int index = model->triangles[
group->triangles[i] ].vindices[v];
- float *f = model->vertices+(index*3);
-
- // Copy out the vertex.
- vertex[v][0] = f[0];
- vertex[v][1] = f[1];
- vertex[v][2] = f[2];
-
- index = model->triangles[ group->triangles[i] ].nindices[v];
- f = model->normals+(index*3);
-
- // Copy out the normal.
- normal[v][0] = f[0];
- normal[v][1] = f[1];
- normal[v][2] = f[2];
-
- }
-
- for (int v=0; v<3; ++v) {
-
- int index = model->triangles[ group->triangles[i] ].tindices[v];
- float *f = &model->texcoords[index*2];
-
- // Copy out the texcoord
- texcoord[v][0] = f[0];
- texcoord[v][1] = f[1];
- texcoord[v][2] = 1.0;
-
- }
-
- // for (int v=0;v<3;++v) {
- // texcoord[v] = Vector(vertex[v])+Vector(0.5,0.5,0.5);
- // texcoord[v][1] = texcoord[v][2];
- // }
-
- // Create a new triangle.
- TexTriangle *triangle = new TexTriangle( material,
- vertex[0],
vertex[1]-vertex[0], vertex[2]-vertex[0],
- normal[0], normal[1],
normal[2],
- texcoord[0], texcoord[1],
texcoord[2]
- );
-
- switch (which_BVH) {
- case RealisticBvh_Build:
- triangle_array[tri] = triangle;
- break;
- case DynBVH_Build:
- case BVH_Build:
- // both cases just add
- bvh_group->add(triangle);
- break;
- }
- ++tri;
- }
-
- // Move to the next group.
- group = group->next;
- ++mtl;
- }
-
- std::cerr << "Total triangles added: " << tri << std::endl;
-
- Object* bvh = 0;
-
/////////////////////////////////////////////////////////////////////////////
- // Create an acceleration structure.
- switch (which_BVH) {
- case RealisticBvh_Build:
+ Material *default_material = 0;
+ if (use_lambertian) {
+ default_material = new Lambertian( Color(RGB( 1.0, 0.0, 0.0 ) ) );
+ }
+ else {
+ default_material = new Flat( new NormalTexture() );
+ }
+
+
+ // Read in the groups.
+ GLMgroup *group = model->groups;
+ while (group != 0) {
+
+ // Determine the material for this group.
+ Material *material;
+ if ((group->material-1) < model->nummaterials) {
+ material = material_array[group->material-1];
+ }
+ else {
+ material = default_material;
+ }
+
+ // Copy out triangles.
+ int total_faces = group->numtriangles;
+ for (int i=0;i<total_faces;++i) {
+
+ Vector vertex[3];
+ Vector normal[3];
+ Vector texcoord[3];
+
+ for (int v=0;v<3;++v) {
+ int index = model->triangles[ group->triangles[i]
].vindices[v];
+ float *f = model->vertices+(index*3);
+
+ // Copy out the vertex.
+ vertex[v][0] = f[0];
+ vertex[v][1] = f[1];
+ vertex[v][2] = f[2];
+
+ index = model->triangles[ group->triangles[i] ].nindices[v];
+ f = model->normals+(index*3);
+
+ // Copy out the normal.
+ normal[v][0] = f[0];
+ normal[v][1] = f[1];
+ normal[v][2] = f[2];
+
+ }
+
+ for (int v=0; v<3; ++v) {
+
+ int index = model->triangles[ group->triangles[i]
].tindices[v];
+ float *f = &model->texcoords[index*2];
+
+ // Copy out the texcoord
+ texcoord[v][0] = f[0];
+ texcoord[v][1] = f[1];
+ texcoord[v][2] = 1.0;
+
+ }
+
+ // for (int v=0;v<3;++v) {
+ // texcoord[v] = Vector(vertex[v])+Vector(0.5,0.5,0.5);
+ // texcoord[v][1] = texcoord[v][2];
+ // }
+
+ // Create a new triangle.
+ TexTriangle *triangle = new TexTriangle( material,
+ vertex[0],
vertex[1]-vertex[0], vertex[2]-vertex[0],
+ normal[0], normal[1],
normal[2],
+ texcoord[0],
texcoord[1], texcoord[2]
+ );
+
+ switch (which_BVH) {
+ case RealisticBvh_Build:
+ triangle_array[tri] = triangle;
+ break;
+ case DynBVH_Build:
+ case BVH_Build:
+ // both cases just add
+ bvh_group->add(triangle);
+ break;
+ }
+ ++tri;
+ }
+
+ // Move to the next group.
+ group = group->next;
+ ++mtl;
+ }
+
+ std::cerr << "Total triangles added: " << tri << std::endl;
+
+ Object* bvh = 0;
+
/////////////////////////////////////////////////////////////////////////////
+ // Create an acceleration structure.
+ switch (which_BVH) {
+ case RealisticBvh_Build:
{
- double time_begin = Time::currentSeconds();
+ double time_begin = Time::currentSeconds();
- // Construct the bvh.
- bvh = new RealisticBvh( (Object **)triangle_array, total_triangles );
+ // Construct the bvh.
+ bvh = new RealisticBvh( (Object **)triangle_array, total_triangles );
- double time_end = Time::currentSeconds();
+ double time_end = Time::currentSeconds();
- std::cerr << "Bvh creation time: " << (time_end - time_begin) << "
seconds." << std::endl;
+ std::cerr << "Bvh creation time: " << (time_end - time_begin) << "
seconds." << std::endl;
}
break;
- case DynBVH_Build:
- case BVH_Build:
- bvh = bvh_group;
- // Preprocesing will be done during the preprocessing phase
- break;
- }
+ case DynBVH_Build:
+ case BVH_Build:
+ bvh = bvh_group;
+ // Preprocesing will be done during the preprocessing phase
+ break;
+ }
-
/////////////////////////////////////////////////////////////////////////////
- // Check the size of bounding boxes.
- PreprocessContext p_context;
- bvh->computeBounds( p_context, bounds );
+
/////////////////////////////////////////////////////////////////////////////
+ // Check the size of bounding boxes.
+ PreprocessContext p_context;
+ bvh->computeBounds( p_context, bounds );
- std::cerr << "Bvh: Bounding box " << bounds[0] << " : " << bounds[1]
<< std::endl;
+ std::cerr << "Bvh: Bounding box " << bounds[0] << " : " << bounds[1] <<
std::endl;
- return bvh;
+ return bvh;
}
- [MANTA] r959 - trunk/scenes, boulos, 02/24/2006
Archive powered by MHonArc 2.6.16.