Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r401 - in branches/itanium2: Engine/Control Interface Model/MiscObjects fox


Chronological Thread 
  • From: abe@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r401 - in branches/itanium2: Engine/Control Interface Model/MiscObjects fox
  • Date: Tue, 21 Jun 2005 03:23:52 -0600 (MDT)

Author: abe
Date: Tue Jun 21 03:23:46 2005
New Revision: 401

Modified:
   branches/itanium2/Engine/Control/RTRT.cc
   branches/itanium2/Engine/Control/RTRT.h
   branches/itanium2/Interface/CMakeLists.txt
   branches/itanium2/Interface/Callback.h
   branches/itanium2/Interface/CallbackHelpers.h
   branches/itanium2/Interface/RTRTInterface.h
   branches/itanium2/Model/MiscObjects/CuttingPlane.h
   branches/itanium2/fox/FMantaImageFrame.cc
   branches/itanium2/fox/FMantaImageFrame.h
   branches/itanium2/fox/FMantaUniformNav.cc
   branches/itanium2/fox/FMantaWindow.cc
   branches/itanium2/fox/FMantaWindow.h
Log:




M    fox/FMantaUniformNav.cc
M    fox/FMantaWindow.cc
M    fox/FMantaWindow.h
M    fox/FMantaImageFrame.cc
M    fox/FMantaImageFrame.h
Improvements to demo. Remaining:
1.) Make bookmarks work with quake camera.
2.) *** Cutting plane GUI.

M    Model/MiscObjects/CuttingPlane.h
M    Interface/CMakeLists.txt
M    Interface/Callback.h
M    Interface/RTRTInterface.h
M    Interface/CallbackHelpers.h
M    Engine/Control/RTRT.cc
M    Engine/Control/RTRT.h

Added experimental method to RTRT to shoot one ray. Use it for placing a 
cutting plane (works sometimes).

I'm not thrilled with the interface for sending a "standalone" ray. It's 
quite messy. We'll have to revisit this, I think it is a useful feature.



Modified: branches/itanium2/Engine/Control/RTRT.cc
==============================================================================
--- branches/itanium2/Engine/Control/RTRT.cc    (original)
+++ branches/itanium2/Engine/Control/RTRT.cc    Tue Jun 21 03:23:46 2005
@@ -38,6 +38,7 @@
 #include <stdio.h>
 #include <iostream>
 
+#include <Interface/Material.h>
 
 using namespace Manta;
 using namespace std;
@@ -938,6 +939,11 @@
   scene = newScene;
 }
 
+Scene *RTRT::getScene() {
+
+       return scene;
+}
+
 bool RTRT::readScene(const string& spec)
 {
   string name;
@@ -1115,3 +1121,47 @@
   transactions.push_back(transaction);
   transaction_lock.unlock();
 }
+
+///////////////////////////////////////////////////////////////////////////////
+
+// Experimental. Shoot one ray from the calling thread. Populates the result 
ray
+// packet datastructure. Useful for debugging. Very un-thread-safe.
+
+void RTRT::shootOneRay( Color &result_color, RayPacket &result_rays, Real 
image_x, Real image_y, int channel_index ) {
+
+       // Only shoot one ray.
+       result_rays.resize( 1 );
+
+       // Set the image space coordinates of the pixel.
+       result_rays.setPixel(0, 0, image_x, image_y, &result_color );
+       result_rays.setFlag ( RayPacket::HaveImageCoordinates );
+       
+       // Get a pointer to the channel.
+       Channel *channel = channels[ channel_index ];
+       
+       // Create a render context.
+       RenderContext render_context(this, channel_index, -1, 
workersRendering, 0,
+                                                                             
                               currentLoadBalancer, currentPixelSampler,
+                                                                             
                                           currentRenderer, 
currentShadowAlgorithm,
+                                                                             
                                           channel->camera, scene );
+
+       // Send this to the renderer.
+       currentRenderer->traceEyeRays( render_context, result_rays );
+       
+       // Check to see if the ray hit anything.
+       if (result_rays.hitInfo(0).wasHit()) {
+       
+               // Compute hit positions.
+               result_rays.computeHitPositions();
+       
+               // Compute the normal.
+               result_rays.computeNormals( render_context );
+               
+               // Shade.
+               result_rays.hitInfo(0).hitMaterial()->shade( render_context, 
result_rays );
+       }
+}
+
+
+
+

