Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r432 - in branches/itanium2: Core/Color Image Interface Model/Cameras Model/Groups Model/Materials Model/MiscObjects Readers UserInterface fox


Chronological Thread 
  • From: abe@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r432 - in branches/itanium2: Core/Color Image Interface Model/Cameras Model/Groups Model/Materials Model/MiscObjects Readers UserInterface fox
  • Date: Fri, 15 Jul 2005 01:28:22 -0600 (MDT)

Author: abe
Date: Fri Jul 15 01:28:12 2005
New Revision: 432

Modified:
   branches/itanium2/Core/Color/ColorDB.cc
   branches/itanium2/Core/Color/ColorDB.h
   branches/itanium2/Image/SimpleImage.h
   branches/itanium2/Interface/Camera.h
   branches/itanium2/Model/Cameras/PinholeCamera.cc
   branches/itanium2/Model/Cameras/PinholeCamera.h
   branches/itanium2/Model/Groups/RealisticBvh.cc
   branches/itanium2/Model/Groups/RealisticBvh.h
   branches/itanium2/Model/Materials/Phong.cc
   branches/itanium2/Model/MiscObjects/CuttingPlane.cc
   branches/itanium2/Model/MiscObjects/CuttingPlane.h
   branches/itanium2/Readers/CMakeLists.txt
   branches/itanium2/UserInterface/XWindowUI.cc
   branches/itanium2/fox/CMakeLists.txt
   branches/itanium2/fox/FMantaQuakeNav.h
   branches/itanium2/fox/FMantaTrackballNav.cc
   branches/itanium2/fox/FMantaWindow.cc
   branches/itanium2/fox/FMantaWindow.h
   branches/itanium2/fox/fox_manta.cc
Log:

Hopefully the last big commit before the Newport News demo.

M    Image/SimpleImage.h
M    Readers/CMakeLists.txt
Added a utility for converting files from the Double Eagle dataset format to 
.v3c1. Maybe this belongs somewhere else.

M    Core/Color/ColorDB.cc
M    Core/Color/ColorDB.h
"green" was out of order.

M    fox/FMantaTrackballNav.cc
M    fox/FMantaWindow.cc
M    fox/FMantaWindow.h
M    fox/FMantaQuakeNav.h
M    fox/fox_manta.cc
M    fox/CMakeLists.txt
Changed the name of bin/fox_manta to bin/dm_demo. (Digital Mockup)
Moved camera bookmarks to a text file-- specify using -bookmarks <file name>
Use tab to switch between navigators, the three navigators are "Video Game", 
"Fly", and "Trackball"

M    Model/Groups/RealisticBvh.cc
M    Model/Groups/RealisticBvh.h
3.05x speedup since first checkin (don't remember if that was the previous 
checkin)

M    Model/Materials/Phong.cc
M    Model/MiscObjects/CuttingPlane.cc
M    Model/MiscObjects/CuttingPlane.h
Fixed vanishing cutting plane bug.

M    UserInterface/XWindowUI.cc
M    Model/Cameras/PinholeCamera.cc
M    Model/Cameras/PinholeCamera.h
M    Interface/Camera.h
Changed Camera::output() so it takes a ostream to output to (used for camera 
bookmarks)

Modified: branches/itanium2/Core/Color/ColorDB.cc
==============================================================================
--- branches/itanium2/Core/Color/ColorDB.cc     (original)
+++ branches/itanium2/Core/Color/ColorDB.cc     Fri Jul 15 01:28:12 2005
@@ -480,8 +480,8 @@
   {"gray97", 247, 247, 247},
   {"gray98", 250, 250, 250},
   {"gray99", 252, 252, 252},
-  {"green yellow", 173, 255, 47},
   {"green", 0, 255, 0},
+       {"green yellow", 173, 255, 47},
   {"green1", 0, 255, 0},
   {"green2", 0, 238, 0},
   {"green3", 0, 205, 0},
@@ -780,4 +780,29 @@
   float scale = 1.f/255.f;
   RGBData& nc = namedColors[l];
   return Color(RGBColor(nc.r*scale, nc.g*scale, nc.b*scale));
+}
+
+bool ColorDB::getNamedColor( unsigned char result[3], const std::string 
&name ) {
+
+       int l = 0;
+  int h = sizeof(namedColors)/sizeof(RGBData)-1;
+  
+       while(h > l+1){
+    int m = (h+l)/2;
+    if(name < namedColors[m].name)
+      h = m;
+    else
+      l = m;
+  }
+       
+  if(name != namedColors[l].name)
+    return false;
+       
+  RGBData& nc = namedColors[l];
+       
+       result[0] = nc.r;
+       result[1] = nc.g;
+       result[2] = nc.b;
+               
+  return true;
 }

