Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r903 - in trunk/fox/afr_demo: Engine/Control StandAlone


Chronological Thread 
  • From: abe@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r903 - in trunk/fox/afr_demo: Engine/Control StandAlone
  • Date: Tue, 7 Feb 2006 19:11:53 -0700 (MST)

Author: abe
Date: Tue Feb  7 19:11:52 2006
New Revision: 903

Added:
   trunk/fox/afr_demo/StandAlone/afr.cc
      - copied, changed from r902, trunk/StandAlone/manta.cc
Modified:
   trunk/fox/afr_demo/Engine/Control/AFRPipeline.cc
   trunk/fox/afr_demo/Engine/Control/AFRPipeline.h
Log:

Fixed afr.cc.



M    fox/afr_demo/Engine/Control/AFRPipeline.cc
M    fox/afr_demo/Engine/Control/AFRPipeline.h
A    fox/afr_demo/StandAlone/afr.cc


Modified: trunk/fox/afr_demo/Engine/Control/AFRPipeline.cc
==============================================================================
--- trunk/fox/afr_demo/Engine/Control/AFRPipeline.cc    (original)
+++ trunk/fox/afr_demo/Engine/Control/AFRPipeline.cc    Tue Feb  7 19:11:52 
2006
@@ -218,6 +218,12 @@
   callbackLock.writeUnlock();
 }
 
+void AFRPipeline::registerTerminationCallback( CallbackBase_1Data< 
MantaInterface *> *cb ) {
+  callbackLock.writeLock();
+  terminationCallbacks.push_back(cb);
+  callbackLock.writeUnlock();
+}
+
 void AFRPipeline::setTimeMode(TimeMode tm, double rate)
 {
   timeMode = tm;
@@ -1406,6 +1412,51 @@
     scene = newScene;
     return true;
   }
+}
+
+Scene* AFRPipeline::readMOScene(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++){
+    string fullname = *dir + "/"+name;
+    struct stat statbuf;
+    if(stat(fullname.c_str(), &statbuf) != 0){
+      if(printErrors){
+        cerr << "Error reading " << fullname << ": " << strerror(errno) << 
'\n';
+      }
+      continue;
+    }
+    void* handle=dlopen(fullname.c_str(), RTLD_NOW);
+    if(!handle){
+      if(printErrors){
+        cerr << "Error opening scene: " << fullname << '\n';
+        cerr << dlerror() << '\n';
+      }
+      continue;
+    }
+    void* scene_fn=dlsym(handle, "make_scene");
+    if(!scene_fn){
+      if(printErrors){
+        cerr << "Scene file found, but make_scene() function not found\n";
+      }
+      // If we get here, we fail so that we don't keep searching the path
+      // for another scene
+      return 0;
+    }
+    typedef Scene* (*MakerType)(const ReadContext&, const vector<string>&);
+    //    MakerType make_scene = reinterpret_cast<MakerType>(scene_fn);
+    MakerType make_scene = (MakerType)(scene_fn);
+    ReadContext context(this);
+    Scene* scene=(*make_scene)(context, args);
+    if(!scene){
+      if(printErrors)
+        cerr << "scene " << name << " did not produce a scene\n";
+      return 0;
+    }
+    return scene;
+  }
+  return 0;
 }
 
 
///////////////////////////////////////////////////////////////////////////////

Modified: trunk/fox/afr_demo/Engine/Control/AFRPipeline.h
==============================================================================
--- trunk/fox/afr_demo/Engine/Control/AFRPipeline.h     (original)
+++ trunk/fox/afr_demo/Engine/Control/AFRPipeline.h     Tue Feb  7 19:11:52 
2006
@@ -249,6 +249,9 @@
       PRCallbackMapType serialPreRenderCallbacks;
       ACallbackMapType parallelAnimationCallbacks;
       ACallbackMapType serialAnimationCallbacks;
