Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r595 - in branches/itanium2: Engine/Display Model/Cameras UserInterface fox


Chronological Thread 
  • From: abe@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r595 - in branches/itanium2: Engine/Display Model/Cameras UserInterface fox
  • Date: Wed, 5 Oct 2005 16:13:10 -0600 (MDT)

Author: abe
Date: Wed Oct  5 16:13:09 2005
New Revision: 595

Modified:
   branches/itanium2/Engine/Display/GLXImageDisplay.cc
   branches/itanium2/Model/Cameras/StereoPinholeCamera.cc
   branches/itanium2/UserInterface/CameraPathAutomator.cc
   branches/itanium2/UserInterface/CameraPathAutomator.h
   branches/itanium2/fox/dm_demo.cc
Log:

Added several command line options to the camera path tool:

bin/manta -ui "camerapath( <below options> )"

-file <file.txt>       Load control points from file.txt
-warmup <n>            Start running the path after <n> frames.
-channel <n>           Update the camera on channel <n>

-sync <n>              Synchronize the path tool thread with the render 
threads
                       every <n> update transactions:

                       Outputs:
                       <frame> <transaction> <elapse frames> <elapse seconds> 
<avg fps>

                       Adjust -delta_time so that <elapse frames> equals <n> 
(Idealy you want
                       only one transaction per frame.)

-delta_t <f>           Increment the spline parameter t by <f> each update.
-delta_time <sec>      Minimum number of seconds between updates.
-behavior <exit|loop>  Either exit or loop at the end of the path.
-interval <m> <n>      Only use control points between <m> and <n>

For example:

bin/manta -np 12 -scene "lib/libscene_boeing777.so( -file 
/dev/shm/cockpit.v3c1 -np 12 -lambertianalt )" -ui X \
-ui "camerapath( -file cockpit-path1.txt -interval 250 300 -sync 10 -behavior 
exit )"

Runs the path from "cockpit-path1.txt" using control points 250-300 
synchronizing after every 10 transactions are issued and exits when done.

bin/manta -np 12 -scene "lib/libscene_boeing777.so( -file 
/dev/shm/cockpit.v3c1 -np 12 -lambertianalt )" \
-ui "camerapath( -file cockpit-path1.txt -interval 250 300 -behavior exit )" 
-imagedisplay "file( /dev/shm/frame )"

Outputs frames between control points 250-300 as .tga files in /dev/shm.




Also updated dm_demo for stereo support. GUI's for camera path and stereo 
coming soon.


M    fox/dm_demo.cc
M    UserInterface/CameraPathAutomator.cc
M    UserInterface/CameraPathAutomator.h
M    Model/Cameras/StereoPinholeCamera.cc
M    Engine/Display/GLXImageDisplay.cc


Modified: branches/itanium2/Engine/Display/GLXImageDisplay.cc
==============================================================================
--- branches/itanium2/Engine/Display/GLXImageDisplay.cc (original)
+++ branches/itanium2/Engine/Display/GLXImageDisplay.cc Wed Oct  5 16:13:09 
2005
@@ -2,6 +2,7 @@
 #include <GL/glu.h>
 #include <X11/Xutil.h>
 
+
 #include <Engine/Display/GLXImageDisplay.h>
 #include <Image/SimpleImage.h>
 #include <Image/Pixel.h>

Modified: branches/itanium2/Model/Cameras/StereoPinholeCamera.cc
==============================================================================
--- branches/itanium2/Model/Cameras/StereoPinholeCamera.cc      (original)
+++ branches/itanium2/Model/Cameras/StereoPinholeCamera.cc      Wed Oct  5 
16:13:09 2005
@@ -24,7 +24,7 @@
   bool gotStereo = false;
   normalizeRays = false;
 
-  stereo_offset = 0.0;
+  stereo_offset = 1.0;
 
   // pinhole(-eye 3 3 2 -lookat 0 0 0.3 -up 0 0 1 -fov 60
   eye    = Point ( 3.0, 3.0, 2.0 );