Modified: branches/itanium2/Core/Color/ColorDB.h
==============================================================================
--- branches/itanium2/Core/Color/ColorDB.h      (original)
+++ branches/itanium2/Core/Color/ColorDB.h      Fri Jul 15 01:28:12 2005
@@ -11,6 +11,7 @@
   class ColorDB {
   public:
     static Color getNamedColor(const std::string& name);
+               static bool  getNamedColor(unsigned char result[3], const 
std::string &name);
   private:
     // Prevent instantiation
     ColorDB(const ColorDB&);

Modified: branches/itanium2/Image/SimpleImage.h
==============================================================================
--- branches/itanium2/Image/SimpleImage.h       (original)
+++ branches/itanium2/Image/SimpleImage.h       Fri Jul 15 01:28:12 2005
@@ -24,7 +24,7 @@
     static Image* create(const std::vector<std::string>& args, bool stereo,
                         int xres, int yres);
 
-    const Pixel* getRaw(int which_eye) const;
+    Pixel* getRaw(int which_eye) const;
   private:
     SimpleImage(const Image&);
     SimpleImage& operator=(const SimpleImage&);
@@ -119,7 +119,7 @@
   }
 
   template<class Pixel>
-  const Pixel* SimpleImage<Pixel>::getRaw(int which_eye) const
+       Pixel* SimpleImage<Pixel>::getRaw(int which_eye) const
   {
     return eyeStart[which_eye][0];
   }

Modified: branches/itanium2/Interface/Camera.h
==============================================================================
--- branches/itanium2/Interface/Camera.h        (original)
+++ branches/itanium2/Interface/Camera.h        Fri Jul 15 01:28:12 2005
@@ -3,6 +3,7 @@
 #define Manta_Interface_Camera_h
 
 #include <MantaTypes.h>
+#include <ostream>
 
 namespace Manta {
   class RayPacket;
@@ -34,7 +35,7 @@
     };
     virtual void transform(AffineTransform t, TransformCenter) = 0;
     virtual void autoview(double fov) = 0;
-               virtual void output() { /* Default does nothing. */ }; // 
Output a text description of the camera's state.
+               virtual void output( std::ostream &os ) { /* Default does 
nothing. */ }; // Output a text description of the camera's state.
   private:
     Camera(const Camera&);
     Camera& operator=(const Camera&);

Modified: branches/itanium2/Model/Cameras/PinholeCamera.cc
==============================================================================
--- branches/itanium2/Model/Cameras/PinholeCamera.cc    (original)
+++ branches/itanium2/Model/Cameras/PinholeCamera.cc    Fri Jul 15 01:28:12 
2005
@@ -56,9 +56,9 @@
 {
 }
 
-void PinholeCamera::output() {
+void PinholeCamera::output( std::ostream &os ) {
 
-       std::cout << "pinhole( -eye " << eye 
+       os << "pinhole( -eye " << eye 
                  << " -lookat " << lookat 
                                                << " -up " << up 
                                                << " -fov " << hfov << " )" 

Modified: branches/itanium2/Model/Cameras/PinholeCamera.h
==============================================================================
--- branches/itanium2/Model/Cameras/PinholeCamera.h     (original)
+++ branches/itanium2/Model/Cameras/PinholeCamera.h     Fri Jul 15 01:28:12 
2005
@@ -26,7 +26,7 @@
     virtual void dolly(double);
     virtual void transform(AffineTransform t, TransformCenter);
     virtual void autoview(double fov);
-               virtual void output();
+               virtual void output( std::ostream &os );
          virtual Point project(const Point &point);  // project a 3D point 
to the camera image plane
     static Camera* create(const vector<string>& args);
                

Modified: branches/itanium2/Model/Groups/RealisticBvh.cc
==============================================================================
--- branches/itanium2/Model/Groups/RealisticBvh.cc      (original)
+++ branches/itanium2/Model/Groups/RealisticBvh.cc      Fri Jul 15 01:28:12 
2005
@@ -67,15 +67,15 @@
                array[i]->computeBounds( context, new_node->bounds );
        }
        
-       // new_node->bounds.extendByPoint( 
new_node->bounds[0]+(Vector(new_node->bounds[0])*0.1) );
-       // new_node->bounds.extendByPoint( 
new_node->bounds[1]+(Vector(new_node->bounds[1])*0.1) );
-       
        // Find a pivot point.
        Point pivot((Vector(new_node->bounds[0]) + 
Vector(new_node->bounds[1])) * 0.5);
        
        // Split along the axis.
        int mid_point = qsplit( array, size, pivot[axis], axis );
        
+       // save the split axis.
+       new_node->split_axis = axis;
+       
        // Create new left and right children.
        new_node->child[0] = build_branch( array, mid_point, (axis+1)%3 );
        new_node->child[1] = build_branch( array+mid_point, size-mid_point, 
(axis+1)%3 );
@@ -100,6 +100,9 @@
        // Split along the axis.
        int mid_point = qsplit( array, size, pivot[0], 0 );
        
