00001
00002
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
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include <stdlib.h>
00044 #include <stdio.h>
00045
00046 #include <OSGConfig.h>
00047
00048 #include <OSGMatrixUtility.h>
00049
00050 #include "OSGNodePtr.h"
00051 #include "OSGPerspectiveCamera.h"
00052 #include "OSGShearedStereoCameraDecorator.h"
00053
00054 OSG_USING_NAMESPACE
00055
00056
00057
00058
00059
00070
00071
00072 ShearedStereoCameraDecorator::ShearedStereoCameraDecorator(void) :
00073 Inherited()
00074 {
00075 }
00076
00077 ShearedStereoCameraDecorator::ShearedStereoCameraDecorator(const ShearedStereoCameraDecorator &source) :
00078 Inherited(source)
00079 {
00080 }
00081
00082 ShearedStereoCameraDecorator::~ShearedStereoCameraDecorator(void)
00083 {
00084 }
00085
00086
00087
00088 void ShearedStereoCameraDecorator::initMethod (void)
00089 {
00090 }
00091
00092 void ShearedStereoCameraDecorator::changed(BitVector whichField, UInt32 origin)
00093 {
00094 Inherited::changed(whichField, origin);
00095 }
00096
00097 void ShearedStereoCameraDecorator::dump( UInt32 ,
00098 const BitVector ) const
00099 {
00100 SLOG << "Dump ShearedStereoCameraDecorator NI" << std::endl;
00101 }
00102
00103
00107 void ShearedStereoCameraDecorator::getProjection( Matrix &result,
00108 UInt32 width, UInt32 height)
00109 {
00110 if(width == 0 || height == 0)
00111 {
00112 result.setIdentity();
00113 return;
00114 }
00115
00116 PerspectiveCameraPtr cam = PerspectiveCameraPtr::dcast(getDecoratee());
00117
00118 if(cam == NullFC)
00119 {
00120 FFATAL(("ShearedStereoCameraDecorator::getProjection: can only"
00121 " decorate PerspectiveCameras!\n"));
00122 result.setIdentity();
00123 return;
00124 }
00125
00126 Matrix trans;
00127 MatrixStereoPerspective(result, trans, cam->getFov(),
00128 width / (Real32) height * cam->getAspect(),
00129 cam->getNear(), cam->getFar(),
00130 getZeroParallaxDistance(),
00131 getEyeSeparation(),
00132 getLeftEye() ? 0.f : 1.f,
00133 getOverlap());
00134
00135 result.mult(trans);
00136 }
00137
00138 void ShearedStereoCameraDecorator::getDecoration(Matrix &result,
00139 UInt32 width, UInt32 height)
00140 {
00141 if(width == 0 || height == 0)
00142 {
00143 result.setIdentity();
00144 return;
00145 }
00146
00147 CameraPtr camera = getDecoratee();
00148 if(camera == NullFC)
00149 {
00150 FWARNING(("TileCameraDecorator::getProjection: no decoratee!\n"));
00151 result.setIdentity();
00152 return;
00153 }
00154
00155 camera->getDecoration(result, width, height);
00156 }
00157
00158
00159
00160
00161 #ifdef __sgi
00162 #pragma set woff 1174
00163 #endif
00164
00165 #ifdef OSG_LINUX_ICC
00166 #pragma warning( disable : 177 )
00167 #endif
00168
00169 namespace
00170 {
00171 static char cvsid_cpp[] = "@(#)$Id: $";
00172 static char cvsid_hpp[] = OSGSHEAREDSTEREOCAMERADECORATOR_HEADER_CVSID;
00173 static char cvsid_inl[] = OSGSHEAREDSTEREOCAMERADECORATOR_INLINE_CVSID;
00174 }