Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1316 - in trunk: Core/Util Interface Model/Groups Model/Readers/glm StandAlone UserInterface scenes


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1316 - in trunk: Core/Util Interface Model/Groups Model/Readers/glm StandAlone UserInterface scenes
  • Date: Fri, 23 Mar 2007 12:25:14 -0700 (MST)

Author: bigler
Date: Fri Mar 23 12:24:52 2007
New Revision: 1316

Modified:
   trunk/Core/Util/Args.cc
   trunk/Core/Util/Args.h
   trunk/Interface/RenderParameters.h
   trunk/Model/Groups/DynBVH.cc
   trunk/Model/Readers/glm/glm.cc
   trunk/StandAlone/manta.cc
   trunk/UserInterface/XWindowUI.cc
   trunk/UserInterface/XWindowUI.h
   trunk/scenes/objviewer.cc
Log:

Core/Util/Args.cc
Core/Util/Args.h

  Added getColorArg.

Interface/RenderParameters.h

  Added changeMaxDepth, setMaxDepth, and setImportanceCutoff
  functions.

Model/Groups/DynBVH.cc

  Print out some useful time information.

Model/Readers/glm/glm.cc

  Changed the default value for refraction from 0 to 1.  This seems to
  be more in line with the spec.

StandAlone/manta.cc

  Added bgcolor and maxdepth arguments.

UserInterface/XWindowUI.cc

  Alphabetized keyboard bindings.

  Added interface for changing the maximum ray depth.
  
UserInterface/XWindowUI.h

  Added change_maxDepth function.

scenes/objviewer.cc

  Set the default maxDepth to 5, to help threads from going to la la
  land.

  Use dielectric if Tr is not 1 (the new default) instead of 0.  Some
  maya materials are dumping out Tr = 1 to show that it isn't used.


Modified: trunk/Core/Util/Args.cc
==============================================================================
--- trunk/Core/Util/Args.cc     (original)
+++ trunk/Core/Util/Args.cc     Fri Mar 23 12:24:52 2007
@@ -2,6 +2,7 @@
 #include <Core/Util/Args.h>
 #include <Core/Exceptions/IllegalValue.h>
 #include <Core/Geometry/Vector.h>
+#include <Core/Color/ColorDB.h>
 
 using namespace std;
 using SCIRun::IllegalValue;
@@ -126,6 +127,36 @@
       return false;
     }
     v = Vector(x,y,z);
+    return true;
+  }
+
+  bool getColorArg(int& i, const vector<string>& args, Color& color)
+  {
+    string name;
+    if (!getStringArg(i, args, name)) {
+      return false;
+    }
+    if (name == "RGB8" || name == "RGBfloat") {
+      ColorComponent r, g, b;
+      if (!getArg<ColorComponent>(i, args, r)) {
+        return false;
+      }
+      if (!getArg<ColorComponent>(i, args, g)) {
+        i--;
+        return false;
+      }
+      if (!getArg<ColorComponent>(i, args, b)) {
+        i-=2;
+        return false;
+      }
+      color = Color(RGBColor(r,g,b));
+      if (name == "RGB8") {
+        color *= (ColorComponent)1/255;
+      }
+    } else {
+      // Now try and look up the name
+      color = ColorDB::getNamedColor(name);
+    }
     return true;
   }
 

Modified: trunk/Core/Util/Args.h
==============================================================================
--- trunk/Core/Util/Args.h      (original)
+++ trunk/Core/Util/Args.h      Fri Mar 23 12:24:52 2007
@@ -21,6 +21,14 @@
   bool getVectorArg(int& i, const vector<string>&, Vector& p);
   void parseSpec(const string& spec, string& name, vector<string>& args);
 
+  // This parsers out a color argument from the commandline.
+  // The format can be one of three things:
+  //
+  // 1. colorName      - the color is looked up in the ColorDB.
+  // 2. RGB8 r g b     - RGB components in [0,255]
+  // 3. RGBfloat r g b - RGB components in [0,1]
+  bool getColorArg(int& i, const vector<string>&, Color& color);
+  
   // Parse a resolution value from a string.
   bool getResolutionArg(const string& arg, int& xres, int& yres);
   

