Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r407 - in branches/itanium2: . Engine/Control Model/Cameras Model/Groups Model/MiscObjects fox


Chronological Thread 
  • From: abe@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r407 - in branches/itanium2: . Engine/Control Model/Cameras Model/Groups Model/MiscObjects fox
  • Date: Thu, 23 Jun 2005 02:27:03 -0600 (MDT)

Author: abe
Date: Thu Jun 23 02:26:53 2005
New Revision: 407

Modified:
   branches/itanium2/Engine/Control/RTRT.cc
   branches/itanium2/Model/Cameras/EnvironmentCamera.h
   branches/itanium2/Model/Cameras/OrthogonalCamera.h
   branches/itanium2/Model/Groups/CMakeLists.txt
   branches/itanium2/Model/MiscObjects/CuttingPlane.cc
   branches/itanium2/Model/MiscObjects/CuttingPlane.h
   branches/itanium2/fox/FMantaNavigator.h
   branches/itanium2/fox/FMantaQuakeNav.cc
   branches/itanium2/fox/FMantaQuakeNav.h
   branches/itanium2/fox/FMantaWindow.cc
   branches/itanium2/fox/FMantaWindow.h
   branches/itanium2/fox/fox_manta.cc
   branches/itanium2/manta-commands.txt
Log:



M    fox/fox_manta.cc
M    fox/FMantaWindow.cc
M    fox/FMantaWindow.h
M    fox/FMantaQuakeNav.cc
M    fox/FMantaNavigator.h
M    fox/FMantaQuakeNav.h
M    Model/Groups/CMakeLists.txt
M    Model/MiscObjects/CuttingPlane.cc
M    Model/MiscObjects/CuttingPlane.h
M    Model/Cameras/EnvironmentCamera.h
M    Model/Cameras/OrthogonalCamera.h
M    Engine/Control/RTRT.cc
M    manta-commands.txt


Added the following features to the demo:
+ Camera bookmarks work between different navigators.
+ Navigators drop down list.
+ Menus for sampling rate selection or enter a specification string.
+ Menus for camera selection or ender a spec string.

Cutting plane usage: Double click on geometry to add. Double click on 
background to remove.
+ Snap cutting planes to nearest axis.
+ Flip cutting plane.
+ Move cutting plane along its normal.

Note demo loads with multi-sample and shadows turned on. Sending the "debug" 
rays doesn't always work as expected. Environment Map camera very cool in 
plane.



Modified: branches/itanium2/Engine/Control/RTRT.cc
==============================================================================
--- branches/itanium2/Engine/Control/RTRT.cc    (original)
+++ branches/itanium2/Engine/Control/RTRT.cc    Thu Jun 23 02:26:53 2005
@@ -764,6 +764,7 @@
   if(iter == loadBalancers.end())
     return false;
   currentLoadBalancer = (*iter->second)(args);
+  pipelineNeedsSetup = true;
   return true;
 }
 
@@ -793,6 +794,7 @@
   if(iter == pixelSamplers.end())
     return false;
   currentPixelSampler = (*iter->second)(args);
+       pipelineNeedsSetup = true;
   return true;
 }
 

