Text archives Help
- From: abe@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r592 - in branches/itanium2: . Core Core/Geometry Core/Math Core/Util Engine/Control Engine/Display Interface Model/Cameras StandAlone UserInterface fox scenes
- Date: Mon, 3 Oct 2005 15:23:52 -0600 (MDT)
Author: abe
Date: Mon Oct 3 15:23:48 2005
New Revision: 592
Added:
branches/itanium2/Core/Math/CatmullRomInterpolator.h
branches/itanium2/Model/Cameras/StereoPinholeCamera.cc
branches/itanium2/Model/Cameras/StereoPinholeCamera.h
branches/itanium2/UserInterface/AutomatorUI.cc
branches/itanium2/UserInterface/AutomatorUI.h
branches/itanium2/UserInterface/CameraPathAutomator.cc
branches/itanium2/UserInterface/CameraPathAutomator.h
Modified:
branches/itanium2/CMakeLists.txt
branches/itanium2/Core/CMakeLists.txt
branches/itanium2/Core/Geometry/PointVector.cc
branches/itanium2/Core/Geometry/PointVector.h
branches/itanium2/Core/Util/Args.h
branches/itanium2/Engine/Control/RTRT_register.cc
branches/itanium2/Engine/Display/GLXImageDisplay.cc
branches/itanium2/Engine/Display/OpenGLDisplay.cc
branches/itanium2/Interface/Callback.h
branches/itanium2/Interface/CallbackHelpers.h
branches/itanium2/Interface/HitInfo.h
branches/itanium2/Model/Cameras/CMakeLists.txt
branches/itanium2/StandAlone/manta.cc
branches/itanium2/UserInterface/CMakeLists.txt
branches/itanium2/fox/CMakeLists.txt
branches/itanium2/fox/FMantaImageFrame.cc
branches/itanium2/fox/dm_demo.cc
branches/itanium2/scenes/CMakeLists.txt
Log:
Added Catmull-Rom spline camera paths. Integrated as a "UserInterface". Runs
asynchronously from the renderer and interacts
exactly as a real user would. Next I will add functionality to the dm_demo
gui to create and run camera paths.
bin/manta -np 8 -ui "camerapath( -file path.txt )" -ui X
The file path might look something like:
delta_t( 0.1 )
delta_time( 0.15 )
control( -eye 3 3 2 -lookat 0 0 0.3 -up 0 0 1 -fov 60 )
control( -eye 4.18376 -0.260208 2.12167 -lookat -7.39408e-17 -2.32608e-17
0.3 -up -0.0330953 -0.114221 0.992904 -fov 60 )
control( -eye 2.73712 -3.18735 2.09972 -lookat 6.48461e-17 -2.15539e-17 0.3
-up -0.0896368 -0.0486321 0.994786 -fov 60 )
control( -eye -0.217132 -4.21666 2.05005 -lookat 1.12663e-17 -1.74205e-17
0.3 -up -0.152749 0.014818 0.988154 -fov 60 )
control( -eye -4.12355 -1.73399 1.23789 -lookat 7.40437e-17 -6.21118e-17 0.3
-up -0.337569 0.304183 0.890797 -fov 60 )
control( -eye -1.41346 4.2673 1.12599 -lookat -5.07002e-17 -4.77869e-17 0.3
-up 0.141878 0.260522 0.954986 -fov 60 )
control( -eye 2.41061 3.14222 2.58153 -lookat -1.8791e-16 2.06005e-17 0.3
-up 0.126055 -0.252299 0.959404 -fov 60 )
control( -eye 3.70746 -2.59701 0.932687 -lookat -7.58092e-17 1.27764e-16 0.3
-up -0.0234438 -0.473572 0.880443 -fov 60 )
control( -eye -1.78581 -4.20679 0.361436 -lookat -1.68586e-17 9.86746e-17
0.3 -up -0.407909 -0.218 0.886615 -fov 60 )
control( -eye -4.41013 1.16355 0.594776 -lookat -1.31251e-18 4.99702e-17 0.3
-up -0.230207 0.359399 0.904344 -fov 60 )
control( -eye -2.26883 3.91878 0.920931 -lookat 3.20154e-17 1.41303e-17 0.3
-up 0.160944 0.38285 0.909683 -fov 60 )
More examples and instructions for benchmarking soon.
Incremental changes to stereo code for integrating with fox based demo.
M scenes/CMakeLists.txt
M StandAlone/manta.cc
A Core/Math/CatmullRomInterpolator.h
M Core/Geometry/PointVector.cc
M Core/Geometry/PointVector.h
M Core/Util/Args.h
M Core/CMakeLists.txt
M fox/dm_demo.cc
M fox/FMantaImageFrame.cc
M fox/CMakeLists.txt
A UserInterface/AutomatorUI.h
A UserInterface/CameraPathAutomator.cc
A UserInterface/CameraPathAutomator.h
M UserInterface/CMakeLists.txt
A UserInterface/AutomatorUI.cc
A Model/Cameras/StereoPinholeCamera.h
M Model/Cameras/CMakeLists.txt
A Model/Cameras/StereoPinholeCamera.cc
M Interface/HitInfo.h
M Interface/Callback.h
M Interface/CallbackHelpers.h
M Engine/Control/RTRT_register.cc
M Engine/Display/GLXImageDisplay.cc
M Engine/Display/OpenGLDisplay.cc
M CMakeLists.txt
Modified: branches/itanium2/CMakeLists.txt
==============================================================================
--- branches/itanium2/CMakeLists.txt (original)
+++ branches/itanium2/CMakeLists.txt Mon Oct 3 15:23:48 2005
@@ -78,8 +78,8 @@
# For now force sproc on IRIX systems.
# MESSAGE("Forcing Irix Threads")
- SET(CMAKE_USE_SPROC_INIT 1)
- SET(CMAKE_USE_PTHREADS_INIT 0)
+ SET(CMAKE_USE_SPROC_INIT 0)
+ SET(CMAKE_USE_PTHREADS_INIT 1)
SET(CMAKE_THREAD_LIBS_INIT -lfetchop)
# Check for CC compiler and add -LANG:std to it
Modified: branches/itanium2/Core/CMakeLists.txt
==============================================================================
--- branches/itanium2/Core/CMakeLists.txt (original)
+++ branches/itanium2/Core/CMakeLists.txt Mon Oct 3 15:23:48 2005
@@ -24,7 +24,9 @@
Math/MT_RNG.cc
Math/Noise.h
Math/Noise.cc
- Math/ipow.h)
+ Math/ipow.h
+ Math/CatmullRomInterpolator.h
+ )
SET (CORE_SOURCES ${CORE_SOURCES}
Util/Args.h
Util/Args.cc)
Modified: branches/itanium2/Core/Geometry/PointVector.cc
==============================================================================
--- branches/itanium2/Core/Geometry/PointVector.cc (original)
+++ branches/itanium2/Core/Geometry/PointVector.cc Mon Oct 3 15:23:48
2005
@@ -20,6 +20,20 @@
return os;
}
+ template<typename T, int Dim>
+ std::istream &operator>> (std::istream &is, VectorT<T,Dim> &v) {
+ for (int i=0;i<Dim;++i)
+ is >> v[i];
+ return is;
+ }
+
+ template<typename T, int Dim>
+ std::istream &operator>> (std::istream &is, PointT<T,Dim> &v) {
+ for (int i=0;i<Dim;++i)
+ is >> v[i];
+ return is;
+ }
+
// Explicit instantiations for ostream operators
// 3D Vectors
@@ -41,4 +55,27 @@
template std::ostream& operator<<(std::ostream& os, const PointT<double,
2>&);
template std::ostream& operator<<(std::ostream& os, const PointT<float,
2>&);
template std::ostream& operator<<(std::ostream& os, const PointT<int, 2>&);
+
+ // Explicit instantiations for istream operators
+
+ // 3D Vectors
+ template std::istream& operator>>(std::istream& is, VectorT<double, 3>&);
+ template std::istream& operator>>(std::istream& is, VectorT<float, 3>&);
+ template std::istream& operator>>(std::istream& is, VectorT<int, 3>&);
+
+ // 3D Points
+ template std::istream& operator>>(std::istream& is, PointT<double, 3>&);
+ template std::istream& operator>>(std::istream& is, PointT<float, 3>&);
+ template std::istream& operator>>(std::istream& is, PointT<int, 3>&);
+
+ // 2D Vectors
+ template std::istream& operator>>(std::istream& is, VectorT<double, 2>&);
+ template std::istream& operator>>(std::istream& is, VectorT<float, 2>&);
+ template std::istream& operator>>(std::istream& is, VectorT<int, 2>&);
+
+ // 2D Points
+ template std::istream& operator>>(std::istream& is, PointT<double, 2>&);
+ template std::istream& operator>>(std::istream& is, PointT<float, 2>&);
+ template std::istream& operator>>(std::istream& is, PointT<int, 2>&);
+
}
Modified: branches/itanium2/Core/Geometry/PointVector.h
==============================================================================
--- branches/itanium2/Core/Geometry/PointVector.h (original)
+++ branches/itanium2/Core/Geometry/PointVector.h Mon Oct 3 15:23:48
2005
@@ -481,6 +481,11 @@
template<typename T, int Dim>
std::ostream &operator<< (std::ostream &os, const PointT<T,Dim> &v);
+ template<typename T, int Dim>
+ std::istream &operator>> (std::istream &is, VectorT<T,Dim> &v);
+
+ template<typename T, int Dim>
+ std::istream &operator>> (std::istream &is, PointT<T,Dim> &v);
}
#endif
Added: branches/itanium2/Core/Math/CatmullRomInterpolator.h
==============================================================================
--- (empty file)
+++ branches/itanium2/Core/Math/CatmullRomInterpolator.h Mon Oct 3
15:23:48 2005
@@ -0,0 +1,60 @@
+
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institue, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef __CATMULLROMINTERPOLATOR_H__
+#define __CATMULLROMINTERPOLATOR_H__
+
+#include <MantaTypes.h>
+
+namespace Manta {
+
+ template< typename PointIterator, typename PointType >
+ void catmull_rom_interpolate( const PointIterator &P_iter, Real t,
PointType &result ) {
+
+ PointType &P_i = *(P_iter); // "Pi"
+ PointType &P_im1 = *(P_iter-1); // "Pi minus 1"
+ PointType &P_ip1 = *(P_iter+1); // "Pi plus 1"
+ PointType &P_ip2 = *(P_iter+2); // "Pi plus 2"
+
+ Real t2 = t*t;
+ Real t3 = t*t2;
+
+ PointType r0 = (P_i * 2.0);
+ PointType r1 = (P_im1*-1.0 + P_ip1) * t;
+ PointType r2 = (P_im1* 2.0 + P_i*-5.0 + P_ip1* 4.0 -P_ip2) * t2;
+ PointType r3 = (P_im1*-1.0 + P_i* 3.0 + P_ip1*-3.0 +P_ip2) * t3;
+
+ result = (r0 + r1)*0.5 + (r2 + r3)*0.5;
+ }
+
+
+};
+
+#endif
+
Modified: branches/itanium2/Core/Util/Args.h
==============================================================================
--- branches/itanium2/Core/Util/Args.h (original)
+++ branches/itanium2/Core/Util/Args.h Mon Oct 3 15:23:48 2005
@@ -42,8 +42,6 @@
}
}
-
-
// This will separate input into whitespace separated arguments. If
// you want a single argument to contain whitespace you must
// encapsulate the argument with single quotes.
Modified: branches/itanium2/Engine/Control/RTRT_register.cc
==============================================================================
--- branches/itanium2/Engine/Control/RTRT_register.cc (original)
+++ branches/itanium2/Engine/Control/RTRT_register.cc Mon Oct 3 15:23:48
2005
@@ -32,6 +32,7 @@
#include <Image/SimpleImage.h>
#include <Model/Cameras/EnvironmentCamera.h>
#include <Model/Cameras/PinholeCamera.h>
+#include <Model/Cameras/StereoPinholeCamera.h>
#include <Model/Cameras/OrthogonalCamera.h>
#include <Model/Cameras/FisheyeCamera.h>
#include <Model/Groups/BVH.h>
@@ -40,6 +41,7 @@
#include <UserInterface/PromptUI.h>
#include <UserInterface/XWindowUI.h>
#include <UserInterface/NullUI.h>
+#include <UserInterface/CameraPathAutomator.h>
@@ -91,6 +93,7 @@
// Register cameras
rtrt->registerComponent("environment", &EnvironmentCamera::create);
rtrt->registerComponent("pinhole", &PinholeCamera::create);
+ rtrt->registerComponent("stereo", &StereoPinholeCamera::create);
rtrt->registerComponent("orthogonal", &OrthogonalCamera::create);
rtrt->registerComponent("fisheye", &FisheyeCamera::create);
@@ -106,6 +109,7 @@
rtrt->registerComponent("null", &NullUI::create);
rtrt->registerComponent("prompt", &PromptUI::create);
rtrt->registerComponent("X", &XWindowUI::create);
+ rtrt->registerComponent("camerapath", &CameraPathAutomator::create);
// Register groups
rtrt->registerObject("group", &Group::create);
Modified: branches/itanium2/Engine/Display/GLXImageDisplay.cc
==============================================================================
--- branches/itanium2/Engine/Display/GLXImageDisplay.cc (original)
+++ branches/itanium2/Engine/Display/GLXImageDisplay.cc Mon Oct 3 15:23:48
2005
@@ -39,9 +39,13 @@
// Manta ImageDisplay interface.
void GLXImageDisplay::setupDisplayChannel( SetupContext &context ) {
- // The setup for the window should be done in the driving application.
- std::cout << "setupDisplayChannel " << context.proc << std::endl;
+
+ // The setup for the window should be done in the driving application.
+ // Note that if stereo is desired it must be specified when creating the
visual
+ // in the driving application.
+
+ // std::cout << "setupDisplayChannel " << context.proc << std::endl;
// Only the display processor.
if (context.proc != 0)
@@ -49,7 +53,7 @@
// Check to see if we are already connected to the X server.
if (x_display == 0) {
- std::cout << "setupDisplayChannel: Connecting to server. " <<
context.proc << std::endl;
+ // std::cout << "setupDisplayChannel: Connecting to server. "
<< context.proc << std::endl;
x_display = XOpenDisplay( 0 ); // Open a new connection to
the same display...
}
@@ -78,7 +82,6 @@
bool stereo;
image->getResolution( stereo, xres, yres );
-
// This code is from OpenGLImageDisplay.
glViewport(0, 0, xres, yres);
@@ -120,7 +123,6 @@
} else if(typeid(*image) ==
typeid(SimpleImage<RGBAfloatPixel>)){
const SimpleImage<RGBAfloatPixel>* si =
dynamic_cast<const SimpleImage<RGBAfloatPixel>*>(image);
-
///////////////////////////////////////////////////////////////////////////
// Assuming this is a performance image: normalize
the image values.
int total_size = xres * yres;
@@ -184,4 +186,5 @@
std::cerr << "GLXImageDisplay: Error code from
OpenGL: " << gluErrorString(errcode) << std::endl;
}
}
-}
\ No newline at end of file
+}
+
Modified: branches/itanium2/Engine/Display/OpenGLDisplay.cc
==============================================================================
--- branches/itanium2/Engine/Display/OpenGLDisplay.cc (original)
+++ branches/itanium2/Engine/Display/OpenGLDisplay.cc Mon Oct 3 15:23:48
2005
@@ -236,34 +236,17 @@
if(typeid(*image) == typeid(SimpleImage<RGBA8Pixel>)){
const SimpleImage<RGBA8Pixel>* si = dynamic_cast<const
SimpleImage<RGBA8Pixel>*>(image);
if(stereo){
- gl_print_error(__FILE__,__LINE__);
-
glDrawBuffer(GL_BACK_LEFT);
- gl_print_error(__FILE__,__LINE__);
-
glRasterPos2i(0,0);
- gl_print_error(__FILE__,__LINE__);
-
glDrawPixels(xres, yres, GL_RGBA, GL_UNSIGNED_BYTE, si->getRaw(0));
- gl_print_error(__FILE__,__LINE__);
-
glDrawBuffer(GL_BACK_RIGHT);
- gl_print_error(__FILE__,__LINE__);
-
glRasterPos2i(0,0); gl_print_error(__FILE__,__LINE__);
- gl_print_error(__FILE__,__LINE__);
-
glDrawPixels(xres, yres, GL_RGBA, GL_UNSIGNED_BYTE, si->getRaw(1));
- gl_print_error(__FILE__,__LINE__);
-
-
} else {
glDrawBuffer(GL_BACK);
glRasterPos2i(0,0);
glDrawPixels(xres, yres, GL_RGBA, GL_UNSIGNED_BYTE, si->getRaw(0));
-
- gl_print_error(__FILE__,__LINE__);
}
} else if(typeid(*image) == typeid(SimpleImage<RGB8Pixel>)){
const SimpleImage<RGB8Pixel>* si = dynamic_cast<const
SimpleImage<RGB8Pixel>*>(image);
Modified: branches/itanium2/Interface/Callback.h
==============================================================================
--- branches/itanium2/Interface/Callback.h (original)
+++ branches/itanium2/Interface/Callback.h Mon Oct 3 15:23:48 2005
@@ -43,6 +43,12 @@
return new Callback_0Data_2Arg_const<T, Arg1, Arg2>(ptr, pmf, arg1,
arg2);
}
+ template<class T, typename Arg1, typename Arg2, typename Arg3> static
+ CallbackBase_0Data*
+ create(T* ptr, void (T::*pmf)(Arg1, Arg2, Arg3), Arg1 arg1, Arg2 arg2,
Arg3 arg3) {
+ return new Callback_0Data_3Arg<T, Arg1, Arg2, Arg3>(ptr, pmf, arg1,
arg2, arg3);
+ }
+
template<class T, typename Arg1, typename Arg2, typename
Arg3, typename Arg4> static
CallbackBase_0Data*
create(T* ptr, void (T::*pmf)(Arg1, Arg2, Arg3, Arg4), Arg1 arg1, Arg2
arg2, Arg3 arg3, Arg4 arg4) {
Modified: branches/itanium2/Interface/CallbackHelpers.h
==============================================================================
--- branches/itanium2/Interface/CallbackHelpers.h (original)
+++ branches/itanium2/Interface/CallbackHelpers.h Mon Oct 3 15:23:48
2005
@@ -242,6 +242,29 @@
Arg2 arg2;
};
+ template<class T, typename Arg1, typename Arg2, typename Arg3>
+ class Callback_0Data_3Arg : public CallbackBase_0Data {
+ public:
+ Callback_0Data_3Arg(T* ptr, void (T::*pmf)(Arg1, Arg2, Arg3), Arg1
arg1, Arg2 arg2, Arg3 arg3)
+ : ptr(ptr), pmf(pmf), arg1(arg1), arg2(arg2), arg3(arg3)
+ {
+ }
+ virtual ~Callback_0Data_3Arg()
+ {
+ }
+ virtual void call()
+ {
+ (ptr->*pmf)(arg1, arg2, arg3);
+ }
+ private:
+ T* ptr;
+ void (T::*pmf)(Arg1, Arg2, Arg3);
+ Arg1 arg1;
+ Arg2 arg2;
+ Arg3 arg3;
+ };
+
+
template<class T, typename Arg1, typename Arg2, typename Arg3,
typename Arg4 >
class Callback_0Data_4Arg : public CallbackBase_0Data {
public:
Modified: branches/itanium2/Interface/HitInfo.h
==============================================================================
--- branches/itanium2/Interface/HitInfo.h (original)
+++ branches/itanium2/Interface/HitInfo.h Mon Oct 3 15:23:48 2005
@@ -111,7 +111,7 @@
static const size_t MaxScratchpadSize = 128;
void copyScratchpad( const HitInfo &info ) {
- for (int i=0;i<MaxScratchpadSize;++i)
+ for (size_t i=0;i<MaxScratchpadSize;++i)
scratchpad_data[i] = info.scratchpad_data[i];
}
Modified: branches/itanium2/Model/Cameras/CMakeLists.txt
==============================================================================
--- branches/itanium2/Model/Cameras/CMakeLists.txt (original)
+++ branches/itanium2/Model/Cameras/CMakeLists.txt Mon Oct 3 15:23:48
2005
@@ -8,4 +8,6 @@
Cameras/OrthogonalCamera.cc
Cameras/FisheyeCamera.h
Cameras/FisheyeCamera.cc
+ Cameras/StereoPinholeCamera.h
+ Cameras/StereoPinholeCamera.cc
)
Added: branches/itanium2/Model/Cameras/StereoPinholeCamera.cc
==============================================================================
--- (empty file)
+++ branches/itanium2/Model/Cameras/StereoPinholeCamera.cc Mon Oct 3
15:23:48 2005
@@ -0,0 +1,253 @@
+
+#include <MantaTypes.h>
+#include <Model/Cameras/StereoPinholeCamera.h>
+#include <Core/Util/Args.h>
+#include <Core/Exceptions/IllegalArgument.h>
+#include <Interface/RayPacket.h>
+#include <Core/Geometry/BBox.h>
+#include <Core/Geometry/AffineTransform.h>
+#include <Core/Math/MiscMath.h>
+#include <Core/Math/Trig.h>
+#include <Core/Util/Assert.h>
+#include <iostream>
+
+using namespace Manta;
+using namespace std;
+using SCIRun::Clamp;
+
+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 = 0.0;
+
+ // 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 );
+ up = Vector( 0.0, 0.0, 1.0 );
+ hfov = 60.0;
+
+ 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;
+ } 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 {
+ throw IllegalArgument("StereoPinholeCamera", i, args);
+ }
+ }
+
+ setup();
+}
+
+StereoPinholeCamera::~StereoPinholeCamera()
+{
+}
+
+void StereoPinholeCamera::output( std::ostream &os ) {
+
+ os << "pinhole( -eye " << eye
+ << " -lookat " << lookat
+ << " -up " << up
+ << " -fov " << hfov << " )"
+ << std::endl;
+}
+
+Camera* StereoPinholeCamera::create(const vector<string>& args)
+{
+ return new StereoPinholeCamera(args);
+}
+
+void StereoPinholeCamera::setup()
+{
+ int i;
+ vfov = hfov;
+ direction=lookat-eye;
+ nearZ=direction.length();
+
+ Vector n = direction;
+ n.normalize();
+
+ for(i=0; i<3; i++)
+ uvn[2][i] = n[i];
+
+ v=Cross(direction, up);
+ if(v.length2() == 0.0){
+ std::cerr << __FILE__ << " line: " << __LINE__ << " Ambiguous up
direciton...\n";
+ }
+ v.normalize();
+
+ for(i=0; i<3; i++)
+ uvn[1][i] = v[i];
+
+ u=Cross(v, direction);
+ u.normalize();
+
+ for(i=0; i<3; i++)
+ uvn[0][i] = u[i];
+
+ 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
+{
+ 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);
+ raydir.normalize();
+ e.ray.set(stereo_eye[e.whichEye], raydir);
+ e.importance = 1.0;
+ }
+ rays.setFlag(RayPacket::NormalizedDirections);
+
+
+ } else {
+ for(int i=0;i<rays.getSize();i++){
+ RayPacket::Element& e = rays.get(i);
+
+ Vector raydir(v*e.imageX+u*e.imageY+direction);
+
+ e.ray.set(stereo_eye[e.whichEye], raydir);
+ e.importance = 1.0;
+ }
+
+
+ }
+}
+
+void StereoPinholeCamera::scaleFOV(double scale)
+{
+ double fov_min = 0;
+ double fov_max = 180;
+ hfov = RtoD(2*atan(scale*tan(DtoR(hfov/2.))));
+ hfov = Clamp(hfov, fov_min, fov_max);
+ vfov = RtoD(2*atan(scale*tan(DtoR(vfov/2.))));
+ vfov = Clamp(vfov, fov_min, fov_max);
+ setup();
+}
+
+void StereoPinholeCamera::translate(Vector t)
+{
+ Vector trans(u*t.y()+v*t.x());
+
+ eye += trans;
+ lookat += trans;
+ setup();
+}
+
+void StereoPinholeCamera::dolly(double scale)
+{
+ Vector d = (lookat - eye) * scale;
+ eye += d;
+ // lookat += d; // Maybe we need two types of dolly. // Maybe not.
+ setup();
+}
+
+void StereoPinholeCamera::transform(AffineTransform t, TransformCenter
center)
+{
+ Point cen;
+ switch(center){
+ case Eye:
+ cen = eye;
+ break;
+ case LookAt:
+ cen = lookat;
+ break;
+ case Origin:
+ cen = Point(0,0,0);
+ break;
+ }
+
+ Vector lookdir(eye-lookat);
+ double length = lookdir.length();
+
+ AffineTransform frame;
+ frame.initWithBasis(v.normal(), u.normal(), lookdir.normal(), cen);
+
+ AffineTransform frame_inv = frame;
+ frame_inv.invert();
+
+ AffineTransform t2 = frame * t * frame_inv;
+ up = t2 * up;
+ eye = t2 * eye;
+ lookat = t2 * lookat;
+ setup();
+}
+
+void StereoPinholeCamera::autoview(double new_fov)
+{
+ BBox bbox(Point(-1,-1,0.2), Point(1,1,2.2));
+ // double ratio = tan(DtoR(vfov/2))/tan(DtoR(hfov/2));
+ hfov = new_fov;
+ vfov = RtoD(2*atan(tan(DtoR(hfov/2))));
+ Vector diag(bbox.diagonal());
+ double w=diag.length();
+ Vector lookdir(eye-lookat);
+ lookdir.normalize();
+ double scale = 1.0/(2*tan(DtoR(hfov/2.0)));
+ double length = w*scale;
+ lookat = bbox.center();
+ eye = lookat+lookdir*length;
+ setup();
+}
+
+Point StereoPinholeCamera::project(const Point &point) const
+{
+ // translate camera center to origin
+ Vector trans(-eye.x(), -eye.y(), -eye.z());
+ Point p1 = point + trans;
+
+ // rotate to align with camera axis
+ Point p2((uvn[0][0]*p1.x() + uvn[0][1]*p1.y() + uvn[0][2]*p1.z()),
+ (uvn[1][0]*p1.x() + uvn[1][1]*p1.y() + uvn[1][2]*p1.z()),
+ (uvn[2][0]*p1.x() + uvn[2][1]*p1.y() + uvn[2][2]*p1.z()));
+
+ // project the point to the image plane using simlar triangles
+ // the viewZ is just a ratio to tell whether point is valid or not
+ // if returned viewZ>1, it means that the point lied beyong the image plane
+ // and is visible to camera, else it is not
+ // It is not a sufficient condition though, the x and y coordinates should
lie within the
+ // width and height of the image, so returned coordinates are in the
normalized space [-1,1]
+ if(fabs(p2.z())<0.0001) // check for inconsistencies
+ return Point(0,0,0);
+ else
+ return Point((p2.x()*nearZ/p2.z())/(width/2.0),
+ (p2.y()*nearZ/p2.z())/(height/2.0),
+ p2.z()/nearZ);
+}
Added: branches/itanium2/Model/Cameras/StereoPinholeCamera.h
==============================================================================
--- (empty file)
+++ branches/itanium2/Model/Cameras/StereoPinholeCamera.h Mon Oct 3
15:23:48 2005
@@ -0,0 +1,61 @@
+
+#ifndef Manta_Model_StereoPinholeCamera_h
+#define Manta_Model_StereoPinholeCamera_h
+
+#include <Interface/Camera.h>
+#include <Core/Geometry/PointVector.h>
+#include <sgi_stl_warnings_off.h>
+#include <string>
+#include <vector>
+#include <sgi_stl_warnings_on.h>
+
+namespace Manta {
+ using namespace std;
+
+ 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 vector<string>& args);
+
+ virtual ~StereoPinholeCamera();
+ virtual void makeRays(RayPacket&) const;
+
+ // Camera manipulation
+ virtual void scaleFOV(double);
+ virtual void translate(Vector);
+ virtual void dolly(double);
+ virtual void transform(AffineTransform t, TransformCenter);
+ 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);
+
+ 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(); };
+
+ private:
+ void setup();
+ Point eye;
+ Point lookat;
+ Vector up;
+ Real stereo_offset;
+ 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;
+
+ // for projection we maintain a uvn rotation matrix
+ double uvn[3][3];
+ };
+}
+
+#endif
Modified: branches/itanium2/StandAlone/manta.cc
==============================================================================
--- branches/itanium2/StandAlone/manta.cc (original)
+++ branches/itanium2/StandAlone/manta.cc Mon Oct 3 15:23:48 2005
@@ -107,8 +107,7 @@
#if HAVE_IEEEFP_H
fpsetmask(FP_X_OFL|FP_X_DZ|FP_X_INV);
#endif
-
-
+
// Copy args into a vector<string>
vector<string> args;
for(int i=1;i<argc;i++)
Added: branches/itanium2/UserInterface/AutomatorUI.cc
==============================================================================
--- (empty file)
+++ branches/itanium2/UserInterface/AutomatorUI.cc Mon Oct 3 15:23:48
2005
@@ -0,0 +1,86 @@
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institue, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#include <UserInterface/AutomatorUI.h>
+
+#include <SCIRun/Core/Thread/Thread.h>
+
+#include <Interface/Callback.h>
+
+using namespace Manta;
+using namespace SCIRun;
+
+AutomatorUI::AutomatorUI( RTRTInterface *manta_interface_, int
warmup_frames_ ) :
+ manta_interface( manta_interface_ ),
+ warmup_frames( warmup_frames_ ),
+ startup_semaphore( "AutomatorUI semaphore", 0 )
+{
+}
+
+void AutomatorUI::run() {
+
+ // Have manta call release_automator after warmup_frames.
+ manta_interface->addOneShotCallback( RTRTInterface::Absolute,
warmup_frames,
+ Callback::create(this,
&AutomatorUI::release_automator) );
+
+
+ // Wait for the manta rendering threads to signal the semaphore.
+ startup_semaphore.down();
+
+ // Run the automator function.
+ run_automator();
+
+ // Send a final transaction to make sure all of the state changes sent from
+ // run_automator are processed before the thread exits.
+ startup_semaphore.down();
+
+ getMantaInterface()->addTransaction("AutomatorUI finished",
+ Callback::create(this,
&AutomatorUI::release_automator,
+ 0, 0));
+}
+
+void AutomatorUI::startup() {
+
+ // Create a detached thread for the automator.
+ Thread *t = new Thread( this, "AutomatorUI" );
+ t->setDaemon( true );
+ t->detach();
+}
+
+void AutomatorUI::release_automator(int, int) {
+
+ // Signal the semaphore.
+ startup_semaphore.up();
+}
+
+
+
+
+
+
+
Added: branches/itanium2/UserInterface/AutomatorUI.h
==============================================================================
--- (empty file)
+++ branches/itanium2/UserInterface/AutomatorUI.h Mon Oct 3 15:23:48
2005
@@ -0,0 +1,88 @@
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institue, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef __AUTOMATOR_UI_H__
+#define __AUTOMATOR_UI_H__
+
+#include <Interface/RTRTInterface.h>
+#include <Interface/UserInterface.h>
+
+#include <SCIRun/Core/Thread/Runnable.h>
+#include <SCIRun/Core/Thread/Semaphore.h>
+
+
+
+namespace Manta {
+
+ using SCIRun::Runnable;
+ using SCIRun::Semaphore;
+
+
/////////////////////////////////////////////////////////////////////////////
+ // An Automator is an automated user interface. Classes which implement the
+ // run method may send transactions to Manta or interact with
+ // the renderer in any way that a normal user interface would.
+ //
+ // The Automator runs in a seperate thread and is completely asynchronous
+ // after it is started. The thread is created by a startup but will block
so that it
+ // doesn't come online until the renderer is ready to accept transactions.
+ //
+ // Abe Stephens
+ class AutomatorUI : public UserInterface, public Runnable {
+ private:
+ // Flag to signal that the renderer is ready to begin accepting
connections.
+ Semaphore startup_semaphore;
+
+ // Interface to communicate with the renderer.
+ RTRTInterface *manta_interface;
+
+ // Number of frames to wait before starting.
+ int warmup_frames;
+
+ protected:
+ inline RTRTInterface *getMantaInterface() { return manta_interface; };
+
+ public:
+ // Renderer will release the semaphore after "warmup_frames" have been
rendered
+ AutomatorUI( RTRTInterface *manta_interface_, int warmup_frames_ = 0 );
+ virtual ~AutomatorUI() { };
+
+ // This method must be implemented by Automator implementations.
+ virtual void run_automator() = 0;
+
+ // Runnable interface.
+ void run();
+
+ // UserInterface interface.
+ void startup();
+
+ // Called by manta to release semaphore.
+ void release_automator( int, int );
+ };
+};
+
+#endif
Modified: branches/itanium2/UserInterface/CMakeLists.txt
==============================================================================
--- branches/itanium2/UserInterface/CMakeLists.txt (original)
+++ branches/itanium2/UserInterface/CMakeLists.txt Mon Oct 3 15:23:48
2005
@@ -4,6 +4,11 @@
PromptUI.cc
XWindowUI.h
XWindowUI.cc
- NullUI.h)
+ NullUI.h
+ AutomatorUI.h
+ AutomatorUI.cc
+ CameraPathAutomator.h
+ CameraPathAutomator.cc
+ )
TARGET_LINK_LIBRARIES(Manta_UserInterface Manta_Core Manta_Interface)
TARGET_LINK_LIBRARIES(Manta_UserInterface ${X11_LIBRARIES})
Added: branches/itanium2/UserInterface/CameraPathAutomator.cc
==============================================================================
--- (empty file)
+++ branches/itanium2/UserInterface/CameraPathAutomator.cc Mon Oct 3
15:23:48 2005
@@ -0,0 +1,298 @@
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institue, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#include <UserInterface/CameraPathAutomator.h>
+
+#include <SCIRun/Core/Thread/Time.h>
+#include <SCIRun/Core/Exceptions/ErrnoException.h>
+
+#include <Interface/Camera.h>
+#include <Interface/Callback.h>
+
+#include <Core/Math/CatmullRomInterpolator.h>
+#include <Core/Exceptions/IllegalArgument.h>
+#include <Core/Util/Args.h>
+
+#include <stdio.h>
+
+using namespace Manta;
+using namespace SCIRun;
+
+extern int errno;
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP
SETU
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+CameraPathAutomator::CameraPathAutomator( RTRTInterface *manta_interface_,
int channel_,
+ int warmup_frames, const string
&file_name ) :
+ AutomatorUI( manta_interface_, warmup_frames ),
+ channel( channel_ )
+{
+ delta_t = 0.25;
+ delta_time = 0.1;
+ total_points = 0;
+
+ vector<string> args;
+ string name;
+
+ char line[128];
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Load the input file.
+ FILE *file = fopen( file_name.c_str(), "r" );
+ if (file == 0) {
+ throw ErrnoException( "Cannot open camera path file: " + file_name,
+ errno, __FILE__, __LINE__ );
+ }
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Count input.
+ while (!feof(file)) {
+
+ // Read in one line at a time.
+ fgets( line, 127, file );
+
+ // Parse a manta specification.
+ parseSpec( line, name, args );
+
+ // Count the number of control points.
+ if (name == "control") {
+ total_points++;
+ }
+ }
+
+ // Rewind the input file.
+ fseek( file, SEEK_SET, 0 );
+
+ // Allocate storage for points.
+ eye = new Point [total_points];
+ lookat = new Point [total_points];
+ up = new Vector[total_points];
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Copy out input.
+ int line_num = 0;
+ int control_point = 0;
+ char error_message[64];
+
+ while (!feof(file)) {
+
+ // Parse a new set of args.
+ args.clear();
+
+ fgets( line, 127, file );
+ parseSpec( line, name, args );
+
+ // Set i so that ++i == 0 to trick getArg
+ int i = -1;
+
+
///////////////////////////////////////////////////////////////////////////
+ // Parse the args.
+
+ // Line should be "delta_t( 0.25 )"
+ if (name == "delta_t") {
+ if (!getArg(i,args,delta_t)) {
+ sprintf(error_message, "CameraPathAutomator input line: %d",
line_num );
+ throw IllegalArgument(error_message, i, args);
+ }
+ }
+ else if (name == "delta_time") {
+ if (!getArg(i,args,delta_time)) {
+ sprintf(error_message, "CameraPathAutomator input line: %d",
line_num );
+ throw IllegalArgument(error_message, i, args);
+ }
+ }
+ else if (name == "control") {
+
+
/////////////////////////////////////////////////////////////////////////
+ // Parse eye, lookat and up from the args.
+ Point eye_, lookat_;
+ Vector up_;
+
+ bool got_eye = false;
+ bool got_lookat = false;
+ bool got_up = false;
+
+ for (int i=0;i<(int)args.size();++i) {
+ if (args[i] == "-eye") {
+ if (!getPointArg(i,args,eye_)) {
+ sprintf(error_message, "CameraPathAutomator -eye input line:
%d", line_num );
+ throw IllegalArgument(error_message, i, args);
+ }
+ got_eye = true;
+ }
+ else if (args[i] == "-lookat") {
+ if (!getPointArg(i,args,lookat_)) {
+ sprintf(error_message, "CameraPathAutomator -lookat input line:
%d", line_num );
+ throw IllegalArgument(error_message, i, args);
+ }
+ got_lookat = true;
+ }
+ else if (args[i] == "-up") {
+ if (!getVectorArg(i,args,up_)) {
+ sprintf(error_message, "CameraPathAutomator -up input line: %d",
line_num );
+ throw IllegalArgument(error_message, i, args);
+ }
+ got_up = true;
+ }
+ }
+
+
/////////////////////////////////////////////////////////////////////////
+ // Add the control point.
+ if (got_eye && got_lookat && got_up) {
+ eye [control_point] = eye_;
+ lookat[control_point] = lookat_;
+ up [control_point] = up_;
+ ++control_point;
+ }
+ else {
+ sprintf(error_message, "CameraPathAutomator incomplete spec input
line: %d", line_num );
+ throw IllegalArgument(error_message, line_num, args);
+ }
+ }
+
+ ++line_num;
+ }
+
+
/////////////////////////////////////////////////////////////////////////////
+
+ std::cerr << "CameraPathAutomator: " << total_points
+ << " control points from " << file_name << std::endl;
+ std::cerr << " Points in path: " << (total_points-3) << std::endl;
+ std::cerr << " delta_t: " << delta_t
+ << " delta_time: " << delta_time << std::endl;
+ std::cerr << " Total time for issue: " <<
((1.0/delta_t)*(total_points-3.0)*delta_time) << " seconds" << std::endl;
+}
+
+CameraPathAutomator::~CameraPathAutomator() {
+
+ delete [] eye;
+ delete [] lookat;
+ delete [] up;
+}
+
+UserInterface *CameraPathAutomator::create( const vector<string> &args,
RTRTInterface *manta_interface_ ) {
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Parse args.
+ string file_name;
+ int warmup_frames = 2;
+ int channel = 0;
+
+ for (int i=0; i<args.size(); ++i) {
+ if (args[i] == "-file") {
+ file_name = args[++i];
+ }
+ else if (args[i] == "-warmup") {
+ getArg(i, args, warmup_frames );
+ }
+ else if (args[i] == "-channel") {
+ getArg(i, args, channel );
+ }
+ }
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Create the Automator.
+ return new CameraPathAutomator( manta_interface_, channel, warmup_frames,
file_name );
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// RUN RUN RUN RUN RUN RUN RUN RUN RUN RUN RUN RUN RUN RUN RUN
R
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
+// Implementation of the interpolator.
+void CameraPathAutomator::run_automator() {
+
+ int current_point = 0;
+ int last_point = total_points-2;
+
+ Point current_eye, current_lookat;
+ Vector current_up;
+
+ std::cerr << "Beginning camera path " << total_points
+ << " control points." << std::endl;
+
+ int transaction_number = 0;
+
+
/////////////////////////////////////////////////////////////////////////////
+ // Main Automator loop.
+ for (current_point=1;current_point<last_point;++current_point) {
+
+
///////////////////////////////////////////////////////////////////////////
+ // Sample by delta_t between the points.
+ for (Real t=0.0; t<(1.0-delta_t); t+=delta_t) {
+
+ // Evaluate the spline.
+ // NOTE: operator & is overloaded by Vector to return (Real *)
+ // NOTE: none of the necessary operations are defined for Points...
+ // so we cast to vectors for the interpolation.
+
+ catmull_rom_interpolate( (Vector *)&eye[current_point], t,
*((Vector *)¤t_eye) );
+ catmull_rom_interpolate( (Vector *)&lookat[current_point], t,
*((Vector *)¤t_lookat) );
+ catmull_rom_interpolate( (Vector *)&up[current_point], t,
current_up );
+
+#if 0
+ std::cerr << "CameraPath: control point: " << current_point << " t: "
<< t
+ << " update: " << transaction_number << std::endl;
+ // << " eye: " << current_eye
+ // << " lookat: " << current_lookat
+ // << " up: " << current_up << std::endl;
+#endif
+ // Send the transaction to manta.
+ getMantaInterface()->addTransaction("CameraPathAutomator",
+ Callback::create(this,
&CameraPathAutomator::mantaSetCamera,
+ current_eye,
current_lookat, current_up ));
+
+ transaction_number++;
+
+
/////////////////////////////////////////////////////////////////////////
+ // Wait for delta_time seconds.
+ double start_time = SCIRun::Time::currentSeconds();
+ while ((SCIRun::Time::currentSeconds()-start_time) < delta_time);
+ }
+ }
+}
+
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+// TRANSACTION CALLBACK TRANSACTION CALLBACK TRANSACTION CALLBACK
TRANSACTIO
+///////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
+
+void CameraPathAutomator::mantaSetCamera( const Point eye_, const Point
lookat_, const Vector up_ ) {
+
+ // Reset the current camera.
+ getMantaInterface()->getCamera( channel )->reset( eye_, up_, lookat_ );
+}
+
+
+
Added: branches/itanium2/UserInterface/CameraPathAutomator.h
==============================================================================
--- (empty file)
+++ branches/itanium2/UserInterface/CameraPathAutomator.h Mon Oct 3
15:23:48 2005
@@ -0,0 +1,77 @@
+/*
+ For more information, please see:
http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institue, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef __CAMERAPATHAUTOMATOR_H__
+#define __CAMERAPATHAUTOMATOR_H__
+
+#include <UserInterface/AutomatorUI.h>
+
+#include <MantaTypes.h>
+#include <Core/Geometry/PointVector.h>
+
+#include <string>
+#include <vector>
+
+namespace Manta {
+
+ using std::string;
+ using std::vector;
+
+ class CameraPathAutomator : public AutomatorUI {
+ private:
+ // Control points.
+ Point *eye;
+ Point *lookat;
+ Vector *up;
+ int total_points;
+
+ // Parameter t interval between control points.
+ Real delta_t;
+
+ // Minimum time to wait between camera movements.
+ Real delta_time;
+
+ // Channel to apply camera changes to.
+ int channel;
+
+ public:
+ CameraPathAutomator( RTRTInterface *manta_interface_, int channel_, int
warmup_, const string &file_name );
+ ~CameraPathAutomator();
+
+ // Create method called by RTRT_register.
+ static UserInterface *create( const vector<string> &args, RTRTInterface
*manta_interface_ );
+
+ // Implementation of the interpolator.
+ virtual void run_automator();
+
+ // This method is called by the manta rendering thread to update the
camera.
+ void mantaSetCamera( const Point eye_, const Point lookat_, const Vector
up_ );
+ };
+};
+
+#endif
Modified: branches/itanium2/fox/CMakeLists.txt
==============================================================================
--- branches/itanium2/fox/CMakeLists.txt (original)
+++ branches/itanium2/fox/CMakeLists.txt Mon Oct 3 15:23:48 2005
@@ -74,4 +74,9 @@
${HISTX_LINK} )
ENDIF(HISTX_PATH)
+ # Fox seems to insist on using pthreads.
+ # IF(CMAKE_USE_SPROC_INIT)
+ TARGET_LINK_LIBRARIES(dm_demo pthread)
+ # ENDIF(CMAKE_USE_SPROC_INIT)
+
ENDIF(FOX_PATH)
Modified: branches/itanium2/fox/FMantaImageFrame.cc
==============================================================================
--- branches/itanium2/fox/FMantaImageFrame.cc (original)
+++ branches/itanium2/fox/FMantaImageFrame.cc Mon Oct 3 15:23:48 2005
@@ -31,7 +31,7 @@
// Constructor, creates a GLX Visual with a double buffer.
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,
+ : FXGLCanvas( p, new FXGLVisual( app, VISUAL_DOUBLEBUFFER |
VISUAL_STEREO ), this, ID_IMAGE,
LAYOUT_FILL|LAYOUT_TOP, 0, 0, width, height ),
fox_target( target_ ),
manta_interface( manta_interface_ )
Modified: branches/itanium2/fox/dm_demo.cc
==============================================================================
--- branches/itanium2/fox/dm_demo.cc (original)
+++ branches/itanium2/fox/dm_demo.cc Mon Oct 3 15:23:48 2005
@@ -196,7 +196,10 @@
int np = 1;
char *scene_text = 0;
string bookmark_file_name;
-
+ string default_camera = "pinhole(-eye 3 3 2 -lookat 0 0 0.3 -up 0 0 1 -fov
60)";
+ bool use_stereo = false;
+
+
// Look for specific args.
for (int i=0;i<argc;++i) {
string arg = argv[i];
@@ -209,6 +212,12 @@
else if (arg == "-bookmarks") {
bookmark_file_name = argv[++i];
}
+ else if (arg == "-stereo") {
+ use_stereo = true;
+ }
+ else if (arg == "-camera") {
+ default_camera = argv[++i];
+ }
}
std::cerr << "Using " << np << " workers plus one gui thread." <<
std::endl;
@@ -285,12 +294,13 @@
}
else {
-
- // Add a camera bookmark for the default camera.
- manta_window.addCameraBookmark( "Default", "pinhole(-eye 3 3
2 -lookat 0 0 0.3 -up 0 0 1 -fov 60)" );
+ std::cout << "Camera: " << default_camera << 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 ) );
@@ -317,7 +327,7 @@
// Create manta channel for the interface.
int manta_channel = 0; // !!! See XWindowUI.cc line: 586
- manta_interface->createChannel( &glx_image_display, camera, false,
width, height );
+ manta_interface->createChannel( &glx_image_display, camera,
use_stereo, width, height );
// Set the manta interface for the application.
manta_window.setMantaInterface( manta_interface, manta_channel );
Modified: branches/itanium2/scenes/CMakeLists.txt
==============================================================================
--- branches/itanium2/scenes/CMakeLists.txt (original)
+++ branches/itanium2/scenes/CMakeLists.txt Mon Oct 3 15:23:48 2005
@@ -51,7 +51,7 @@
ENDIF(SCENE_BOEING777)
# volume
-SET(SCENE_VOLUME 1 CACHE BOOL "volume rendering")
+SET(SCENE_VOLUME 0 CACHE BOOL "volume rendering")
IF(SCENE_VOLUME)
ADD_LIBRARY(scene_volume volume.cc)
TARGET_LINK_LIBRARIES(scene_volume ${manta_scene_link})
- [MANTA] r592 - in branches/itanium2: . Core Core/Geometry Core/Math Core/Util Engine/Control Engine/Display Interface Model/Cameras StandAlone UserInterface fox scenes, abe, 10/03/2005
Archive powered by MHonArc 2.6.16.