+
+      typedef vector<CallbackBase_1Data<MantaInterface *>*> TCallbackMapType;
+      TCallbackMapType terminationCallbacks;
       vector<SetupCallback*> setupCallbacks;
 
       // Transactions

Copied: trunk/fox/afr_demo/StandAlone/afr.cc (from r902, 
trunk/StandAlone/manta.cc)
==============================================================================
--- trunk/StandAlone/manta.cc   (original)
+++ trunk/fox/afr_demo/StandAlone/afr.cc        Tue Feb  7 19:11:52 2006
@@ -42,6 +42,10 @@
 #include <Core/Exceptions/IllegalArgument.h>
 #include <Core/Thread/Time.h>
 
+#include <Engine/ImageTraversers/GSTAFRImageTraverser.h>
+#include <Engine/Control/AFRPipeline.h>
+#include <Model/Cameras/AfrPinholeCamera.h>
+
 // Default scene includes.
 #include <Core/Color/ColorDB.h>
 #include <Interface/LightSet.h>
@@ -68,8 +72,8 @@
 
 using namespace std;
 using namespace Manta;
+using namespace Manta::Afr;
 using SCIRun::InternalError;
-using SCIRun::Time;
 
 #if HAVE_IEEEFP_H
 #include <ieeefp.h>
@@ -144,12 +148,12 @@
 
 void BenchHelper::start(int, int)
 {
-  startTime = Time::currentSeconds();
+  startTime = SCIRun::Time::currentSeconds();
 }
 
 void BenchHelper::stop(int, int)
 {
-  double dt = Time::currentSeconds()-startTime;
+  double dt = SCIRun::Time::currentSeconds()-startTime;
   double fps = numFrames/dt;
   if(verbose)
     cout << "Benchmark completed in " << dt << " seconds (" << numFrames << 
" frames, " << fps << " frames per second)\n";
@@ -175,7 +179,7 @@
 
     
///////////////////////////////////////////////////////////////////////////
     // Create Manta.
-    MantaInterface* rtrt = createManta();
+    MantaInterface* rtrt = createAFRPipeline();
 
     // Set the scene search path based on an env variable.
     if(getenv("MANTA_SCENEPATH"))
@@ -194,9 +198,9 @@
       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__ 
);
+    Camera* currentCamera = new AFRPinholeCamera( Point( 3, 3, 2 ),
+                                                  Point( 0, 0, 0.3 ),
+                                                  Vector( 0, 0, 1 ), 60 );
 
     // Defaults for command line args.
     int xres = 512, yres = 512;
@@ -420,10 +424,12 @@
   
   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__ );
-  
+
+  AFRImageTraverser *imagetraverser = new 
GSTAFRImageTraverser(vector<string>());
+  rtrt->setImageTraverser( imagetraverser );
+  // 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__ );
   
@@ -435,13 +441,27 @@
     string arg = args[i];
 
     if(arg == "-imagetraverser"){
-      string s;
-      if(!getStringArg(i, args, s))
+      string spec;
+      if(!getStringArg(i, args, spec))
         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 );
+
+      // Parse the command line args.
+      string name;
+      vector<string> args;
+      parseSpec(spec, name, args);
+      
+      // Check to see if the image traverser specified is supported by afr.
+      if (name == "gstafr") {
+        rtrt->setImageTraverser( GSTAFRImageTraverser::create( args ) );
+      }
+
+      // Otherwise attempt to load a default image traverser from manta.
+      else {
+        if(!rtrt->selectImageTraverser(spec)){
+          cerr << "Invalid image traverser: " << spec << ", available image 
traversers are:\n";
+          printList(cerr, rtrt->listImageTraversers());
+          throw IllegalArgument( spec, i, args );
+        }
       }
 
     } else if(arg == "-loadbalancer"){
@@ -451,15 +471,6 @@
       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"){




  • [MANTA] r903 - in trunk/fox/afr_demo: Engine/Control StandAlone, abe, 02/07/2006

Archive powered by MHonArc 2.6.16.

Top of page