Modified: branches/itanium2/Model/Cameras/EnvironmentCamera.h
==============================================================================
--- branches/itanium2/Model/Cameras/EnvironmentCamera.h (original)
+++ branches/itanium2/Model/Cameras/EnvironmentCamera.h Thu Jun 23 02:26:53 
2005
@@ -15,6 +15,8 @@
   class EnvironmentCamera : public Camera {
   public:
     EnvironmentCamera(const vector<string>& args);
+               EnvironmentCamera( const Point &eye_, const Point &lookat_, 
const Vector &up_ ) :
+                       eye( eye_ ), lookat( lookat_ ), up( up_ ) { setup(); }
     virtual ~EnvironmentCamera();
     virtual void makeRays(RayPacket&) const;
 

Modified: branches/itanium2/Model/Cameras/OrthogonalCamera.h
==============================================================================
--- branches/itanium2/Model/Cameras/OrthogonalCamera.h  (original)
+++ branches/itanium2/Model/Cameras/OrthogonalCamera.h  Thu Jun 23 02:26:53 
2005
@@ -14,6 +14,8 @@
   class OrthogonalCamera : public Camera {
   public:
     OrthogonalCamera(const vector<string>& args);
+               OrthogonalCamera( const Point &eye_, const Point &lookat_, 
const Vector &up_, Real hscale_ ) :
+                       eye( eye_ ), lookat( lookat_ ), up( up_ ), hscale( 
hscale_ ) { setup(); }
     virtual ~OrthogonalCamera();
     virtual void makeRays(RayPacket&) const;
 

Modified: branches/itanium2/Model/Groups/CMakeLists.txt
==============================================================================
--- branches/itanium2/Model/Groups/CMakeLists.txt       (original)
+++ branches/itanium2/Model/Groups/CMakeLists.txt       Thu Jun 23 02:26:53 
2005
@@ -7,4 +7,6 @@
      Groups/kdtree.h
      Groups/kdtree.cc
      Groups/varray.h
+#     Groups/Grid.h
+#     Groups/Grid.cc
 )

Modified: branches/itanium2/Model/MiscObjects/CuttingPlane.cc
==============================================================================
--- branches/itanium2/Model/MiscObjects/CuttingPlane.cc (original)
+++ branches/itanium2/Model/MiscObjects/CuttingPlane.cc Thu Jun 23 02:26:53 
2005
@@ -2,7 +2,30 @@
 #include <Model/Intersections/AxisAlignedBox.h>
 #include <Model/Intersections/Plane.h>
 
+#include <iostream>
+
 using namespace Manta;
+
+void CuttingPlane::movePlaneAlongNormal( Real distance ) { 
+
+       plane_point = initial_point + (plane_normal * distance * 
movement_scale); 
+       
+       std::cout << "MovePlaneAlongNormal: " << plane_point << std::endl;
+};
+
+// Preprocess the internal object and compute its bounds.
+void CuttingPlane::preprocess( const PreprocessContext &context ) {
+       
+       // Call preprocess on the object.
+       internal_object->preprocess( context );
+       
+       // Compute its bounds.
+       internal_object->computeBounds( context, bounds );
+
+       // Determine how far away the edges of the bounding box are from the 
+       // initial point.
+       movement_scale = bounds.diagonal().length() * 0.5;
+}
 
 void CuttingPlane::intersect(const RenderContext& context, RayPacket& rays) 
const {
 

Modified: branches/itanium2/Model/MiscObjects/CuttingPlane.h
==============================================================================
--- branches/itanium2/Model/MiscObjects/CuttingPlane.h  (original)
+++ branches/itanium2/Model/MiscObjects/CuttingPlane.h  Thu Jun 23 02:26:53 
2005
@@ -18,22 +18,18 @@
                BBox bounds;             // Bounds of the internal object.
                Object *internal_object; // Object to be cut.
                
+               Real   movement_scale;
+               Point  initial_point;
+               
                Point  plane_point;
                Vector plane_normal;
                
        public:
     CuttingPlane( const Point &point_, const Vector &normal_, Object 
*internal_object_ ) :
-                       plane_point( point_ ), plane_normal( normal_ ), 
internal_object( internal_object_ ) {  }
+                       initial_point( point_ ), plane_point( point_ ), 
plane_normal( normal_ ), internal_object( internal_object_ ) {  }
                
                // Preprocess the internal object and compute its bounds.
-    void preprocess( const PreprocessContext &context ) {
-                       
-                       // Call preprocess on the object.
-                       internal_object->preprocess( context );
-                       
-                       // Compute its bounds.
-                       internal_object->computeBounds( context, bounds );
-               }
+    void preprocess( const PreprocessContext &context );
                
                // Return the bounds of the object.
     void computeBounds(const PreprocessContext& context, BBox& bbox) const { 
bbox.extendByBox( bounds ); };
@@ -52,7 +48,7 @@
                void setPlaneNormal( const Vector &plane_normal_ ) { 
plane_normal = plane_normal_; };
                
                // Move the plane point a signed distance along the plane 
normal.
-               void movePlaneAlongNormal( Real distance ) { plane_point += 
(plane_normal * distance); };
+               void movePlaneAlongNormal( Real distance );
        };
 }
 

Modified: branches/itanium2/fox/FMantaNavigator.h
==============================================================================
--- branches/itanium2/fox/FMantaNavigator.h     (original)
+++ branches/itanium2/fox/FMantaNavigator.h     Thu Jun 23 02:26:53 2005
@@ -39,7 +39,7 @@
                virtual long onMouseChange   ( FXObject *sender, FXSelector 
sel, void *data ) = 0;
                
                virtual void setControlSpeed( Real new_speed ) = 0;
-               virtual void resetToCamera( const Point &eye, const Point 
&lookat, const Vector &up ) = 0;
+               virtual void resetToCamera( const Point &eye, const Point 
&lookat, const Vector &up ) {  };
        };
 
 };

Modified: branches/itanium2/fox/FMantaQuakeNav.cc
==============================================================================
--- branches/itanium2/fox/FMantaQuakeNav.cc     (original)
+++ branches/itanium2/fox/FMantaQuakeNav.cc     Thu Jun 23 02:26:53 2005
@@ -39,7 +39,7 @@
 };
 
 void FMantaQuakeNav::turn( Real d ) { 
-       viewDirAngle += d; 
+       viewDirAngle += (d*0.5); 
 };
 
 void FMantaQuakeNav::tilt( Real d ) { 
@@ -132,12 +132,12 @@
   // use dx and dy to determine the view direction angle  
   double dx = lookat.x() - eye.x();
   double dy = lookat.y() - eye.y();
-  viewDirAngle = (float)atan2(dy,dx);
+  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 dV = sqrt(dx*dx+dy*dy);
-  viewElevAngle = (float)atan2(dZ,dV);
+  viewElevAngle = (float)atan2(dZ,dV)/TORADS;
 }
 
 