Modified: trunk/Interface/RenderParameters.h
==============================================================================
--- trunk/Interface/RenderParameters.h  (original)
+++ trunk/Interface/RenderParameters.h  Fri Mar 23 12:24:52 2007
@@ -14,6 +14,20 @@
     }
     int maxDepth;
     Manta::Real importanceCutoff;
+
+    // Helper functions for GUIs
+    void changeMaxDepth(int change) {
+      setMaxDepth(maxDepth + change);
+    }
+    void setMaxDepth(int new_maxDepth) {
+      if (new_maxDepth >= 0)
+        maxDepth = new_maxDepth;
+    }
+
+    void setImportanceCutoff(Manta::Real new_importanceCutoff) {
+      if (new_importanceCutoff >= 0)
+        importanceCutoff = new_importanceCutoff;
+    }
   private:
   };
 }

Modified: trunk/Model/Groups/DynBVH.cc
==============================================================================
--- trunk/Model/Groups/DynBVH.cc        (original)
+++ trunk/Model/Groups/DynBVH.cc        Fri Mar 23 12:24:52 2007
@@ -4,6 +4,8 @@
 #include <float.h>
 #include <limits>
 
+#include <SCIRun/Core/Thread/Time.h>
+
 using namespace Manta;
 
 // these constants control the SAH cost model
@@ -421,7 +423,10 @@
 
 void DynBVH::preprocess(const PreprocessContext& context)
 {
+  cerr << "\nDynBVH::preprocess START\n";
+  double start = SCIRun::Time::currentSeconds();
     Group::preprocess(context);
+    double group_preprocess_end = SCIRun::Time::currentSeconds();
 
     nodes = new BVHNode[2*this->getSize()];
     object_ids = new int[this->getSize()];
@@ -430,8 +435,16 @@
 
     num_nodes = 1; // root node
     int nextFree = 1;
+    double build_start = SCIRun::Time::currentSeconds();
     build(context, 0, 0, this->getSize(), nextFree);
+    double updateBound_start = SCIRun::Time::currentSeconds();
     updateBounds(context, 0);
+    double end = SCIRun::Time::currentSeconds();
+    cerr << "\nDynBVH Preprocess time: Total ("<<end-start<<")\n"
+         << "Group::preprocess ("<<group_preprocess_end-start<<")\n"
+         << "object_ids initialization 
("<<build_start-group_preprocess_end<<")\n"
+         << "build ("<<updateBound_start-build_start<<")\n"
+         << "updateBounds ("<<end-updateBound_start<<")\n\n";
 }
 
 void DynBVH::build(const PreprocessContext& context,

Modified: trunk/Model/Readers/glm/glm.cc
==============================================================================
--- trunk/Model/Readers/glm/glm.cc      (original)
+++ trunk/Model/Readers/glm/glm.cc      Fri Mar 23 12:24:52 2007
@@ -327,7 +327,7 @@
     for (i = 0; i < nummaterials; i++) {
       model->materials[i].name = NULL;
       model->materials[i].shininess = 0;
-      model->materials[i].refraction = 0;
+      model->materials[i].refraction = 1;
       model->materials[i].alpha      = 1;
       model->materials[i].shader     = GLM_FLAT_SHADE;
     

Modified: trunk/StandAlone/manta.cc
==============================================================================
--- trunk/StandAlone/manta.cc   (original)
+++ trunk/StandAlone/manta.cc   Fri Mar 23 12:24:52 2007
@@ -43,6 +43,7 @@
 #include <Core/Exceptions/InternalError.h>
 #include <Core/Exceptions/IllegalArgument.h>
 #include <Core/Exceptions/UnknownComponent.h>
+#include <Core/Exceptions/UnknownColor.h>
 #include <Core/Thread/Time.h>
 #include <Core/Util/About.h>
 #include <Engine/PixelSamplers/TimeViewSampler.h>
@@ -137,7 +138,11 @@
   printList(cerr, rtrt->listRenderers(), 2);
   cerr << " -scene S        - Render Scene S\n";
   cerr << " -t, --timeview[=\"args\"] - Display a scaled view of the time it 
took to render some pixels.\n";
-  
+  cerr << " --bgcolor [option] - Change the color the background.  Options 
are:\n"
+       << "           o [colorName]      (such as black or white)\n"
+       << "           o [RGB8     r g b] (where components range [0,255])\n"
+       << "           o [RGBfloat r g b] (where components range [0,1])\n";
+  cerr << " --maxdepth [val] - The maximum ray depth\n";
   Thread::exitAll(1);
 }
 
@@ -232,6 +237,9 @@
     bool compute_bb_camera = false;
     bool timeView = false;
     vector<string> timeViewArgs;
+    Color bgcolor;
+    bool override_scene_bgcolor = false;
+    int maxDepth = -1;          // -1 is invalid and represent unset state.
     
 
     // Parse command line args.
@@ -376,6 +384,24 @@
             parseArgs(argString, timeViewArgs);
           }
         }