+       // Save the split axis.
+       split_axis = 0;
+       
        // Create new left and right children.
        child[0] = build_branch( array, mid_point, 1 );
        child[1] = build_branch( array+mid_point, size-mid_point, 1 );
@@ -131,13 +134,16 @@
                // Check to see if the ray hits this node's bounding box.
                Real min_t, max_t;
                bbox_intersect[i] = Intersection::intersectAaBox( bounds, 
min_t, max_t, e.ray, 
-                                                                             
                                                                              
                                                      e.signMask, 
e.inverseDirection );
+                                                                             
                                                                              
                                                      e.signMask, 
e.inverseDirection,
+                                                                             
                                                                              
                                                            0.0,
+                                                                             
                                                                              
                                                            e.hitInfo.minT() 
);
        }
        
        // Find runs of rays which intersect this bounding box and intersect 
those 
        // with the children.
        int begin = 0;
        int end   = 0;
+       int first_child;
 
        while (begin < rays.getSize()) {
        
@@ -145,18 +151,22 @@
                while ((begin < rays.getSize()) && (!bbox_intersect[begin]))
                        ++begin;
        
+               // Determine the first child for the first ray in the packet.
+               first_child = rays.get( begin ).signMask[ split_axis ];
+       
                // Find the end of this run.
                end = begin;
-               while ((end < rays.getSize()) && (bbox_intersect[end]))
+               while ((end < rays.getSize()) && (bbox_intersect[end]) && 
+                      (rays.get( begin ).signMask[ split_axis ] == 
first_child))
                        ++end;
 
                if ((end > begin) && (begin < rays.getSize())) {
                        // Create a sub packet.
                        RayPacket sub_packet( rays, begin, end );
-                               
+                       
                        // Intersect with both children.
-                       child[0]->intersect( context, sub_packet );
-                       child[1]->intersect( context, sub_packet );
+                       child[ first_child]->intersect( context, sub_packet );
+                       child[!first_child]->intersect( context, sub_packet );
                        
                }
                

Modified: branches/itanium2/Model/Groups/RealisticBvh.h
==============================================================================
--- branches/itanium2/Model/Groups/RealisticBvh.h       (original)
+++ branches/itanium2/Model/Groups/RealisticBvh.h       Fri Jul 15 01:28:12 
2005
@@ -11,16 +11,21 @@
 
        // This class follows the implementation from
        // "Realistic Ray Tracing"
+       // This implemention relies on virtual method calls to determine
+       // internal nodes from leaf nodes, there is no explicit 
representation.
        
        // This bvh contains pointers to objects in it's leaves.
        class RealisticBvh : public Object {
        protected:
                BBox bounds;      // Bounds of this node.
                Object *child[2]; // Childern of this node.
+               int split_axis;   // Axis that this node's children were 
split on.
                
                // Protected constructors.
                RealisticBvh( Object *child0, Object *child1 );
                RealisticBvh() { child[0] = child[1] = 0; };
+               ~RealisticBvh() { if (child[0]) delete child[0];
+                                                                             
          if (child[1]) delete child[1]; };
 
                static int qsplit( Object **array, int size, Real pivot, int 
axis );
                static Object *build_branch( Object **array, int size, int 
axis );
@@ -33,6 +38,23 @@
     void preprocess   (const PreprocessContext& context);
     void computeBounds(const PreprocessContext& context, BBox& bbox) const;
     void intersect    (const RenderContext& context, RayPacket& rays) const; 
          
+       };
+       
+       // This class contains code to rebuild the bvh in parallel.
+       class RealisticBvhBuilder {
+       protected:
+               // Objects that compose the bvh.
+               Object **object_array;
+               int size;
+               
+               // Bvh to rebuild.
+               RealisticBvh *bvh;
+               
+       public:
+               RealtisticBvhBuilder( RealisticBvh *bvh_, Object 
**object_array_, int size_ );
+               
+               // This function should be called as a parallel animation 
callback to rebuild the bvh.
+               void parallel_rebuild_bvh( int proc, int num_procs );
        };
 };
 

Modified: branches/itanium2/Model/Materials/Phong.cc
==============================================================================
--- branches/itanium2/Model/Materials/Phong.cc  (original)
+++ branches/itanium2/Model/Materials/Phong.cc  Fri Jul 15 01:28:12 2005
@@ -50,22 +50,24 @@
   // Compute colors
   Color diffuse[RayPacket::MaxSize];
   diffusetex->mapValues(context, rays, diffuse);
+       
   Color specular[RayPacket::MaxSize];
   speculartex->mapValues(context, rays, specular);
-  double refl[RayPacket::MaxSize];
+  
+       double refl[RayPacket::MaxSize];
   refltex->mapValues(context, rays, refl);
 
   // Compute normals
   rays.computeNormals(context);
 
   // Compute ambient contributions for all rays