///////////////////////////////////////////////////////////////////////////////

Modified: branches/itanium2/fox/FMantaQuakeNav.h
==============================================================================
--- branches/itanium2/fox/FMantaQuakeNav.h      (original)
+++ branches/itanium2/fox/FMantaQuakeNav.h      Thu Jun 23 02:26:53 2005
@@ -105,6 +105,7 @@
                
                void setControlSpeed( Real new_speed ) { translateStepSize = 
new_speed; };
     void resetToCamera( const Point &eye, const Point &lookat, const Vector 
&up );
+
                
                // Transaction callback for manta thread. 
                void mantaThreadCallback() const;

Modified: branches/itanium2/fox/FMantaWindow.cc
==============================================================================
--- branches/itanium2/fox/FMantaWindow.cc       (original)
+++ branches/itanium2/fox/FMantaWindow.cc       Thu Jun 23 02:26:53 2005
@@ -8,6 +8,9 @@
 #include <Interface/Scene.h>
 #include <Interface/Object.h>
 #include <Interface/Context.h>
+#include <Model/Cameras/PinholeCamera.h>
+#include <Model/Cameras/OrthogonalCamera.h>
+#include <Model/Cameras/EnvironmentCamera.h>
 #include <Model/MiscObjects/CuttingPlane.h>
 
 #include <iostream>
@@ -21,18 +24,30 @@
        FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_QUIT,          
FMantaWindow::onQuit ),
        FXMAPFUNC(SEL_COMMAND, FXApp::ID_QUIT,                 
FMantaWindow::onQuit ),
        
-       FXMAPFUNC(SEL_CHANGED, FMantaWindow::ID_SPEED_SLIDER,  
FMantaWindow::onSpeedSlider ),
-       FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_BOOKMARK_LIST, 
FMantaWindow::onCameraBookmark ),
+       // Control options
+       FXMAPFUNC(SEL_CHANGED, FMantaWindow::ID_SPEED_SLIDER,   
FMantaWindow::onSpeedSlider ),
+       FXMAPFUNC(SEL_CHANGED, FMantaWindow::ID_CUTTING_SLIDER, 
FMantaWindow::onCuttingSlider ),
+       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 ),
+       
+       // Cameras.
+       FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_PINHOLE_CAMERA,     
FMantaWindow::onCamera ),
+       FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_ORTHO_CAMERA,       
FMantaWindow::onCamera ),
+       FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_ENVIRONMENT_CAMERA, 
FMantaWindow::onCamera ),
+       FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_TEXT_CAMERA,        
FMantaWindow::onCameraText ),       
        
        // Shadows.
-       FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_HARD_SHADOWS,  
FMantaWindow::onShadowAlgorithm ),
-       FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_NO_SHADOWS,    
FMantaWindow::onShadowAlgorithm ),
+       FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_HARD_SHADOWS, 
FMantaWindow::onShadowAlgorithm ),
+       FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_NO_SHADOWS,   
FMantaWindow::onShadowAlgorithm ),
+       FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_TEXT_SHADOWS, 
FMantaWindow::onShadowAlgorithmText ),
        
        // Samplers.
-       FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_SINGLE_SAMPLER, 
FMantaWindow::onPixelSampler ),
+       FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_SINGLE_SAMPLER,  
FMantaWindow::onPixelSampler ),
        FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_JITTER2_SAMPLER, 
FMantaWindow::onPixelSampler ),
        FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_JITTER4_SAMPLER, 
FMantaWindow::onPixelSampler ),
        FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_JITTER8_SAMPLER, 
FMantaWindow::onPixelSampler ),
+       FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_TEXT_SAMPLER,    
FMantaWindow::onPixelSamplerText ),
 
        // Cutting planes.
        FXMAPFUNC(SEL_LEFTBUTTONPRESS, FMantaImageFrame::ID_PIXEL_SELECT, 
FMantaWindow::onAddCuttingPlane )
@@ -45,7 +60,8 @@
        : FXMainWindow( app, name, ic, mi, opts, x, y, w, h, pl, pr, pt, pb, 
hs, vs ),
        
          manta_interface( 0 ),
