Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r749 - branches/itanium2/fox


Chronological Thread 
  • From: abe@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r749 - branches/itanium2/fox
  • Date: Mon, 5 Dec 2005 17:25:01 -0700 (MST)

Author: abe
Date: Mon Dec  5 17:24:59 2005
New Revision: 749

Modified:
   branches/itanium2/fox/CMakeLists.txt
   branches/itanium2/fox/FMantaNavigator.h
   branches/itanium2/fox/FMantaQuakeNav.cc
   branches/itanium2/fox/FMantaQuakeNav.h
   branches/itanium2/fox/FMantaStereo.cc
   branches/itanium2/fox/FMantaWindow.cc
   branches/itanium2/fox/FMantaWindow.h
   branches/itanium2/fox/dm_demo.cc
Log:

Added support for coordinate systems with a positive y up direction to the 
video game and fly interation modes.

Added a transaction to switch on the stereo camera automatically if dm_demo 
is run with the -stereo option.


M    fox/FMantaWindow.cc
M    fox/FMantaWindow.h
M    fox/FMantaQuakeNav.cc
M    fox/FMantaQuakeNav.h
M    fox/dm_demo.cc
M    fox/FMantaNavigator.h
M    fox/FMantaStereo.cc
M    fox/CMakeLists.txt


Modified: branches/itanium2/fox/CMakeLists.txt
==============================================================================
--- branches/itanium2/fox/CMakeLists.txt        (original)
+++ branches/itanium2/fox/CMakeLists.txt        Mon Dec  5 17:24:59 2005
@@ -57,7 +57,7 @@
   SET(FOX_X11_LIBRARIES m jpeg png tiff)
 
   # Append Xcursor if it is available.