Modified: branches/itanium2/Engine/Control/RTRT.h
==============================================================================
--- branches/itanium2/Engine/Control/RTRT.h     (original)
+++ branches/itanium2/Engine/Control/RTRT.h     Tue Jun 21 03:23:46 2005
@@ -14,6 +14,11 @@
 #include <set>
 #include <vector>
 
+// The following are used by shootOneRay (experimental)
+#include <MantaTypes.h>
+#include <Interface/RayPacket.h>
+#include <Core/Color/Color.h>
+
 namespace SCIRun {
   class Thread;
 }
@@ -88,6 +93,7 @@
     // Scenes
     virtual bool haveScene();
     virtual void setScene(Scene* scene);
+               virtual Scene *getScene();
     virtual bool readScene(const string& sceneSpec/*, const vector<string> 
&args*/);
     virtual void setScenePath(const string& path);
 
@@ -133,7 +139,12 @@
 
     // Transactions
     virtual void addTransaction(TransactionBase*);
-  protected:
+               
+               // Debug:
+               void shootOneRay( Color &result_color, RayPacket 
&result_rays, Real image_x, Real image_y, int channel_index );
+  
+       
+       protected:
     friend class Worker;
     void internalRenderLoop(int workerIndex, bool lateComerFlag);
 

Modified: branches/itanium2/Interface/CMakeLists.txt
==============================================================================
--- branches/itanium2/Interface/CMakeLists.txt  (original)
+++ branches/itanium2/Interface/CMakeLists.txt  Tue Jun 21 03:23:46 2005
@@ -38,6 +38,7 @@
         RTRTInterface.cc
         SetupCallback.h
         SetupCallback.cc
+        Scene.h
         ShadowAlgorithm.h
         ShadowAlgorithm.cc
         TexCoordMapper.h

Modified: branches/itanium2/Interface/Callback.h
==============================================================================
--- branches/itanium2/Interface/Callback.h      (original)
+++ branches/itanium2/Interface/Callback.h      Tue Jun 21 03:23:46 2005
@@ -36,6 +36,12 @@
     create(T* ptr, void (T::*pmf)(Arg1, Arg2), Arg1 arg1, Arg2 arg2) {
       return new Callback_0Data_2Arg<T, Arg1, Arg2>(ptr, pmf, arg1, arg2);
     }
+               
+               template<class T, typename Arg1, typename Arg2> static
+    CallbackBase_0Data*
+    create(T* ptr, void (T::*pmf)(Arg1, Arg2) const, Arg1 arg1, Arg2 arg2) {
+      return new Callback_0Data_2Arg_const<T, Arg1, Arg2>(ptr, pmf, arg1, 
arg2);
+    }
 
                template<class T, typename Arg1, typename Arg2, typename 
Arg3, typename Arg4> static
     CallbackBase_0Data*

Modified: branches/itanium2/Interface/CallbackHelpers.h
==============================================================================
--- branches/itanium2/Interface/CallbackHelpers.h       (original)
+++ branches/itanium2/Interface/CallbackHelpers.h       Tue Jun 21 03:23:46 
2005
@@ -221,6 +221,27 @@
     Arg2 arg2;
   };
 
+       template<class T, typename Arg1, typename Arg2>
+       class Callback_0Data_2Arg_const : public CallbackBase_0Data {
+       public:
+               Callback_0Data_2Arg_const(T* ptr, void (T::*pmf)(Arg1, Arg2) 
const, Arg1 arg1, Arg2 arg2)
+               : ptr(ptr), pmf(pmf), arg1(arg1), arg2(arg2)
+       {
+       }
+               virtual ~Callback_0Data_2Arg_const()
+       {
+       }
+               virtual void call()
+       {
+                       (ptr->*pmf)(arg1, arg2);
+       }
+       private:
+               T* ptr;
+               void (T::*pmf)(Arg1, Arg2) const;
+               Arg1 arg1;
+               Arg2 arg2;
+       };
+
        template<class T, typename Arg1, typename Arg2, typename Arg3, 
