Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r2275 - in trunk: Interface Model/Cameras UserInterface


Chronological Thread 
  • From: abe@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [Manta] r2275 - in trunk: Interface Model/Cameras UserInterface
  • Date: Wed, 28 May 2008 13:34:18 -0600 (MDT)

Author: abe
Date: Wed May 28 13:34:18 2008
New Revision: 2275

Modified:
   trunk/Interface/Camera.h
   trunk/Model/Cameras/EnvironmentCamera.cc
   trunk/Model/Cameras/EnvironmentCamera.h
   trunk/Model/Cameras/FisheyeCamera.cc
   trunk/Model/Cameras/FisheyeCamera.h
   trunk/Model/Cameras/OrthogonalCamera.cc
   trunk/Model/Cameras/OrthogonalCamera.h
   trunk/Model/Cameras/PinholeCamera.cc
   trunk/Model/Cameras/PinholeCamera.h
   trunk/Model/Cameras/SphereCamera.h
   trunk/Model/Cameras/ThinLensCamera.cc
   trunk/Model/Cameras/ThinLensCamera.h
   trunk/UserInterface/XWindowUI.cc
   trunk/UserInterface/XWindowUI.h
Log:

Reverted changes to the Camera interface from 2272. I moved the video
game mouse code back into the XWindowUI GUI. We've always supported
this type of interaction in the GUI layer, just not in XWindowUI ;-).

The interaction is possible using the exisitng get/setBasicCameraData
methods without changing the Camera interface (and breaking embedded
projects). I can totally understand that it might not be obvious that
this approach is possible if you look at the other interaction methods
in XWindowUI which all seem to have custom methods in Camera...

The basic idea is that the mouse event handler sends a transaction to
Manta which calls another method XWindowUI::gameTransform(). The
transaction obtains the camera eye, lookat, and up vectors, applies
the video game camera logic, and then sends the vectors back to the
camera.

Let me know if there are any concerns- I'm pretty sure we can support
just about any interaction model without changing the Camera.h
interface itself ;-)

M    UserInterface/XWindowUI.cc
M    UserInterface/XWindowUI.h
M    Interface/Camera.h
M    Model/Cameras/EnvironmentCamera.cc
M    Model/Cameras/ThinLensCamera.cc
M    Model/Cameras/EnvironmentCamera.h
M    Model/Cameras/ThinLensCamera.h
M    Model/Cameras/SphereCamera.h
M    Model/Cameras/FisheyeCamera.cc
M    Model/Cameras/OrthogonalCamera.cc
M    Model/Cameras/FisheyeCamera.h
M    Model/Cameras/OrthogonalCamera.h
M    Model/Cameras/PinholeCamera.cc
M    Model/Cameras/PinholeCamera.h


Modified: trunk/Interface/Camera.h
==============================================================================
--- trunk/Interface/Camera.h    (original)
+++ trunk/Interface/Camera.h    Wed May 28 13:34:18 2008
@@ -102,7 +102,6 @@
     // AffineTransform needs to not be a reference in order to get the
     // transactions to work properly.  A copy is needed.
     virtual void transform(AffineTransform t, TransformCenter) = 0;
-    virtual void gameTransform(Vector, Vector) = 0;
     virtual void autoview(const BBox bbox) = 0;
     virtual void output( std::ostream& os ) = 0; // Output a text
                                                  // description of the

Modified: trunk/Model/Cameras/EnvironmentCamera.cc
==============================================================================
--- trunk/Model/Cameras/EnvironmentCamera.cc    (original)
+++ trunk/Model/Cameras/EnvironmentCamera.cc    Wed May 28 13:34:18 2008
@@ -218,31 +218,6 @@
   setup();
 }
 
