Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r837 - in trunk: . Engine/Control Interface StandAlone scenes


Chronological Thread 
  • From: abe@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r837 - in trunk: . Engine/Control Interface StandAlone scenes
  • Date: Wed, 11 Jan 2006 00:33:51 -0700 (MST)

Author: abe
Date: Wed Jan 11 00:33:51 2006
New Revision: 837

Modified:
   trunk/CMakeLists.txt
   trunk/Engine/Control/RTRT.cc
   trunk/Engine/Control/RTRT.h
   trunk/Interface/Context.h
   trunk/Interface/MantaInterface.h
   trunk/MantaTypes.h
   trunk/StandAlone/manta.cc
   trunk/scenes/CMakeLists.txt
Log:


Reorganized manta.cc

Now the render stack may be loaded using code in a shared library specified 
by the -stack <lib> command line option. 

Other command line options are unchanged.

M    scenes/CMakeLists.txt
M    StandAlone/manta.cc
M    Interface/MantaInterface.h
M    Interface/Context.h
M    Engine/Control/RTRT.cc
M    Engine/Control/RTRT.h
M    MantaTypes.h
M    CMakeLists.txt


Modified: trunk/CMakeLists.txt
==============================================================================
--- trunk/CMakeLists.txt        (original)
+++ trunk/CMakeLists.txt        Wed Jan 11 00:33:51 2006
@@ -182,6 +182,7 @@
   SCIRun_Core
   )
 
+
 # Since SWIG support wasn't added to CMake until version 2.0, only do
 # the check if we have a new enough version.
 IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 1.9)

Modified: trunk/Engine/Control/RTRT.cc
==============================================================================
--- trunk/Engine/Control/RTRT.cc        (original)
+++ trunk/Engine/Control/RTRT.cc        Wed Jan 11 00:33:51 2006
@@ -24,6 +24,7 @@
 #include <Core/Exceptions/IllegalValue.h>
 #include <Core/Exceptions/InternalError.h>
 #include <Core/Exceptions/InvalidState.h>
+#include <Core/Exceptions/InputError.h>
 #include <Core/Thread/Thread.h>
 #include <Core/Thread/Time.h>
 #include <Core/Util/Assert.h>
@@ -1128,6 +1129,11 @@
   }
 }
 
+void RTRT::readStack(const string &name, const vector<string> &args )
+{
+  readMOStack(name, args, true);
+}
+
 void RTRT::setScenePath(const string& path)
 {
   scenePath = path;
@@ -1205,6 +1211,58 @@
     return scene;
   }
   return 0;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// This dynamically loads code to configure the manta rendering stack.
+void RTRT::readMOStack(const string& name, const vector<string>& args, bool 
printErrors )
+{
+  vector<string> dirs = split_string(scenePath, ':');
+  for(vector<string>::iterator dir = dirs.begin(); dir != dirs.end(); dir++){
+
+    // Check to see if the file exists in the directory.
+    string fullname = *dir + "/"+name;
+    struct stat statbuf;
+    if(stat(fullname.c_str(), &statbuf) != 0){
+      // if(printErrors){
+      //   cerr << "Error reading " << fullname << ": " << strerror(errno) 
<< '\n';
+      // }
+      continue;
+    }
+
+    // Open the file.
+    void* handle=dlopen(fullname.c_str(), RTLD_NOW);
+    if(!handle){
+      if(printErrors){
+        cerr << "Error opening scene: " << fullname << '\n';
+        cerr << dlerror() << '\n';
+        throw InputError( "Could not load stack" );
+      }
+      continue;
+    }
+
+    // Access the make_stack symbol
+    void* stack_fn=dlsym(handle, "make_stack");
+    if(!stack_fn){
+      if(printErrors){
+        cerr << "Stack configuration file found, but make_stack() function 
not found\n";
+      }
+      // If we get here, we fail so that we don't keep searching the path
+      // for another library
+      return;
+    }
+
+    
///////////////////////////////////////////////////////////////////////////
+    // Invoke the function.
+    
+    typedef void (*MakerType)(ReadContext &, const vector<string>&);
+    MakerType make_stack = (MakerType)(stack_fn);
+    ReadContext context(this);
+
+    // Call the function.
+    (*make_stack)(context, args);
+        
+  }
 }
 
 UserInterface* RTRT::createUserInterface(const string& spec)