-  FIND_LIBRARY( FOUND_XCURSOR NAMES Xcursor PATHS /usr/X11R6/lib )    
+  FIND_LIBRARY( FOUND_XCURSOR NAMES Xcursor PATHS /usr/X11R6/lib DOC "Only 
required if Fox linked w/ Xcursor")    
   IF(FOUND_XCURSOR)
     SET(FOX_X11_LIBRARIES ${FOX_X11_LIBRARIES}
                           Xcursor)
@@ -65,7 +65,7 @@
 
  
   # Append Xrandr if it is available.
-  FIND_LIBRARY( FOUND_XRANDR NAMES Xrandr PATHS /usr/X11R6/lib )    
+  FIND_LIBRARY( FOUND_XRANDR NAMES Xrandr PATHS /usr/X11R6/lib DOC "Only 
required if Fox linked w/ Xrandr")    
   IF(FOUND_XRANDR)
     SET(FOX_X11_LIBRARIES ${FOX_X11_LIBRARIES}
                           Xrandr)

Modified: branches/itanium2/fox/FMantaNavigator.h
==============================================================================
--- branches/itanium2/fox/FMantaNavigator.h     (original)
+++ branches/itanium2/fox/FMantaNavigator.h     Mon Dec  5 17:24:59 2005
@@ -15,18 +15,25 @@
        // This class defines the interface for Navigators 
        // which manipulate a Manta camera on mouse and keyboard input.
        class FMantaNavigator {
+  private:
+    // Coordinate system properties.
+    int coord_system;
+               
        protected:
        
                // Manta interfaces.
                RTRTInterface *manta_interface;
                int            manta_channel;
-               
+
        public:
-               FMantaNavigator() : manta_interface( 0 ), manta_channel( 0 ) 
{  };
+               FMantaNavigator() : manta_interface( 0 ), manta_channel( 0 ), 
coord_system( PositiveZUp ) {  };
                virtual ~FMantaNavigator() {  };
                
                // Accessors.
-               
+    enum { PositiveYUp, PositiveZUp };
+
+    virtual void setCoordSystemUp( int up ) { coord_system = up; };
+         virtual int  getCoordSystemUp() const    { return coord_system; };
                
                void setMantaInterface( RTRTInterface *manta_interface_ ) { 
manta_interface = manta_interface_; };
                void setMantaChannel  ( int manta_channel_ )  { manta_channel 
= manta_channel_; };

Modified: branches/itanium2/fox/FMantaQuakeNav.cc
==============================================================================
--- branches/itanium2/fox/FMantaQuakeNav.cc     (original)
+++ branches/itanium2/fox/FMantaQuakeNav.cc     Mon Dec  5 17:24:59 2005
@@ -131,42 +131,67 @@
 
 void FMantaQuakeNav::resetToCamera( const Point &eye, const Point &lookat, 
const Vector &up )
 {
-  posX=eye.x();
-  posY=eye.y();
-  height=eye.z();
-  
-  // for now up is assumed to be positive Z
+
+  // Extract the camera position.
+  posX   = Dot( eye, forward_dir );
+  posY   = Dot( eye, right_dir );
+  height = Dot( eye, up_dir );
+
+  Real lookatX   = Dot( lookat, forward_dir );
+  Real lookatY   = Dot( lookat, right_dir );
+  Real lookatZ   = Dot( lookat, up_dir );
 
   // use dx and dy to determine the view direction angle  
-  double dx = lookat.x() - eye.x();
-  double dy = lookat.y() - eye.y();
+  double dx = lookatX - posX;
+  double dy = lookatY - posY;
   viewDirAngle = (float)atan2(dy,dx)/TORADS;
   
   // dV and dZ form adjacent edges of a right triangle, use this to 
determine elevation angle
-  double dZ = lookat.z() - eye.z();
+  double dZ = lookatZ - height;
   double dV = sqrt(dx*dx+dy*dy);
   viewElevAngle = (float)atan2(dZ,dV)/TORADS;
+
 }
 
 void FMantaQuakeNav::getCamera    ( Point &eye, Point &lookat, Vector &up ) 
const {
-
        // Transform a default eye, up, and lookat.
   double Azi=viewDirAngle*TORADS , Elev=viewElevAngle*TORADS;
 
   float dX=(float)(cos(Azi)*cos(Elev)), 
         dY=(float)(sin(Azi)*cos(Elev)),
         dZ=(float)sin(Elev);
+
+  eye = Point(
+    (forward_dir*posX) +
+    (right_dir*posY) +
+    (up_dir*height));
   
-  eye    = Point( posX, posY, height );
-  lookat = Point( posX+dX, posY+dY, height+dZ );
-  up     = Vector( 0.0, 0.0, 1.0 );
+  lookat = eye +
+    (forward_dir*dX) +
+    (right_dir*dY) +
+    (up_dir*dZ);
+
+  up = up_dir;
   
-/* for y-up
-Point eye   ( posX, posY, height );
-Point lookat( posX+dX, -(height+dZ), posY+dY );
-Vector up   ( 0.0, 1.0, 0.0 );
-*/
   
+}
+
+void FMantaQuakeNav::setCoordSystemUp( int up ) {
+
+  switch (up) {
+  case PositiveZUp:
+    forward_dir = Vector( 1, 0, 0 );
+    right_dir   = Vector( 0, 1, 0 );
+    up_dir      = Vector( 0, 0, 1 );
+    break;
+  case PositiveYUp:
+    forward_dir = Vector( 1, 0,  0 );
+    right_dir   = Vector( 0, 0, -1 );
+    up_dir      = Vector( 0, 1,  0 );    
+    break;
+  };
+
+  FMantaNavigator::setCoordSystemUp( up );
 }
 
 
///////////////////////////////////////////////////////////////////////////////

Modified: branches/itanium2/fox/FMantaQuakeNav.h
==============================================================================
--- branches/itanium2/fox/FMantaQuakeNav.h      (original)
+++ branches/itanium2/fox/FMantaQuakeNav.h      Mon Dec  5 17:24:59 2005
@@ -29,6 +29,11 @@
                Real viewDirAngle;
                Real viewElevAngle;
                Real height;
+
+    // Orientation of movement plane in world space
+    Vector forward_dir;
+    Vector right_dir;
+    Vector up_dir;
                
        public:
                // Key map.
@@ -66,7 +71,10 @@
                                                                              
           viewElevAngle( 0.0 ),
                                                                              
           height( 0 ),
                        left_mouse_down( false ),
-                       right_mouse_down( false )
+                       right_mouse_down( false ),
+                       forward_dir( 1, 0, 0 ),
+                       right_dir  ( 0, 1, 0 ),
+                       up_dir     ( 0, 0, 1 )
                                                                              
           {  
                                                                              
              key_map[0] = 'w';
                                                                              
              key_map[1] = 's';
@@ -82,7 +90,10 @@
                        viewElevAngle( 0.0 ),
                        height( 0 ),
                        left_mouse_down( false ),
-                       right_mouse_down( false )
+                                       right_mouse_down( false ),
+                       forward_dir( 1, 0, 0 ),
+                       right_dir  ( 0, 1, 0 ),
+                       up_dir     ( 0, 0, 1 )      
                {  
                                key_map[0] = 'w';
                                key_map[1] = 's';
@@ -103,7 +114,10 @@
                        viewElevAngle( viewElevAngle_ ),
                        height( height_ ),
       left_mouse_down( false ),
-      right_mouse_down( false )
+      right_mouse_down( false ),
+      forward_dir( 1, 0, 0 ),
+      right_dir  ( 0, 1, 0 ),
+      up_dir     ( 0, 0, 1 )
                        
                  { key_map[0] = 'w';
                                key_map[1] = 's';
@@ -113,7 +127,9 @@
         timerStarted = false; }; 
                        
                // Accessors.
-               void setKeyMap( int map, char k ) { key_map[map] = k; };
+    virtual void setCoordSystemUp( int up );
+    
+    void setKeyMap( int map, char k ) { key_map[map] = k; };
                char getKeyMap( int map )         { return key_map[map]; };
                
                int &getAllowFly() { return allowFly; }

Modified: branches/itanium2/fox/FMantaStereo.cc
==============================================================================
--- branches/itanium2/fox/FMantaStereo.cc       (original)
+++ branches/itanium2/fox/FMantaStereo.cc       Mon Dec  5 17:24:59 2005
@@ -70,7 +70,7 @@
   distance_spinner = new FXRealSpinner( frame, 5, this, ID_DISTANCE );
   distance_spinner->setRange( 0, 999 );
   distance_spinner->setIncrement( 0.001 );
-  distance_spinner->setValue( 0.01 );
+  distance_spinner->setValue( 1.0 );
 
   frame = new FXHorizontalFrame( this );
   new FXLabel( frame, "Focus distance" );
@@ -84,7 +84,7 @@
   focus_eye_spinner = new FXRealSpinner( frame, 5, this, ID_FOCUS_EYE );
   focus_eye_spinner->setRange( 0, 999 );
   focus_eye_spinner->setIncrement( 0.001 );
-  focus_eye_spinner->setValue( 0.01 );  
+  focus_eye_spinner->setValue( 0.5 );  
   
 }
 

Modified: branches/itanium2/fox/FMantaWindow.cc
==============================================================================
--- branches/itanium2/fox/FMantaWindow.cc       (original)
+++ branches/itanium2/fox/FMantaWindow.cc       Mon Dec  5 17:24:59 2005
@@ -70,15 +70,19 @@
   FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_TEXT_TRAVERSER,            
FMantaWindow::onTraverserText ),
 
   // Cutting planes.
-  FXMAPFUNC(SEL_LEFTBUTTONPRESS, FMantaImageFrame::ID_PIXEL_SELECT, 
FMantaWindow::onAddCuttingPlane ),
+  FXMAPFUNC(SEL_LEFTBUTTONPRESS, FMantaImageFrame::ID_PIXEL_SELECT,  
FMantaWindow::onAddCuttingPlane ),
 
   // Picking
-  FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_HIDE_SELECTED, 
FMantaWindow::onHideSelected ),
+  FXMAPFUNC(SEL_COMMAND,          FMantaWindow::ID_HIDE_SELECTED,    
FMantaWindow::onHideSelected ),
   FXMAPFUNC(SEL_RIGHTBUTTONPRESS, FMantaImageFrame::ID_PIXEL_SELECT, 
FMantaWindow::onPick ),
 
   // Other options.
   FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_EXTRA_OPTIONS, 
FMantaWindow::onExtraOptions ),
-  FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_UNHIDE_ALL, 
FMantaWindow::onUnHideAll )
+  FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_UNHIDE_ALL,    
FMantaWindow::onUnHideAll ),
+
+  FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_POSITIVEZ_UP, 
FMantaWindow::onCoordSystemUp ),
+  FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_POSITIVEY_UP, 
FMantaWindow::onCoordSystemUp )
+  
 };
 
 
