Text archives Help
- From: sparker@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1074 - in trunk: Engine/Control Interface Model/Cameras StandAlone UserInterface
- Date: Thu, 18 May 2006 18:37:19 -0600 (MDT)
Author: sparker
Date: Thu May 18 18:37:13 2006
New Revision: 1074
Modified:
trunk/Engine/Control/RTRT.cc
trunk/Interface/Camera.h
trunk/Interface/Context.h
trunk/Interface/MantaInterface.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/StandAlone/manta.cc
trunk/UserInterface/XWindowUI.cc
trunk/UserInterface/XWindowUI.h
Log:
On startup, move to the first bookmark if there is one. Otherwise, autoview.
The B (shift b) key now adds a bookmark to the list in the XWindowUI
Modified: trunk/Engine/Control/RTRT.cc
==============================================================================
--- trunk/Engine/Control/RTRT.cc (original)
+++ trunk/Engine/Control/RTRT.cc Thu May 18 18:37:13 2006
@@ -208,6 +208,10 @@
lights->preprocess(context);
scene->getBackground()->preprocess(context);
scene->getObject()->preprocess(context);
+ for(int index = 0;index < static_cast<int>(channels.size());index++){
+ Channel* channel = channels[index];
+ channel->camera->preprocess(context);
+ }
if(!currentImageCreator)
throw InvalidState("Image type was not selected", __FILE__, __LINE__ );
Modified: trunk/Interface/Camera.h
==============================================================================
--- trunk/Interface/Camera.h (original)
+++ trunk/Interface/Camera.h Thu May 18 18:37:13 2006
@@ -11,6 +11,7 @@
#include <sgi_stl_warnings_on.h>
namespace Manta {
+ class PreprocessContext;
class RayPacket;
class BasicCameraData {
@@ -39,6 +40,7 @@
public:
Camera();
virtual ~Camera();
+ virtual void preprocess(const PreprocessContext& context) = 0;
virtual void makeRays(RayPacket&) const = 0;
// Camera manipulation
Modified: trunk/Interface/Context.h
==============================================================================
--- trunk/Interface/Context.h (original)
+++ trunk/Interface/Context.h Thu May 18 18:37:13 2006
@@ -184,15 +184,16 @@
};
class PreprocessContext {
public:
- PreprocessContext() { }; // Lights are dynamic now. This
context isn't needed.
- PreprocessContext(MantaInterface* /*rtrt_int*/, LightSet* globalLights)
- : globalLights(globalLights)
+ PreprocessContext() {}
+ PreprocessContext(MantaInterface* manta_interface, LightSet*
globalLights)
+ : manta_interface(manta_interface), globalLights(globalLights)
{
}
~PreprocessContext()
{
}
+ MantaInterface* manta_interface;
LightSet* globalLights;
private:
PreprocessContext(const PreprocessContext&);
Modified: trunk/Interface/MantaInterface.h
==============================================================================
--- trunk/Interface/MantaInterface.h (original)
+++ trunk/Interface/MantaInterface.h Thu May 18 18:37:13 2006
@@ -112,7 +112,7 @@
// Scenes
virtual bool haveScene() = 0;
virtual void setScene(Scene* scene) = 0;
- virtual Scene *getScene() = 0;
+ virtual Scene *getScene() = 0;
virtual bool readScene(const string& sceneSpec) = 0;
virtual void readStack( const string &name, const vector<string> &args )
= 0;
virtual void setScenePath(const string& path) = 0;
Modified: trunk/Model/Cameras/EnvironmentCamera.cc
==============================================================================
--- trunk/Model/Cameras/EnvironmentCamera.cc (original)
+++ trunk/Model/Cameras/EnvironmentCamera.cc Thu May 18 18:37:13 2006
@@ -3,7 +3,10 @@
#include <Model/Cameras/EnvironmentCamera.h>
#include <Core/Util/Args.h>
#include <Core/Exceptions/IllegalArgument.h>
+#include <Interface/Context.h>
+#include <Interface/MantaInterface.h>
#include <Interface/RayPacket.h>
+#include <Interface/Scene.h>
#include <Core/Geometry/BBox.h>
#include <Core/Geometry/AffineTransform.h>
#include <Core/Math/MiscMath.h>
@@ -21,11 +24,13 @@
const Vector& up_ )
: eye( eye_ ), lookat( lookat_ ), up( up_ )
{
+ haveCamera = true;
setup();
}
EnvironmentCamera::EnvironmentCamera(const vector<string>& args)
{
+ haveCamera = false;
bool gotEye=false;
bool gotLookat=false;
bool gotUp=false;
@@ -37,14 +42,17 @@
if (!getVectorArg(i, args, eye))
throw IllegalArgument("EnvironmentCamera -eye", i, args);
gotEye=true;
+ haveCamera = true;
} else if (arg=="-lookat") {
if (!getVectorArg(i, args, lookat))
throw IllegalArgument("EnvironmentCamera -lookat", i, args);
gotLookat=true;
+ haveCamera = true;
} else if (arg=="-up") {
if (!getVectorArg(i, args, up))
throw IllegalArgument("EnvironmentCamera -up", i, args);
gotUp=true;
+ haveCamera = true;
} else if (arg=="-normalizeRays") {
normalizeRays=true;
} else {
@@ -63,6 +71,23 @@
Camera* EnvironmentCamera::create(const vector<string>& args)
{
return new EnvironmentCamera(args);
+}
+
+void EnvironmentCamera::preprocess(const PreprocessContext& context)
+{
+ Scene* scene = context.manta_interface->getScene();
+ if(!haveCamera){
+ const BasicCameraData* bookmark = scene->nextBookmark();
+ if(bookmark){
+ setBasicCameraData(*bookmark);
+ haveCamera = true;
+ } else {
+ BBox bbox;
+ scene->getObject()->computeBounds(context, bbox);
+ autoview(bbox);
+ }
+ haveCamera = true;
+ }
}
void EnvironmentCamera::getBasicCameraData(BasicCameraData& cam) const
Modified: trunk/Model/Cameras/EnvironmentCamera.h
==============================================================================
--- trunk/Model/Cameras/EnvironmentCamera.h (original)
+++ trunk/Model/Cameras/EnvironmentCamera.h Thu May 18 18:37:13 2006
@@ -19,6 +19,7 @@
EnvironmentCamera(const vector<string>& args);
virtual ~EnvironmentCamera();
+ virtual void preprocess(const PreprocessContext& context);
virtual void makeRays(RayPacket&) const;
// Camera manipulation
@@ -48,10 +49,11 @@
Vector eye;
Vector lookat;
Vector up;
- bool normalizeRays;
Vector direction;
Vector u, v, n;
+ bool normalizeRays;
+ bool haveCamera;
};
}
Modified: trunk/Model/Cameras/FisheyeCamera.cc
==============================================================================
--- trunk/Model/Cameras/FisheyeCamera.cc (original)
+++ trunk/Model/Cameras/FisheyeCamera.cc Thu May 18 18:37:13 2006
@@ -3,7 +3,10 @@
#include <Model/Cameras/FisheyeCamera.h>
#include <Core/Util/Args.h>
#include <Core/Exceptions/IllegalArgument.h>
+#include <Interface/Context.h>
+#include <Interface/MantaInterface.h>
#include <Interface/RayPacket.h>
+#include <Interface/Scene.h>
#include <Core/Geometry/BBox.h>
#include <Core/Geometry/AffineTransform.h>
#include <Core/Math/MiscMath.h>
@@ -23,12 +26,14 @@
const Vector& up_, Real hfov_)
: eye( eye_ ), up( up_ ), lookat( lookat_ ), hfov( hfov_ )
{
+ haveCamera = true;
setup();
hfov = hfov / 90;
}
FisheyeCamera::FisheyeCamera(const vector<string>& args)
{
+ haveCamera = false;
bool gotEye = false;
bool gotLookat = false;
bool gotFov = false;
@@ -40,18 +45,22 @@
if(!getVectorArg(i, args, eye))
throw IllegalArgument("FisheyeCamera -eye", i, args);
gotEye = true;
+ haveCamera = true;
} else if(arg == "-lookat"){
if(!getVectorArg(i, args, lookat))
throw IllegalArgument("FisheyeCamera -lookat", i, args);
gotLookat = true;
+ haveCamera = true;
} else if(arg == "-up"){
if(!getVectorArg(i, args, up))
throw IllegalArgument("FisheyeCamera -up", i, args);
gotUp = true;
+ haveCamera = true;
} else if(arg == "-fov"){
if(!getArg<Real>(i, args, hfov))
throw IllegalArgument("FisheyeCamera -fov", i, args);
gotFov = true;
+ haveCamera = true;
} else {
throw IllegalArgument("FisheyeCamera", i, args);
}
@@ -210,3 +219,21 @@
setup();
}
+
+void FisheyeCamera::preprocess(const PreprocessContext& context)
+{
+ Scene* scene = context.manta_interface->getScene();
+ if(!haveCamera){
+ const BasicCameraData* bookmark = scene->nextBookmark();
+ if(bookmark){
+ setBasicCameraData(*bookmark);
+ haveCamera = true;
+ } else {
+ hfov = 90;
+ BBox bbox;
+ scene->getObject()->computeBounds(context, bbox);
+ autoview(bbox);
+ }
+ haveCamera = true;
+ }
+}
Modified: trunk/Model/Cameras/FisheyeCamera.h
==============================================================================
--- trunk/Model/Cameras/FisheyeCamera.h (original)
+++ trunk/Model/Cameras/FisheyeCamera.h Thu May 18 18:37:13 2006
@@ -21,6 +21,7 @@
Real hfov_ = 60 );
virtual ~FisheyeCamera();
+ virtual void preprocess(const PreprocessContext& context);
virtual void makeRays(RayPacket&) const;
// Camera manipulation
@@ -54,6 +55,7 @@
Vector direction;
Vector u,v,n;
+ bool haveCamera;
};
}
Modified: trunk/Model/Cameras/OrthogonalCamera.cc
==============================================================================
--- trunk/Model/Cameras/OrthogonalCamera.cc (original)
+++ trunk/Model/Cameras/OrthogonalCamera.cc Thu May 18 18:37:13 2006
@@ -2,7 +2,10 @@
#include <Model/Cameras/OrthogonalCamera.h>
#include <Core/Util/Args.h>
#include <Core/Exceptions/IllegalArgument.h>
+#include <Interface/Context.h>
+#include <Interface/MantaInterface.h>
#include <Interface/RayPacket.h>
+#include <Interface/Scene.h>
#include <Core/Geometry/BBox.h>
#include <Core/Geometry/AffineTransform.h>
#include <Core/Math/MiscMath.h>
@@ -17,11 +20,13 @@
const Vector& up_, Real hscale_ )
: eye( eye_ ), lookat( lookat_ ), up( up_ ), hscale( hscale_ )
{
+ haveCamera = true;
setup();
}
OrthogonalCamera::OrthogonalCamera(const vector<string>& args)
{
+ haveCamera = false;
bool gotEye = false;
bool gotLookat = false;
bool gotScale = false;
@@ -33,18 +38,22 @@
if(!getVectorArg(i, args, eye))
throw IllegalArgument("OrthogonalCamera -eye", i, args);
gotEye = true;
+ haveCamera = true;
} else if(arg == "-lookat"){
if(!getVectorArg(i, args, lookat))
throw IllegalArgument("OrthogonalCamera -lookat", i, args);
gotLookat = true;
+ haveCamera = true;
} else if(arg == "-up"){
if(!getVectorArg(i, args, up))
throw IllegalArgument("OrthogonalCamera -up", i, args);
gotUp = true;
+ haveCamera = true;
} else if(arg == "-scale"){
if(!getArg<Real>(i, args, hscale))
throw IllegalArgument("OrthogonalCamera -scale", i, args);
gotScale = true;
+ haveCamera = true;
} else {
throw IllegalArgument("OrthogonalCamera", i, args);
}
@@ -199,3 +208,20 @@
setup();
}
+
+void OrthogonalCamera::preprocess(const PreprocessContext& context)
+{
+ Scene* scene = context.manta_interface->getScene();
+ if(!haveCamera){
+ const BasicCameraData* bookmark = scene->nextBookmark();
+ if(bookmark){
+ setBasicCameraData(*bookmark);
+ haveCamera = true;
+ } else {
+ BBox bbox;
+ scene->getObject()->computeBounds(context, bbox);
+ autoview(bbox);
+ }
+ haveCamera = true;
+ }
+}
Modified: trunk/Model/Cameras/OrthogonalCamera.h
==============================================================================
--- trunk/Model/Cameras/OrthogonalCamera.h (original)
+++ trunk/Model/Cameras/OrthogonalCamera.h Thu May 18 18:37:13 2006
@@ -16,6 +16,7 @@
OrthogonalCamera(const Vector& eye_, const Vector& lookat_,
const Vector& up_, Real hscale_ );
OrthogonalCamera(const vector<string>& args);
+ virtual void preprocess(const PreprocessContext& context);
virtual ~OrthogonalCamera();
virtual void makeRays(RayPacket&) const;
@@ -48,6 +49,7 @@
Vector direction;
Vector u,v;
+ bool haveCamera;
};
}
Modified: trunk/Model/Cameras/PinholeCamera.cc
==============================================================================
--- trunk/Model/Cameras/PinholeCamera.cc (original)
+++ trunk/Model/Cameras/PinholeCamera.cc Thu May 18 18:37:13 2006
@@ -3,7 +3,10 @@
#include <Model/Cameras/PinholeCamera.h>
#include <Core/Util/Args.h>
#include <Core/Exceptions/IllegalArgument.h>
+#include <Interface/Context.h>
+#include <Interface/MantaInterface.h>
#include <Interface/RayPacket.h>
+#include <Interface/Scene.h>
#include <Core/Geometry/BBox.h>
#include <Core/Geometry/AffineTransform.h>
#include <Core/Math/MiscMath.h>
@@ -22,11 +25,13 @@
: eye( eye_ ), lookat( lookat_ ), up( up_ ),
stereo_offset( 0.0 ), hfov( fov_ )
{
+ haveCamera = true;
setup();
}
PinholeCamera::PinholeCamera(const vector<string>& args)
{
+ haveCamera = false;
normalizeRays = false;
stereo_offset = 0;
@@ -46,15 +51,19 @@
} else if(arg == "-eye"){
if(!getVectorArg(i, args, eye))
throw IllegalArgument("PinholeCamera -eye", i, args);
+ haveCamera = true;
} else if(arg == "-lookat"){
if(!getVectorArg(i, args, lookat))
throw IllegalArgument("PinholeCamera -lookat", i, args);
+ haveCamera = true;
} else if(arg == "-up"){
if(!getVectorArg(i, args, up))
throw IllegalArgument("PinholeCamera -up", i, args);
+ haveCamera = true;
} else if(arg == "-fov"){
if(!getArg<Real>(i, args, hfov))
throw IllegalArgument("PinholeCamera -fov", i, args);
+ haveCamera = true;
} else if(arg == "-normalizeRays"){
normalizeRays = true;
} else {
@@ -425,4 +434,25 @@
up = cam.up;
hfov = cam.hfov;
setup();
+}
+
+void PinholeCamera::preprocess(const PreprocessContext& context)
+{
+ Scene* scene = context.manta_interface->getScene();
+ if(!haveCamera){
+ const BasicCameraData* bookmark = scene->nextBookmark();
+ if(bookmark){
+ setBasicCameraData(*bookmark);
+ haveCamera = true;
+ } else {
+ eye = Vector(0,1,0);
+ lookat = Vector(0,0,0);
+ up = Vector(0, 0, 1);
+ hfov = 90;
+ BBox bbox;
+ scene->getObject()->computeBounds(context, bbox);
+ autoview(bbox);
+ }
+ haveCamera = true;
+ }
}
Modified: trunk/Model/Cameras/PinholeCamera.h
==============================================================================
--- trunk/Model/Cameras/PinholeCamera.h (original)
+++ trunk/Model/Cameras/PinholeCamera.h Thu May 18 18:37:13 2006
@@ -19,6 +19,7 @@
const Vector &up_, Real fov_ );
PinholeCamera(const vector<string>& args);
virtual ~PinholeCamera();
+ virtual void preprocess(const PreprocessContext& context);
virtual void makeRays(RayPacket&) const;
// Camera manipulation
@@ -55,8 +56,9 @@
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;
void setup();
+ bool normalizeRays;
+ bool haveCamera;
};
}
Modified: trunk/StandAlone/manta.cc
==============================================================================
--- trunk/StandAlone/manta.cc (original)
+++ trunk/StandAlone/manta.cc Thu May 18 18:37:13 2006
@@ -202,7 +202,7 @@
throw InternalError("default shadow algorithm not found", __FILE__,
__LINE__ );
// Set camera for the default scene.
- Camera* currentCamera = rtrt->createCamera("pinhole(-eye 3 3 2 -lookat 0
0 0.3 -up 0 0 1 -fov 60)");
+ Camera* currentCamera = rtrt->createCamera("pinhole(-normalizeRays)");
if(!currentCamera)
throw InternalError("cannot create default camera", __FILE__, __LINE__
);
@@ -254,9 +254,6 @@
printList(cerr, rtrt->listCameras());
throw IllegalArgument( s, i, args );
}
- } else if(arg == "-bbcamera" || arg == "-autoview"){
- compute_bb_camera = true;
-
} else if(arg == "-res"){
if(!getResolutionArg(i, args, xres, yres)){
cerr << "Error parsing resolution: " << args[i+1] << '\n';
@@ -344,14 +341,6 @@
///////////////////////////////////////////////////////////////////////////
// Use defaults if necessary.
- // Check if we should compute the camera based on the scene's bounds.
- if(compute_bb_camera) {
- BBox bbox;
- PreprocessContext ppc;
- rtrt->getScene()->getObject()->computeBounds(ppc, bbox);
- currentCamera->autoview(bbox);
- }
-
// Check to see if a channel was created.
if(!channelCreated){
rtrt->createChannel("opengl", currentCamera, stereo, xres, yres);
Modified: trunk/UserInterface/XWindowUI.cc
==============================================================================
--- trunk/UserInterface/XWindowUI.cc (original)
+++ trunk/UserInterface/XWindowUI.cc Thu May 18 18:37:13 2006
@@ -417,6 +417,9 @@
register_key(0, XStringToKeysym("b"),
"next bookmark",
Callback::create(this, &XWindowUI::next_bookmark));
+ register_key(0, XStringToKeysym("B"),
+ "add bookmark",
+ Callback::create(this, &XWindowUI::add_bookmark));
register_key(0, XStringToKeysym("c"),
"output camera",
Callback::create(this, &XWindowUI::output_camera));
@@ -503,6 +506,14 @@
Callback::create(camera,
&Camera::setBasicCameraData,
*bookmark));
}
+}
+
+void XWindowUI::add_bookmark(unsigned int, unsigned long, int channel)
+{
+ Camera* camera = rtrt_interface->getCamera(channel);
+ BasicCameraData bookmark;
+ camera->getBasicCameraData(bookmark);
+ rtrt_interface->getScene()->addBookmark("user added", bookmark);
}
void XWindowUI::output_camera(unsigned int, unsigned long, int channel)
Modified: trunk/UserInterface/XWindowUI.h
==============================================================================
--- trunk/UserInterface/XWindowUI.h (original)
+++ trunk/UserInterface/XWindowUI.h Thu May 18 18:37:13 2006
@@ -74,6 +74,7 @@
void autoview(unsigned int, unsigned long, int);
void next_bookmark(unsigned int, unsigned long, int);
+ void add_bookmark(unsigned int, unsigned long, int);
void output_camera(unsigned int, unsigned long, int);
void mouse_fov(unsigned int, unsigned int, int, int, int, int);
- [MANTA] r1074 - in trunk: Engine/Control Interface Model/Cameras StandAlone UserInterface, sparker, 05/18/2006
Archive powered by MHonArc 2.6.16.