-  activeLights->getAmbientLight()->computeAmbient(context, rays);
+       
context.scene->getLights()->getAmbientLight()->computeAmbient(context, rays);
 
   RayPacketData data;
   int start = 0;
   do {
     RayPacket shadowRays(data, 0, rays.getDepth(), 0);
-    int end = context.shadowAlgorithm->computeShadows(context, activeLights,
+    int end = context.shadowAlgorithm->computeShadows(context, 
context.scene->getLights(),
                                                      rays, start, 
shadowRays);
     
     if(shadowRays.getFlags() & RayPacket::NormalizedDirections){

Modified: branches/itanium2/Model/MiscObjects/CuttingPlane.cc
==============================================================================
--- branches/itanium2/Model/MiscObjects/CuttingPlane.cc (original)
+++ branches/itanium2/Model/MiscObjects/CuttingPlane.cc Fri Jul 15 01:28:12 
2005
@@ -1,3 +1,4 @@
+
 #include <Model/MiscObjects/CuttingPlane.h>
 #include <Model/Intersections/AxisAlignedBox.h>
 #include <Model/Intersections/Plane.h>
@@ -8,9 +9,7 @@
 
 void CuttingPlane::movePlaneAlongNormal( Real distance ) { 
 
-       plane_point = initial_point + (plane_normal * distance * 
movement_scale); 
-       
-       std::cout << "MovePlaneAlongNormal: " << plane_point << std::endl;
+       plane_point = initial_point + (plane_normal * distance * 100.0);
 };
 
 // Preprocess the internal object and compute its bounds.

Modified: branches/itanium2/Model/MiscObjects/CuttingPlane.h
==============================================================================
--- branches/itanium2/Model/MiscObjects/CuttingPlane.h  (original)
+++ branches/itanium2/Model/MiscObjects/CuttingPlane.h  Fri Jul 15 01:28:12 
2005
@@ -26,7 +26,9 @@
                
        public:
     CuttingPlane( const Point &point_, const Vector &normal_, Object 
*internal_object_ ) :
-                       initial_point( point_ ), plane_point( point_ ), 
plane_normal( normal_ ), internal_object( internal_object_ ) {  }
+                       initial_point( point_ ), plane_point( point_ ), 
+                       plane_normal( normal_ ), internal_object( 
internal_object_ ),
+                       movement_scale( 1.0 ) {  }
                
                // Preprocess the internal object and compute its bounds.
     void preprocess( const PreprocessContext &context );

Modified: branches/itanium2/Readers/CMakeLists.txt
==============================================================================
--- branches/itanium2/Readers/CMakeLists.txt    (original)
+++ branches/itanium2/Readers/CMakeLists.txt    Fri Jul 15 01:28:12 2005
@@ -1,4 +1,16 @@
 
+SET (READERS_DOUBLE_EAGLE 0 CACHE BOOL "Include Double Eagle Tanker 
Conversion Program")
+IF (READERS_DOUBLE_EAGLE) 
+   ADD_EXECUTABLE(vn2v3c1 DoubleEagle/vn2v3c1.cc)
+   TARGET_LINK_LIBRARIES(vn2v3c1 SCIRun_Core Manta_Core)
+                                                                             
           
+ TARGET_LINK_LIBRARIES(vn2v3c1 ${CMAKE_THREAD_LIBS_INIT}                     
              
+                               ${OPENGL_LIBRARIES}                           
               
+                               ${X11_LIBRARIES}                              
               
+                               -lm)  
+ENDIF(READERS_DOUBLE_EAGLE)
+
+
 SET (READERS_SOURCES)
 SET (READERS_SOURCES ${READERS_SOURCES}
      BART/animation.c
@@ -11,3 +23,4 @@
 ADD_LIBRARY (Manta_Readers ${READERS_SOURCES})
 
 TARGET_LINK_LIBRARIES(Manta_Readers SCIRun_Core Manta_Model)
+

Modified: branches/itanium2/UserInterface/XWindowUI.cc
==============================================================================
--- branches/itanium2/UserInterface/XWindowUI.cc        (original)
+++ branches/itanium2/UserInterface/XWindowUI.cc        Fri Jul 15 01:28:12 
2005
@@ -462,7 +462,7 @@
 {
   Camera* camera = rtrt_interface->getCamera(channel);
   rtrt_interface->addTransaction("output camera",
-                                 Callback::create(camera, &Camera::output));
+                                 Callback::create<Camera,std::ostream 
&>(camera, &Camera::output, std::cout));
 }
 
 void XWindowUI::mouse_fov(unsigned int, unsigned int,

Modified: branches/itanium2/fox/CMakeLists.txt
==============================================================================
--- branches/itanium2/fox/CMakeLists.txt        (original)
+++ branches/itanium2/fox/CMakeLists.txt        Fri Jul 15 01:28:12 2005
@@ -15,7 +15,7 @@
     LINK_DIRECTORIES   (${HISTX_LIB} )     
   ENDIF(HISTX_PATH)
 
-  ADD_EXECUTABLE(fox_manta fox_manta.cc
+  ADD_EXECUTABLE(dm_demo fox_manta.cc
                            FMantaImageFrame.cc
                            FMantaImageFrame.h
                            FMantaWidgets.cc
@@ -31,7 +31,7 @@
                            FMantaTrackballNav.cc )
 
 
-  TARGET_LINK_LIBRARIES(fox_manta Manta_Engine 
+  TARGET_LINK_LIBRARIES(dm_demo Manta_Engine 
                                   Manta_UserInterface 
                                   Manta_Model 
                                   Manta_Image 
@@ -39,7 +39,7 @@
                                   Manta_Core 
                                   SCIRun_Core)
 
-  TARGET_LINK_LIBRARIES(fox_manta ${FOX_STATIC}
+  TARGET_LINK_LIBRARIES(dm_demo ${FOX_STATIC}
                                 ${CMAKE_THREAD_LIBS_INIT}
                                 ${OPENGL_LIBRARIES} 
                                 ${X11_LIBRARIES} 
@@ -47,7 +47,7 @@
                                 -lXcursor
                                 -lXrandr)
   IF(HISTX_PATH)
-    TARGET_LINK_LIBRARIES(fox_manta Manta_histx
+    TARGET_LINK_LIBRARIES(dm_demo Manta_histx
                                     ${HISTX_LINK} )
   ENDIF(HISTX_PATH)
 

Modified: branches/itanium2/fox/FMantaQuakeNav.h
==============================================================================
--- branches/itanium2/fox/FMantaQuakeNav.h      (original)
+++ branches/itanium2/fox/FMantaQuakeNav.h      Fri Jul 15 01:28:12 2005
@@ -21,7 +21,7 @@
        // This class is based on Kenny Hoff's glvu classes (khoff@sgi.com).
        class FMantaQuakeNav : public FMantaNavigator {
        private:
-               bool allowFly;
+               int allowFly;
                Real translateStepSize;
                Real rotateStepSize;
                
@@ -57,7 +57,7 @@
                
        public:
                // Constructor with default options.
-               FMantaQuakeNav() : allowFly( true ),
+               FMantaQuakeNav() : allowFly( false ),
                                   translateStepSize( 0.2 ),
                                                                              
           rotateStepSize   ( 0.5 ),
                                                                              
           posX( 0 ),
@@ -72,6 +72,23 @@
                                                                              
              key_map[1] = 's';
                                                                              
                          key_map[2] = 'a';
                                                                              
                          key_map[3] = 'd'; };
+                                                                             
                          
+               FMantaQuakeNav( bool allowFly_ ) : allowFly( allowFly_ ),
+                       translateStepSize( 0.2 ),
+                       rotateStepSize   ( 0.5 ),
+                       posX( 0 ),
+                       posY( 0 ),
+                       viewDirAngle( 0.0 ),
+                       viewElevAngle( 0.0 ),
+                       height( 0 ),
+                       left_mouse_down( false ),
+                       right_mouse_down( false )
+               {  
+                               key_map[0] = 'w';
+                               key_map[1] = 's';
+                               key_map[2] = 'a';
+                               key_map[3] = 'd'; };
+                                                                             
                                          
                // Constructor 
                FMantaQuakeNav( bool allowFly_, Real translateStepSize_, Real 
rotateStepSize_, 
                                Real posX_, Real posY_, Real viewDirAngle_, 
Real viewElevAngle_,
@@ -98,6 +115,8 @@
                // Accessors.
                void setKeyMap( int map, char k ) { key_map[map] = k; };
                char getKeyMap( int map )         { return key_map[map]; };
+               
+               int &getAllowFly() { return allowFly; }
                
                // Fox interaction via keyboard and mouse.
                long onKeyPress   ( FXObject *sender, FXSelector sel, void 
*data );

Modified: branches/itanium2/fox/FMantaTrackballNav.cc
==============================================================================
--- branches/itanium2/fox/FMantaTrackballNav.cc (original)
+++ branches/itanium2/fox/FMantaTrackballNav.cc Fri Jul 15 01:28:12 2005
@@ -60,8 +60,6 @@
                        Point lookat;
                        Vector normal;
                        
-                       std::cout << "Calling shoot one ray" << std::endl;
-                       
                        if (manta_frame->shootOneRay( event->win_x, 
event->win_y, lookat, normal )) {
                                manta_interface->addTransaction("camera 
lookat",
                                        Callback::create( this, 
&FMantaTrackballNav::mantaLookat, lookat ) );

Modified: branches/itanium2/fox/FMantaWindow.cc
==============================================================================
--- branches/itanium2/fox/FMantaWindow.cc       (original)
+++ branches/itanium2/fox/FMantaWindow.cc       Fri Jul 15 01:28:12 2005
@@ -15,6 +15,7 @@
 #include <Model/MiscObjects/CuttingPlane.h>
 
 #include <iostream>
+#include <sstream>
 
 using namespace fox_manta;
 using namespace Manta;
@@ -31,6 +32,8 @@
        FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_CUTTING_FLIP,   
FMantaWindow::onCuttingFlip ),
        FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_BOOKMARK_LIST,  
FMantaWindow::onCameraBookmark ),
        FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_NAVIGATOR_LIST, 
FMantaWindow::onNavigator ),
+       FXMAPFUNC(SEL_KEYPRESS,0,                               
FMantaWindow::onNavigatorToggle ),
+       FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_ADD_BOOKMARK,   
FMantaWindow::onAddBookmark ),
        
        // Cameras.
        FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_PINHOLE_CAMERA,     
FMantaWindow::onCamera ),
@@ -110,6 +113,7 @@
        cutting_flip = new FXMenuCommand( options_menu, "Flip Cutting Plane", 
0, this, ID_CUTTING_FLIP );
        new FXMenuTitle( menu_bar, "Options", 0, options_menu );
 
+
        // Create the content of the window.
        FXComposite *frame = new FXHorizontalFrame( this, LAYOUT_FILL );
        
@@ -140,7 +144,7 @@
        camera_bookmark_list = new FXListBox( frame, this, ID_BOOKMARK_LIST, 
LAYOUT_FILL_X|LAYOUT_BOTTOM|COMBOBOX_REPLACE,0,0,0,20 );
        camera_bookmark_list->setNumVisible( 5 );
        
-       // new FXButton( frame, "Add", 0, this, ID_ADD_BOOKMARK );
+       new FXButton( frame, "Add", 0, this, ID_ADD_BOOKMARK );
 }
 
 // Quit the program.
@@ -209,6 +213,15 @@
        // Get a pointer to the camera.
        Camera *camera = manta_interface->getCamera( 
manta_frame->getMantaChannel() );
        
+       // Get the camera in text form.
+       ostringstream str;
+       camera->output( str );
+       
+       std::cout << "New Bookmark" << std::endl 
+                 << str.str() << std::endl;
+       
+       addCameraBookmark( "New Bookmark", str.str() );
+       
        return 1;
 }
 
@@ -418,6 +431,36 @@
        return 1;
 }
 
+long FMantaWindow::onNavigatorToggle( FXObject *sender, FXSelector key, void 
*data ) {
+       
+       FXEvent *event = (FXEvent *)data;
+       if (event->text[0] == '\t') {
+               
+               // Determine the selected index.
+               int index = (navigator_list->getCurrentItem() + 1) % 
navigator_list->getNumItems(); 
+               navigator_list->setCurrentItem( index );
+               
+               // Get the pointer to the new navigator.
+               FMantaNavigator *nav = (FMantaNavigator 
*)navigator_list->getItemData(index);
+               
+               // Get the current manta camera.
+               int channel = manta_frame->getNavigator()->getMantaChannel();
+               Camera *camera = manta_interface->getCamera( channel );
+               
+               // Reset the new nav to this camera.
+               nav->resetToCamera( camera->getPosition(), 
camera->getLookAt(), camera->getUp());
+               
+               manta_frame->setNavigator( nav );
+               
+               return 0;
+       }
+       else {
+       
+                       return manta_frame->getNavigator()->onKeyPress( 
sender, key, data );
+       }
+       
+}
+
 
///////////////////////////////////////////////////////////////////////////////
 
 void FMantaWindow::mantaThreadBookmark( const string camera_text ) {
@@ -543,8 +586,6 @@
 // This method is called by the manta thread to add a cutting plane.
 void FMantaWindow::mantaAddCuttingPlane( Point point, Vector normal ) const {
        
-       std::cout << "Adding cutting plane. " << std::endl;
-       
        // Add a cutting plane on top of the root object.
        Scene *scene = manta_interface->getScene();
        Object *root_object = scene->getObject();
@@ -573,8 +614,6 @@
 
 void FMantaWindow::mantaRemoveCuttingPlane() const {
 
-       std::cout << "Removing cutting plane. " << std::endl;
-       
        // Add a cutting plane on top of the root object.
        Scene *scene = manta_interface->getScene();
        Object *root_object = scene->getObject();
@@ -598,8 +637,6 @@
        
        CuttingPlane *cutting_plane = dynamic_cast< CuttingPlane * >( 
root_object );
        if (cutting_plane) {
-       
-               std::cout << "Move Cutting plane: " << amount << std::endl;
 
                // Move the plane along the normal.
                cutting_plane->movePlaneAlongNormal( amount );
@@ -614,8 +651,6 @@
        
        CuttingPlane *cutting_plane = dynamic_cast< CuttingPlane * >( 
root_object );
        if (cutting_plane) {
-               
-               std::cout << "Flip Cutting plane" << std::endl;
                
                // Move the plane along the normal.
                Vector normal;

Modified: branches/itanium2/fox/FMantaWindow.h
==============================================================================
--- branches/itanium2/fox/FMantaWindow.h        (original)
+++ branches/itanium2/fox/FMantaWindow.h        Fri Jul 15 01:28:12 2005
@@ -71,6 +71,7 @@
                        
                        // Navigators.
                        ID_NAVIGATOR_LIST,
+                       ID_NAVIGATOR_TOGGLE,
                        
                        // Shadow options.
                        ID_PINHOLE_CAMERA,
@@ -109,6 +110,8 @@
                void addCameraBookmark ( const string &description, const 
string &camera_text );
                void addNavigatorOption( const string &description, 
FMantaNavigator *nav );
 
+               const string &getCameraBookmark( int i ) { return 
camera_text_list[i]; }; 
+
                // Create the window.
                void create() { FXMainWindow::create(); show( 
PLACEMENT_DEFAULT ); };
                
@@ -119,6 +122,7 @@
                long onCuttingFlip    ( FXObject *sender, FXSelector key, 
void *data );
                long onCameraBookmark ( FXObject *sender, FXSelector key, 
void *data );
                long onNavigator      ( FXObject *sender, FXSelector key, 
void *data );
+               long onNavigatorToggle( FXObject *sender, FXSelector key, 
void *data );
                long onAddBookmark    ( FXObject *sender, FXSelector key, 
void *data );
                long onCamera         ( FXObject *sender, FXSelector key, 
void *data );
                long onCameraText     ( FXObject *sender, FXSelector key, 
void *data );

Modified: branches/itanium2/fox/fox_manta.cc
==============================================================================
--- branches/itanium2/fox/fox_manta.cc  (original)
+++ branches/itanium2/fox/fox_manta.cc  Fri Jul 15 01:28:12 2005
@@ -19,22 +19,29 @@
 
 #include <string>
 #include <stdlib.h>
+#include <fstream>
 
 using namespace FX;
 using namespace fox_manta;
 using namespace Manta;
+using namespace std;
 
 Scene* createDefaultScene();
 
 int main( int argc, char *argv[]) {
 
-       // Don't catch thread exceptions.
-       setenv("THREAD_NO_CATCH_SIGNALS","1",false);
+       // Make sure the necessary environment is setup.
+       if (getenv("THREAD_NO_CATCH_SIGNALS") == 0) {
+               cerr << "ALERT: setenv THREAD_NO_CATCH_SIGNALS 1 to avoid 
instability on exit." << std::endl;
+       };
+       if (getenv("FGL_MACRO_TILE_FB") == 0) {
+               cerr << "ALERT: setenv FGL_MACRO_TILE_FB 1 to improve 
performance over vizserver." << std::endl;
+       }
 
        // Parse args.
        int np = 1;
        char *scene_text = 0;
-       string nav_text;
+       string bookmark_file_name;
        
        // Look for specific args.
        for (int i=0;i<argc;++i) {
@@ -45,8 +52,8 @@
                else if (arg == "-scene") {
                        scene_text = argv[++i];
                }
-               else if (arg == "-nav") {
-                       nav_text = argv[++i];
+               else if (arg == "-bookmarks") {
+                       bookmark_file_name = argv[++i];
                }
        }
        
@@ -81,7 +88,6 @@
        manta_interface->selectRenderer       ( "raytracer" );
        manta_interface->selectShadowAlgorithm( "hard" );
        
-       Camera *camera = manta_interface->createCamera( "pinhole(-eye 3 3 2 
-lookat 0 0 0.3 -up 0 0 1 -fov 60)" );
        // Camera *camera = new PinholeCamera( Point ( 0.0, 0.0, 0.0 ), Point 
( 0.0, -1.0, 0.0 ), Vector( 0.0, 0.0, 1.0 ), 60 );
        
        // Create the manta image frame.
@@ -91,50 +97,73 @@
        GLXImageDisplay glx_image_display( (XVisualInfo 
*)manta_frame->getVisual()->getInfo(),
                                      (Window)       manta_frame->id() );
        
+       // Try to load a scene.
+       if ((scene_text == 0) || (!manta_interface->readScene( scene_text ))) 
{
+               // Create a default scene.
+               manta_interface->setScene( createDefaultScene() );
+       }
+       
+       // Check to see if a bookmark file was specified.
+       if (bookmark_file_name.size() > 0) {
+
+               char description[128];
+               char specification[128];
+               ifstream file( bookmark_file_name.c_str() );
+               
+               if (file.is_open()) {
+                       while (!file.eof()) {
+                       
+                               file.getline( description, 128 );
+                               if (string(description).size() > 0) {
+                                       
+                                       file.getline( specification, 128 );
+                                       if (string(specification).size() > 0) 
{
+                                               
manta_window.addCameraBookmark( description, specification );
+                                       }
+                               }
+                       }
+                       
+                       file.close();
+               }
+               else {
+                       std::cerr << "Could not load bookmark file." << 
std::endl;
+               }
+       }
+       
+       else {
+       
+               // Add a camera bookmark for the default camera.
+               manta_window.addCameraBookmark( "Default", "pinhole(-eye 3 3 
2 -lookat 0 0 0.3 -up 0 0 1 -fov 60)" );
+
+       }
+
+       // Create the camera using the first camera bookmark.
+       Camera *camera = manta_interface->createCamera( 
manta_window.getCameraBookmark( 0 ) );
+
        // Create a default quake navigator.
-       std::cerr << "Using default video game navigator." << std::endl;
-       FMantaQuakeNav *quake_nav = new FMantaQuakeNav();
+       FMantaQuakeNav *quake_nav = new FMantaQuakeNav( false );
        quake_nav->setMantaInterface( manta_interface );
        manta_window.addNavigatorOption( "Video Game", quake_nav );
 
+       // Create a default quake navigator.
+       FMantaQuakeNav *fly_nav = new FMantaQuakeNav( true );
+       fly_nav->setMantaInterface( manta_interface );
+       manta_window.addNavigatorOption( "Fly", fly_nav );
+
        // Create a navigator for the image frame.
        FMantaTrackballNav *trackball_nav = new FMantaTrackballNav();
        trackball_nav->setMantaInterface( manta_interface );
        trackball_nav->setMantaFrame( manta_frame );
        trackball_nav->setMantaChannel( 0 );    
        manta_window.addNavigatorOption("Trackball", trackball_nav );   
-       
-       // Create a navigator for the image frame.
-       FMantaUniformNav *uniform_nav = new FMantaUniformNav();
-       uniform_nav->setMantaInterface( manta_interface );
-       uniform_nav->setMantaChannel( 0 );      
-       manta_window.addNavigatorOption("Uniform", uniform_nav );       
 
        // Use the quake nav by default.
        quake_nav->resetToCamera( 
camera->getPosition(),camera->getLookAt(),camera->getUp());
        manta_window.setNavigator( quake_nav );
-               
+
        // Create manta channel for the interface.
        int manta_channel = 0; // !!! See XWindowUI.cc line: 586
        manta_interface->createChannel( &glx_image_display, camera, false, 
width, height );
-       
-       // Check for a command line scene.
-       if ((scene_text == 0) || (!manta_interface->readScene( scene_text ))) 
{
-               // Create a default scene.
-               manta_interface->setScene( createDefaultScene() );
-               
-               // Add a camera bookmark for the default camera.
-               manta_window.addCameraBookmark( "Default", "pinhole(-eye 3 3 
2 -lookat 0 0 0.3 -up 0 0 1 -fov 60)" );
-       }
-       else {
-               // Assume we are viewing the boeing scene.
-               manta_window.addCameraBookmark( "Left Engine Cross-Section", 
"pinhole( -eye 1038.31 -517.053 108.78  -lookat 1057.9 169.557 123.655  -up 
0.0107751 -0.392417 0.919724  -fov 60 )" );
-               manta_window.addCameraBookmark( "Whole Cross-Section",       
"pinhole( -eye 1408.56 -2172.05 110.736  -lookat 1350.55 188.313 354.277  -up 
0.0117111 -0.465077 0.885192  -fov 60 )" );
-               manta_window.addCameraBookmark( "Cockpit Cross-Section",     
"pinhole( -eye 312.31 -315.671 199.735  -lookat 280.305 98.0706 184.652  -up 
0.0256952 -0.337005 0.941152  -fov 60 )" );
-               manta_window.addCameraBookmark( "Top View",                  
"pinhole( -eye 1821.5 -29.356 2323.27  -lookat 1446.55 13.6745 -591.948  -up 
-0.323033 -0.85584 0.403966  -fov 60 )" );
-               manta_window.addCameraBookmark( "Cargo Area",                
"pinhole( -eye 1858.79 -33.8248 155.066  -lookat 1273.5 -40.34 146.295  -up 
0.357763 0.0232703 0.933523  -fov 60 )" );
-               manta_window.addCameraBookmark( "Inside Cockpit",            
"pinhole( -eye 209.886 14.2034 244.021  -lookat -241.326 -158.379 185.454  
-up 0.216817 0.154821 0.963858  -fov 56.8882 )" );
-       }
 
        // Set the manta interface for the application.
        manta_window.setMantaInterface( manta_interface, manta_channel );




  • [MANTA] r432 - in branches/itanium2: Core/Color Image Interface Model/Cameras Model/Groups Model/Materials Model/MiscObjects Readers UserInterface fox, abe, 07/15/2005

Archive powered by MHonArc 2.6.16.

Top of page