-               fast_quit( false ) 
+               fast_quit( false ) ,
+               cutting_snap( 1 )
 {
        // Menu Bar.
        menu_bar = new FXMenuBar( this, LAYOUT_FILL_X );
@@ -55,42 +71,63 @@
        new FXMenuCommand( file_menu, "Quit", 0, this, ID_QUIT );
        new FXMenuTitle  ( menu_bar, "File", 0, file_menu );
        
+       // Camera menu.
+       camera_menu = new FXMenuPane( this );
+       new FXMenuCommand( camera_menu, "Pinhole Camera", 0, this, 
ID_PINHOLE_CAMERA );
+       new FXMenuCommand( camera_menu, "Orthogonal Camera", 0, this, 
ID_ORTHO_CAMERA );
+       new FXMenuCommand( camera_menu, "Environment Camera", 0, this, 
ID_ENVIRONMENT_CAMERA );
+       new FXMenuCommand( camera_menu, "Enter Text...", 0, this, 
ID_TEXT_CAMERA );
+       new FXMenuTitle  ( menu_bar, "Camera", 0, camera_menu );
+       
        // Shadow Menu.
        shadow_menu = new FXMenuPane( this );
        new FXMenuCommand( shadow_menu, "Hard Shadows", 0, this, 
ID_HARD_SHADOWS );
        new FXMenuCommand( shadow_menu, "No Shadows", 0, this, ID_NO_SHADOWS 
);
+       new FXMenuCommand( shadow_menu, "Enter Text...", 0, this, 
ID_TEXT_SHADOWS );
        new FXMenuTitle  ( menu_bar,  "Shadows", 0, shadow_menu );
        
        // Sampler menu.
-       /*
        sampler_menu = new FXMenuPane( this );
-       new FXMenuCommand( sampler_menu, "Single Sample", 0, this, 
ID_SINGLE_SAMPLER );
+       new FXMenuCommand( sampler_menu, "Single Sample", 0, this,    
ID_SINGLE_SAMPLER );
        new FXMenuCommand( sampler_menu, "Jitter 2 Samples", 0, this, 
ID_JITTER2_SAMPLER );
        new FXMenuCommand( sampler_menu, "Jitter 4 Samples", 0, this, 
ID_JITTER4_SAMPLER );
        new FXMenuCommand( sampler_menu, "Jitter 8 Samples", 0, this, 
ID_JITTER8_SAMPLER );
+       new FXMenuCommand( sampler_menu, "Enter Text...", 0, this,    
ID_TEXT_SAMPLER );
        new FXMenuTitle( menu_bar, "Samplers", 0, sampler_menu );
-        */
-       // Config Menu.
-       // config_menu = new FXMenuPane( this );
-       // new FXMenuCommand( config_menu, "Cutting Planes", 0, 
cutting_dialog, FMantaCuttingDialog::ID_SHOW );
+
+       // Options menu.
+       options_menu = new FXMenuPane( this );
+       new FXMenuCheck( options_menu, "Snap Cutting Planes", new 
FXDataTarget( cutting_snap ), FXDataTarget::ID_VALUE );
+       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 );
        
-       FXComposite *left_controls  = new FXVerticalFrame  ( frame, 
LAYOUT_FILL_Y|LAYOUT_LEFT );
+       FXComposite *left_controls  = new FXVerticalFrame( frame, 
LAYOUT_FILL_Y|LAYOUT_LEFT );
        FXComposite *viewers        = new FXVerticalFrame( frame, LAYOUT_FILL 
);
-       // FXComposite *bottom_controls = new FXHorizontalFrame  ( frame, 
LAYOUT_FILL_X|LAYOUT_BOTTOM );
+       FXComposite *right_controls = new FXVerticalFrame( frame, 
LAYOUT_FILL_Y|LAYOUT_RIGHT );
 
        // Manta Image Frame.
        manta_frame = new FMantaImageFrame( viewers, app, this, width, 
height, 0 );
        
        // Control speed.
        speed_slider = new FXRealSlider( left_controls, this, 
ID_SPEED_SLIDER, REALSLIDER_VERTICAL|LAYOUT_FILL_Y );
-       speed_slider->setRange( 0.001, 1.0 );
+       speed_slider->setRange( 0.001, 5.0 );
+       
+       // Cutting plane slider.
+       cutting_slider = new FXRealSlider( right_controls, this, 
ID_CUTTING_SLIDER, REALSLIDER_VERTICAL|LAYOUT_FILL_Y );
+       cutting_slider->setRange( -1.0, 1.0 );
+       cutting_slider->setValue( 0.0 );
+       cutting_slider->disable();
        
-       // Camera bookmarks.
        frame = new FXHorizontalFrame( viewers, LAYOUT_FILL_X );
+
+       // Navigators.
+       navigator_list = new FXListBox( frame, this, ID_NAVIGATOR_LIST, 
LAYOUT_BOTTOM|COMBOBOX_STATIC,0,0,0,20 );
+       navigator_list->setNumVisible( 3 );
        
+       // Camera bookmarks.
        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 );
        
@@ -117,11 +154,32 @@
        // Set the control speed for interaction.
        Real new_speed = *((double *)data);
        
-       std::cout << "Control speed: " << new_speed << std::endl;
+       // std::cout << "Control speed: " << new_speed << std::endl;
        manta_frame->getNavigator()->setControlSpeed( new_speed );
        return 1;
 }
 
