00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #pragma once
00013
00015 #include "nvsgcommon.h"
00016
00017 #include "nvmath/Vec2f.h"
00018 #include "nvmath/Vec3f.h"
00019 #include "nvmath/Quatf.h"
00020 #include "nvsg/Object.h"
00021
00022
00023 namespace nvmath
00024 {
00025 class Mat44f;
00026 class Vec2f;
00027 }
00028 namespace nvsg
00029 {
00030 class LightSource;
00031 class Node;
00032 }
00033
00034 namespace nvsg
00035 {
00037 class Camera : public Object
00038 {
00039 public:
00041
00042 NVSG_API virtual const Camera * clone( void ) const = 0;
00043
00044
00045
00046
00047
00049 NVSG_API virtual void addHeadLight(
00050 const LightSource * pLight
00051 , const nvmath::Vec3f &trans = nvmath::Vec3f( 0.0f, 0.0f, 0.0f )
00052 , const nvmath::Quatf &quat = nvmath::Quatf( 0.0f, 0.0f, 0.0f, 1.0f )
00053 ) = 0;
00054
00056
00057 NVSG_API virtual bool removeHeadLight( size_t index = 0
00058 ) = 0;
00059
00061
00062 NVSG_API virtual size_t getNumberOfHeadLights() const = 0;
00063
00065
00067 NVSG_API virtual const LightSource* getHeadLight( size_t index
00068 ) const = 0;
00069
00071 NVSG_API virtual void getHeadLightTrafo(
00072 nvmath::Vec3f &trans
00073 , nvmath::Quatf &quat
00074 , size_t index = 0
00075 ) const = 0;
00076
00078
00079 NVSG_API virtual bool setHeadLightTrafo(
00080 const nvmath::Vec3f &trans
00081 , const nvmath::Quatf &quat
00082 , size_t index = 0
00083 ) = 0;
00084
00085
00086
00087
00088
00090
00091 NVSG_API virtual float getTargetDistance() const = 0;
00092
00094 NVSG_API virtual void setTargetDistance( float td
00095 ) = 0;
00096
00098
00099 NVSG_API virtual const nvmath::Vec3f& getPosition() const = 0;
00100
00102 NVSG_API virtual void setPosition( const nvmath::Vec3f& pos
00103 ) = 0;
00104
00106 NVSG_API virtual void setUpVector( const nvmath::Vec3f &up
00107 ) = 0;
00108
00110
00111 NVSG_API virtual nvmath::Vec3f getUpVector() const = 0;
00112
00114
00115 NVSG_API virtual nvmath::Vec3f getDirection() const = 0;
00116
00118 NVSG_API virtual void setDirection( const nvmath::Vec3f& dir
00119 ) = 0;
00120
00122 NVSG_API virtual void setOrientation( const nvmath::Quatf &quat
00123 ) = 0;
00124
00126 NVSG_API virtual void setOrientation( const nvmath::Vec3f &dir
00127 , const nvmath::Vec3f &up
00128 ) = 0;
00129
00131 NVSG_API virtual void setOrientation( const nvmath::Vec3f &axis
00132 , float angle
00133 ) = 0;
00134
00136
00137 NVSG_API virtual nvmath::Quatf getOrientation( void ) const = 0;
00138
00140
00141 NVSG_API virtual nvmath::Mat44f getWorldToViewMatrix() const = 0;
00142
00144
00145 NVSG_API virtual nvmath::Mat44f getViewToWorldMatrix() const = 0;
00146
00148
00149 NVSG_API virtual const nvmath::Vec2f& getWindowOffset( void ) const = 0;
00150
00152 NVSG_API virtual void setWindowOffset( const nvmath::Vec2f &offset
00153 ) = 0;
00154
00156 NVSG_API virtual void getWindowRegion( nvmath::Vec2f &lowerLeft
00157 , nvmath::Vec2f &upperRight
00158 ) const = 0;
00159
00161 NVSG_API virtual void setWindowRegion( const nvmath::Vec2f &lowerLeft
00162 , const nvmath::Vec2f &upperRight
00163 ) = 0;
00164
00166
00167 NVSG_API virtual const nvmath::Vec2f& getWindowSize() const = 0;
00168
00170 NVSG_API virtual void setWindowSize( const nvmath::Vec2f &size
00171 ) = 0;
00172
00174
00175 NVSG_API virtual float getAspectRatio() const = 0;
00176
00178 NVSG_API virtual void setAspectRatio( float ar
00179 , bool keepWidth = false
00180 ) = 0;
00181
00183
00187 NVSG_API virtual bool isAutoClipPlanes() const = 0;
00188
00190 NVSG_API virtual void setAutoClipPlanes( bool on
00191 ) = 0;
00192
00194 NVSG_API virtual void calcNearFarDistances( const nvmath::Sphere3f &sphere
00195 ) = 0;
00196
00198
00199 NVSG_API virtual float getFarDistance() const = 0;
00200
00202 NVSG_API virtual void setFarDistance( float fd
00203 ) = 0;
00204
00206
00207 NVSG_API virtual float getNearDistance() const = 0;
00208
00210 NVSG_API virtual void setNearDistance( float nd
00211 ) = 0;
00212
00213
00214
00215
00216
00218 NVSG_API virtual void move( const nvmath::Vec3f& delta
00219 ) = 0;
00220
00222 NVSG_API virtual void orbit( const nvmath::Vec3f& axis
00223 , float rad
00224 ) = 0;
00225
00227 NVSG_API virtual void rotate( const nvmath::Vec3f& axis
00228 , float rad
00229 , bool cameraRelative = true
00230
00231 ) = 0;
00232
00234 NVSG_API virtual void zoom( float factor
00235 ) = 0;
00236
00238 NVSG_API virtual void zoom( const nvmath::Sphere3f &sphere
00239 , float fovy = -1.0f
00240 ) = 0;
00241
00243 void moveX( float val
00244 );
00245
00247 void moveY( float val
00248 );
00249
00251 void moveZ( float val
00252 );
00253
00255 void orbitX( float rad
00256 );
00257
00259 void orbitY( float rad
00260 );
00261
00263 void orbitZ( float rad
00264 );
00265
00267 void rotateX( float rad
00268 , bool cameraRelative = true
00269 );
00270
00272 void rotateY( float rad
00273 , bool cameraRelative = true
00274 );
00275
00277 void rotateZ( float rad
00278 , bool cameraRelative = true
00279 );
00280
00281 protected:
00283 NVSG_API Camera();
00284
00286 NVSG_API virtual ~Camera( void );
00287 };
00288
00289
00290
00291
00292
00293 inline Camera::Camera( void )
00294 {
00295 __TRACE();
00296 }
00297
00298 inline Camera::~Camera(void)
00299 {
00300 __TRACE();
00301 }
00302
00303 inline void Camera::moveX( float val )
00304 {
00305 __TRACE();
00306 move( nvmath::Vec3f( val, 0.f, 0.f ) );
00307 }
00308
00309 inline void Camera::moveY( float val )
00310 {
00311 __TRACE();
00312 move( nvmath::Vec3f( val, 1.f, 0.f ) );
00313 }
00314
00315 inline void Camera::moveZ( float val )
00316 {
00317 __TRACE();
00318 move( nvmath::Vec3f( val, 0.f, 1.f ) );
00319 }
00320
00321 inline void Camera::orbitX( float rad )
00322 {
00323 __TRACE();
00324 orbit( nvmath::Vec3f( 1.f, 0.f, 0.f ), rad );
00325 }
00326
00327 inline void Camera::orbitY( float rad )
00328 {
00329 __TRACE();
00330 orbit( nvmath::Vec3f( 0.f, 1.f, 0.f ), rad );
00331 }
00332
00333 inline void Camera::orbitZ( float rad )
00334 {
00335 __TRACE();
00336 orbit( nvmath::Vec3f( 0.f, 0.f, 1.f ), rad );
00337 }
00338
00339 inline void Camera::rotateX( float rad, bool cameraRelative )
00340 {
00341 __TRACE();
00342 rotate( nvmath::Vec3f(1.f, 0.f, 0.f), rad, cameraRelative );
00343 }
00344
00345 inline void Camera::rotateY( float rad, bool cameraRelative )
00346 {
00347 __TRACE();
00348 rotate( nvmath::Vec3f(0.f, 1.f, 0.f), rad, cameraRelative );
00349 }
00350
00351 inline void Camera::rotateZ( float rad, bool cameraRelative )
00352 {
00353 __TRACE();
00354 rotate( nvmath::Vec3f(0.f, 0.f, 1.f), rad, cameraRelative );
00355 }
00356
00357 }