typename Arg4 >
                class Callback_0Data_4Arg : public CallbackBase_0Data {
        public:

Modified: branches/itanium2/Interface/RTRTInterface.h
==============================================================================
--- branches/itanium2/Interface/RTRTInterface.h (original)
+++ branches/itanium2/Interface/RTRTInterface.h Tue Jun 21 03:23:46 2005
@@ -106,6 +106,7 @@
     // Scenes
     virtual bool haveScene() = 0;
     virtual void setScene(Scene* scene) = 0;
+               virtual Scene *getScene() = 0;
     virtual bool readScene(const string& sceneSpec) = 0;
     virtual void setScenePath(const string& path) = 0;
 
@@ -153,6 +154,7 @@
 
     // Transactions
     virtual void addTransaction(TransactionBase*) = 0;
+               
     template<class T, class Op>
       void addTransaction(const char* name, TValue<T>& value, Op op)
       {

Modified: branches/itanium2/Model/MiscObjects/CuttingPlane.h
==============================================================================
--- branches/itanium2/Model/MiscObjects/CuttingPlane.h  (original)
+++ branches/itanium2/Model/MiscObjects/CuttingPlane.h  Tue Jun 21 03:23:46 
2005
@@ -40,7 +40,20 @@
     
                // Intersection method.
                void intersect(const RenderContext& context, RayPacket& rays) 
const;
-  };
+               
+               // Accessors.
+               const BBox &getBounds() { return bounds; };
+               Object     *getObject() { return internal_object; };
+               
+               void  getPlanePoint ( Point &result ) { result = plane_point; 
};
+               void  getPlaneNormal( Vector &result ) { result = 
plane_normal; };
+  
+               void setPlanePoint ( const Point &plane_point_ )   { 
plane_point = plane_point_; };
+               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); };
+       };
 }
 
 #endif

Modified: branches/itanium2/fox/FMantaImageFrame.cc
==============================================================================
--- branches/itanium2/fox/FMantaImageFrame.cc   (original)
+++ branches/itanium2/fox/FMantaImageFrame.cc   Tue Jun 21 03:23:46 2005
@@ -1,6 +1,7 @@
 
 #include <fox/FMantaImageFrame.h>
 
+
 #include <fxkeys.h>
 
 #include <iostream>
@@ -29,9 +30,10 @@
 
FXIMPLEMENT(FMantaImageFrame,FXGLCanvas,FMantaImageFrameMap,ARRAYNUMBER(FMantaImageFrameMap));
 
 // Constructor, creates a GLX Visual with a double buffer.
-FMantaImageFrame::FMantaImageFrame( FXComposite *p, FXApp *app, int width, 
int height, RTRTInterface *manta_interface_ ) 
+FMantaImageFrame::FMantaImageFrame( FXComposite *p, FXApp *app, FXObject 
*target_, int width, int height, RTRTInterface *manta_interface_ ) 
        : FXGLCanvas( p, new FXGLVisual( app, VISUAL_DOUBLEBUFFER ), this, 
ID_IMAGE, 
                      LAYOUT_FILL|LAYOUT_TOP, 0, 0, width, height ),
+               fox_target( target_ ),
          manta_interface( manta_interface_ ) 
 {
 }
@@ -56,9 +58,15 @@
        FXEvent *event = (FXEvent *)data;
        FXushort sel_type = FXSELTYPE( sel );
 
-       // std::cerr << "In onMouseChange " << event->win_x << " " 
-       //                                  << event->win_y << std::endl;
-                                       
+       // std::cout << "Click count: " << event->click_count << std::endl;
+
+       // Check for a double click.
+       if (event->click_count == 2) {
+               if (fox_target)
+                       return 
fox_target->handle(this,FXSEL(FXSELTYPE(sel),ID_PIXEL_SELECT),data);
+               return 0;
+       }
+
        // Check to see if a button is pressed.
        return navigator->onMouseChange( sender, sel, data );
 