+        else if (arg == "--bgcolor" || arg == "-bgcolor" || arg == "-bgc" ) {
+          try {
+            if (!getColorArg(i, args, bgcolor)) {
+              cerr << "Error parsing bgcolor: " << args[i+1] << '\n';
+              usage(factory);
+            } else {
+              override_scene_bgcolor = true;
+            }
+          } catch (UnknownColor& e) {
+            cerr << "Error parsing bgcolor: "<<e.message()<<"\n";
+          }
+        }
+        else if (arg == "--maxdepth" || arg == "-maxdepth" ) {
+          if (!getArg<int>(i, args, maxDepth)) {
+            cerr << "Error reading max depth\n";
+            usage(factory);
+          }
+        }
       }
     }
     catch (SCIRun::Exception& e) {
@@ -438,6 +464,16 @@
       tvs->setPixelSampler(currentPixelSampler);
       rtrt->setPixelSampler(tvs);
     }
+
+    if (override_scene_bgcolor) {
+      Scene* scene = rtrt->getScene();
+      Background* bg = scene->getBackground();
+      if (bg) delete bg;
+      scene->setBackground(new ConstantBackground(bgcolor));
+    }
+
+    // If maxDepth is < 0, this function has no effect.
+    rtrt->getScene()->getRenderParameters().setMaxDepth(maxDepth);
 
     rtrt->beginRendering(true);
     delete rtrt;

Modified: trunk/UserInterface/XWindowUI.cc
==============================================================================
--- trunk/UserInterface/XWindowUI.cc    (original)
+++ trunk/UserInterface/XWindowUI.cc    Fri Mar 23 12:24:52 2007
@@ -315,7 +315,7 @@
     throw ErrnoException("XWindowUI write 3", errno, __FILE__, __LINE__ );
   }
   xlock.lock();