-void EnvironmentCamera::gameTransform(Vector rotation, Vector translation)
-{
-  Vector gaze( eye - lookat );
-  Vector side( Cross( up, gaze ) );
-  Vector projectedGaze( gaze - up * Dot( up, gaze ) );
-  Vector projectedSide( side - up * Dot( up, side ) );
-  gaze.normalize();
-  side.normalize();
-  projectedGaze.normalize();
-  projectedSide.normalize();
-  AffineTransform frame;
-  frame.initWithTranslation( -eye );
-  frame.rotate( side, rotation.y() );
-  frame.rotate( up, rotation.x() );
-  frame.translate( projectedSide * translation.x() );
-  frame.translate( up * translation.y() );
-  frame.translate( projectedGaze * translation.z() );
-  frame.translate( eye );
-  eye = frame.multiply_point( eye );
-  lookat = frame.multiply_point( lookat );
-  frame.initWithRotation( gaze, rotation.z() );
-  up = frame.multiply_vector( up );
-  setup();
-}
-
 void EnvironmentCamera::autoview(const BBox /*bbox*/)
 {
   // This functionality doesn't make much sense with the environment camera

Modified: trunk/Model/Cameras/EnvironmentCamera.h
==============================================================================
--- trunk/Model/Cameras/EnvironmentCamera.h     (original)
+++ trunk/Model/Cameras/EnvironmentCamera.h     Wed May 28 13:34:18 2008
@@ -25,7 +25,6 @@
     virtual void translate(Vector);
     virtual void dolly(Real);
     virtual void transform(AffineTransform t, TransformCenter);
-    virtual void gameTransform(Vector, Vector);
     virtual void autoview(const BBox bbox);
 
     virtual void getBasicCameraData(BasicCameraData& cam) const;

Modified: trunk/Model/Cameras/FisheyeCamera.cc
==============================================================================
--- trunk/Model/Cameras/FisheyeCamera.cc        (original)
+++ trunk/Model/Cameras/FisheyeCamera.cc        Wed May 28 13:34:18 2008
@@ -168,31 +168,6 @@
   setup();
 }
 
-void FisheyeCamera::gameTransform(Vector rotation, Vector translation)
-{
-  Vector gaze( eye - lookat );
-  Vector side( Cross( up, gaze ) );
-  Vector projectedGaze( gaze - up * Dot( up, gaze ) );
-  Vector projectedSide( side - up * Dot( up, side ) );
-  gaze.normalize();
-  side.normalize();
-  projectedGaze.normalize();
-  projectedSide.normalize();
-  AffineTransform frame;
-  frame.initWithTranslation( -eye );
-  frame.rotate( side, rotation.y() );
-  frame.rotate( up, rotation.x() );
-  frame.translate( projectedSide * translation.x() );
-  frame.translate( up * translation.y() );
-  frame.translate( projectedGaze * translation.z() );
-  frame.translate( eye );
-  eye = frame.multiply_point( eye );
-  lookat = frame.multiply_point( lookat );
-  frame.initWithRotation( gaze, rotation.z() );
-  up = frame.multiply_vector( up );
-  setup();
-}
-
 void FisheyeCamera::autoview(const BBox bbox)
 {
   output(cerr);

Modified: trunk/Model/Cameras/FisheyeCamera.h
==============================================================================
--- trunk/Model/Cameras/FisheyeCamera.h (original)
+++ trunk/Model/Cameras/FisheyeCamera.h Wed May 28 13:34:18 2008
@@ -27,7 +27,6 @@
     virtual void translate(Vector);
     virtual void dolly(Real);
     virtual void transform(AffineTransform t, TransformCenter);
-    virtual void gameTransform(Vector, Vector);
     virtual void autoview(const BBox bbox);
     virtual void output( std::ostream &os );
     static Camera* create(const vector<string>& args);

Modified: trunk/Model/Cameras/OrthogonalCamera.cc
==============================================================================
--- trunk/Model/Cameras/OrthogonalCamera.cc     (original)
+++ trunk/Model/Cameras/OrthogonalCamera.cc     Wed May 28 13:34:18 2008
@@ -171,31 +171,6 @@
   setup();
 }
 
-void OrthogonalCamera::gameTransform(Vector rotation, Vector translation)
-{
-  Vector gaze( eye - lookat );
-  Vector side( Cross( up, gaze ) );
-  Vector projectedGaze( gaze - up * Dot( up, gaze ) );
-  Vector projectedSide( side - up * Dot( up, side ) );
-  gaze.normalize();
-  side.normalize();
-  projectedGaze.normalize();
-  projectedSide.normalize();
-  AffineTransform frame;
-  frame.initWithTranslation( -eye );
-  frame.rotate( side, rotation.y() );
-  frame.rotate( up, rotation.x() );
-  frame.translate( projectedSide * translation.x() );
-  frame.translate( up * translation.y() );
-  frame.translate( projectedGaze * translation.z() );
-  frame.translate( eye );
-  eye = frame.multiply_point( eye );
-  lookat = frame.multiply_point( lookat );
-  frame.initWithRotation( gaze, rotation.z() );
-  up = frame.multiply_vector( up );
-  setup();
-}
-
 void OrthogonalCamera::autoview(const BBox bbox)
 {
   output(cerr);

Modified: trunk/Model/Cameras/OrthogonalCamera.h
==============================================================================
--- trunk/Model/Cameras/OrthogonalCamera.h      (original)
+++ trunk/Model/Cameras/OrthogonalCamera.h      Wed May 28 13:34:18 2008
@@ -24,7 +24,6 @@
     virtual void translate(Vector);
     virtual void dolly(Real);
     virtual void transform(AffineTransform t, TransformCenter);
-    virtual void gameTransform(Vector, Vector);
     virtual void autoview(const BBox bbox);
     virtual void output( std::ostream &os );
     static Camera* create(const vector<string>& args);

Modified: trunk/Model/Cameras/PinholeCamera.cc
==============================================================================
--- trunk/Model/Cameras/PinholeCamera.cc        (original)
+++ trunk/Model/Cameras/PinholeCamera.cc        Wed May 28 13:34:18 2008
@@ -474,31 +474,6 @@
   setup();
 }
 
