Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r693 - branches/itanium2/fox


Chronological Thread 
  • From: hansong@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r693 - branches/itanium2/fox
  • Date: Thu, 3 Nov 2005 19:16:34 -0700 (MST)

Author: hansong
Date: Thu Nov  3 19:16:28 2005
New Revision: 693

Modified:
   branches/itanium2/fox/FMantaWindow.cc
   branches/itanium2/fox/FMantaWindow.h
Log:
Add POI (Point of Interest) feature. When the user double clicks on the right 
mouse button while holding down Ctrl, the camera flys to the location of the 
click. The destination is positioned along the normal of the hit at 1/10 of 
the current (preflight) distance between the eye and the hit.

Modified: branches/itanium2/fox/FMantaWindow.cc
==============================================================================
--- branches/itanium2/fox/FMantaWindow.cc       (original)
+++ branches/itanium2/fox/FMantaWindow.cc       Thu Nov  3 19:16:28 2005
@@ -458,6 +458,11 @@
        FXEvent *event = (FXEvent *)data;
 
        std::cout << "Image location: " << event->win_x << " " << 
event->win_y << std::endl;
+
+       if ((event->state & CONTROLMASK) == CONTROLMASK) {
+               onPOI(sender, key, data);
+               return 1;
+       }
        
        Point point;
        Vector normal;
@@ -577,6 +582,85 @@
   }
 
 };
+
+long FMantaWindow::onPOI( FXObject *sender, FXSelector key, void *data ) {
+
+       FXEvent *event = (FXEvent *)data;
+
+       std::cout << "POI at: " << event->win_x << " " << event->win_y << 
std::endl;
+
+       manta_interface->addTransaction("POI",
+               
Callback::create(this,&FMantaWindow::mantaPOI,event->win_x,event->win_y));
+
+       return 1;
+}
+void FMantaWindow::mantaPOI( int x, int y ) {
+
+       Scene *scene = manta_interface->getScene();
+       Object *root_object = scene->getObject();
+       
+       // Check to see if  the root object is a cutting plane.
+       CuttingPlane *cutting_plane = dynamic_cast< CuttingPlane * >( 
root_object );
+       if (cutting_plane != 0) {
+
+    // If so use the cutting plane's child as the root.
+    root_object = cutting_plane->getObject();
+  }
+
+       Point point;
+       Vector normal;
+  
+  // Check to see if this object is either a transparent or normal kdtree.
+    
+    int result = manta_frame->shootOneRay( x, y, point, normal );
+    if (result) {
+               Point  eye[4];
+               Point  lookat[4];
+               Vector up[4];
+               // Get the current manta camera.
+               int channel = manta_frame->getNavigator()->getMantaChannel();
+               Camera *camera = manta_interface->getCamera( channel );
+
+               eye[0] = eye[1] = camera->getPosition();
+               lookat[0] = lookat[1] = camera->getLookAt();
+               up[0] = up[1] = camera->getUp();
+
+               // distance between POI and current location
+               Vector eyetopoi = point - camera->getPosition();
+               Real dist = sqrt(Dot(eyetopoi, eyetopoi));
+
+               eye[2] = eye[3] = point + normal*dist*0.1;
+               lookat[2] = lookat[3] = point-normal;
+               up[2] = up[3] = camera->getUp();
+
+               dstPosition = eye[3];
+               dstLookAt = lookat[3];
+               dstUp = up[3];
+
+               Real delta_t = 1.0/dist, delta_time = 0.03;
+
+               automator = new CameraPathAutomator(
+                               manta_interface, 0, 0,
+                               eye, lookat, up, 4,
+                               delta_t,
+                               delta_time);
+               automator->set_automator_mode( AutomatorUI::AUTOMATOR_EXIT );
+               automator->set_loop_behavior( CameraPathAutomator::PATH_STOP 
);
+                                                                             
         
+               automator->set_terminate_callback( Callback::create( this, 
&FMantaWindow::mantaPOIManeuverComplete ) );
+
+               automator->restart();
+    }
+};
+
+void FMantaWindow::mantaPOIManeuverComplete()
+{
+       //int channel = manta_frame->getNavigator()->getMantaChannel();
+       //Camera *camera = manta_interface->getCamera( channel );
+       //camera->reset(dstPosition, dstUp, dstLookAt);
+       manta_frame->getNavigator()->resetToCamera(dstPosition, dstLookAt, 
dstUp);
+}
+
 
 long FMantaWindow::onNavigator( FXObject *sender, FXSelector key, void *data 
) {
 

Modified: branches/itanium2/fox/FMantaWindow.h
==============================================================================
--- branches/itanium2/fox/FMantaWindow.h        (original)
+++ branches/itanium2/fox/FMantaWindow.h        Thu Nov  3 19:16:28 2005
@@ -10,6 +10,8 @@
 #include <fox/FMantaImageFrame.h>
 #include <fox/FMantaRecorder.h>
 
+#include <UserInterface/CameraPathAutomator.h>
+
 #include <vector>
 
 namespace fox_manta {
@@ -160,6 +162,7 @@
                long onTraverserText  ( FXObject *sender, FXSelector key, 
void *data );
                long onAddCuttingPlane( FXObject *sender, FXSelector key, 
void *data );
                long onPick( FXObject *sender, FXSelector key, void *data );
+               long onPOI( FXObject *sender, FXSelector key, void *data );
                long onExtraOptions   ( FXObject *sender, FXSelector key, 
void *data );
                
                // Accessors.
@@ -192,6 +195,12 @@
                void mantaMoveCuttingPlane( Real amount ) const;
                void mantaFlipCuttingPlane() const;
                void mantaPick( int x, int y ) const;
+               void mantaPOI( int x, int y ) ;
+
+               void mantaPOIManeuverComplete();
+               mutable CameraPathAutomator *automator;
+               mutable Point dstPosition, dstLookAt;
+               mutable Vector dstUp;
                
                // This method is called by the manta thread to change the 
rendering mode.
                void FMantaWindow::mantaSetSceneObject( Object *root_object_ 
) const;




  • [MANTA] r693 - branches/itanium2/fox, hansong, 11/03/2005

Archive powered by MHonArc 2.6.16.

Top of page