@@ -77,11 +85,57 @@
 long FMantaImageFrame::onKeyPress   ( FXObject *sender, FXSelector sel, void 
*data ) {
 
        FXEvent *event = (FXEvent *)data;
+
+       return navigator->onKeyPress( sender, sel, data );
+}
+
+bool FMantaImageFrame::shootOneRay( int pixel_x, int pixel_y, Point 
&result_position, Vector &result_normal ) {
+
+       // Make sure we have an instance of RTRT.
+       RTRT *rtrt = dynamic_cast< RTRT * >( manta_interface );
+       if (rtrt == 0) {
+               return false;
+       }
        
-       // Check for a quit only by default.
-       if (event->text[0] == 'q') {
-               return 0;
+       // Determine the resolution of the actual image.
+       int xres, yres;
+       bool stereo;
+       rtrt->getResolution( manta_channel, stereo, xres, yres );
+       
+       // Determine the image coordinates of the pixel.
+       Real image_x, image_y;
+       
+       // Scale between [-1,1]
+       Real xscale = 2./xres;
+  Real yscale = xscale;
+  Real xoffset = (-xres/2.+0.5)*xscale; // Offset to pixel center
+  Real yoffset = (-yres/2.+0.5)*yscale;
+       
+       image_x = pixel_x * xscale + xoffset;
+       image_y = pixel_y * yscale + yoffset;
+       
+       // Create a ray packet.
+       RayPacketData data;
+       RayPacket rays( data, 1, 0, 0 );
+       
+       // Shoot the ray.
+       Color color;
+       rtrt->shootOneRay( color, rays, image_x, image_y, manta_channel );
+       
+       // Check for a result.
+       if (rays.hitInfo(0).wasHit()) {
+       
+               // Get the normal.
+               result_position = rays.get(0).hitPosition;
+               result_normal   = rays.get(0).normal;
+       
+               return true;
        }
+       
+       return false;
 
-       return navigator->onKeyPress( sender, sel, data );
 }
+
+
+
+

Modified: branches/itanium2/fox/FMantaImageFrame.h
==============================================================================
--- branches/itanium2/fox/FMantaImageFrame.h    (original)
+++ branches/itanium2/fox/FMantaImageFrame.h    Tue Jun 21 03:23:46 2005
@@ -5,6 +5,7 @@
 #include <fx3d.h>
 
 #include <Interface/RTRTInterface.h>
+#include <Engine/Control/RTRT.h>
 
 #include <fox/FMantaQuakeNav.h>
 
@@ -18,6 +19,9 @@
        class FMantaImageFrame : public FXGLCanvas {
                FXDECLARE(FMantaImageFrame)
        private:
+               // Fox components.
+               FXObject *fox_target;
+       
                // Pointer to the Manta interface to send commands.
                RTRTInterface *manta_interface;
                
@@ -31,12 +35,15 @@
                // Message types.
                enum {
                        ID_IMAGE = FXGLCanvas::ID_LAST, // Messages from the 
gl canvas.
+                       
+                       ID_PIXEL_SELECT, // Sent to fox_target when the user 
double clicks, FXEvent * is passed along.
+                       
                        ID_LAST
                };
        
                // Constructors.
                FMantaImageFrame() : manta_interface( 0 ), navigator( 0 ) {  
};
-               FMantaImageFrame( FXComposite *p, FXApp *app, int width, int 
height, RTRTInterface *manta_interface_ );
+               FMantaImageFrame( FXComposite *p, FXApp *app, FXObject 
*target, int width, int height, RTRTInterface *manta_interface_ );
                
                // Fox message handlers for mouse and keyboard.
                long onConfigure  ( FXObject *sender, FXSelector sel, void 
*data );
@@ -54,6 +61,11 @@
                
                RTRTInterface *getMantaInterface() { return manta_interface; 
};
                int            getMantaChannel  () { return manta_channel;   
};
+               
+               // Debugging.
+               bool shootOneRay( int pixel_x, int pixel_y, Point 
&result_position, Vector &result_normal );
+
+               
        };
 
 };

Modified: branches/itanium2/fox/FMantaUniformNav.cc
==============================================================================
--- branches/itanium2/fox/FMantaUniformNav.cc   (original)
+++ branches/itanium2/fox/FMantaUniformNav.cc   Tue Jun 21 03:23:46 2005
@@ -17,7 +17,7 @@
        x /= radius;
   y /= radius;
   Real rad2 = x*x+y*y;
-  if(rad2 > 1){
+  if(rad2 > 1) {
     Real rad = sqrt(rad2);
     x /= rad;
     y /= rad;

Modified: branches/itanium2/fox/FMantaWindow.cc
==============================================================================
--- branches/itanium2/fox/FMantaWindow.cc       (original)
+++ branches/itanium2/fox/FMantaWindow.cc       Tue Jun 21 03:23:46 2005
@@ -5,6 +5,11 @@
 
 #include <SCIRun/Core/Thread/Thread.h>
 
+#include <Interface/Scene.h>
+#include <Interface/Object.h>
+#include <Interface/Context.h>
+#include <Model/MiscObjects/CuttingPlane.h>
+
 #include <iostream>
 
 using namespace fox_manta;
@@ -21,7 +26,16 @@
        
        // Shadows.
        FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_HARD_SHADOWS,  
FMantaWindow::onShadowAlgorithm ),
-       FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_NO_SHADOWS,    
FMantaWindow::onShadowAlgorithm )
+       FXMAPFUNC(SEL_COMMAND, FMantaWindow::ID_NO_SHADOWS,    
FMantaWindow::onShadowAlgorithm ),
+       
+       // Samplers.
+       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 ),
+
+       // Cutting planes.
+       FXMAPFUNC(SEL_LEFTBUTTONPRESS, FMantaImageFrame::ID_PIXEL_SELECT, 
FMantaWindow::onAddCuttingPlane )
 };
 
 
