OSGShearedStereoCameraDecorator.cpp
Go to the documentation of this file.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 <cstdlib>
00044 #include <cstdio>
00045
00046 #include "OSGConfig.h"
00047
00048 #include "OSGMatrixUtility.h"
00049
00050 #include "OSGPerspectiveCamera.h"
00051 #include "OSGShearedStereoCameraDecorator.h"
00052
00053 OSG_USING_NAMESPACE
00054
00055
00056
00057
00058
00059
00060
00061
00062 ShearedStereoCameraDecorator::ShearedStereoCameraDecorator(void) :
00063 Inherited()
00064 {
00065 }
00066
00067 ShearedStereoCameraDecorator::ShearedStereoCameraDecorator(
00068 const ShearedStereoCameraDecorator &source) :
00069
00070 Inherited(source)
00071 {
00072 }
00073
00074 ShearedStereoCameraDecorator::~ShearedStereoCameraDecorator(void)
00075 {
00076 }
00077
00078
00079
00080 void ShearedStereoCameraDecorator::initMethod(InitPhase ePhase)
00081 {
00082 Inherited::initMethod(ePhase);
00083 }
00084
00085 void ShearedStereoCameraDecorator::changed(ConstFieldMaskArg whichField,
00086 UInt32 origin,
00087 BitVector details)
00088 {
00089 Inherited::changed(whichField, origin, details);
00090 }
00091
00092 void ShearedStereoCameraDecorator::dump( UInt32 ,
00093 const BitVector ) const
00094 {
00095 SLOG << "Dump ShearedStereoCameraDecorator NI" << std::endl;
00096 }
00097
00098
00102 void ShearedStereoCameraDecorator::getProjection(Matrix &result,
00103 UInt32 width,
00104 UInt32 height)
00105 {
00106 if(width == 0 || height == 0)
00107 {
00108 result.setIdentity();
00109 return;
00110 }
00111
00112 PerspectiveCamera *cam =
00113 dynamic_cast<PerspectiveCamera *>(getDecoratee());
00114
00115 if(cam == NULL)
00116 {
00117 FFATAL(("ShearedStereoCameraDecorator::getProjection: can only"
00118 " decorate PerspectiveCameras!\n"));
00119
00120 result.setIdentity();
00121 return;
00122 }
00123
00124 Matrix trans;
00125 MatrixStereoPerspective(result, trans, cam->getFov(),
00126 width / Real32(height) * cam->getAspect(),
00127 cam->getNear(),
00128 cam->getFar(),
00129 getZeroParallaxDistance(),
00130 getEyeSeparation(),
00131 getLeftEye() ? 0.f : 1.f,
00132 getOverlap());
00133
00134 result.mult(trans);
00135 }
00136
00137 void ShearedStereoCameraDecorator::getDecoration(Matrix &result,
00138 UInt32 width,
00139 UInt32 height)
00140 {
00141 if(width == 0 || height == 0)
00142 {
00143 result.setIdentity();
00144 return;
00145 }
00146
00147 Camera *camera = getDecoratee();
00148
00149 if(camera == NULL)
00150 {
00151 FWARNING(("TileCameraDecorator::getProjection: no decoratee!\n"));
00152
00153 result.setIdentity();
00154
00155 return;
00156 }
00157
00158 camera->getDecoration(result, width, height);
00159 }