Modified: trunk/Engine/Control/RTRT.h
==============================================================================
--- trunk/Engine/Control/RTRT.h (original)
+++ trunk/Engine/Control/RTRT.h Wed Jan 11 00:33:51 2006
@@ -99,6 +99,7 @@
     virtual void setScene(Scene* scene);
                virtual Scene *getScene();
     virtual bool readScene(const string& sceneSpec/*, const vector<string> 
&args*/);
+    virtual void readStack( const string &name, const vector<string> &args );
     virtual void setScenePath(const string& path);
 
     // Groups
@@ -298,7 +299,8 @@
     SCIRun::AtomicCounter ids;
 
     Scene* readMOScene(const string& name, const vector<string>& args,
-                      bool printErrors);
+                       bool printErrors);
+    void readMOStack(const string& name, const vector<string>& args, bool 
printErrors );
   };
 }
 

Modified: trunk/Interface/Context.h
==============================================================================
--- trunk/Interface/Context.h   (original)
+++ trunk/Interface/Context.h   Wed Jan 11 00:33:51 2006
@@ -19,10 +19,10 @@
   class ReadContext {
   public:
     ReadContext(MantaInterface* rtrt_int)
-      : rtrt_int(rtrt_int)
+      : manta_interface(rtrt_int)
     {
     }
-    mutable MantaInterface* rtrt_int;
+    mutable MantaInterface* manta_interface;
 
   private:
     ReadContext(const ReadContext&);

Modified: trunk/Interface/MantaInterface.h
==============================================================================
--- trunk/Interface/MantaInterface.h    (original)
+++ trunk/Interface/MantaInterface.h    Wed Jan 11 00:33:51 2006
@@ -111,6 +111,7 @@
     virtual void setScene(Scene* scene) = 0;
                virtual Scene *getScene() = 0;
     virtual bool readScene(const string& sceneSpec) = 0;
+    virtual void readStack( const string &name, const vector<string> &args ) 
= 0;
     virtual void setScenePath(const string& path) = 0;
 
     typedef Group* (*GroupCreator)(const vector<string>& args);

Modified: trunk/MantaTypes.h
==============================================================================
--- trunk/MantaTypes.h  (original)
+++ trunk/MantaTypes.h  Wed Jan 11 00:33:51 2006
@@ -4,7 +4,7 @@
 
   The MIT License
 
-  Copyright (c) 2005
+  Copyright (c) 2005-2006
   Scientific Computing and Imaging Institute, University of Utah
 
   License for the specific language governing rights and limitations under

Modified: trunk/StandAlone/manta.cc
==============================================================================
--- trunk/StandAlone/manta.cc   (original)
+++ trunk/StandAlone/manta.cc   Wed Jan 11 00:33:51 2006
@@ -1,6 +1,34 @@
 
+
+/*
+  For more information, please see: http://software.sci.utah.edu
+
+  The MIT License
+
+  Copyright (c) 2005-2006
+  Scientific Computing and Imaging Institute, University of Utah
+
+  License for the specific language governing rights and limitations under
+  Permission is hereby granted, free of charge, to any person obtaining a
+  copy of this software and associated documentation files (the "Software"),
+  to deal in the Software without restriction, including without limitation
+  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+  and/or sell copies of the Software, and to permit persons to whom the
+  Software is furnished to do so, subject to the following conditions:
+
+  The above copyright notice and this permission notice shall be included
+  in all copies or substantial portions of the Software.
+
+  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+  DEALINGS IN THE SOFTWARE.
+*/
+
 #include <Interface/MantaInterface.h>
-#include <Core/Color/ColorDB.h>
 #include <Core/Util/Args.h>
 #include <Interface/Callback.h>
 #include <Interface/Scene.h>
@@ -11,7 +39,27 @@
 #include <Core/Geometry/BBox.h>
 #include <Core/Exceptions/Exception.h>
 #include <Core/Exceptions/InternalError.h>
+#include <Core/Exceptions/IllegalArgument.h>
 #include <Core/Thread/Time.h>
+
+// Default scene includes.
+#include <Core/Color/ColorDB.h>
+#include <Interface/LightSet.h>
+#include <Model/AmbientLights/ConstantAmbient.h>
+#include <Model/Backgrounds/ConstantBackground.h>
+#include <Model/Backgrounds/TextureBackground.h>
+#include <Model/Lights/PointLight.h>
+#include <Model/Textures/Constant.h>
+#include <Model/Textures/CheckerTexture.h>
+#include <Model/Textures/MarbleTexture.h>
+#include <Model/Materials/Phong.h>
+#include <Model/Materials/Flat.h>
+#include <Model/Groups/Group.h>
+#include <Model/Primitives/Parallelogram.h>
+#include <Model/Primitives/Sphere.h>
+#include <Model/TexCoordMappers/UniformMapper.h>
+#include <SCIRun/Core/Thread/Thread.h>
+
 #include <strings.h>
 
 #include <sgi_stl_warnings_off.h>
@@ -27,7 +75,8 @@
 #include <ieeefp.h>
 #endif
 
-static Scene* createDefaultScene();
+ Scene* createDefaultScene();
+static void make_stack( ReadContext &context, const vector<string> &args );
 
 static void
 printList(ostream& out, const MantaInterface::listType& list, int spaces=0)
@@ -123,40 +172,53 @@
     args.push_back(argv[i]);
        
   try {
+
+    
///////////////////////////////////////////////////////////////////////////
+    // Create Manta.
     MantaInterface* rtrt = createManta();
+
+    // Set the scene search path based on an env variable.
     if(getenv("MANTA_SCENEPATH"))
       rtrt->setScenePath(getenv("MANTA_SCENEPATH"));
     else
       rtrt->setScenePath(".:../scenes");
+
+    // Use one worker by default.
     rtrt->changeNumWorkers(1);
+
+    // Default options.
     if(!rtrt->selectImageType("rgba8"))
       throw InternalError("default image not found", __FILE__, __LINE__);
-    if(!rtrt->selectLoadBalancer("workqueue"))
-      throw InternalError("default load balancer not found",
-                          __FILE__, __LINE__);
-    if(!rtrt->selectImageTraverser("tiled"))
-      throw InternalError("default image traverser not found", __FILE__, 
__LINE__ );
-    if(!rtrt->selectPixelSampler("singlesample"))
-      throw InternalError("default pixel sampler not found", __FILE__, 
__LINE__ );
-    if(!rtrt->selectRenderer("raytracer"))
-      throw InternalError("default renderer not found", __FILE__, __LINE__ );
+    
     if(!rtrt->selectShadowAlgorithm("hard"))
       throw InternalError("default shadow algorithm not found", __FILE__, 
__LINE__ );
+    
+    // Set camera for the default scene.
     Camera* currentCamera = rtrt->createCamera("pinhole(-eye 3 3 2 -lookat 0 
0 0.3 -up 0 0 1 -fov 60)");
     if(!currentCamera)
       throw InternalError("cannot create default camera", __FILE__, __LINE__ 
);
+
+    // Defaults for command line args.
     int xres = 512, yres = 512;
+    string stack_file = "";
+    bool haveUI = false;
     bool channelCreated=false;
     bool stereo = false;
-    bool haveUI = false;
     bool compute_bb_camera = false;
 
+    // Parse command line args.
+    
     int argc = static_cast<int>(args.size());
     for(int i=0;i<argc;i++){
       string arg = args[i];
       if(arg == "-help"){
         usage(rtrt);
+
+        
       } else if(arg == "-bench" || arg == "-quietbench"){
+
+        
///////////////////////////////////////////////////////////////////////
+        // Benchmark Helper.        
         bool verbose = true;
         if(arg == "-quietbench")
           verbose = false;
@@ -172,18 +234,50 @@
                                  Callback::create(b, &BenchHelper::start));
         rtrt->addOneShotCallback(MantaInterface::Absolute, warmup+numFrames,
                                  Callback::create(b, &BenchHelper::stop));
+
+        
       } else if(arg == "-camera"){
-                               string s;
-                               if(!getStringArg(i, args, s))
-                                       usage(rtrt);
-                               currentCamera = rtrt->createCamera(s);
-                               if(!currentCamera){
-                                       cerr << "Error creating camera: " << 
s << ", available cameras are:\n";
-                                       printList(cerr, rtrt->listCameras());
-                                       exit(1);
-                               }
+        string s;
+        if(!getStringArg(i, args, s))
+          usage(rtrt);
+        currentCamera = rtrt->createCamera(s);
+        if(!currentCamera){
+          cerr << "Error creating camera: " << s << ", available cameras 
are:\n";
+          printList(cerr, rtrt->listCameras());
+          throw IllegalArgument( s, i, args );
+        }
       } else if(arg == "-bbcamera"){
-        compute_bb_camera = true;
+        compute_bb_camera = true;  
+        
+      } else if(arg == "-res"){
+        if(!getResolutionArg(i, args, xres, yres)){
+          cerr << "Error parsing resolution: " << args[i+1] << '\n';
+          usage(rtrt);
+        }
+      } else if(arg == "-stereo") {
+        stereo = true;
+        
+      } else if(arg == "-imagedisplay"){
+        string s;
+        if(!getStringArg(i, args, s))
+          usage(rtrt);
+        if(!rtrt->createChannel(s, currentCamera, stereo, xres, yres)){
+          cerr << "Invalid image display: " << s << ", available image 
displays are:\n";
+          printList(cerr, rtrt->listImageDisplays());
+          throw IllegalArgument( s, i, args );
+        }
+        channelCreated=true;
+
+      } else if(arg == "-imagetype"){
+        string s;
+        if(!getStringArg(i, args, s))
+        usage(rtrt);
+        if(!rtrt->selectImageType(s)){
+          cerr << "Invalid image type: " << s << ", available image types 
are:\n";
+          printList(cerr, rtrt->listImageTypes());
+          throw IllegalArgument( s, i, args );
+        }        
+        
       } else if(arg == "-idlemode"){
         string s;
         if(!getStringArg(i, args, s))
@@ -191,75 +285,36 @@
         if(!rtrt->addIdleMode(s)){
           cerr << "Invalid idle mode: " << s << ", available idle modes 
are:\n";
           printList(cerr, rtrt->listIdleModes());
-          exit(1);
+          throw IllegalArgument( s, i, args );
         }
-      } else if(arg == "-imagedisplay"){
-                               string s;
-                               if(!getStringArg(i, args, s))
-                                       usage(rtrt);
-                               if(!rtrt->createChannel(s, currentCamera, 
stereo, xres, yres)){
-                                       cerr << "Invalid image display: " << 
s << ", available image displays are:\n";
-                                       printList(cerr, 
rtrt->listImageDisplays());
-                                       exit(1);
-                               }
-                               channelCreated=true;
-      } else if(arg == "-imagetraverser"){
-                               string s;
-                               if(!getStringArg(i, args, s))
-                                       usage(rtrt);
-                               if(!rtrt->selectImageTraverser(s)){
-                                       cerr << "Invalid image traverser: " 
<< s << ", available image traversers are:\n";
-                                       printList(cerr, 
rtrt->listImageTraversers());
-                                       exit(1);
-                               }
-      } else if(arg == "-imagetype"){
-                               string s;
-                               if(!getStringArg(i, args, s))
-                                       usage(rtrt);
-                               if(!rtrt->selectImageType(s)){
-                                       cerr << "Invalid image type: " << s 
<< ", available image types are:\n";
-                                       printList(cerr, 
rtrt->listImageTypes());
-                                       exit(1);
-                               }
-      } else if(arg == "-loadbalancer"){
-                               string s;
-                               if(!getStringArg(i, args, s))
-                                       usage(rtrt);
-                               if(!rtrt->selectLoadBalancer(s)){
-                                       cerr << "Invalid load balancer: " << 
s << ", available load balancers are:\n";
-                                       printList(cerr, 
rtrt->listLoadBalancers());
-                                       exit(1);
-                               }
       } else if(arg == "-np"){
                                long np;
                                if(!getLongArg(i, args, np))
                                        usage(rtrt);
                                rtrt->changeNumWorkers(static_cast<int>(np));
-      } else if(arg == "-pixelsampler"){
-                               string s;
-                               if(!getStringArg(i, args, s))
-                                       usage(rtrt);
-                               if(!rtrt->selectPixelSampler(s)){
-                                       cerr << "Invalid pixel sampler: " << 
s << ", available pixel samplers are:\n";
-                                       printList(cerr, 
rtrt->listPixelSamplers());
-                                       exit(1);
-                               }
-      } else if(arg == "-renderer"){
+        
+      } else if(arg == "-ui"){
                                string s;
                                if(!getStringArg(i, args, s))
                                        usage(rtrt);
-                               if(!rtrt->selectRenderer(s)){
-                                       cerr << "Invalid renderer: " << s << 
", available renderers are:\n";
-                                       printList(cerr, 
rtrt->listRenderers());
-                                       exit(1);
-                               }
-      } else if(arg == "-res"){
-                               if(!getResolutionArg(i, args, xres, yres)){
-                                       cerr << "Error parsing resolution: " 
<< args[i+1] << '\n';
-                                       usage(rtrt);
+                               UserInterface* ui = 
rtrt->createUserInterface(s);
+                               if(!ui){
+                                       cerr << "Unknown user interface: " << 
s << ", available user interfaces are:\n";
+                                       printList(cerr, 
rtrt->listUserInterfaces());
+                                       throw IllegalArgument( s, i, args );
                                }
-      } else if(arg == "-stereo") {
-        stereo = true;
+                               ui->startup();
+                               haveUI = true;
+
+      } else if(arg == "-shadows"){
+        string s;
+        if(!getStringArg(i, args, s))
+          usage(rtrt);
+        if(!rtrt->selectShadowAlgorithm(s)){
+          cerr << "Invalid shadow algorithm: " << s << ", available shadow 
algorithms are:\n";
+          printList(cerr, rtrt->listShadowAlgorithms());
+          throw IllegalArgument( s, i, args );
+        }
         
       } else if(arg == "-scene"){
                                if(rtrt->haveScene())
@@ -269,34 +324,32 @@
                                        usage(rtrt);
                                if(!rtrt->readScene(scene)){
                                        cerr << "Error reading scene: " << 
scene << '\n';
-                                       exit(1);
-                               }
-      } else if(arg == "-shadows"){
-                               string s;
-                               if(!getStringArg(i, args, s))
-                                       usage(rtrt);
-                               if(!rtrt->selectShadowAlgorithm(s)){
-                                       cerr << "Invalid shadow algorithm: " 
<< s << ", available shadow algorithms are:\n";
-                                       printList(cerr, 
rtrt->listShadowAlgorithms());
-                                       exit(1);
-                               }
-      } else if(arg == "-ui"){
-                               string s;
-                               if(!getStringArg(i, args, s))
-                                       usage(rtrt);
-                               UserInterface* ui = 
rtrt->createUserInterface(s);
-                               if(!ui){
-                                       cerr << "Unknown user interface: " << 
s << ", available user interfaces are:\n";
-                                       printList(cerr, 
rtrt->listUserInterfaces());
-                                       exit(1);
+                                       throw IllegalArgument( scene, i, args 
);
                                }
-                               ui->startup();
-                               haveUI = true;
-      } else {
-                               cerr << "Unknown argument: " << arg << '\n';
-                               usage(rtrt);
       }
+      else if (arg == "-stack") {
+        if (!getStringArg(i,args,stack_file))
+          usage(rtrt);
+      }
+    }
+
+    
///////////////////////////////////////////////////////////////////////////
+    // Use defaults if necessary.
+
+    // Check if we should compute the camera based on the scene's bounds.
+    if(compute_bb_camera) {
+      BBox bbox;
+      PreprocessContext ppc;
+      rtrt->getScene()->getObject()->computeBounds(ppc, bbox);
+      currentCamera->autoview(bbox);
+    }
+    
+    // Check to see if a channel  was created.
+    if(!channelCreated){
+      rtrt->createChannel("opengl", currentCamera, stereo, xres, yres);
     }
+
+    // Check to see if a UI was specified
     if(!haveUI){
       UserInterface* ui = rtrt->createUserInterface("X");
       if(!ui){
@@ -306,54 +359,127 @@
       }
       ui->startup();
     }
+
+    // Check if default scene should be used.
     if(!rtrt->haveScene()){
       rtrt->setScene(createDefaultScene());
     }
-    if(compute_bb_camera) {
-      BBox bbox;
-      PreprocessContext ppc;
-      rtrt->getScene()->getObject()->computeBounds(ppc, bbox);
-      currentCamera->autoview(bbox);
+
+    
+    
///////////////////////////////////////////////////////////////////////////
+    // Configure the rendering stack from a specified file.
+    if (stack_file.size()) {
+      rtrt->readStack( stack_file, args );
     }
-    if(!channelCreated){
-      rtrt->createChannel("opengl", currentCamera, stereo, xres, yres);
+    else {
+      // Pass a read context and all of the command line args to the scene
+      // configuration function. The function will ignore some arguments.
+      ReadContext context( rtrt );
+      make_stack( context, args );
     }
+    
+
     rtrt->beginRendering(true);
     delete rtrt;
-  } catch (SCIRun::Exception *e) {
-    cerr << "Caught exception: " << e->message() << std::endl << std::endl;
-    exit(1);
+
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    
///////////////////////////////////////////////////////////////////////////
+    
   } catch (SCIRun::Exception& e) {
-    cerr << "Caught exception: " << e.message() << '\n';
-    if(e.stackTrace())
-      cerr << "Stack trace: " << e.stackTrace() << '\n';
-    exit(1);
+    cerr << "manta.cc: Caught exception: " << e.message() << '\n';
+    // if(e.stackTrace())
+    //   cerr << "Stack trace: " << e.stackTrace() << '\n';
+    exit( 1 );
                
   } catch (std::exception e){
-    cerr << "Caught std exception: " << e.what() << '\n';
+    cerr << "manta.cc: Caught std exception: "
+         << e.what()
+         << '\n';
     exit(1);
                
   } catch(...){
-    cerr << "Caught unknown exception\n";
+    cerr << "manta.cc: Caught unknown exception\n";
     exit(1);
   }
   exit(0);
 }
 
-#include <Interface/LightSet.h>
-#include <Model/AmbientLights/ConstantAmbient.h>
-#include <Model/Backgrounds/ConstantBackground.h>
-#include <Model/Backgrounds/TextureBackground.h>
-#include <Model/Lights/PointLight.h>
-#include <Model/Textures/Constant.h>
-#include <Model/Textures/CheckerTexture.h>
-#include <Model/Textures/MarbleTexture.h>
-#include <Model/Materials/Phong.h>
-#include <Model/Materials/Flat.h>
-#include <Model/Groups/Group.h>
-#include <Model/Primitives/Parallelogram.h>
-#include <Model/Primitives/Sphere.h>
-#include <Model/TexCoordMappers/UniformMapper.h>
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
+// Default stack setup.
+
+void make_stack( ReadContext &context, const vector<string> &args ) {
+
+  // Obtain a pointer to manta.
+  MantaInterface *rtrt = context.manta_interface;
+
+  // Defaults.
+  
+  if(!rtrt->selectLoadBalancer("workqueue"))
+    throw InternalError("default load balancer not found", __FILE__, 
__LINE__);
+  
+  if(!rtrt->selectImageTraverser("tiled"))
+    throw InternalError("default image traverser not found", __FILE__, 
__LINE__ );
+  
+  if(!rtrt->selectPixelSampler("singlesample"))
+    throw InternalError("default pixel sampler not found", __FILE__, 
__LINE__ );
+  
+  if(!rtrt->selectRenderer("raytracer"))
+    throw InternalError("default renderer not found", __FILE__, __LINE__ );
+
+  // Parse command line args.
+  for (int i=0;i<args.size();++i) {
+    string arg = args[i];
+
+    if(arg == "-imagetraverser"){
+      string s;
+      if(!getStringArg(i, args, s))
+        usage(rtrt);
+      if(!rtrt->selectImageTraverser(s)){
+        cerr << "Invalid image traverser: " << s << ", available image 
traversers are:\n";
+        printList(cerr, rtrt->listImageTraversers());
+        throw IllegalArgument( s, i, args );
+      }
+
+    } else if(arg == "-loadbalancer"){
+      string s;
+      if(!getStringArg(i, args, s))
+        usage(rtrt);
+      if(!rtrt->selectLoadBalancer(s)){
+        cerr << "Invalid load balancer: " << s << ", available load 
balancers are:\n";
+        printList(cerr, rtrt->listLoadBalancers());
+        throw IllegalArgument( s, i, args );
+      }
+    } else if(arg == "-pixelsampler"){
+      string s;
+      if(!getStringArg(i, args, s))
+        usage(rtrt);
+      if(!rtrt->selectPixelSampler(s)){
+        cerr << "Invalid pixel sampler: " << s << ", available pixel 
samplers are:\n";
+        printList(cerr, rtrt->listPixelSamplers());
+        throw IllegalArgument( s, i, args );
+      }
+    } else if(arg == "-renderer"){
+      string s;
+      if(!getStringArg(i, args, s))
+        usage(rtrt);
+      if(!rtrt->selectRenderer(s)){
+        cerr << "Invalid renderer: " << s << ", available renderers are:\n";
+        throw IllegalArgument( s, i, args );
+      }
+    }
+  }
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
+// Default Scene.
 
 Scene* createDefaultScene()
 {
@@ -367,31 +493,31 @@
 #elif 0
   scene->setBackground(new TextureBackground(new 
Constant<Color>(Color(RGBColor(.2,1,1))), Vector(0,1,0)));
 #elif 0
-   scene->setBackground(new TextureBackground
-                        (new MarbleTexture<Color>(Color(RGB(0.1,0.2,0.5)),
-                                                  Color(RGB(0.7,0.8,1.0)),
-                                                  1.0, 1.0, 15.0,
-                                                  6, 2.0, 0.6 ),
-                         Vector(0,1,0)));
+  scene->setBackground(new TextureBackground
+                       (new MarbleTexture<Color>(Color(RGB(0.1,0.2,0.5)),
+                                                 Color(RGB(0.7,0.8,1.0)),
+                                                 1.0, 1.0, 15.0,
+                                                 6, 2.0, 0.6 ),
+                        Vector(0,1,0)));
 #elif 0
-   scene->setBackground(new TextureBackground
-                        (new CheckerTexture<Color>(Color(RGBColor(1,0,0)),
-                                                   Color(RGBColor(0,0,1)),
-                                                   Vector(10,0,0),
-                                                   Vector(0,10,0)),
-                         Vector(0,1,0)));
+  scene->setBackground(new TextureBackground
+                       (new CheckerTexture<Color>(Color(RGBColor(1,0,0)),
+                                                  Color(RGBColor(0,0,1)),
+                                                  Vector(10,0,0),
+                                                  Vector(0,10,0)),
+                        Vector(0,1,0)));
 #endif
 
   Material* red=new Phong(Color(RGBColor(.6,0,0)),
                           Color(RGBColor(.6,.6,.6)), 32, 
(ColorComponent)0.4);
        
   Material* plane_matl = new Phong(new 
CheckerTexture<Color>(Color(RGBColor(.6,.6,.6)),
-                                                                             
                                                                              
                                                                              
       Color(RGBColor(0,0,0)),
-                                                                             
                                                                              
                                                                              
       Vector(1,0,0),
-                                                                             
                                                                              
                                                                              
       Vector(0,1,0)),
-                                                                             
                                                           new 
Constant<Color>(Color(RGBColor(.6,.6,.6))),
-                                                                             
                                                           32,
-                                                                             
                                                           new 
CheckerTexture<ColorComponent>
+                                                             
Color(RGBColor(0,0,0)),
+                                                             Vector(1,0,0),
+                                                             Vector(0,1,0)),
+                                   new 
Constant<Color>(Color(RGBColor(.6,.6,.6))),
+                                   32,
+                                   new CheckerTexture<ColorComponent>
                                    ((ColorComponent)0.2,
                                     (ColorComponent)0.5,
                                     Vector(1,0,0),
@@ -400,7 +526,7 @@
        
   Group* world = new Group();
   Primitive* floor = new Parallelogram(plane_matl, Point(-20,-20,0),
-                                                                             
                                                                           
Vector(40,0,0), Vector(0,40,0));
+                                       Vector(40,0,0), Vector(0,40,0));
   // Setup world-space texture coordinates for the checkerboard floor
   UniformMapper* uniformmap = new UniformMapper();
   floor->setTexCoordMapper(uniformmap);

Modified: trunk/scenes/CMakeLists.txt
==============================================================================
--- trunk/scenes/CMakeLists.txt (original)
+++ trunk/scenes/CMakeLists.txt Wed Jan 11 00:33:51 2006
@@ -1,79 +1,75 @@
 
-SET(manta_scene_link Manta_Engine 
-                     Manta_UserInterface 
-                     Manta_Model 
-                     Manta_Image 
-                     Manta_Interface 
-                     Manta_Core 
-                     SCIRun_Core
-                     ${CMAKE_THREAD_LIBS_INIT}
-                     ${OPENGL_LIBRARIES} 
-                     ${X11_LIBRARIES} 
-                     -lm)
-
 ############################################################
 # Initial test scenes.
 
+SET(MANTA_SCENE_LINK 
+  ${MANTA_TARGET_LINK_LIBRARIES}
+  ${CMAKE_THREAD_LIBS_INIT}
+  ${OPENGL_LIBRARIES} 
+  ${X11_LIBRARIES} 
+  -lm
+  )
+
 # Basic test scene.
 SET(SCENE_0 0 CACHE BOOL "Scene 0")
 IF(SCENE_0)
    ADD_LIBRARY(scene_0 0.cc)
-   TARGET_LINK_LIBRARIES(scene_0 ${manta_scene_link})
+   TARGET_LINK_LIBRARIES(scene_0 ${MANTA_SCENE_LINK})
 ENDIF(SCENE_0)
 
 # Just a cube.
 SET(SCENE_CUBE 0 CACHE BOOL "Just a Cube")
 IF(SCENE_CUBE)
    ADD_LIBRARY(scene_cube cube.cc)
-   TARGET_LINK_LIBRARIES(scene_cube ${manta_scene_link})
+   TARGET_LINK_LIBRARIES(scene_cube ${MANTA_SCENE_LINK})
 ENDIF(SCENE_CUBE)
 
 # Read in a BART scene.
 SET(SCENE_BARTREADER 0 CACHE BOOL "BART Reader")
 IF(SCENE_BARTREADER)
    ADD_LIBRARY(scene_BARTReader BARTReader.cc)
-   TARGET_LINK_LIBRARIES(scene_BARTReader ${manta_scene_link})
+   TARGET_LINK_LIBRARIES(scene_BARTReader ${MANTA_SCENE_LINK})
 ENDIF(SCENE_BARTREADER)
 
 # Test different primitives.
 SET(SCENE_PRIMTEST 0 CACHE BOOL "Primitive Test")
 IF(SCENE_PRIMTEST)
    ADD_LIBRARY(scene_primtest primtest.cc)
-   TARGET_LINK_LIBRARIES(scene_primtest ${manta_scene_link})
+   TARGET_LINK_LIBRARIES(scene_primtest ${MANTA_SCENE_LINK})
 ENDIF(SCENE_PRIMTEST)
 
 # Test different acceleration structures.
 SET(SCENE_ACCELTEST 0 CACHE BOOL "Acceleration Test")
 IF(SCENE_ACCELTEST)
    ADD_LIBRARY(scene_acceltest acceltest.cc)
-   TARGET_LINK_LIBRARIES(scene_acceltest ${manta_scene_link})
+   TARGET_LINK_LIBRARIES(scene_acceltest ${MANTA_SCENE_LINK})
 ENDIF(SCENE_ACCELTEST)
 
 # Test different acceleration structures.
 SET(SCENE_PARTICLEBVHTEST 0 CACHE BOOL "Particle BVH Test")
 IF(SCENE_PARTICLEBVHTEST)
    ADD_LIBRARY(scene_ParticleBVHTest ParticleBVHTest.cc)
-   TARGET_LINK_LIBRARIES(scene_ParticleBVHTest ${manta_scene_link})
+   TARGET_LINK_LIBRARIES(scene_ParticleBVHTest ${MANTA_SCENE_LINK})
 ENDIF(SCENE_PARTICLEBVHTEST)
 
 # Boeing 777 Test Scene.
 SET(SCENE_BOEING777 0 CACHE BOOL "Boeing 777 Test Scene")
 IF(SCENE_BOEING777)
    ADD_LIBRARY(scene_boeing777 boeing777.cc)
-   TARGET_LINK_LIBRARIES(scene_boeing777 ${manta_scene_link})
+   TARGET_LINK_LIBRARIES(scene_boeing777 ${MANTA_SCENE_LINK})
 ENDIF(SCENE_BOEING777)
 
 # volume
 SET(SCENE_VOLUME 0 CACHE BOOL "volume rendering")
 IF(SCENE_VOLUME)
    ADD_LIBRARY(scene_volume volume.cc)
-   TARGET_LINK_LIBRARIES(scene_volume ${manta_scene_link})
+   TARGET_LINK_LIBRARIES(scene_volume ${MANTA_SCENE_LINK})
 ENDIF(SCENE_VOLUME)
 
 SET(SCENE_OBJVIEWER 0 CACHE BOOL "Wavefront Obj file viewer.")
 IF(SCENE_OBJVIEWER)
    ADD_LIBRARY(scene_objviewer objviewer.cc)
-   TARGET_LINK_LIBRARIES(scene_objviewer ${manta_scene_link})
+   TARGET_LINK_LIBRARIES(scene_objviewer ${MANTA_SCENE_LINK})
 ENDIF(SCENE_OBJVIEWER)
 
 




  • [MANTA] r837 - in trunk: . Engine/Control Interface StandAlone scenes, abe, 01/11/2006

Archive powered by MHonArc 2.6.16.

Top of page