Text archives Help
- From: abe@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r621 - in branches/itanium2: Engine/Control Model/Cameras StandAlone fox
- Date: Thu, 13 Oct 2005 04:27:42 -0600 (MDT)
Author: abe
Date: Thu Oct 13 04:27:40 2005
New Revision: 621
Modified:
branches/itanium2/Engine/Control/RTRT_register.cc
branches/itanium2/Model/Cameras/StereoPinholeCamera.cc
branches/itanium2/Model/Cameras/StereoPinholeCamera.h
branches/itanium2/StandAlone/CMakeLists.txt
branches/itanium2/fox/CMakeLists.txt
branches/itanium2/fox/FMantaWindow.cc
branches/itanium2/fox/FMantaWindow.h
branches/itanium2/fox/dm_demo.cc
Log:
Updated stereo code.
M StandAlone/CMakeLists.txt
M fox/FMantaWindow.cc
M fox/FMantaWindow.h
M fox/dm_demo.cc
M fox/CMakeLists.txt
M Model/Cameras/StereoPinholeCamera.h
M Model/Cameras/StereoPinholeCamera.cc
M Engine/Control/RTRT_register.cc
Modified: branches/itanium2/Engine/Control/RTRT_register.cc
==============================================================================
--- branches/itanium2/Engine/Control/RTRT_register.cc (original)
+++ branches/itanium2/Engine/Control/RTRT_register.cc Thu Oct 13 04:27:40
2005
@@ -53,7 +53,9 @@
rtrt->registerComponent("null", &NullDisplay::create);
rtrt->registerComponent("opengl", &OpenGLDisplay::create);
rtrt->registerComponent("file", &FileDisplay::create);
+#ifdef __ia64__
rtrt->registerComponent("mf", &SHMImageDisplay::create);
+#endif
// Register image traversers
rtrt->registerComponent("null", &NullImageTraverser::create);
Modified: branches/itanium2/Model/Cameras/StereoPinholeCamera.cc
==============================================================================
--- branches/itanium2/Model/Cameras/StereoPinholeCamera.cc (original)
+++ branches/itanium2/Model/Cameras/StereoPinholeCamera.cc Thu Oct 13
04:27:40 2005
@@ -17,15 +17,12 @@
StereoPinholeCamera::StereoPinholeCamera(const vector<string>& args)
{
- bool gotEye = false;
- bool gotLookat = false;
- bool gotFov = false;
- bool gotUp = false;
- bool gotStereo = false;
normalizeRays = false;
- stereo_offset = 1.0;
+ eye_distance = 1.0;
+ focus_distance = 10.0;
+ // Parameters for the default scene.
// pinhole(-eye 3 3 2 -lookat 0 0 0.3 -up 0 0 1 -fov 60
eye = Point ( 3.0, 3.0, 2.0 );
lookat = Point ( 0.0, 0.0, 0.3 );
@@ -35,26 +32,26 @@
int argc = static_cast<int>(args.size());
for(int i=0; i< argc; i++){
string arg = args[i];
- if (arg == "-offset") {
- if(!getArg(i, args, stereo_offset))
- throw IllegalArgument("StereoPinholeCamera -offset", i, args);
- gotStereo = true;
+ if (arg == "-focus") {
+ if(!getArg(i, args, focus_distance))
+ throw IllegalArgument("StereoPinholeCamera -focus", i, args);
+ }
+ else if (arg == "-distance") {
+ if(!getArg(i, args, eye_distance))
+ throw IllegalArgument("StereoPinholeCamera -distance", i, args);
+
} else if(arg == "-eye"){
if(!getPointArg(i, args, eye))
throw IllegalArgument("StereoPinholeCamera -eye", i, args);
- gotEye = true;
} else if(arg == "-lookat"){
if(!getPointArg(i, args, lookat))
throw IllegalArgument("StereoPinholeCamera -lookat", i, args);
- gotLookat = true;
} else if(arg == "-up"){
if(!getVectorArg(i, args, up))
throw IllegalArgument("StereoPinholeCamera -up", i, args);
- gotUp = true;
} else if(arg == "-fov"){
if(!getDoubleArg(i, args, hfov))
throw IllegalArgument("StereoPinholeCamera -fov", i, args);
- gotFov = true;
} else if(arg == "-normalizeRays"){
normalizeRays = true;
} else {
@@ -62,6 +59,8 @@
}
}
+ nearZ = (lookat-eye).length();
+
setup();
}
@@ -71,11 +70,14 @@
void StereoPinholeCamera::output( std::ostream &os ) {
- os << "pinhole( -eye " << eye
- << " -lookat " << lookat
- << " -up " << up
- << " -fov " << hfov << " )"
- << std::endl;
+ os << "stereo( -eye " << eye
+ << " -lookat " << lookat
+ << " -up " << up
+ << " -fov " << hfov
+ << " -distance " << eye_distance
+ << " -focus " << focus_distance
+ << " )"
+ << std::endl;
}
Camera* StereoPinholeCamera::create(const vector<string>& args)
@@ -85,36 +87,68 @@
void StereoPinholeCamera::setup()
{
- int i;
- vfov = hfov;
- direction=lookat-eye;
- nearZ=direction.length();
- Vector n = direction;
- n.normalize();
+ // Compute camera direction
+ Vector camera_direction = lookat - eye;
+ // nearZ = camera_direction.length();
+
+ // Normalize
+ camera_direction.normalize();
+
+ vfov = hfov;
+ height = nearZ * tan( vfov*0.5*M_PI/180.0 );
+ width = nearZ * tan( hfov*0.5*M_PI/180.0 );
+
+ // Compute right vector.
+ Vector right = Cross( camera_direction, up );
+ right.normalize();
+ right *= eye_distance;
+
+ // Compute eye point for either eye.
+ stereo_eye[0] = eye + right;
+ stereo_eye[1] = eye - right;
+
+ // Compute the focus point.
+ Point focus_point = eye + (camera_direction * focus_distance);
+
+ for (int i=0;i<2;++i) {
+
+ // Compute direction for either eye.
+ direction[i] = focus_point - stereo_eye[i];
+
+ // Compute v
+ v[i] = Cross( direction[i], up );
+ v[i].normalize();
+ v[i] *= width;
+
+
+ // Compute u
+ u[i] = Cross( v[i], direction[i] );
+ u[i].normalize();
+ u[i] *= height;
+ }
- for(i=0; i<3; i++)
- uvn[2][i] = n[i];
+ camera_n = camera_direction;
+ camera_n.normalize();
- v=Cross(direction, up);
- if(v.length2() == 0.0){
+ camera_v = Cross( camera_direction, up );
+ if( camera_v.length2() == 0.0 ){
std::cerr << __FILE__ << " line: " << __LINE__ << " Ambiguous up
direciton...\n";
}
- v.normalize();
+ camera_v.normalize();
- for(i=0; i<3; i++)
- uvn[1][i] = v[i];
+ camera_u = Cross( camera_v, camera_direction );
+ camera_u.normalize();
- u=Cross(v, direction);
- u.normalize();
+ for(int i=0; i<3; i++) {
+ uvn[1][i] = camera_v[i];
+ uvn[2][i] = camera_n[i];
+ uvn[0][i] = camera_u[i];
+ }
- for(i=0; i<3; i++)
- uvn[0][i] = u[i];
+ camera_u *= height;
+ camera_v *= width;
- height=nearZ*tan(vfov*0.5*M_PI/180.0);
- u*=height;
- width=nearZ*tan(hfov*0.5*M_PI/180.0);
- v*=width;
}
void StereoPinholeCamera::makeRays(RayPacket& rays) const
@@ -122,17 +156,18 @@
ASSERT(rays.getFlags() & RayPacket::HaveImageCoordinates);
rays.setFlag(RayPacket::ConstantOrigin);
- Point stereo_eye[2];
- stereo_eye[0] = (eye - (v*stereo_offset));
- stereo_eye[1] = (eye + (v*stereo_offset));
+
if(normalizeRays){
for(int i=0;i<rays.getSize();i++){
- RayPacket::Element& e = rays.get(i);
- Vector raydir(v*e.imageX+u*e.imageY+direction);
+
+ RayPacket::Element &e = rays.get(i);
+ int which = e.whichEye;
+
+ Vector raydir = v[which]*e.imageX + u[which]*e.imageY +
direction[which];
raydir.normalize();
- e.ray.set(stereo_eye[e.whichEye], raydir);
+ e.ray.set(stereo_eye[which], raydir);
e.importance = 1.0;
}
rays.setFlag(RayPacket::NormalizedDirections);
@@ -140,15 +175,16 @@
} else {
for(int i=0;i<rays.getSize();i++){
- RayPacket::Element& e = rays.get(i);
- Vector raydir(v*e.imageX+u*e.imageY+direction);
+ RayPacket::Element &e = rays.get(i);
+ int which = e.whichEye;
+
+ Vector raydir = v[which]*e.imageX + u[which]*e.imageY +
direction[which];
- e.ray.set(stereo_eye[e.whichEye], raydir);
+ e.ray.set(stereo_eye[which], raydir);
e.importance = 1.0;
}
-
}
}
@@ -162,13 +198,13 @@
vfov = Clamp(vfov, fov_min, fov_max);
setup();
}
-
void StereoPinholeCamera::translate(Vector t)
{
- Vector trans(u*t.y()+v*t.x());
+ Vector trans = camera_u*t[1] + camera_v*t[0];
- eye += trans;
+ eye += trans;
lookat += trans;
+
setup();
}
@@ -176,7 +212,7 @@
{
Vector d = (lookat - eye) * scale;
eye += d;
- // lookat += d; // Maybe we need two types of dolly. // Maybe not.
+
setup();
}
@@ -199,7 +235,7 @@
double length = lookdir.length();
AffineTransform frame;
- frame.initWithBasis(v.normal(), u.normal(), lookdir.normal(), cen);
+ frame.initWithBasis(camera_v.normal(), camera_u.normal(),
lookdir.normal(), cen );
AffineTransform frame_inv = frame;
frame_inv.invert();
@@ -208,6 +244,7 @@
up = t2 * up;
eye = t2 * eye;
lookat = t2 * lookat;
+
setup();
}
Modified: branches/itanium2/Model/Cameras/StereoPinholeCamera.h
==============================================================================
--- branches/itanium2/Model/Cameras/StereoPinholeCamera.h (original)
+++ branches/itanium2/Model/Cameras/StereoPinholeCamera.h Thu Oct 13
04:27:40 2005
@@ -7,6 +7,7 @@
#include <sgi_stl_warnings_off.h>
#include <string>
#include <vector>
+#include <iostream>
#include <sgi_stl_warnings_on.h>
namespace Manta {
@@ -14,11 +15,26 @@
class StereoPinholeCamera : public Camera {
public:
- StereoPinholeCamera( const Point &eye_, const Point &lookat_,
const Vector &up_, Real fov_ ) :
- eye( eye_ ), lookat( lookat_ ), up( up_ ), hfov( fov_
), stereo_offset( 0.0 ) { setup(); }
+ StereoPinholeCamera( const Point &eye_, const Point &lookat_, const
Vector &up_, Real fov_ ) :
+ eye( eye_ ),
+ lookat( lookat_ ),
+ up( up_ ),
+
+ hfov( fov_ ),
+
+ eye_distance( 1.0 ),
+ focus_distance( 10.0 ) { setup(); }
+
+ StereoPinholeCamera( const Point &eye_, const Point &lookat_, const
Vector &up_, Real fov_,
+ Real eye_distance_, Real focus_distance_ ) :
+
+ eye( eye_ ), lookat( lookat_ ), up( up_ ), hfov( fov_
),
+ eye_distance( eye_distance_ ), focus_distance( focus_distance_ ) {
setup(); }
StereoPinholeCamera(const vector<string>& args);
+ static Camera* create(const vector<string>& args);
+
virtual ~StereoPinholeCamera();
virtual void makeRays(RayPacket&) const;
@@ -30,28 +46,51 @@
virtual void autoview(double fov);
virtual void output( std::ostream &os );
virtual Point project(const Point &point) const; // project a 3D
point to the camera image plane
- static Camera* create(const vector<string>& args);
-
+
+ void set_eye_distance ( Real eye_distance_ ) { eye_distance =
eye_distance_; setup(); }
+ void set_focus_distance( Real focus_distance_ ) { focus_distance =
focus_distance_; setup(); }
+
virtual Point getPosition() const { return eye; }
virtual Point getLookAt() const { return lookat; };
virtual Vector getUp() const { return up; };
virtual void reset( const Point &eye_, const Vector &up_,
const Point &lookat_ ) {
- eye = eye_; up = up_; lookat = lookat_; setup(); };
+
+ eye = eye_;
+ up = up_;
+ lookat = lookat_;
+ setup();
+
+
+ };
private:
void setup();
- Point eye;
- Point lookat;
- Vector up;
- Real stereo_offset;
+
+ Point eye; // Location of the camera half way between both eyes.
+ Point lookat; //
+ Vector up; // Both eyes share an up direction.
+
+ // u and v vectors used for project, translate and transform. Not for
casting rays.
+ Vector camera_u, camera_v, camera_n;
+
+ Real eye_distance; // Distance between eyes.
+ Real focus_distance; // Distance from camera point that view from both
eyes cross.
+
+
+ // Assume that fov is the same for both eyes.
Real hfov, vfov, width, height, nearZ; // x and y field of view,
// width and height of image
plane
// distance from eye to image
plane
bool normalizeRays;
- Vector direction;
- Vector u,v;
+ // Ray origin for either eye.
+ Point stereo_eye[2];
+
+ // Direction, u and v for both eyes.
+ Vector direction[2];
+ Vector u[2];
+ Vector v[2];
// for projection we maintain a uvn rotation matrix
double uvn[3][3];
Modified: branches/itanium2/StandAlone/CMakeLists.txt
==============================================================================
--- branches/itanium2/StandAlone/CMakeLists.txt (original)
+++ branches/itanium2/StandAlone/CMakeLists.txt Thu Oct 13 04:27:40 2005
@@ -29,13 +29,15 @@
${CMAKE_THREAD_LIBS_INIT}
)
-ADD_EXECUTABLE(mf_stream_test mf_stream_test.cc)
-TARGET_LINK_LIBRARIES(mf_stream_test Manta_Engine
- Manta_UserInterface
- Manta_Model
- Manta_Image
- Manta_Interface
- Manta_Core
- SCIRun_Core
- ${CMAKE_THREAD_LIBS_INIT}
- )
+IF(SGI_LINUX)
+ ADD_EXECUTABLE(mf_stream_test mf_stream_test.cc)
+ TARGET_LINK_LIBRARIES(mf_stream_test Manta_Engine
+ Manta_UserInterface
+ Manta_Model
+ Manta_Image
+ Manta_Interface
+ Manta_Core
+ SCIRun_Core
+ ${CMAKE_THREAD_LIBS_INIT}
+ )
+ENDIF(SGI_LINUX)
Modified: branches/itanium2/fox/CMakeLists.txt
==============================================================================
--- branches/itanium2/fox/CMakeLists.txt (original)
+++ branches/itanium2/fox/CMakeLists.txt Thu Oct 13 04:27:40 2005
@@ -31,6 +31,8 @@
FMantaTrackballNav.cc
FMantaRecorder.h
FMantaRecorder.cc
+ FMantaStereo.h
+ FMantaStereo.cc
# FMantaTextureChooser.h
# FMantaTextureChooser.cc
# FMantaMaterialChooser.h
Modified: branches/itanium2/fox/FMantaWindow.cc
==============================================================================
--- branches/itanium2/fox/FMantaWindow.cc (original)
+++ branches/itanium2/fox/FMantaWindow.cc Thu Oct 13 04:27:40 2005
@@ -130,8 +130,10 @@
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 );
cutting_flip->disable();
- extra_options = new FXMenuCommand( options_menu, "Extra Options", 0,
this, ID_EXTRA_OPTIONS );
- extra_options->disable();
+
+ // extra_options = new FXMenuCommand( options_menu, "Extra Options",
0, this, ID_EXTRA_OPTIONS );
+ // extra_options->disable();
+ new FXMenuSeparator( options_menu );
new FXMenuTitle( menu_bar, "Options", 0, options_menu );
@@ -171,15 +173,17 @@
camera_path_dialog->hide();
}
-void FMantaWindow::setExtraOptionsDialog( FXDialogBox *extra_options_dialog_
) {
+void FMantaWindow::addExtraOptionsDialog( const FXString &name, FXDialogBox
*extra_options_dialog_ ) {
- extra_options_dialog = extra_options_dialog_;
+ // Create the menu command.
+ FXMenuCommand *command = new FXMenuCommand( options_menu, name, 0, this,
ID_EXTRA_OPTIONS );
+
+ // Add the command and dialog to the vectors.
+ extra_options_dialog.push_back( extra_options_dialog_ );
+ extra_options_command.push_back( command );
- // Check to see if it is safe to turn on the dialog box
- if (extra_options_dialog)
- extra_options->enable();
- else
- extra_options->disable();
+ command->create();
+ command->show();
};
void FMantaWindow::setSceneObject( Object *root_object_ ) {
@@ -540,11 +544,19 @@
long FMantaWindow::onExtraOptions( FXObject *sender, FXSelector key, void
*data ) {
- // Check to see if the extra options dialog box has been specified.
- if (extra_options_dialog) {
- extra_options_dialog->create();
- extra_options_dialog->show();
- }
+ int index = 0;
+
+ // Determine which menu command triggered the event.
+ for (int i=0;i<extra_options_command.size();++i) {
+ if (extra_options_command[i] == sender) {
+ index = i;
+ break;
+ }
+ }
+
+ // Display the dialog.
+ extra_options_dialog[index]->create();
+ extra_options_dialog[index]->show();
return 1;
}
Modified: branches/itanium2/fox/FMantaWindow.h
==============================================================================
--- branches/itanium2/fox/FMantaWindow.h (original)
+++ branches/itanium2/fox/FMantaWindow.h Thu Oct 13 04:27:40 2005
@@ -44,11 +44,10 @@
FXMenuPane *traverser_menu;
FXMenuPane *options_menu;
-
FXMenuCommand *cutting_flip;
-
- FXMenuCommand *extra_options;
- FXDialogBox *extra_options_dialog;
+
+ vector<FXMenuCommand *> extra_options_command;
+ vector<FXDialogBox *> extra_options_dialog;
FMantaRecorderDialog *camera_path_dialog;
@@ -129,7 +128,7 @@
void addCameraBookmark ( const string &description, const
string &camera_text );
void addNavigatorOption( const string &description,
FMantaNavigator *nav );
- void setExtraOptionsDialog( FXDialogBox
*extra_options_dialog_ );
+ void addExtraOptionsDialog( const FXString &name, FXDialogBox
*extra_options_dialog_ );
void setSceneObject( Object *root_object_ );
const string &getCameraBookmark( int i ) { return
camera_text_list[i]; };
Modified: branches/itanium2/fox/dm_demo.cc
==============================================================================
--- branches/itanium2/fox/dm_demo.cc (original)
+++ branches/itanium2/fox/dm_demo.cc Thu Oct 13 04:27:40 2005
@@ -43,6 +43,7 @@
#include <fox/FMantaQuakeNav.h>
#include <fox/FMantaTrackballNav.h>
#include <fox/FMantaWidgets.h>
+#include <fox/FMantaStereo.h>
// #include <histx/SingleSamplerCounter.h>
@@ -266,9 +267,6 @@
manta_interface->setScene( createDefaultScene() );
}
- // Add a camera bookmark for the default camera.
- manta_window.addCameraBookmark( "Default", default_camera );
-
// Check to see if a bookmark file was specified.
if (bookmark_file_name.size() > 0) {
@@ -295,11 +293,13 @@
std::cerr << "Could not load bookmark file." <<
std::endl;
}
}
-
+
+ // Add a camera bookmark for the default camera.
+ manta_window.addCameraBookmark( "Default", default_camera );
// Create the camera using the first camera bookmark.
Camera *camera = manta_interface->createCamera(
manta_window.getCameraBookmark( 0 ) );
-
+
// Create a default quake navigator.
FMantaQuakeNav *quake_nav = new FMantaQuakeNav( false );
quake_nav->setMantaInterface( manta_interface );
@@ -327,7 +327,12 @@
// Set the manta interface for the application.
manta_window.setMantaInterface( manta_interface, manta_channel );
-
+
+ // Check to see if we should enable the stereo dialog.
+ if (use_stereo) {
+ manta_window.addExtraOptionsDialog( "Stereo", new FMantaStereoDialog(
&manta_window, "Stereo" ));
+ }
+
// Check to see if the default scene was a kdtree.
Object *root_object = manta_interface->getScene()->getObject();
@@ -343,8 +348,8 @@
new TransparentKDTree( kdtree, new
KDTreeCopyColorMaterial );
// Create a new extra options dialog.
- manta_window.setExtraOptionsDialog(
- new DmDemoDialog( &manta_window, kdtree,
transparent_kdtree, "Digital Mockup Demo" ) );
+ manta_window.addExtraOptionsDialog( "Transparency",
+ new DmDemoDialog( &manta_window, kdtree, transparent_kdtree,
"Transparency" ));
}
- [MANTA] r621 - in branches/itanium2: Engine/Control Model/Cameras StandAlone fox, abe, 10/13/2005
Archive powered by MHonArc 2.6.16.