@@ -131,6 +131,7 @@
       RayPacket::Element& e = rays.get(i);
       Vector raydir(v*e.imageX+u*e.imageY+direction);
       raydir.normalize();
+
       e.ray.set(stereo_eye[e.whichEye], raydir);
       e.importance = 1.0;
     }

Modified: branches/itanium2/UserInterface/CameraPathAutomator.cc
==============================================================================
--- branches/itanium2/UserInterface/CameraPathAutomator.cc      (original)
+++ branches/itanium2/UserInterface/CameraPathAutomator.cc      Wed Oct  5 
16:13:09 2005
@@ -28,8 +28,10 @@
 
 #include <UserInterface/CameraPathAutomator.h>
 
+#include <SCIRun/Core/Thread/Thread.h>
 #include <SCIRun/Core/Thread/Time.h>
 #include <SCIRun/Core/Exceptions/ErrnoException.h>
+#include <SCIRun/Core/Math/MinMax.h>
 
 #include <Interface/Camera.h>
 #include <Interface/Callback.h>
@@ -55,10 +57,17 @@
                                           Real delta_t_, Real delta_time_ )
   :
   AutomatorUI( manta_interface_, warmup_frames ),
+  synchronize_barrier( "sync barrier" ),
   channel( channel_ ),
+  last_sync_frame( 0 ),
+  last_sync_seconds( 0 ),
   delta_t( delta_t_ ),
   delta_time( delta_time_ ),
-  total_points( total_points_ )
+  total_points( total_points_ ),
+  sync_frames( 0 ),
+  loop_behavior( PATH_STOP ),
+  interval_start( 1 ),
+  interval_last ( total_points-2 )
 {
   eye    = new Point[total_points];
   lookat = new Point[total_points];
@@ -75,10 +84,14 @@
                                           int warmup_frames, const string 
&file_name,
                                           Real delta_t_, Real delta_time_ ) :
   AutomatorUI( manta_interface_, warmup_frames ),
+  synchronize_barrier( "sync barrier" ),  
   channel( channel_ ),
+  last_sync_frame( 0 ),
+  last_sync_seconds( 0 ),  
   delta_t( delta_t_ ),
