| VRS - The Virtual Rendering System |
| version 3.3 |
00001 /********************************************************************** 00002 VRS - The Virtual Rendering System 00003 Copyright (C) 2001 Computer Graphics Systems Group at the 00004 Hasso-Plattner-Institute, Potsdam, Germany. 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 This library is distributed in the hope that it will be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 See the GNU Lesser General Public License for more details. 00013 You should have received a copy of the GNU Lesser+ General Public 00014 License along with this library; if not, write to the FreeSoftware 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA, 02111-1307, USA. 00016 **********************************************************************/ 00017 // $Id: camera.h 6654 2009-01-30 09:57:05Z Rico_Richter $ 00018 // $Date: 2009-01-30 10:57:05 +0100 (Fri, 30 Jan 2009) $ 00019 // $Revision: 6654 $ 00020 // $State$ 00021 // $Author: Rico_Richter $ 00022 // 00023 // $Log$ 00024 // Revision 1.30 2005/10/21 08:52:23 baumann 00025 // missing include added 00026 // 00027 // Revision 1.29 2005/01/03 01:43:07 klimetschek 00028 // - modified win32 project layout, splitted vrs.vcproj into vrs_container, vrs_core, vrs_sg, vrs_image, vrs_opengl and vrs_io 00029 // - removed vrs.vcproj 00030 // minor things: 00031 // - added all glutexamples to vrs4glut.sln 00032 // - fixed some problems in glutexamples 00033 // - removed all project references from all VS projects (using solution wide project dependencies instead) 00034 // 00035 // Revision 1.28 2004/12/17 09:46:40 baumann 00036 // added arguments z1 and z2 to newPixelCoordsCamera() 00037 // 00038 // Revision 1.27 2004/12/17 08:06:56 baumann 00039 // return type for newPixelCoordsCamera() changed from Camera* to SO<Camera> 00040 // 00041 // Revision 1.26 2004/11/05 13:58:09 basch 00042 // Class comment changed (Doxygen style) 00043 // 00044 // Revision 1.25 2004/09/18 13:07:13 baumann 00045 // added method newNormalizedDeviceCoordsCamera(const Bounds& bbox) 00046 // 00047 // Revision 1.24 2004/03/22 11:19:38 grabs 00048 // newNormalizedDeviceCoordsCamera() got some parameters for even more convenience 00049 // 00050 // Revision 1.23 2004/03/12 16:28:38 baumann 00051 // macros VRS_NAMESPACE_BEGIN/_END expanded and removed 00052 // 00053 // Revision 1.22 2004/01/19 11:43:56 baumann 00054 // serialization mechanism improved 00055 // 00056 // Revision 1.21 2004/01/19 07:28:03 baumann 00057 // serialization mechanism improved 00058 // 00059 // Revision 1.20 2003/11/29 11:29:23 kirsch 00060 // - added support for local poly attributes 00061 // - removed PolyAttribute::switchDefault() and Attribute::rememberTransform() 00062 // - renamed Engine::SwType: On/Off/All to Engine::SwitchType: ON/OFF/ALL 00063 // - changed class hierarchy of TechniqueProcessor and Technique 00064 // - GLCanvas::prepareRedisplay() / finishRedisplay() now push / pop standard attributes 00065 // 00066 // Revision 1.19 2003/11/07 14:19:23 kirsch 00067 // removed leading underscore from include guards 00068 // 00069 // Revision 1.18 2003/07/09 13:32:11 kirsch 00070 // moved functionality of ImmediateCamera, CanvasTransform and PixelCoordinateHandler to Camera 00071 // removed CanvasTransform and PixelCoordinateHandler 00072 // deprecated ImmediateCamera, ResizeHandler and SceneView 00073 // see ChangeLog for more details 00074 // 00075 // Revision 1.17 2002/10/29 10:32:51 baumann 00076 // macros VRS_CLASSNAME_* and VRS_IMPL_TYPEINFO_* removed 00077 // 00078 // Revision 1.16 2002/06/24 14:03:38 baumann 00079 // changed List<T> to Array<T> 00080 // 00081 // Revision 1.15 2002/04/27 08:19:31 kirsch 00082 // made getTransform const 00083 // 00084 // Revision 1.14 2002/03/04 11:08:34 kersting 00085 // directory structure changes 00086 // 00087 // Revision 1.13 2002/03/03 21:44:24 kosta 00088 // VRS_TYPEINFO-macro rewritten 00089 // 00090 // Revision 1.12 2002/02/19 10:34:07 kosta 00091 // undone all changes since 2002-02-15 00092 // 00093 // Revision 1.9 2002/02/13 16:54:50 kirsch 00094 // changed: Camera contains ResizeHandler 00095 // 00096 // Revision 1.8 2002/02/05 07:48:24 kosta 00097 // new persistency macros: 00098 // VRS_SERIALIZABLE(CLASS_NAME); 00099 // VRS_SERIALIZABLE_ABSTRACT_CLASS(CLASS_NAME); 00100 // VRS_SERIALIZABLE_NO_SO_CLASS(CLASS_NAME) 00101 // 00102 // Revision 1.7 2002/02/04 13:07:19 kosta 00103 // VRS_SERIALIZABLE macros completely rewritten 00104 // 00105 // Revision 1.6 2002/01/15 16:25:53 kosta 00106 // macros rewritten for a better namespace support 00107 // 00108 // Revision 1.5 2001/11/13 16:36:30 kirsch 00109 // changed line feed to unix style (removed control-M) 00110 // 00111 // Revision 1.4 2001/09/05 10:56:11 kirsch 00112 // Documentation updates 00113 // 00114 // Revision 1.3 2001/07/30 11:17:25 kirsch 00115 // ResizeHandler and PaneManipulator can now use Camera 00116 // 00117 // Revision 1.2 2001/07/26 15:23:47 kirsch 00118 // added camera-attribute 00119 // 00120 // Revision 1.1.2.1 2001/06/26 20:24:38 kirsch 00121 // Added camera-attribute, painter and technique 00122 // 00123 00124 #ifndef VRS_CAMERA_H 00125 #define VRS_CAMERA_H 00126 00127 #include <vrs/bounds.h> 00128 #include <vrs/monoattribute.h> 00129 #include <vrs/transform.h> 00130 #include <vrs/viewinfo.h> 00131 00132 namespace VRS { 00133 00134 template<typename T> class Array; 00135 template<typename T> class Iterator; 00136 00140 class VRS_CORE_API Camera : public MonoAttribute { 00141 00142 public: 00143 00144 enum Scope { SCENE, LOCAL }; 00145 VRS_SERIALIZABLE_CLASS_ENUM(Scope); 00147 00156 enum SizePolicy { NO_POLICY, SAME_SIZE, FIT_INSIDE, FIT_OUTSIDE }; 00157 VRS_SERIALIZABLE_CLASS_ENUM(SizePolicy); 00177 Camera(Transform* projection = 0, Transform* orientation = 0, 00178 Scope = Camera::SCENE, SizePolicy = Camera::FIT_INSIDE); 00179 Camera(Vector from, Vector to, double angle, double nearPlane=0, double farPlane=0, 00180 Scope = Camera::SCENE, SizePolicy = Camera::FIT_INSIDE); 00196 static SO<Camera> newNormalizedDeviceCoordsCamera( 00197 double x1 = -1.0, double x2 = 1.0, 00198 double y1 = -1.0, double y2 = 1.0, 00199 double z1 = -1.0, double z2 = 100.0 00200 ); 00201 static SO<Camera> newNormalizedDeviceCoordsCamera( 00202 const Bounds& bbox 00203 ); 00205 00220 static SO<Camera> newPixelCoordsCamera( 00221 double z1 = -1.0, double z2 = 100.0 00222 ); 00224 00230 void setOrientation(Transform* tf); 00232 Transform* getOrientation() const; 00234 00235 void setProjection(Transform* tf); 00237 Transform* getProjection() const; 00239 00240 void setScope(Scope); 00242 Scope getScope() const; 00244 00245 void setSizePolicy(SizePolicy); 00247 SizePolicy getSizePolicy() const; 00249 00250 void setPixelCoordsTransform(bool); 00254 bool getPixelCoordsTransform() const; 00256 00257 void pushTransform(Transform* tf); 00265 Iterator<SO<Transform> >* getTransform() const; 00267 void popTransform(); 00269 00270 virtual SO<ViewInfoFactory> newViewInfoFactory() const; 00271 00272 VRS_TYPEINFO(Camera, MonoAttribute); 00273 VRS_SERIALIZABLE(Camera); 00274 00275 private: 00276 SO<Transform> projection_; 00277 SO<Transform> orientation_; 00278 Camera::Scope scope_; 00279 Camera::SizePolicy policy_; 00280 bool pixelCoordsTransform_; 00281 SO<Array<SO<Transform> > > transform_; 00282 00283 bool init_; 00284 }; 00285 00287 class Engine; 00288 00289 class VRS_CORE_API CameraViewInfo : 00290 public ModelviewProjectionViewInfo 00291 { 00292 public: 00293 VRS_TYPEINFO(CameraViewInfo, ModelviewProjectionViewInfo); 00294 00295 CameraViewInfo( 00296 SO<const Camera> camera, 00297 SO<const Engine> engine, 00298 unsigned int viewportSizeX, 00299 unsigned int viewportSizeY 00300 ); 00301 00302 virtual CullingPos culling(const Vector& point, double radius) const; 00303 virtual CullingPos culling(const Vector& point) const; 00304 virtual CullingPos culling(const Bounds& bbox) const; 00305 00306 protected: 00307 template<class T> 00308 CullingPos cullPlanes(const T& obj) const; 00309 00310 private: 00311 SO<const Camera> m_camera; 00312 WO<const Engine> m_engine; 00313 bool m_testCullingPlanes; 00314 }; 00315 00316 inline Transform* Camera::getOrientation() const { return orientation_; } 00317 inline Transform* Camera::getProjection() const { return projection_; } 00318 inline Camera::Scope Camera::getScope() const { return scope_; } 00319 inline Camera::SizePolicy Camera::getSizePolicy() const { return policy_; } 00320 inline bool Camera::getPixelCoordsTransform() const { return pixelCoordsTransform_; } 00321 00322 } // namespace VRS 00323 00324 #endif // VRS_CAMERA_H