-void PinholeCamera::gameTransform(Vector rotation, Vector translation)
-{
-  Vector gaze( eye - lookat );
-  Vector side( Cross( up, gaze ) );
-  Vector projectedGaze( gaze - up * Dot( up, gaze ) );
-  Vector projectedSide( side - up * Dot( up, side ) );
-  gaze.normalize();
-  side.normalize();
-  projectedGaze.normalize();
-  projectedSide.normalize();
-  AffineTransform frame;
-  frame.initWithTranslation( -eye );
-  frame.rotate( side, rotation.y() );
-  frame.rotate( up, rotation.x() );
-  frame.translate( projectedSide * translation.x() );
-  frame.translate( up * translation.y() );
-  frame.translate( projectedGaze * translation.z() );
-  frame.translate( eye );
-  eye = frame.multiply_point( eye );
-  lookat = frame.multiply_point( lookat );
-  frame.initWithRotation( gaze, rotation.z() );
-  up = frame.multiply_vector( up );
-  setup();
-}
-
 void PinholeCamera::autoview(const BBox bbox)
 {
   Vector diag(bbox.diagonal());

Modified: trunk/Model/Cameras/PinholeCamera.h
==============================================================================
--- trunk/Model/Cameras/PinholeCamera.h (original)
+++ trunk/Model/Cameras/PinholeCamera.h Wed May 28 13:34:18 2008
@@ -25,7 +25,6 @@
     virtual void translate(Vector);
     virtual void dolly(Real);
     virtual void transform(AffineTransform t, TransformCenter);
-    virtual void gameTransform(Vector, Vector);
     virtual void autoview(const BBox bbox);
     virtual void output( std::ostream& os );
 

Modified: trunk/Model/Cameras/SphereCamera.h
==============================================================================
--- trunk/Model/Cameras/SphereCamera.h  (original)
+++ trunk/Model/Cameras/SphereCamera.h  Wed May 28 13:34:18 2008
@@ -24,7 +24,6 @@
     virtual void translate(Vector) { }
     virtual void dolly(Real) { }
     virtual void transform(AffineTransform t, TransformCenter) { }
-    virtual void gameTransform(Vector, Vector) { }
     virtual void autoview(const BBox bbox) { }
     virtual void output( std::ostream &os );
     static Camera* create(const vector<string>& args);

Modified: trunk/Model/Cameras/ThinLensCamera.cc
==============================================================================
--- trunk/Model/Cameras/ThinLensCamera.cc       (original)
+++ trunk/Model/Cameras/ThinLensCamera.cc       Wed May 28 13:34:18 2008
@@ -349,31 +349,6 @@
   setup();
 }
 
-void ThinLensCamera::gameTransform(Vector rotation, Vector translation)
-{
-  Vector gaze( eye - lookat );
-  Vector side( Cross( up, gaze ) );
-  Vector projectedGaze( gaze - up * Dot( up, gaze ) );
-  Vector projectedSide( side - up * Dot( up, side ) );
-  gaze.normalize();
-  side.normalize();
-  projectedGaze.normalize();
-  projectedSide.normalize();
-  AffineTransform frame;
-  frame.initWithTranslation( -eye );
-  frame.rotate( side, rotation.y() );
-  frame.rotate( up, rotation.x() );
-  frame.translate( projectedSide * translation.x() );
-  frame.translate( up * translation.y() );
-  frame.translate( projectedGaze * translation.z() );
-  frame.translate( eye );
-  eye = frame.multiply_point( eye );
-  lookat = frame.multiply_point( lookat );
-  frame.initWithRotation( gaze, rotation.z() );
-  up = frame.multiply_vector( up );
-  setup();
-}
-
 void ThinLensCamera::autoview(const BBox bbox)
 {
   Vector diag(bbox.diagonal());

Modified: trunk/Model/Cameras/ThinLensCamera.h
==============================================================================
--- trunk/Model/Cameras/ThinLensCamera.h        (original)
+++ trunk/Model/Cameras/ThinLensCamera.h        Wed May 28 13:34:18 2008
@@ -26,7 +26,6 @@
     virtual void translate(Vector);
     virtual void dolly(Real);
     virtual void transform(AffineTransform t, TransformCenter);
-    virtual void gameTransform(Vector, Vector);
     virtual void autoview(const BBox bbox);
     virtual void output( std::ostream& os );
 

Modified: trunk/UserInterface/XWindowUI.cc
==============================================================================
--- trunk/UserInterface/XWindowUI.cc    (original)
+++ trunk/UserInterface/XWindowUI.cc    Wed May 28 13:34:18 2008
@@ -946,6 +946,36 @@
                                                   scale));
 }
 