-}  
+}
 
 void XWindowUI::unlock_x()
 {
@@ -327,7 +327,7 @@
 {
   XHelper::Xlock.lock();
   int screen=DefaultScreen(dpy);
-    
+
   XSetWindowAttributes atts;
   int flags=CWEventMask;
   
atts.event_mask=StructureNotifyMask|ExposureMask|ButtonPressMask|ButtonReleaseMask|ButtonMotionMask|KeyPressMask|KeyReleaseMask;
@@ -345,15 +345,15 @@
   char* name = strdup(title.str().c_str());
   XStringListToTextProperty(&name, 1, &tp);
   free(name);
-  
+
   XSizeHints sh;
   sh.flags = USPosition|USSize;
-  
+
   XSetWMProperties(dpy, window->window, &tp, &tp, 0, 0, &sh, 0, 0);
   // The last arg is the number of atom &deleteWindow points to.
   XSetWMProtocols(dpy, window->window, &deleteWindow, 1);
   XMapWindow(dpy, window->window);
-  
+
   XHelper::Xlock.unlock();
 
   // Wait for the window to appear before proceeding
@@ -464,45 +464,42 @@
 
 void XWindowUI::register_default_keys()
 {
-  register_key(0, XStringToKeysym("h"),
-               "print help message to stderr",
-               Callback::create(this, &XWindowUI::helpkey));
-  register_key(0, XStringToKeysym("q"),
-               "quit after this frame, press again to immediately quit",
-               Callback::create(this, &XWindowUI::quitkey));
-  register_key(0, XStringToKeysym("question"),
-               "print help message to stderr",
-               Callback::create(this, &XWindowUI::helpkey));
-  register_key(0, XStringToKeysym("p"),
-               "increase/decrease number of processors",
-               Callback::create(this, &XWindowUI::prockey));
-  register_key(0, XStringToKeysym("P"),
-               "increase/decrease number of processors",
-               Callback::create(this, &XWindowUI::prockey));
-  register_key(0, XStringToKeysym("v"),
-               "autoview",
-               Callback::create(this, &XWindowUI::autoview));
   register_key(0, XStringToKeysym("b"),
                "next bookmark",
                Callback::create(this, &XWindowUI::next_bookmark));
   register_key(0, XStringToKeysym("B"),
                "add bookmark",
                Callback::create(this, &XWindowUI::add_bookmark));
+  register_key(0, XStringToKeysym("c"),
+               "output camera",
+               Callback::create(this, &XWindowUI::output_camera));
+  register_key(0, XStringToKeysym("d"),
+               "increase maxDepth by one",
+               Callback::create(this, &XWindowUI::change_maxDepth));
+  register_key(0, XStringToKeysym("D"),
+               "decrease maxDepth by one",
+               Callback::create(this, &XWindowUI::change_maxDepth));
+  register_key(0, XStringToKeysym("h"),
+               "print help message to stderr",
+               Callback::create(this, &XWindowUI::helpkey));
   register_key(0, XStringToKeysym("k"),
                "add knot",
                Callback::create(this, &XWindowUI::add_knot));
   register_key(0, XStringToKeysym("K"),
                "write knots",
                Callback::create(this, &XWindowUI::write_knots));
-  register_key(0, XK_space,
-               "animate path",
-               Callback::create(this, &XWindowUI::animate_path));
+  register_key(0, XStringToKeysym("p"),
+               "increase/decrease number of processors",
+               Callback::create(this, &XWindowUI::prockey));
+  register_key(0, XStringToKeysym("P"),
+               "increase/decrease number of processors",
+               Callback::create(this, &XWindowUI::prockey));
+  register_key(0, XStringToKeysym("q"),
+               "quit after this frame, press again to immediately quit",
+               Callback::create(this, &XWindowUI::quitkey));
   register_key(0, XStringToKeysym("r"),
                "reset path",
                Callback::create(this, &XWindowUI::reset_path));
-  register_key(0, XStringToKeysym("c"),
-               "output camera",
-               Callback::create(this, &XWindowUI::output_camera));           
                                   
   register_key(0, XStringToKeysym("t"),
                "time profile display",
                Callback::create(this, &XWindowUI::timeView_keyboard));
@@ -512,9 +509,18 @@
   register_key(ControlMask, XStringToKeysym("T"),
                "time profile scale decrease",
                Callback::create(this, &XWindowUI::timeView_keyboard));
+  register_key(0, XStringToKeysym("v"),
+               "autoview",
+               Callback::create(this, &XWindowUI::autoview));
+  register_key(0, XK_space,
+               "animate path",
+               Callback::create(this, &XWindowUI::animate_path));
   register_key(0, XStringToKeysym("Escape"),
                "quit after this frame, press again to immediately quit",
                Callback::create(this, &XWindowUI::quitkey));
+  register_key(0, XStringToKeysym("question"),
+               "print help message to stderr",
+               Callback::create(this, &XWindowUI::helpkey));
 }
 
 void XWindowUI::register_default_mouse()
@@ -673,7 +679,7 @@
     ColorComponent factor = static_cast<ColorComponent>(1.1);
     if(key == XStringToKeysym("T"))
       factor = 1/factor;
-    rtrt_interface->addTransaction("TimeView scale up",
+    rtrt_interface->addTransaction("TimeView scale change",
                                    Callback::create(timeView,
                                                     
&TimeViewSampler::changeScale,
                                                     factor));
@@ -957,7 +963,7 @@
     // This will make sure that the mouse functions are only sensitive
     // to when the Shift, Control, or Mod1Mask is set.  Similar to the
     // KeyPress event.
-    
+
     //cerr << "e.xbutton.state = "<<e.xbutton.state<<" Mod1Mask = 
"<<Mod1Mask;
     e.xbutton.state &= ShiftMask|ControlMask|Mod1Mask;
     //cerr << " e.xbutton.state = "<<e.xbutton.state<<"\n";
@@ -972,7 +978,7 @@
       }
     }
     if(!ias.current_mouse_handler){
-      cerr << "Warning, didn't find mouse handler for button " 
+      cerr << "Warning, didn't find mouse handler for button "
            << ias.current_button << ", state=" << e.xbutton.state << '\n';
     }
     break;
@@ -984,7 +990,7 @@
       ias.current_button = 0;
       ias.current_mouse_handler = 0;
     } else {
-      //cerr << "Dropped button relase event for button " << 
e.xbutton.button 
+      //cerr << "Dropped button relase event for button " << e.xbutton.button
       //<< ", probably because multiple mouse buttons pressed\n";
     }
     break;