+long FMantaWindow::onCuttingSlider( FXObject *sender, FXSelector key, void 
*data ) {
+       
+       // Set the control speed for interaction.
+       Real amount = *((double *)data);
+       
+       manta_interface->addTransaction("Move Cutting Plane.",
+               
Callback::create(this,&FMantaWindow::mantaMoveCuttingPlane,amount));
+       
+       return 1;
+}      
+
+long FMantaWindow::onCuttingFlip( FXObject *sender, FXSelector key, void 
*data ) {
+
+       std::cout << "onCuttingFlip" << std::endl;
+
+       manta_interface->addTransaction("Flip Cutting Plane.",
+               Callback::create(this,&FMantaWindow::mantaFlipCuttingPlane));
+
+       return 1;
+}
+
 long FMantaWindow::onCameraBookmark( FXObject *sender, FXSelector key, void 
*data ) {
 
        // Determine the selected index.
@@ -145,6 +203,49 @@
        return 1;
 }
 
+long FMantaWindow::onCamera( FXObject *sender, FXSelector key, void *data ) {
+
+       // Determine which shadow algorithm to use.
+       int id = FXSELID( key );
+       
+       // Get the channel's camera.
+       int channel = manta_frame->getMantaChannel();
+       Camera *camera = manta_interface->getCamera( channel );
+       Camera *new_camera = 0;
+       
+       switch (id) {
+               case ID_PINHOLE_CAMERA:
+                       new_camera = new PinholeCamera( 
camera->getPosition(), camera->getLookAt(), camera->getUp(), 60.0 );
+                       manta_interface->addTransaction("Camera",
+                               
Callback::create(this,&FMantaWindow::mantaCamera1,new_camera));
+                       break;
+               case ID_ORTHO_CAMERA:
+                       new_camera = new OrthogonalCamera( 
camera->getPosition(), camera->getLookAt(), camera->getUp(), 10.0 );
+                       manta_interface->addTransaction("Camera",
+                                                                             
                                                                          
Callback::create(this,&FMantaWindow::mantaCamera1,new_camera));
+                       break;
+               case ID_ENVIRONMENT_CAMERA:
+                       new_camera = new EnvironmentCamera( 
camera->getPosition(), camera->getLookAt(), camera->getUp() );
+                       manta_interface->addTransaction("Camera",
+                                                                             
                                                                          
Callback::create(this,&FMantaWindow::mantaCamera1,new_camera));
+                       break;
+       };
+
+       return 1;
+}
+
+long FMantaWindow::onCameraText( FXObject *sender, FXSelector key, void 
*data ) {
+
+       // Collect a string from the user.
+       FXString description;
+       if (FXInputDialog::getString(description, getApp(), "Enter Text..", 
"Camera Spec:", 0 )) {
+               manta_interface->addTransaction("Camera",
+                       
Callback::create(this,&FMantaWindow::mantaCamera2,string(description.text())));
+       }
+
+       return 1;
+}
+
 long FMantaWindow::onShadowAlgorithm( FXObject *sender, FXSelector key, void 
*data ) {
 
        // Determine which shadow algorithm to use.
@@ -164,6 +265,18 @@
        return 1;
 }
 
+long FMantaWindow::onShadowAlgorithmText( FXObject *sender, FXSelector key, 
void *data ) {
+       
+       // Collect a string from the user.
+       FXString description;
+       if (FXInputDialog::getString(description, getApp(), "Enter Text..", 
"Shadow Algorithm Spec:", 0 )) {
+               manta_interface->addTransaction("Shadow Algorithm.",
+                       
Callback::create(this,&FMantaWindow::mantaShadowAlgorithm,string(description.text())));
+       }
+       
+       return 1;
+}
+
 long FMantaWindow::onPixelSampler( FXObject *sender, FXSelector key, void 
*data ) {
        
        // Determine which shadow algorithm to use.
@@ -191,6 +304,17 @@
        return 1;
 }
 
