Text archives Help
- From: "Thiago Ize" <
>
- To:
- Subject: [Manta] r2312 - in trunk: Core/Util Interface Model/Cameras Model/Materials Model/Primitives UserInterface
- Date: Tue, 29 Jul 2008 17:02:39 -0600 (MDT)
Author: thiago
Date: Tue Jul 29 17:02:37 2008
New Revision: 2312
Modified:
trunk/Core/Util/Callback.h
trunk/Core/Util/CallbackHelpers.h
trunk/Interface/Camera.h
trunk/Model/Cameras/PinholeCamera.cc
trunk/Model/Cameras/PinholeCamera.h
trunk/Model/Materials/Dielectric.cc
trunk/Model/Primitives/MeshTriangle.h
trunk/UserInterface/CameraPathAutomator.cc
trunk/UserInterface/CameraPathAutomator.h
Log:
Core/Util/Callback.h
Core/Util/CallbackHelpers.h:
-Added a "0 call time args --- 5 creating time args" callback.
UserInterface/CameraPathAutomator.h:
-Now also interpolates the fov
Model/Materials/Dielectric.cc:
-quite a compiler warning
Model/Primitives/MeshTriangle.h:
-Added method for returning triangle area.
Model/Cameras/PinholeCamera
Interface/Camera.h:
-Added a reset() that includes fov.
Modified: trunk/Core/Util/Callback.h
==============================================================================
--- trunk/Core/Util/Callback.h (original)
+++ trunk/Core/Util/Callback.h Tue Jul 29 17:02:37 2008
@@ -171,6 +171,13 @@
return new Callback_0Data_4Arg<T, Arg1, Arg2, Arg3, Arg4>(ptr, pmf,
arg1, arg2, arg3, arg4);
}
+ // 0 call time args --- 5 creating time args
+ template<class T, typename Arg1, typename Arg2, typename Arg3, typename
Arg4, typename Arg5> static
+ CallbackBase_0Data*
+ create(T* ptr, void (T::*pmf)(Arg1, Arg2, Arg3, Arg4, Arg5), Arg1 arg1,
Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5) {
+ return new Callback_0Data_5Arg<T, Arg1, Arg2, Arg3, Arg4, Arg5>(ptr,
pmf, arg1, arg2, arg3, arg4, arg5);
+ }
+
// 1 call time args --- 0 creating time args
template<class T, typename Data1> static
CallbackBase_1Data<Data1>*
Modified: trunk/Core/Util/CallbackHelpers.h
==============================================================================
--- trunk/Core/Util/CallbackHelpers.h (original)
+++ trunk/Core/Util/CallbackHelpers.h Tue Jul 29 17:02:37 2008
@@ -546,6 +546,31 @@
Arg4 arg4;
};
+ // 0 call time args --- 5 creating time args
+ template<class T, typename Arg1, typename Arg2, typename Arg3, typename
Arg4, typename Arg5>
+ class Callback_0Data_5Arg : public CallbackBase_0Data {
+ public:
+ Callback_0Data_5Arg(T* ptr, void (T::*pmf)(Arg1, Arg2, Arg3, Arg4,
Arg5), Arg1 arg1, Arg2 arg2, Arg3 arg3, Arg4 arg4, Arg5 arg5)
+ : ptr(ptr), pmf(pmf), arg1(arg1), arg2(arg2), arg3(arg3), arg4(arg4),
arg5(arg5)
+ {
+ }
+ virtual ~Callback_0Data_5Arg()
+ {
+ }
+ virtual void call()
+ {
+ (ptr->*pmf)(arg1, arg2, arg3, arg4, arg5);
+ }
+ private:
+ T* ptr;
+ void (T::*pmf)(Arg1, Arg2, Arg3, Arg4, Arg5);
+ Arg1 arg1;
+ Arg2 arg2;
+ Arg3 arg3;
+ Arg4 arg4;
+ Arg5 arg5;
+ };
+
// 1 call time args --- 0 creating time args
template<class T, typename Data1>
class Callback_1Data_0Arg : public CallbackBase_1Data<Data1> {
Modified: trunk/Interface/Camera.h
==============================================================================
--- trunk/Interface/Camera.h (original)
+++ trunk/Interface/Camera.h Tue Jul 29 17:02:37 2008
@@ -93,6 +93,12 @@
virtual void reset( const Vector& eye_,
const Vector& up_,
const Vector& lookat_ ) = 0;
+ virtual void reset( const Vector& eye_,
+ const Vector& up_,
+ const Vector& lookat_,
+ Real hfov_, Real vfov_) {
+ reset(eye_, up_, lookat_);
+ }
enum TransformCenter {
LookAt,
Modified: trunk/Model/Cameras/PinholeCamera.cc
==============================================================================
--- trunk/Model/Cameras/PinholeCamera.cc (original)
+++ trunk/Model/Cameras/PinholeCamera.cc Tue Jul 29 17:02:37 2008
@@ -497,6 +497,15 @@
setup();
}
+void PinholeCamera::reset( const Vector& eye_, const Vector& up_,
+ const Vector& lookat_, Real hfov_, Real vfov_ )
+{
+ hfov = hfov_;
+ vfov = vfov_;
+ reset(eye_, up_, lookat_);
+}
+
+
void PinholeCamera::getBasicCameraData(BasicCameraData& cam) const
{
cam = BasicCameraData(eye, lookat, up, hfov, vfov);
Modified: trunk/Model/Cameras/PinholeCamera.h
==============================================================================
--- trunk/Model/Cameras/PinholeCamera.h (original)
+++ trunk/Model/Cameras/PinholeCamera.h Tue Jul 29 17:02:37 2008
@@ -42,6 +42,8 @@
virtual void reset( const Vector& eye_, const Vector& up_,
const Vector& lookat_ );
+ virtual void reset( const Vector& eye_, const Vector& up_,
+ const Vector& lookat_, Real hfov_, Real vfov_);
void setStereoOffset( Real stereo_offset_ ) { stereo_offset =
stereo_offset_; }
Real getStereoOffset() const { return stereo_offset; }
Modified: trunk/Model/Materials/Dielectric.cc
==============================================================================
--- trunk/Model/Materials/Dielectric.cc (original)
+++ trunk/Model/Materials/Dielectric.cc Tue Jul 29 17:02:37 2008
@@ -49,7 +49,7 @@
Dielectric::Dielectric(const Texture<Real>* n, const Texture<Real>* nt,
const Texture<Color>* sigma_a,
Real cutoff)
- : n(n), nt(nt), sigma_a(sigma_a), doSchlick(false),
localCutoffScale(cutoff)
+ : n(n), nt(nt), sigma_a(sigma_a), localCutoffScale(cutoff),
doSchlick(false)
{
}
Modified: trunk/Model/Primitives/MeshTriangle.h
==============================================================================
--- trunk/Model/Primitives/MeshTriangle.h (original)
+++ trunk/Model/Primitives/MeshTriangle.h Tue Jul 29 17:02:37 2008
@@ -35,6 +35,12 @@
bbox.extendByBox(mesh->getBBox(myID));
}
+ virtual Real computeArea() const {
+ const Vector v0 = getVertex(0);
+ return static_cast<Real>(0.5) * Cross(getVertex(2) - v0,
+ getVertex(1) - v0).length();
+ }
+
virtual void computeSurfaceDerivatives(const RenderContext& context,
RayPacket& rays) const;
Modified: trunk/UserInterface/CameraPathAutomator.cc
==============================================================================
--- trunk/UserInterface/CameraPathAutomator.cc (original)
+++ trunk/UserInterface/CameraPathAutomator.cc Tue Jul 29 17:02:37 2008
@@ -77,11 +77,14 @@
eye = new Vector[total_points];
lookat = new Vector[total_points];
up = new Vector[total_points];
+ hfov = new float[total_points];
+ vfov = new float[total_points];
for(int i = 0; i < total_points; ++i) {
eye[i] = Vector(eye_[i]);
lookat[i] = Vector(lookat_[i]);
up[i] = up_[i];
+ hfov[i] = vfov[i] = 60; //some arbitrary default
}
}
@@ -107,11 +110,15 @@
eye = new Vector[total_points];
lookat = new Vector[total_points];
up = new Vector[total_points];
+ hfov = new float[total_points];
+ vfov = new float[total_points];
for(int i = 0; i < total_points; ++i) {
eye[i] = camera_data[i].eye;
lookat[i] = camera_data[i].lookat;
up[i] = camera_data[i].up;
+ hfov[i] = camera_data[i].hfov;
+ vfov[i] = camera_data[i].vfov;
}
// Reserve storage for the performance statistics results.
@@ -181,6 +188,8 @@
eye = new Vector[total_points];
lookat = new Vector[total_points];
up = new Vector[total_points];
+ hfov = new float[total_points];
+ vfov = new float[total_points];
/////////////////////////////////////////////////////////////////////////////
// Copy out input.
@@ -219,6 +228,8 @@
/////////////////////////////////////////////////////////////////////////
// Parse eye, lookat and up from the args.
Vector eye_, lookat_, up_;
+ Real hfov_ = 60;
+ Real vfov_ = 60;
bool got_eye = false;
bool got_lookat = false;
@@ -246,6 +257,18 @@
}
got_up = true;
}
+ else if (args[i] == "-hfov") {
+ if (!getArg(i,args,hfov_)) {
+ sprintf(error_message, "CameraPathAutomator -hfov input line:
%d", line_num );
+ throw IllegalArgument(error_message, i, args);
+ }
+ }
+ else if (args[i] == "-vfov") {
+ if (!getArg(i,args,vfov_)) {
+ sprintf(error_message, "CameraPathAutomator -vfov input line:
%d", line_num );
+ throw IllegalArgument(error_message, i, args);
+ }
+ }
}
/////////////////////////////////////////////////////////////////////////
@@ -254,6 +277,8 @@
eye [control_point] = eye_;
lookat[control_point] = lookat_;
up [control_point] = up_;
+ hfov [control_point] = hfov_;
+ vfov [control_point] = vfov_;
++control_point;
}
else {
@@ -283,6 +308,8 @@
delete [] eye;
delete [] lookat;
delete [] up;
+ delete [] hfov;
+ delete [] vfov;
}
UserInterface *CameraPathAutomator::create( const vector<string> &args,
MantaInterface *manta_interface_ ) {
@@ -370,7 +397,8 @@
void CameraPathAutomator::run_automator() {
Vector current_eye, current_lookat, current_up;
-
+ float current_hfov, current_vfov;
+
int current_point = 0;
int last_point = Min(total_points-2,interval_last);
@@ -401,13 +429,17 @@
// 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( &eye[current_point], t, current_eye);
catmull_rom_interpolate( &lookat[current_point], t, current_lookat);
catmull_rom_interpolate( &up[current_point], t, current_up );
+ //We really can't have negative fov, and it's possible to get
+ //it with catmull rom (it can overshoot), so to be safe we
+ //linearly interpolate
+ current_hfov = (1-t)*hfov[current_point] + t*hfov[current_point+1];
+ current_vfov = (1-t)*vfov[current_point] + t*vfov[current_point+1];
+
// Record the time of this transaction before a potential sync
double start_time = Time::currentSeconds();
@@ -415,7 +447,8 @@
getMantaInterface()->addTransaction
("CameraPathAutomator",
Callback::create(this, &CameraPathAutomator::mantaSetCamera,
- current_eye, current_lookat, current_up ) );
+ current_eye, current_lookat, current_up,
+ current_hfov, current_vfov) );
// Check to see if this is a synchronization point.
@@ -464,10 +497,12 @@
void CameraPathAutomator::mantaSetCamera( const Vector eye_,
const Vector lookat_,
- const Vector up_ ) {
+ const Vector up_,
+ const float hfov_,
+ const float vfov_) {
// Reset the current camera.
- getMantaInterface()->getCamera( channel )->reset( eye_, up_, lookat_ );
+ getMantaInterface()->getCamera( channel )->reset( eye_, up_, lookat_,
hfov_, vfov_);
}
Modified: trunk/UserInterface/CameraPathAutomator.h
==============================================================================
--- trunk/UserInterface/CameraPathAutomator.h (original)
+++ trunk/UserInterface/CameraPathAutomator.h Tue Jul 29 17:02:37 2008
@@ -81,6 +81,7 @@
Vector *eye;
Vector *lookat;
Vector *up;
+ float *hfov, *vfov;
int total_points;
CameraPathPerformanceVector performance;
@@ -149,7 +150,7 @@
// This method is called by the manta rendering thread to update
// the camera.
void mantaSetCamera( Vector eye_, Vector lookat_,
- Vector up_ );
+ Vector up_, float hfov_, float vfov_ );
// This method is called by the manta rendering thread to synchronize.
void mantaSynchronize( int issue_transaction );
@@ -183,7 +184,8 @@
// Access path control points.
inline BasicCameraData GetControlPoint( const unsigned index ) {
- return BasicCameraData( eye[index], lookat[index], up[index], 0, 0 );
+ return BasicCameraData( eye[index], lookat[index], up[index],
+ hfov[index], vfov[index] );
}
- [Manta] r2312 - in trunk: Core/Util Interface Model/Cameras Model/Materials Model/Primitives UserInterface, Thiago Ize, 07/29/2008
Archive powered by MHonArc 2.6.16.