FXIMPLEMENT(FMantaWindow,FXMainWindow,FMantaWindowMap,ARRAYNUMBER(FMantaWindowMap));
@@ -159,6 +163,11 @@
   fly_bookmarks_check = new FXMenuCheck( options_menu, "Fly to Bookmarks" );
   fly_bookmarks_check->enable();
 
+  // Coordinate system up.
+  new FXMenuSeparator( options_menu );
+  positivez_up = new FXMenuRadio( options_menu, "Positive Z up", this, 
ID_POSITIVEZ_UP );
+  positivez_up->setCheck( true );
+  positivey_up = new FXMenuRadio( options_menu, "Positive Y up", this, 
ID_POSITIVEY_UP );
   new FXMenuSeparator( options_menu );
        
   new FXMenuTitle( menu_bar, "Options", 0, options_menu );
@@ -176,7 +185,9 @@
   frame = new FXHorizontalFrame( controls, LAYOUT_FILL_X );
   new FXLabel( frame, "Control Speed: " );
   speed_slider = new FXRealSlider( frame, this, ID_SPEED_SLIDER, 
REALSLIDER_HORIZONTAL|LAYOUT_FILL_X );
-  speed_slider->setRange( 0.001, 5.0 );
+  speed_slider->setRange( 0.001, 10.0 );
+  speed_slider->setIncrement( 0.001 );
+  speed_slider->setValue( 1.0 );
        
   // Cutting plane slider.
   frame = new FXHorizontalFrame( controls, LAYOUT_FILL_X );