+long FMantaWindow::onPixelSamplerText( FXObject *sender, FXSelector key, 
void *data ) {
+
+       // Collect a string from the user.
+       FXString description;
+       if (FXInputDialog::getString(description, getApp(), "Enter Text", 
"Pixel Sampler Spec:", 0 )) {
+               manta_interface->addTransaction("Pixel Sampler.",
+                       
Callback::create(this,&FMantaWindow::mantaPixelSampler,string(description.text())));
+       }
+
+       return 1;
+}
 
 long FMantaWindow::onAddCuttingPlane( FXObject *sender, FXSelector key, void 
*data ) {
 
@@ -204,8 +328,29 @@
        // Shoot a ray into the scene.
        if (manta_frame->shootOneRay( event->win_x, event->win_y, point, 
normal )) {
                
-               // Point eye = manta_interface->getCamera( 
manta_frame->getMantaChannel() )->getPosition();
-               // normal = (eye - point).normal();
+               // Check to see if the cutting plane should be snapped to an 
axis.
+               if (cutting_snap) {
+               
+                       Real   snap_data[] = {  1.0, 0.0, 0.0 ,
+                                                                             
                                    0.0, 1.0, 0.0 ,
+                                                                             
                                    0.0, 0.0, 1.0 ,
+                                                                             
                                   -1.0, 0.0, 0.0 ,
+                                                                             
                                    0.0,-1.0, 0.0 ,
+                                                                             
                                    0.0, 0.0,-1.0  };
+                       Vector *snap_axis = (Vector *)snap_data;
+                       // Find the axis with the greatest dot product.
+                       Real max_dot = 0.0;
+                       int max_axis = 0;
+                       for (int i=0;i<6;++i) {
+                               Real d = Dot( snap_axis[i], normal );
+                               if (d > max_dot) {
+                                       max_dot = d;
+                                       max_axis = i;
+                               }
+                       }
+                       
+                       normal = snap_axis[ max_axis ];
+               }
                
                std::cout << "Adding cutting plane" << std::endl;
                std::cout << point << std::endl;
@@ -214,11 +359,44 @@
                // Add a cutting plane at this point.
                manta_interface->addTransaction("Add Cutting Plane",
                        
Callback::create(this,&FMantaWindow::mantaAddCuttingPlane,point,normal));
+               
+               // Enable the cutting plane slider.
+               cutting_slider->enable();
+               cutting_flip->enable();
+               cutting_slider->setValue( 0.0 );
+               
+       }
+       else {
+               // Remove the cutting plane if one exists.
+               manta_interface->addTransaction("Remove Cutting Plane",
+                       
Callback::create(this,&FMantaWindow::mantaRemoveCuttingPlane));
+               cutting_slider->disable();
+               cutting_flip->disable();
        }
        
        return 1;
 };
 
+long FMantaWindow::onNavigator( FXObject *sender, FXSelector key, void *data 
) {
+
+       // Determine the selected index.
+       int index = (FXint)(FXival)data;
+       
+       // 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 1;
+}
+
 
///////////////////////////////////////////////////////////////////////////////
 
 void FMantaWindow::mantaThreadBookmark( const string camera_text ) {
@@ -240,6 +418,44 @@
        }
 }
 
+void FMantaWindow::mantaCamera1( Camera *new_camera ) {
+       
+       // Determine the channel number.
+       int channel = manta_frame->getMantaChannel();
+       
+       // Get the old camera.
+       Camera *old_camera = manta_interface->getCamera( channel );
+       
+       // Replace the camera.
+       manta_interface->setCamera( channel, new_camera );
+       
+       delete old_camera;
+}
+
+void FMantaWindow::mantaCamera2( const string text ) {
+       
+       // Determine the channel number.
+       int channel = manta_frame->getMantaChannel();
+       
+       // Update the shadow algorithm.
+       Camera *new_camera = manta_interface->createCamera( text );
+       if (new_camera == 0) {
+               std::cout << "Could not select camera " << text << std::endl;
+               return;
+       }
+       
+       // Get the old camera.
+       Camera *old_camera = manta_interface->getCamera( channel );
+       
+       // Replace the camera.
+       manta_interface->setCamera( channel, new_camera );
+       
+       delete old_camera;
+       
+       // This is unsafe.
+manta_frame->getNavigator()->resetToCamera( 
new_camera->getPosition(),new_camera->getLookAt(),new_camera->getUp());
+}
+
 void FMantaWindow::mantaShadowAlgorithm( const string text ) const {
 
        // Determine the channel number.
@@ -256,12 +472,9 @@
        // Determine the channel number.
        int channel = manta_frame->getMantaChannel();
        
-       std::cout << "Doesn't work yet." << std::endl;
-       
-       // Update the shadow algorithm.
-       //if (!manta_interface->selectPixelSampler( text )) {
-       //      std::cout << "Could not select pixel sampler " << text << 
std::endl;
-       ///}
+       if (!manta_interface->selectPixelSampler( text )) {
+               std::cout << "Could not select pixel sampler " << text << 
std::endl;
+       }
 }
 
 
///////////////////////////////////////////////////////////////////////////////
@@ -275,6 +488,12 @@
        camera_text_list.push_back( camera_text );
 }
 
+void FMantaWindow::addNavigatorOption( const string &description, 
FMantaNavigator *nav ) {
+
+       // Add the navigator to the list.
+       navigator_list->appendItem( description.c_str(), 0, nav );
+}
+
 // This method is called by the manta thread to add a cutting plane.
 void FMantaWindow::mantaAddCuttingPlane( Point point, Vector normal ) const {
        
@@ -304,6 +523,58 @@
                // Place the cutting plane at the top of the tree.
                scene->setObject( cutting_plane );
        }
-};
+}
 
+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();
+
+       CuttingPlane *cutting_plane = dynamic_cast< CuttingPlane * >( 
root_object );
+       if (cutting_plane) {
+       
+               // Replace the root object by the cutting plane's child.
+               scene->setObject( cutting_plane->getObject() );
+               
+               // Delete the cutting plane.
+               delete cutting_plane;
+       }
+}
+
+void FMantaWindow::mantaMoveCuttingPlane( Real amount ) const {
+
+       // Add a cutting plane on top of the root object.
+       Scene *scene = manta_interface->getScene();
+       Object *root_object = scene->getObject();
+       
+       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 );
+       }       
+}
+
+void FMantaWindow::mantaFlipCuttingPlane() const {
+       
+       // Add a cutting plane on top of the root object.
+       Scene *scene = manta_interface->getScene();
+       Object *root_object = scene->getObject();
+       
+       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;
+               cutting_plane->getPlaneNormal( normal );
+               normal *= -1.0;
+               cutting_plane->setPlaneNormal( normal );
+       }       
+}

