00001 #ifndef COIN_SOCAMERA_H
00002 #define COIN_SOCAMERA_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <Inventor/nodes/SoSubNode.h>
00028 #include <Inventor/SbViewportRegion.h>
00029 #include <Inventor/SbViewVolume.h>
00030 #include <Inventor/fields/SoSFRotation.h>
00031 #include <Inventor/fields/SoSFEnum.h>
00032 #include <Inventor/fields/SoSFVec3f.h>
00033 #include <Inventor/fields/SoSFFloat.h>
00034
00035 #include <Inventor/SbVec3f.h>
00036 #include <Inventor/SbBox3f.h>
00037
00038 #define SO_ASPECT_SQUARE 1.0f
00039 #define SO_ASPECT_VIDEO (4.0f/3.0f)
00040 #define SO_ASPECT_35mm_ACADEMY 1.371
00041 #define SO_ASPECT_16mm 1.369
00042 #define SO_ASPECT_35mm_FULL 1.33333
00043 #define SO_ASPECT_70mm 2.287
00044 #define SO_ASPECT_CINEMASCOPE 2.35
00045 #define SO_ASPECT_HDTV (16.0f/9.0f)
00046 #define SO_ASPECT_PANAVISION 2.361
00047 #define SO_ASPECT_35mm (3.0f/2.0f)
00048 #define SO_ASPECT_VISTAVISION 2.301
00049
00050 class SoPath;
00051
00052 class SoCameraP;
00053
00054 class COIN_DLL_API SoCamera : public SoNode {
00055 typedef SoNode inherited;
00056
00057 SO_NODE_ABSTRACT_HEADER(SoCamera);
00058
00059 public:
00060 static void initClass(void);
00061
00062 enum ViewportMapping {
00063 CROP_VIEWPORT_FILL_FRAME,
00064 CROP_VIEWPORT_LINE_FRAME,
00065 CROP_VIEWPORT_NO_FRAME,
00066 ADJUST_CAMERA,
00067 LEAVE_ALONE
00068 };
00069
00070 SoSFEnum viewportMapping;
00071 SoSFVec3f position;
00072 SoSFRotation orientation;
00073 SoSFFloat aspectRatio;
00074 SoSFFloat nearDistance;
00075 SoSFFloat farDistance;
00076 SoSFFloat focalDistance;
00077
00078 void pointAt(const SbVec3f & targetpoint);
00079 void pointAt(const SbVec3f & targetpoint, const SbVec3f & upvector);
00080 virtual void scaleHeight(float scalefactor) = 0;
00081 virtual SbViewVolume getViewVolume(float useaspectratio = 0.0f) const = 0;
00082 void viewAll(SoNode * const sceneroot, const SbViewportRegion & vpregion,
00083 const float slack = 1.0f);
00084 void viewAll(SoPath * const path, const SbViewportRegion & vpregion,
00085 const float slack = 1.0f);
00086 SbViewportRegion getViewportBounds(const SbViewportRegion & region) const;
00087
00088 enum StereoMode {
00089 MONOSCOPIC,
00090 LEFT_VIEW,
00091 RIGHT_VIEW
00092 };
00093
00094 void setStereoMode(StereoMode mode);
00095 StereoMode getStereoMode(void) const;
00096
00097 void setStereoAdjustment(float adjustment);
00098 float getStereoAdjustment(void) const;
00099 void setBalanceAdjustment(float adjustment);
00100 float getBalanceAdjustment(void) const;
00101
00102 virtual void doAction(SoAction * action);
00103 virtual void callback(SoCallbackAction * action);
00104 virtual void GLRender(SoGLRenderAction * action);
00105 virtual void audioRender(SoAudioRenderAction *action);
00106 virtual void getBoundingBox(SoGetBoundingBoxAction * action);
00107 virtual void handleEvent(SoHandleEventAction * action);
00108 virtual void rayPick(SoRayPickAction * action);
00109 virtual void getPrimitiveCount(SoGetPrimitiveCountAction * action);
00110
00111 protected:
00112 SoCamera(void);
00113 virtual ~SoCamera();
00114
00115 virtual void viewBoundingBox(const SbBox3f & box, float aspect,
00116 float slack) = 0;
00117 virtual void jitter(int numpasses, int curpass,
00118 const SbViewportRegion & vpreg,
00119 SbVec3f & jitteramount) const;
00120
00121 private:
00122 void getView(SoAction * action, SbViewVolume & resultvv,
00123 SbViewportRegion & resultvp,
00124 const SbBool considermodelmatrix = TRUE);
00125
00126 void drawCroppedFrame(SoGLRenderAction * action,
00127 const int viewportmapping,
00128 const SbViewportRegion & oldvp,
00129 const SbViewportRegion & newvp);
00130
00131 void lookAt(const SbVec3f & dir, const SbVec3f & up);
00132
00133 StereoMode stereomode;
00134 float stereoadjustment;
00135 float balanceadjustment;
00136 private:
00137 SoCameraP *pimpl;
00138 friend class SoCameraP;
00139 };
00140
00141 #endif // !COIN_SOCAMERA_H