@@ -260,11 +271,9 @@
 
 long FMantaWindow::onSpeedSlider( FXObject *sender, FXSelector key, void 
*data ) {
 
-  // Set the control speed for interaction.
-  Real new_speed = *((double *)data);
-       
+    
   // std::cout << "Control speed: " << new_speed << std::endl;
-  manta_frame->getNavigator()->setControlSpeed( new_speed );
+  manta_frame->getNavigator()->setControlSpeed( getControlSpeed() );
   return 1;
 }
 
@@ -820,9 +829,16 @@
        
   // Reset the new nav to this camera.
   nav->resetToCamera( camera->getPosition(), camera->getLookAt(), 
camera->getUp());
-
+  nav->setControlSpeed( getControlSpeed() );
+  
+  // Set the up direction.
+  if (positivez_up->getCheck())
+    nav->setCoordSystemUp( FMantaNavigator::PositiveZUp );
+  else
+    nav->setCoordSystemUp( FMantaNavigator::PositiveYUp );  
+  
   manta_frame->setNavigator( nav );
-       
+    
   return 1;
 }
 
@@ -844,7 +860,13 @@
                
     // Reset the new nav to this camera.
     nav->resetToCamera( camera->getPosition(), camera->getLookAt(), 
camera->getUp());
-    nav->setControlSpeed( speed_slider->getValue() );
+    nav->setControlSpeed( getControlSpeed() );
+
+    // Set the up direction.
+    if (positivez_up->getCheck())
+      nav->setCoordSystemUp( FMantaNavigator::PositiveZUp );
+    else
+      nav->setCoordSystemUp( FMantaNavigator::PositiveYUp );
                
     manta_frame->setNavigator( nav );
                
@@ -874,6 +896,32 @@
 
   return 1;
 }
+long FMantaWindow::onCoordSystemUp  ( FXObject *sender, FXSelector key, void 
*data ) {
+
+  FXEvent *event = (FXEvent *)data;
+       FXushort id = FXSELID( key );
+
+  // Determine which radio button selected.
+  if (id == ID_POSITIVEZ_UP) {
+    positivey_up->setCheck( false );
+    manta_frame->getNavigator()->setCoordSystemUp( 
FMantaNavigator::PositiveZUp );
+
+    // Set the camera up direction.
+    manta_interface->addTransaction("Up Direction",
+      
Callback::create(this,&FMantaWindow::mantaSetCameraUp,(int)FMantaNavigator::PositiveZUp));
+
+  }
+  else {
+    positivez_up->setCheck( false );
+    manta_frame->getNavigator()->setCoordSystemUp( 
FMantaNavigator::PositiveYUp );
+
+    // Set the camera up direction.
+    manta_interface->addTransaction("Up Direction",
+      
Callback::create(this,&FMantaWindow::mantaSetCameraUp,(int)FMantaNavigator::PositiveYUp));
    
+  }
+  
+  return 1;
+}
 
 
///////////////////////////////////////////////////////////////////////////////
 