-  delta_time( delta_time_ )
-
+  delta_time( delta_time_ ),
+  loop_behavior( PATH_STOP ), 
+  interval_start( 1 )
 {
 
   total_points = 0;
@@ -140,7 +153,7 @@
     
///////////////////////////////////////////////////////////////////////////
     // Parse the args.
     
-    // Line should be "delta_t( 0.25 )"
+    // Line should be in the form "delta_t( 0.25 )"
     if (name == "delta_t") {
       if (!getArg(i,args,delta_t)) {
         sprintf(error_message, "CameraPathAutomator input line: %d", 
line_num );
@@ -204,6 +217,9 @@
     
     ++line_num;
   }
+
+  // Set the end point
+  interval_last = total_points-2;
   
   
/////////////////////////////////////////////////////////////////////////////
 
@@ -229,6 +245,12 @@
   string file_name;
   int warmup_frames = 2;
   int channel = 0;
+  int sync_frames = 0;
+  int behavior = PATH_STOP;
+  int start = 0, last = 0;
+  
+  Real delta_t    = 0.0;
+  Real delta_time = 0.0;
 
   for (int i=0; i<args.size(); ++i) {
     if (args[i] == "-file") {
@@ -240,11 +262,51 @@
     else if (args[i] == "-channel") {
       getArg(i, args, channel );
     }
+    else if (args[i] == "-sync") {
+      getArg(i, args, sync_frames );
+    }
+    else if (args[i] == "-delta_t") {
+      getArg(i, args, delta_t );
+    }
+    else if (args[i] == "-delta_time") {
+      getArg(i, args, delta_time );
+    }
+    else if (args[i] == "-behavior") {
+      ++i;
+      if (args[i] == "exit") {
+        behavior = PATH_EXIT;
+      }
+      else if (args[i] == "loop") {
+        behavior = PATH_LOOP;
+      }
+    }
+    else if (args[i] == "-interval") {
+      getArg(i, args, start );
+      getArg(i, args, last  );
+    }
   }
 
   
/////////////////////////////////////////////////////////////////////////////
   // Create the Automator.
-  return new CameraPathAutomator( manta_interface_, channel, warmup_frames, 
file_name );
+  CameraPathAutomator *automator = new CameraPathAutomator( 
manta_interface_, channel, warmup_frames, file_name );
+
+  automator->set_sync_frames  ( sync_frames );
+  automator->set_loop_behavior( behavior );
+  
+  // Check to see if either delta was specified on the command line.
+  if (delta_t != 0.0) {
+    automator->set_delta_t( delta_t );
+  }
+  if (delta_time != 0.0) {
+    automator->set_delta_time( delta_time );
+  }
+
+  // Check to see if an interval was specified.
+  if (start != 0 || last != 0) {
+    automator->set_interval( start, last );
+  }
+
+  return automator;
 }
 
 
///////////////////////////////////////////////////////////////////////////////
@@ -256,62 +318,84 @@
 // Implementation of the interpolator.
 void CameraPathAutomator::run_automator() {
 
-  int current_point = 0;
-  int last_point = total_points-2;
-
   Point current_eye, current_lookat;
   Vector current_up;
+  
+  int current_point = 0;
 
+  int last_point  = SCIRun::Min(total_points-2,interval_last);
+  int first_point = SCIRun::Max(1,SCIRun::Min(interval_start,last_point));
+  
   int start_frame = getMantaInterface()->getCurrentFrame();
   Real start_seconds = SCIRun::Time::currentSeconds();
   
   std::cerr << "Beginning camera path " << total_points 
-            << " control points." << std::endl;
+            << " control points. Using interval " << first_point << ":" << 
last_point << std::endl;
 
   int transaction_number = 0;
-
-  
/////////////////////////////////////////////////////////////////////////////
-  // Main Automator loop.
-  for (current_point=1;current_point<last_point;++current_point) {
+  
+  do {
     
-    
///////////////////////////////////////////////////////////////////////////
-    // Sample by delta_t between the points.
-    for (Real t=0.0; t<(1.0-delta_t); t+=delta_t) {
+    
/////////////////////////////////////////////////////////////////////////////
+    // Main Automator loop.
+    for (current_point=first_point;current_point<last_point;++current_point) 
{
+    
+      
///////////////////////////////////////////////////////////////////////////
+      // Sample by delta_t between the points.
+      for (Real t=0.0; t<(1.0-delta_t); t+=delta_t) {
     
-      // Evaluate the spline.
-      // NOTE: operator & is overloaded by Vector to return (Real *)
-      // NOTE: none of the necessary operations are defined for Points...
-      //       so we cast to vectors for the interpolation.
+        // Evaluate the spline.
+        // NOTE: operator & is overloaded by Vector to return (Real *)
+        // NOTE: none of the necessary operations are defined for Points...
+        //       so we cast to vectors for the interpolation.
       
-      catmull_rom_interpolate( (Vector *)&eye[current_point],    t, 
*((Vector *)&current_eye) );
-      catmull_rom_interpolate( (Vector *)&lookat[current_point], t, 
*((Vector *)&current_lookat) );
-      catmull_rom_interpolate( (Vector *)&up[current_point],     t, 
current_up );
-
-#if 0
-      std::cerr << "CameraPath: control point: " << current_point << " t: " 
<< t
-                << " update: " << transaction_number << std::endl;
-        // << " eye: "              << current_eye
-        //     << " lookat: "           << current_lookat 
-        //      << " up: "               << current_up    << std::endl;
-#endif
-      // Send the transaction to manta.
-      getMantaInterface()->addTransaction("CameraPathAutomator",
-                                          Callback::create(this, 
&CameraPathAutomator::mantaSetCamera,
-                                                           current_eye, 
current_lookat, current_up ));
+        catmull_rom_interpolate( (Vector *)&eye[current_point],    t, 
*((Vector *)&current_eye) );
+        catmull_rom_interpolate( (Vector *)&lookat[current_point], t, 
*((Vector *)&current_lookat) );
+        catmull_rom_interpolate( (Vector *)&up[current_point],     t, 
current_up );
+
+        // Send the transaction to manta.
+        getMantaInterface()->addTransaction("CameraPathAutomator",
+                                            Callback::create(this, 
&CameraPathAutomator::mantaSetCamera,
+                                                             current_eye, 
current_lookat, current_up ));
 
-      transaction_number++;
+        // Record the time of this transaction before a potential sync
+        double start_time = SCIRun::Time::currentSeconds();      
       
-      
/////////////////////////////////////////////////////////////////////////
-      // Wait for delta_time seconds.
-      double start_time = SCIRun::Time::currentSeconds();
-      while ((SCIRun::Time::currentSeconds()-start_time) < delta_time);
+        // Check to see if this is a synchronization point.
+        if (sync_frames && ((transaction_number % sync_frames) == 0)) {
+
+          // Add a synchronization transaction.
+          getMantaInterface()->addTransaction("CameraPathAutomator-Sync",
+                                              Callback::create(this, 
&CameraPathAutomator::mantaSynchronize,
+                                                               
transaction_number ));
+
+          // Wait for the render thread.
+          synchronize_barrier.wait( 2 );
+        }
+
+        transaction_number++;
+
+        
/////////////////////////////////////////////////////////////////////////
+        // Wait for delta_time seconds.
+        while ((SCIRun::Time::currentSeconds()-start_time) < delta_time);
+      }
     }
-  }
 
-  int total_frames = getMantaInterface()->getCurrentFrame() - start_frame;
+    int total_frames = getMantaInterface()->getCurrentFrame() - start_frame;
   
-  std::cerr << "Path complete. " << total_frames
-            << " frames. Avg fps: " << 
(Real)total_frames/(SCIRun::Time::currentSeconds()-start_seconds) << 
std::endl;
+    std::cerr << "Path complete. "    << total_frames
+              << " frames. Avg fps: " << 
(Real)total_frames/(SCIRun::Time::currentSeconds()-start_seconds) << 
std::endl;
+
+
+  }
+
+  // Check to see if we should continue looping.
+  while (loop_behavior == PATH_LOOP);
+
+  // Check to see if we should exit the renderer.
+  if (loop_behavior == PATH_EXIT) {
+    Thread::exitAll( 0 );
+  }
 }
 
 
///////////////////////////////////////////////////////////////////////////////
@@ -325,6 +409,28 @@
   // Reset the current camera.
   getMantaInterface()->getCamera( channel )->reset( eye_, up_, lookat_ );
 }
+
+void CameraPathAutomator::mantaSynchronize( int issue_transaction ) {
+
+  // Wait for either the renderer thread or the camera path thread.
+  synchronize_barrier.wait( 2 );
+
+  Real current_sync_seconds = SCIRun::Time::currentSeconds();
+  int  current_sync_frame   = getMantaInterface()->getCurrentFrame();
+
+  Real elapse_seconds = current_sync_seconds - last_sync_seconds;
+  int  elapse_frame   = current_sync_frame   - last_sync_frame;
+
+  last_sync_seconds = current_sync_seconds;
+  last_sync_frame   = current_sync_frame;
+
+  // Output performance since last sync.
+  std::cout << current_sync_frame << " "
+            << issue_transaction << " "
+            << elapse_frame << " "
+            << elapse_seconds << " "
+            << ((Real)elapse_frame/elapse_seconds) << std::endl;
+};
 
 
///////////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////////

Modified: branches/itanium2/UserInterface/CameraPathAutomator.h
==============================================================================
--- branches/itanium2/UserInterface/CameraPathAutomator.h       (original)
+++ branches/itanium2/UserInterface/CameraPathAutomator.h       Wed Oct  5 
16:13:09 2005
@@ -34,6 +34,8 @@
 #include <MantaTypes.h>
 #include <Core/Geometry/PointVector.h>
 
+#include <SCIRun/Core/Thread/Barrier.h>
+
 #include <string>
 #include <vector>
 
@@ -41,15 +43,19 @@
 
   using std::string;
   using std::vector;
+  using SCIRun::Barrier;
   
   class CameraPathAutomator : public AutomatorUI {
   private:
+
+    
///////////////////////////////////////////////////////////////////////////
     // Control points.
     Point  *eye;
     Point  *lookat;
     Vector *up;
     int total_points;
 
+    
///////////////////////////////////////////////////////////////////////////
     // Parameter t interval between control points.
     Real delta_t;
 
@@ -58,6 +64,22 @@
     
     // Channel to apply camera changes to.
     int channel;
+
+    
///////////////////////////////////////////////////////////////////////////
+    // Synchronization barrier.
+    Barrier synchronize_barrier;
+
+    int  last_sync_frame;
+    Real last_sync_seconds;
+
+    // Number of frames between synchronization points.
+    int sync_frames;
+
+    
///////////////////////////////////////////////////////////////////////////
+    // Behavior
+    enum { PATH_STOP, PATH_EXIT, PATH_LOOP };
+    int loop_behavior;
+    int interval_start, interval_last;
     
   public:
     CameraPathAutomator( RTRTInterface *manta_interface_, int channel_, int 
warmup_, const string &file_name, 
@@ -77,6 +99,9 @@
     // This method is called by the manta rendering thread to update the 
camera.
     void mantaSetCamera( const Point eye_, const Point lookat_, const Vector 
up_ );
 
+    // This method is called by the manta rendering thread to synchronize.
+    void mantaSynchronize( int issue_transaction );
+
     // This may be called to write the camera path to a specified file in 
the correct format.
     void write_path( const string &file_name );
     
@@ -89,6 +114,12 @@
     inline Real get_delta_time()                   { return delta_time; };
     inline void set_delta_time( Real delta_time_ ) { delta_time = 
delta_time_; };
 
+    inline int  get_sync_frames()                   { return sync_frames; };
+    inline void set_sync_frames( int sync_frames_ ) { sync_frames = 
sync_frames_; };
+
+    inline void set_loop_behavior( int behavior_ )  { loop_behavior = 
behavior_; };
+
+    inline void set_interval( int start, int last ) { interval_start = 
start; interval_last = last; };
   };
 };
 

Modified: branches/itanium2/fox/dm_demo.cc
==============================================================================
--- branches/itanium2/fox/dm_demo.cc    (original)
+++ branches/itanium2/fox/dm_demo.cc    Wed Oct  5 16:13:09 2005
@@ -265,7 +265,10 @@
                // Create a default scene.
                manta_interface->setScene( createDefaultScene() );
        }
-       
+
+  // Add a camera bookmark for the default camera.
+  manta_window.addCameraBookmark( "Default", default_camera );
+  
        // Check to see if a bookmark file was specified.
        if (bookmark_file_name.size() > 0) {
 
@@ -293,13 +296,6 @@
                }
        }
        
-       else {
-
-    std::cout << "Camera: " << default_camera << std::endl;
-    
-               // Add a camera bookmark for the default camera.
-               manta_window.addCameraBookmark( "Default", default_camera );
-       }
   
        // Create the camera using the first camera bookmark.
        Camera *camera = manta_interface->createCamera( 
manta_window.getCameraBookmark( 0 ) );




  • [MANTA] r595 - in branches/itanium2: Engine/Display Model/Cameras UserInterface fox, abe, 10/05/2005

Archive powered by MHonArc 2.6.16.

Top of page