Text archives Help
- From: "Thiago Ize" <
>
- To:
- Subject: [Manta] r2290 - trunk/scenes
- Date: Wed, 25 Jun 2008 16:27:07 -0600 (MDT)
Author: thiago
Date: Wed Jun 25 16:27:07 2008
New Revision: 2290
Modified:
trunk/scenes/triangleSceneViewer.cc
Log:
In the last commit, I forgot to include the updated triangleSceneViewer that
lets you use the BSP and load/save BSP/kd-tree structures.
Modified: trunk/scenes/triangleSceneViewer.cc
==============================================================================
--- trunk/scenes/triangleSceneViewer.cc (original)
+++ trunk/scenes/triangleSceneViewer.cc Wed Jun 25 16:27:07 2008
@@ -9,6 +9,7 @@
#include <Model/AmbientLights/ArcAmbient.h>
#include <Model/Backgrounds/ConstantBackground.h>
#include <Model/Backgrounds/LinearBackground.h>
+#include <Model/Groups/BSP/BSP.h>
#include <Model/Groups/DynBVH.h>
#include <Model/Groups/Group.h>
#include <Model/Groups/KDTree.h>
@@ -46,6 +47,7 @@
void argumentError(int i, const vector<string>& args) {
cerr << "Valid options for scene meshViewer:\n";
+ cerr << " -BSP - use BSP acceleration structure\n";
cerr << " -DynBVH - use DynBVH acceleration structure\n";
#ifdef USE_PRIVATE_CODE
cerr << " -CGT - use Coherent Grid Traversal acceleration
structure\n";
@@ -54,9 +56,11 @@
cerr << " -rgrid - use single ray recursive grid acceleration
structure\n";
cerr << " -model - Required. The file to load (obj or ply file)\n";
cerr << " Can call this multiple times to load an
animation.\n";
+ cerr << " -save [filename] - save acceleration structure to file
(currently kdtree and bsp).\n";
+ cerr << " -load [filename] - load acceleration structure from file
(currently kdtree and bsp).\n";
cerr << " -animationLength - Number of seconds animation takes\n";
cerr << " -interpolateNormals - creates vertex normals if the data does"
- << " not already contain vertex normals.\n";
+ << " not already contain vertex normals.\n";
cerr << " -useFaceNormals - force to use only face normals\n";
cerr << " -smoothAnimation - interpolates between keyframes.\n";
cerr << " -triangleType - Triangle implementation to use.\n"
@@ -157,6 +161,9 @@
Vector lightPosition;
MeshTriangle::TriangleType triangleType =
MeshTriangle::KENSLER_SHIRLEY_TRI;
+ string saveName;
+ string loadName;
+
for(size_t i=0;i<args.size();i++){
string arg = args[i];
if(arg == "-model"){
@@ -164,6 +171,9 @@
if(!getStringArg(i, args, fileNames.back()))
throw IllegalArgument("scene MeshLoader -model", i, args);
setModel = true;
+ } else if (arg == "-BSP") {
+ delete as;
+ as = new BSP;
} else if (arg == "-DynBVH") {
delete as;
as = new DynBVH;
@@ -180,6 +190,12 @@
#else
throw IllegalArgument("CGT is not available to you.", i, args);
#endif
+ } else if(arg == "-save"){
+ if (!getStringArg(i, args, saveName))
+ throw IllegalArgument("wrong argument to -save", i, args);
+ } else if(arg == "-load"){
+ if (!getStringArg(i, args, loadName))
+ throw IllegalArgument("wrong argument to -load", i, args);
} else if (arg == "-animationLength") {
if(!getArg<float>(i, args, animationLength))
throw IllegalArgument("scene MeshLoader -animationLength", i, args);
@@ -266,7 +282,21 @@
Mesh* singleFrame = LoadModel(fileNames[0], defaultMatl, overrideMatl,
triangleType,
useFaceNormals, interpolateNormals);
as->setGroup(singleFrame);
- as->rebuild();
+
+ if (!loadName.empty()) {
+ bool success = as->buildFromFile(loadName);
+ if (!success) {
+ cerr << "BSP had trouble loading " << loadName<<endl;
+ cerr << "Building it from scratch instead\n";
+ as->rebuild();
+ }
+ }
+ else
+ as->rebuild();
+
+ if (!saveName.empty())
+ as->saveToFile(saveName);
+
group->add(as);
}
- [Manta] r2290 - trunk/scenes, Thiago Ize, 06/25/2008
Archive powered by MHonArc 2.6.16.