Modified: branches/itanium2/fox/FMantaWindow.h
==============================================================================
--- branches/itanium2/fox/FMantaWindow.h        (original)
+++ branches/itanium2/fox/FMantaWindow.h        Thu Jun 23 02:26:53 2005
@@ -34,15 +34,23 @@
                // Fox GUI Components.
                FXMenuBar  *menu_bar;
                FXMenuPane *file_menu;
+               FXMenuPane *camera_menu;
                FXMenuPane *shadow_menu;
                FXMenuPane *sampler_menu;
-               FXMenuPane *cutting_menu;
+               FXMenuPane *options_menu;
+               FXMenuCommand *cutting_flip;
                
                FXRealSlider  *speed_slider;
-               FXLabel       *speed_text;
+               FXRealSlider  *cutting_slider;
+               int cutting_snap;
+               
+               // Camera options.
                FXListBox     *camera_bookmark_list;
                vector<string> camera_text_list;
                
+               // Navigator options.
+               FXListBox     *navigator_list; // User data field will hold 
pointer to navigator.
+               
                // Image panels for displaying output.
                FMantaImageFrame *manta_frame;
                
@@ -53,20 +61,33 @@
                enum {
                        ID_QUIT = FXMainWindow::ID_LAST, // Sent when the 
application must quit.
                        ID_SPEED_SLIDER,                 // Control speed 
slider was changed.
+                       ID_CUTTING_SLIDER,               // Cutting plane 
slider was changed.
+                       ID_CUTTING_FLIP,
                        
                        // Bookmarks.
                        ID_BOOKMARK_LIST,                // User selected a 
camera bookmark.
                        ID_ADD_BOOKMARK,
                        
+                       // Navigators.
+                       ID_NAVIGATOR_LIST,
+                       
+                       // Shadow options.
+                       ID_PINHOLE_CAMERA,
+                       ID_ORTHO_CAMERA,
+                       ID_ENVIRONMENT_CAMERA,
+                       ID_TEXT_CAMERA,
+                       
                        // Shadow options.
                        ID_HARD_SHADOWS,
                        ID_NO_SHADOWS, 
+                       ID_TEXT_SHADOWS,
                        
                        // Multisample options.
                        ID_SINGLE_SAMPLER,
                        ID_JITTER2_SAMPLER,
                        ID_JITTER4_SAMPLER,
                        ID_JITTER8_SAMPLER,
+                       ID_TEXT_SAMPLER,    // User wants to enter a 
description manually.
                        
                        // Cutting planes.
                        ID_ADD_CUTTING_PLANE,
@@ -76,23 +97,31 @@
                
                // Constructors.
                FMantaWindow() : manta_interface( 0 ), fast_quit( false ) {  
};
-               FMantaWindow( FXApp *app, const FXString &name, int width = 
256, int height = 256,
+               FMantaWindow( FXApp *app, const FXString &name, int width = 
512, int height = 512,
                              FXIcon *ic=NULL,FXIcon *mi=NULL,FXuint 
opts=(DECOR_ALL),
-                                                                       FXint 
x=20,FXint y=20,FXint w=256,FXint h=256,FXint pl=0,FXint pr=0,FXint 
pt=0,FXint pb=0,FXint hs=0,FXint vs=0);
+                                                                       FXint 
x=20,FXint y=20,FXint w=512,FXint h=512,FXint pl=0,FXint pr=0,FXint 
pt=0,FXint pb=0,FXint hs=0,FXint vs=0);
                
                // Setup
-               void addCameraBookmark( const string &description, const 
string &camera_text );
-               
+               void addCameraBookmark ( const string &description, const 
string &camera_text );
+               void addNavigatorOption( const string &description, 
FMantaNavigator *nav );
+
                // Create the window.
                void create() { FXMainWindow::create(); show( 
PLACEMENT_DEFAULT ); };
                
                // Message handlers.
                long onQuit           ( FXObject *sender, FXSelector key, 
void *data );
                long onSpeedSlider    ( FXObject *sender, FXSelector key, 
void *data );
+               long onCuttingSlider  ( FXObject *sender, FXSelector key, 
void *data );
+               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 onAddBookmark    ( FXObject *sender, FXSelector key, 
void *data );
+               long onCamera         ( FXObject *sender, FXSelector key, 
void *data );
+               long onCameraText     ( FXObject *sender, FXSelector key, 
void *data );
                long onShadowAlgorithm( FXObject *sender, FXSelector key, 
void *data );
+               long onShadowAlgorithmText( FXObject *sender, FXSelector key, 
void *data );
                long onPixelSampler   ( FXObject *sender, FXSelector key, 
void *data );
+               long onPixelSamplerText( FXObject *sender, FXSelector key, 
void *data );
                long onAddCuttingPlane( FXObject *sender, FXSelector key, 
void *data );
                
                // Accessors.
@@ -106,6 +135,10 @@
                // This method is called by the manta thread to replace the 
camera.
                void mantaThreadBookmark( const string camera_text );
                
+               // This method is called by the manta thread to replace the 
camera.
+               void mantaCamera2( const string camera_text );
+               void mantaCamera1( Camera *new_camera );
+               
                // This method is called by the manta thread to replace the 
shadow algorithm.
                void mantaShadowAlgorithm( const string shadow_text ) const;
                
@@ -114,6 +147,9 @@
                
                // This method is called by the manta thread to add a cutting 
plane.
                void mantaAddCuttingPlane( Point point, Vector normal ) const;
+               void mantaRemoveCuttingPlane() const;
+               void mantaMoveCuttingPlane( Real amount ) const;
+               void mantaFlipCuttingPlane() const;
                
        };
 };

