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/Mat44f.h"
00020 #include "nvmath/Quatf.h"
00021 #include "nvsg/MonoCamera.h"
00022
00023 namespace nvsg
00024 {
00026
00027 class SimpleCamera : public MonoCamera
00028 {
00029 public:
00031 NVSG_API virtual const SimpleCamera * clone( void ) const = 0;
00032
00034
00035 NVSG_API virtual bool isDataShared() const;
00036
00038
00039 NVSG_API virtual DataID getDataID() const;
00040
00041
00042
00043
00044
00046
00047 NVSG_API virtual float getProjectionDx() const;
00048
00050 NVSG_API virtual void setProjectionDx( float dx
00051 );
00052
00053
00054
00055
00056
00058
00059 NVSG_API virtual size_t getNumberOfHeadLights() const;
00060
00062
00063 NVSG_API virtual const LightSource * getHeadLight( size_t index
00064 ) const;
00065
00067
00068 NVSG_API virtual bool setHeadLightTrafo( const nvmath::Vec3f &trans
00069 , const nvmath::Quatf &quat
00070 , size_t index = 0
00071 );
00072
00074
00075 NVSG_API virtual void getHeadLightTrafo(
00076 nvmath::Vec3f &trans
00077 , nvmath::Quatf &quat
00078 , size_t index = 0
00079 ) const;
00080
00082
00085 NVSG_API virtual void addHeadLight(
00086 const LightSource * pLight
00087 , const nvmath::Vec3f &position = nvmath::Vec3f( 0.0f, 0.0f, 0.0f )
00088 , const nvmath::Quatf &quat = nvmath::Quatf( 0.0f, 0.0f, 0.0f, 1.0f )
00089 );
00090
00092
00093 NVSG_API virtual bool removeHeadLight( size_t index = 0
00094 );
00095
00096
00097
00098
00099
00101
00102 NVSG_API virtual float getTargetDistance() const;
00103
00105 NVSG_API virtual void setTargetDistance( float td
00106 );
00107
00109
00110 NVSG_API virtual const nvmath::Vec3f & getPosition() const;
00111
00113 NVSG_API virtual void setPosition( const nvmath::Vec3f& pos
00114 );
00115
00117
00118 NVSG_API virtual nvmath::Vec3f getUpVector() const;
00119
00121 NVSG_API virtual void setUpVector( const nvmath::Vec3f &up
00122 );
00123
00125
00127 NVSG_API virtual nvmath::Vec3f getDirection() const;
00128
00130 NVSG_API virtual void setDirection( const nvmath::Vec3f& dir
00131 );
00132
00134 NVSG_API virtual void setOrientation( const nvmath::Quatf &quat
00135 );
00136
00138 NVSG_API virtual void setOrientation( const nvmath::Vec3f &dir
00139 , const nvmath::Vec3f &up
00140 );
00141
00143 NVSG_API virtual void setOrientation( const nvmath::Vec3f &axis
00144 , float angle
00145 );
00146
00148
00149 NVSG_API virtual nvmath::Quatf getOrientation( void ) const;
00150
00152
00153 NVSG_API virtual nvmath::Mat44f getWorldToViewMatrix() const;
00154
00156
00157 NVSG_API virtual nvmath::Mat44f getViewToWorldMatrix() const;
00158
00160 NVSG_API virtual void setWindowOffset( const nvmath::Vec2f &offset
00161 );
00162
00164
00165 NVSG_API virtual const nvmath::Vec2f & getWindowOffset() const;
00166
00168 NVSG_API virtual void setWindowSize( const nvmath::Vec2f &size
00169 );
00170
00172
00173 NVSG_API virtual const nvmath::Vec2f & getWindowSize() const;
00174
00176 NVSG_API virtual void setAspectRatio( float ar
00177 , bool keepWidth = false
00178 );
00179
00181
00182 NVSG_API virtual float getAspectRatio() const;
00183
00185 NVSG_API virtual void setWindowRegion( const nvmath::Vec2f &lowerLeft
00186 , const nvmath::Vec2f &upperRight
00187 );
00188
00190 NVSG_API virtual void getWindowRegion( nvmath::Vec2f &lowerLeft
00191 , nvmath::Vec2f &upperRight
00192 ) const;
00193
00195 NVSG_API virtual void setAutoClipPlanes( bool on
00196 );
00197
00199
00202 NVSG_API virtual bool isAutoClipPlanes() const;
00203
00205
00207 NVSG_API virtual void calcNearFarDistances( const nvmath::Sphere3f &sphere
00208 );
00209
00211 NVSG_API virtual void setNearDistance( float nd
00212 );
00213
00215
00217 NVSG_API virtual float getNearDistance() const;
00218
00220
00222 NVSG_API virtual float getFarDistance() const;
00223
00225 NVSG_API virtual void setFarDistance( float fd
00226 );
00227
00228
00229
00230
00231
00233 NVSG_API virtual void move( const nvmath::Vec3f& delta
00234 );
00235
00237 NVSG_API virtual void orbit( const nvmath::Vec3f& axis
00238 , float rad
00239 );
00240
00242 NVSG_API virtual void rotate( const nvmath::Vec3f& axis
00243 , float rad
00244 , bool cameraRelative = true
00245 );
00246
00248 NVSG_API virtual void zoom( float factor
00249 );
00250
00252 NVSG_API virtual void zoom( const nvmath::Sphere3f &sphere
00253 , float fovy = -1.0f
00254 );
00255
00256 protected:
00258 NVSG_API SimpleCamera();
00259
00261 NVSG_API SimpleCamera( const SimpleCamera& rhs
00262 );
00263
00265 NVSG_API virtual ~SimpleCamera();
00266
00267 private:
00268 std::vector<const LightSource *> m_headLights;
00269
00270 nvmath::Quatf m_orientation;
00271 nvmath::Vec3f m_position;
00272 float m_targDist;
00273
00274 bool m_isAutoClipPlanes;
00275 float m_farDist;
00276 float m_nearDist;
00277
00278 float m_projectionDx;
00279
00280 nvmath::Vec2f m_windowSize;
00281 nvmath::Vec2f m_windowOffset;
00282 nvmath::Vec2f m_lowerLeft;
00283 nvmath::Vec2f m_upperRight;
00284 };
00285
00286 inline const LightSource * SimpleCamera::getHeadLight( size_t index ) const
00287 {
00288 __TRACE();
00289 __ASSERT( index < m_headLights.size() );
00290 return m_headLights[index];
00291 }
00292
00293 }