FXIMPLEMENT(FMantaWindow,FXMainWindow,FMantaWindowMap,ARRAYNUMBER(FMantaWindowMap));
@@ -41,13 +55,23 @@
        new FXMenuCommand( file_menu, "Quit", 0, this, ID_QUIT );
        new FXMenuTitle  ( menu_bar, "File", 0, file_menu );
        
-       // Manta 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 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, "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 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 );
 
        // Create the content of the window.
        FXComposite *frame = new FXHorizontalFrame( this, LAYOUT_FILL );
@@ -57,15 +81,19 @@
        // FXComposite *bottom_controls = new FXHorizontalFrame  ( frame, 
LAYOUT_FILL_X|LAYOUT_BOTTOM );
 
        // Manta Image Frame.
-       manta_frame = new FMantaImageFrame( viewers, app, width, height, 0 );
+       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, 5.0 );
        
        // Camera bookmarks.
-       camera_bookmark_list = new FXListBox( viewers, this, 
ID_BOOKMARK_LIST, LAYOUT_FILL_X|LAYOUT_BOTTOM|COMBOBOX_REPLACE,0,0,0,20 );
+       frame = new FXHorizontalFrame( viewers, LAYOUT_FILL_X );
+       
+       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 );
 }
 
 // Quit the program.
@@ -108,6 +136,14 @@
        return 1;
 }
 
+long FMantaWindow::onAddBookmark( FXObject *sender, FXSelector key, void 
*data ) {
+
+       // Get a pointer to the camera.
+       Camera *camera = manta_interface->getCamera( 
manta_frame->getMantaChannel() );
+       
+       return 1;
+}
+
 long FMantaWindow::onShadowAlgorithm( FXObject *sender, FXSelector key, void 
*data ) {
 
        // Determine which shadow algorithm to use.
@@ -127,6 +163,60 @@
        return 1;
 }
 