Modified: branches/itanium2/fox/fox_manta.cc
==============================================================================
--- branches/itanium2/fox/fox_manta.cc  (original)
+++ branches/itanium2/fox/fox_manta.cc  Thu Jun 23 02:26:53 2005
@@ -53,8 +53,8 @@
        FXApp app( "", "Abe Stephens -- SGI" );
        app.init( argc, argv );
 
-       int width = 256;
-       int height = 256;
+       int width = 512;
+       int height = 512;
 
        // Add an FMantaWindow.
        FMantaWindow manta_window( &app, "Open-Source MANTA. Silicon Graphics 
Inc. and SCI Institute, University of Utah", width, height );
@@ -70,7 +70,7 @@
        manta_interface->selectImageType      ( "rgba8" );
        manta_interface->selectLoadBalancer   ( "workqueue" );
        manta_interface->selectImageTraverser ( "tiled" );
-       manta_interface->selectPixelSampler   ( "singlesample" );
+       manta_interface->selectPixelSampler   ( "jittersample( 
-numberOfSamples 4 )" );
        manta_interface->selectRenderer       ( "raytracer" );
        manta_interface->selectShadowAlgorithm( "hard" );
        
@@ -84,25 +84,21 @@
        GLXImageDisplay glx_image_display( (XVisualInfo 
*)manta_frame->getVisual()->getInfo(),
                                      (Window)       manta_frame->id() );
        
+       // Create a default quake navigator.
+       std::cerr << "Using default video game navigator." << std::endl;
+       FMantaQuakeNav *quake_nav = new FMantaQuakeNav();
+       quake_nav->setMantaInterface( manta_interface );
+       manta_window.addNavigatorOption( "Video Game", quake_nav );
+
        // Create a navigator for the image frame.
-       FMantaNavigator *nav = 0;
-       if (nav_text == "uniform") {
-               // Create a uniform navigator.
-               FMantaUniformNav *uniform_nav = new FMantaUniformNav();
-               uniform_nav->setMantaInterface( manta_interface );
-               uniform_nav->setMantaChannel( 0 );
-               
-               nav = uniform_nav;
-       }
-       else {
-               // Create a default quake navigator.
-               std::cerr << "Using default video game navigator." << 
std::endl;
-               FMantaQuakeNav *quake_nav = new FMantaQuakeNav();
-               quake_nav->setMantaInterface( manta_interface );
-               nav = quake_nav;
-       }
-       
-       manta_window.setNavigator( nav );
+       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

Modified: branches/itanium2/manta-commands.txt
==============================================================================
--- branches/itanium2/manta-commands.txt        (original)
+++ branches/itanium2/manta-commands.txt        Thu Jun 23 02:26:53 2005
@@ -12,3 +12,6 @@
 
 # Massive cross section NOTE RESOLUTION
 dplace -c 1-511 bin/manta -res 46080x14400 -bench 1 0 -np 508 -scene 
"lib/libscene_boeing777.so( -file /dev/shm/Boeing777.v3c1 -np 64 -cutting 
default )" -camera "pinhole( -eye 1408.56 -2172.05 110.736  -lookat 1350.55 
188.313 354.277  -up 0.0117111 -0.465077 0.885192  -fov 60 )" -shadows 
noshadows -imagedisplay "file( /tmp/test_img46080x14400 )
+
+# Boeing demo.
+dplace -c 1-121 bin/fox_manta -np 118 -scene "lib/libscene_boeing777.so( 
-file /dev/shm/Boeing777.v3c1 -np 64 )"
\ No newline at end of file




  • [MANTA] r407 - in branches/itanium2: . Engine/Control Model/Cameras Model/Groups Model/MiscObjects fox, abe, 06/23/2005

Archive powered by MHonArc 2.6.16.

Top of page