@@ -1051,3 +1057,24 @@
       break;
     }
 }
+
+static void change_maxDepth_callback(Scene* scene,
+                                     int change)
+{
+  scene->getRenderParameters().changeMaxDepth(change);
+  cerr << "New ray maxDepth = "<<scene->getRenderParameters().maxDepth<<"\n";
+}
+
+void XWindowUI::change_maxDepth(unsigned int /*state*/,
+                                unsigned long key,
+                                int /*chanel*/)
+{
+  int change = 1;
+  if (key == XStringToKeysym("D"))
+    change = -1;
+  rtrt_interface->addTransaction("maxDepth change",
+                                 Callback::create(&change_maxDepth_callback,
+                                                  rtrt_interface->getScene(),
+                                                  change));
+}
+

Modified: trunk/UserInterface/XWindowUI.h
==============================================================================
--- trunk/UserInterface/XWindowUI.h     (original)
+++ trunk/UserInterface/XWindowUI.h     Fri Mar 23 12:24:52 2007
@@ -96,6 +96,8 @@
 
     void animation_callback(int, int, bool&);
 
+    void change_maxDepth(unsigned int, unsigned long, int);
+
     // Utility functions
     Vector projectToSphere(Real x, Real y, Real radius) const;
 

Modified: trunk/scenes/objviewer.cc
==============================================================================
--- trunk/scenes/objviewer.cc   (original)
+++ trunk/scenes/objviewer.cc   Fri Mar 23 12:24:52 2007
@@ -260,6 +260,8 @@
     // Background.
     scene->setBackground( new ConstantBackground( Color(RGB(0.8, 0.8, 0.8)) 
) );
 
+    scene->getRenderParameters().setMaxDepth(5);
+
     return scene;
 }
 
@@ -373,7 +375,7 @@
 
         
//////////////////////////////////////////////////////////////////////
         // Check for a dielectric.
-        if (Tr != 0) {
+        if (Tr != 1) {
 
             std::cerr << "Material " << index << " dielectric" << std::endl;
 




  • [MANTA] r1316 - in trunk: Core/Util Interface Model/Groups Model/Readers/glm StandAlone UserInterface scenes, bigler, 03/23/2007

Archive powered by MHonArc 2.6.16.

Top of page