@@ -1166,3 +1214,19 @@
 
 }
 
+// This method is called when the user changes the coordinate system up 
direction
+// to make sure that the camera uses the same up direction.
+void FMantaWindow::mantaSetCameraUp( int up ) {
+
+  Camera *camera = manta_interface->getCamera( 
manta_frame->getMantaChannel() );
+  
+  // Positive Z up.
+  if (up == FMantaNavigator::PositiveZUp) {
+    camera->reset( camera->getPosition(), Vector( 0, 0, 1 ), 
camera->getLookAt() );
+  }
+
+  // Positive Y up.
+  else {
+    camera->reset( camera->getPosition(), Vector( 0, 1, 0 ), 
camera->getLookAt() );
+  }
+}

Modified: branches/itanium2/fox/FMantaWindow.h
==============================================================================
--- branches/itanium2/fox/FMantaWindow.h        (original)
+++ branches/itanium2/fox/FMantaWindow.h        Mon Dec  5 17:24:59 2005
@@ -65,7 +65,11 @@
                                
     // Navigator options.
     FXListBox     *navigator_list; // User data field will hold pointer to 
navigator.
-               
+
+    // Coordinate system.
+    FXMenuRadio *positivez_up;
+    FXMenuRadio *positivey_up;
+    
     // Image panels for displaying output.
     FMantaImageFrame *manta_frame;
                
@@ -122,7 +126,11 @@
       ID_HIDE_SELECTED,
       ID_UNHIDE_ALL,
       ID_EXTRA_OPTIONS,
-                       
+
+      // Coordinate system up
+      ID_POSITIVEZ_UP,
+      ID_POSITIVEY_UP,
+      
       ID_LAST
     };
                
@@ -176,6 +184,7 @@
     long onPick( FXObject *sender, FXSelector key, void *data );
     long onPOI( FXObject *sender, FXSelector key, void *data );
     long onExtraOptions   ( FXObject *sender, FXSelector key, void *data );
+    long onCoordSystemUp  ( FXObject *sender, FXSelector key, void *data );
                
     // Accessors.
     void setMantaInterface( RTRTInterface *manta_interface_, int 
manta_channel_ ) { 
@@ -184,7 +193,10 @@
                
     RTRTInterface    *getMantaInterface() { return manta_interface; };
     FMantaImageFrame *getMantaFrame()     { return manta_frame; };
-               
+
+    
+    Real getControlSpeed() const { return pow( 2, speed_slider->getValue() ) 
- 1.0; }
+    
     // This method is called by the manta thread to replace the camera.
     void mantaThreadBookmark( const string camera_text );
                
@@ -225,6 +237,8 @@
 
     // This methid is called by manta when the last rendering thread exits.
     void mantaTerminate( RTRTInterface *manta_interface );
+
+    void mantaSetCameraUp( int up );
   };
 };
 

Modified: branches/itanium2/fox/dm_demo.cc
==============================================================================
--- branches/itanium2/fox/dm_demo.cc    (original)
+++ branches/itanium2/fox/dm_demo.cc    Mon Dec  5 17:24:59 2005
@@ -268,6 +268,10 @@
     // Check to see if we should enable the stereo dialog.
     if (use_stereo) {
       manta_window.addExtraOptionsDialog( "Stereo", new FMantaStereoDialog( 
&manta_window, "Stereo" ));
+
+      // Add a transaction to switch on the stereo camera.
+      manta_interface->addTransaction("Switch to stereo",
+                                   
Callback::create(&manta_window,&FMantaWindow::mantaCamera2,string("stereo")) 
);      
     }
   
     // Check to see if the default scene was a kdtree.




  • [MANTA] r749 - branches/itanium2/fox, abe, 12/05/2005

Archive powered by MHonArc 2.6.16.

Top of page