+void XWindowUI::gameTransform(int channel, Vector rotation, Vector 
translation)
+{
+  // This code is called by a transaction so it is thread safe.
+  BasicCameraData cd = 
rtrt_interface->getCamera(channel)->getBasicCameraData();
+
+  Vector gaze( cd.eye - cd.lookat );
+  Vector side( Cross( cd.up, gaze ) );
+  Vector projectedGaze( gaze - cd.up * Dot( cd.up, gaze ) );
+  Vector projectedSide( side - cd.up * Dot( cd.up, side ) );
+  gaze.normalize();
+  side.normalize();
+  projectedGaze.normalize();
+  projectedSide.normalize();
+  AffineTransform frame;
+  frame.initWithTranslation( -cd.eye );
+  frame.rotate( side, rotation.y() );
+  frame.rotate( cd.up, rotation.x() );
+  frame.translate( projectedSide * translation.x() );
+  frame.translate( cd.up * translation.y() );
+  frame.translate( projectedGaze * translation.z() );
+  frame.translate( cd.eye );
+  cd.eye = frame.multiply_point( cd.eye );
+  cd.lookat = frame.multiply_point( cd.lookat );
+  frame.initWithRotation( gaze, rotation.z() );
+  cd.up = frame.multiply_vector( cd.up );
+
+  rtrt_interface->getCamera(channel)->setBasicCameraData( cd );
+}
+
+
 void XWindowUI::mouse_track_and_pan(unsigned int, unsigned int,
                                     int event, int channel, int mouse_x, int 
mouse_y)
 {
@@ -959,10 +989,10 @@
     Real ymotion = -Real(ias.last_y-mouse_y)/window->yres;
     Vector rotation(xmotion*rotate_speed, 0, 0);
     Vector translation(0, 0, ymotion*translate_speed);
-    Camera* camera = rtrt_interface->getCamera(channel);
+
     rtrt_interface->addTransaction("game",
-                                   Callback::create(camera, 
&Camera::gameTransform,
-                                                    rotation, translation));
+                                   Callback::create(this, 
&XWindowUI::gameTransform,
+                                                    channel, rotation, 
translation));
     ias.last_x = mouse_x;
     ias.last_y = mouse_y;
   }
@@ -981,10 +1011,11 @@
     Real ymotion =  Real(ias.last_y-mouse_y)/window->yres;
     Vector rotation(0, 0, 0);
     Vector translation(xmotion*translate_speed, ymotion*translate_speed, 0);
-    Camera* camera = rtrt_interface->getCamera(channel);
+
     rtrt_interface->addTransaction("game",
-                                   Callback::create(camera, 
&Camera::gameTransform,
-                                                    rotation, translation));
+                                   Callback::create(this, 
&XWindowUI::gameTransform,
+                                                    channel, rotation, 
translation));
+
     ias.last_x = mouse_x;
     ias.last_y = mouse_y;
   }
@@ -1003,10 +1034,11 @@
     Real ymotion = invert*Real(ias.last_y-mouse_y)/window->yres;
     Vector rotation(xmotion*rotate_speed, ymotion*rotate_speed, 0);
     Vector translation(0, 0, 0);
-    Camera* camera = rtrt_interface->getCamera(channel);
+
     rtrt_interface->addTransaction("game",
-                                   Callback::create(camera, 
&Camera::gameTransform,
-                                                    rotation, translation));
+                                   Callback::create(this, 
&XWindowUI::gameTransform,
+                                                    channel, rotation, 
translation));    
+    
     ias.last_x = mouse_x;
     ias.last_y = mouse_y;
   }

Modified: trunk/UserInterface/XWindowUI.h
==============================================================================
--- trunk/UserInterface/XWindowUI.h     (original)
+++ trunk/UserInterface/XWindowUI.h     Wed May 28 13:34:18 2008
@@ -68,6 +68,8 @@
 
     void shutdown(MantaInterface*);
 
+    void gameTransform(int, Vector, Vector); // This method is called via a 
transaction.
+
   protected:
     void register_default_keys();
     void register_default_mouse();



Archive powered by MHonArc 2.6.16.

Top of page