+long FMantaWindow::onPixelSampler( FXObject *sender, FXSelector key, void 
*data ) {
+       
+       // Determine which shadow algorithm to use.
+       int id = FXSELID( key );
+               
+       switch (id) {
+               case ID_SINGLE_SAMPLER:
+                       manta_interface->addTransaction("Pixel Sampler.",
+                               
Callback::create(this,&FMantaWindow::mantaPixelSampler,string("singlesample")));
+                       break;
+               case ID_JITTER2_SAMPLER:
+                       manta_interface->addTransaction("Pixel Sampler.",
+                               
Callback::create(this,&FMantaWindow::mantaPixelSampler,string("jittersample( 
-numberOfSamples 2 )")));
+                       break;
+               case ID_JITTER4_SAMPLER:
+                       manta_interface->addTransaction("Pixel Sampler.",
+                               
Callback::create(this,&FMantaWindow::mantaPixelSampler,string("jittersample( 
-numberOfSamples 4 )")));
+                       break;
+               case ID_JITTER8_SAMPLER:
+                       manta_interface->addTransaction("Pixel Sampler.",
+                               
Callback::create(this,&FMantaWindow::mantaPixelSampler,string("jittersample( 
-numberOfSamples 8 )")));
+                       break;
+       }
+       
+       return 1;
+}
+
+
+long FMantaWindow::onAddCuttingPlane( FXObject *sender, FXSelector key, void 
*data ) {
+
+       FXEvent *event = (FXEvent *)data;
+
+       std::cout << "Image location: " << event->win_x << " " << 
event->win_y << std::endl;
+       
+       Point point;
+       Vector normal;
+       
+       // 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();
+               
+               std::cout << "Adding cutting plane" << std::endl;
+               std::cout << point << std::endl;
+               std::cout << normal << std::endl;
+               
+               // Add a cutting plane at this point.
+               manta_interface->addTransaction("Add Cutting Plane",
+                       
Callback::create(this,&FMantaWindow::mantaAddCuttingPlane,point,normal));
+       }
+       
+       return 1;
+};
 
 
///////////////////////////////////////////////////////////////////////////////
 
@@ -157,6 +247,19 @@
        }
 }
 
+void FMantaWindow::mantaPixelSampler( const string text ) const {
+       
+       // 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;
+       ///}
+}
+
 
///////////////////////////////////////////////////////////////////////////////
 
 void FMantaWindow::addCameraBookmark( const string &description, const 
string &camera_text ) {
@@ -168,7 +271,35 @@
        camera_text_list.push_back( camera_text );
 }
 
-
-
+// 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();
+       
+       // Normalize the normal.
+       normal.normalize();
+       
+       // Check to see if  the root object is already a cutting plane.
+       CuttingPlane *cutting_plane = dynamic_cast< CuttingPlane * >( 
root_object );
+       if (cutting_plane != 0) {
+               cutting_plane->setPlanePoint( point );
+               cutting_plane->setPlaneNormal( normal );
+       }
+       else {
+               // Create the cutting plane.
+               cutting_plane = new CuttingPlane( point, normal, root_object 
);
+       
+               // Preprocess the cutting plane.
+               PreprocessContext preprocess_context( manta_interface, 
scene->getLights() );
+               cutting_plane->preprocess( preprocess_context );
+       
+               // Place the cutting plane at the top of the tree.
+               scene->setObject( cutting_plane );
+       }
+};
 
 

Modified: branches/itanium2/fox/FMantaWindow.h
==============================================================================
--- branches/itanium2/fox/FMantaWindow.h        (original)
+++ branches/itanium2/fox/FMantaWindow.h        Tue Jun 21 03:23:46 2005
@@ -35,6 +35,7 @@
                FXMenuBar  *menu_bar;
                FXMenuPane *file_menu;
                FXMenuPane *shadow_menu;
+               FXMenuPane *sampler_menu;
                FXMenuPane *cutting_menu;
                
                FXRealSlider  *speed_slider;
@@ -52,12 +53,24 @@
                enum {
                        ID_QUIT = FXMainWindow::ID_LAST, // Sent when the 
application must quit.
                        ID_SPEED_SLIDER,                 // Control speed 
slider was changed.
+                       
+                       // Bookmarks.
                        ID_BOOKMARK_LIST,                // User selected a 
camera bookmark.
+                       ID_ADD_BOOKMARK,
                        
                        // Shadow options.
                        ID_HARD_SHADOWS,
                        ID_NO_SHADOWS, 
                        
+                       // Multisample options.
+                       ID_SINGLE_SAMPLER,
+                       ID_JITTER2_SAMPLER,
+                       ID_JITTER4_SAMPLER,
+                       ID_JITTER8_SAMPLER,
+                       
+                       // Cutting planes.
+                       ID_ADD_CUTTING_PLANE,
+                       
                        ID_LAST
                };
                
@@ -74,10 +87,13 @@
                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 onCameraBookmark( FXObject *sender, FXSelector key, void 
*data );
+               long onQuit           ( FXObject *sender, FXSelector key, 
void *data );
+               long onSpeedSlider    ( FXObject *sender, FXSelector key, 
void *data );
+               long onCameraBookmark ( FXObject *sender, FXSelector key, 
void *data );
+               long onAddBookmark    ( FXObject *sender, FXSelector key, 
void *data );
                long onShadowAlgorithm( FXObject *sender, FXSelector key, 
void *data );
+               long onPixelSampler   ( FXObject *sender, FXSelector key, 
void *data );
+               long onAddCuttingPlane( FXObject *sender, FXSelector key, 
void *data );
                
                // Accessors.
                void setMantaInterface( RTRTInterface *manta_interface_, int 
manta_channel_ ) { 
@@ -92,6 +108,12 @@
                
                // This method is called by the manta thread to replace the 
shadow algorithm.
                void mantaShadowAlgorithm( const string shadow_text ) const;
+               
+               // This method is called by the manta thread to replace the 
shadow algorithm.
+               void mantaPixelSampler( const string shadow_text ) const;
+               
+               // This method is called by the manta thread to add a cutting 
plane.
+               void mantaAddCuttingPlane( Point point, Vector normal ) const;
                
        };
 };




  • [MANTA] r401 - in branches/itanium2: Engine/Control Interface Model/MiscObjects fox, abe, 06/21/2005

Archive powered by MHonArc 2.6.16.

Top of page