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
00044 #include <stdlib.h>
00045 #include <stdio.h>
00046
00047 #include <OSGConfig.h>
00048
00049 #include "OSGNodePtr.h"
00050 #include "OSGTileCameraDecorator.h"
00051
00052 OSG_USING_NAMESPACE
00053
00054
00055
00056
00057
00058
00071
00072
00073
00074
00075 void TileCameraDecorator::initMethod (void)
00076 {
00077 }
00078
00079
00080
00081
00082
00083
00084
00085 TileCameraDecorator::TileCameraDecorator(void) :
00086 Inherited()
00087 {
00088 }
00089
00090 TileCameraDecorator::TileCameraDecorator(const TileCameraDecorator &source) :
00091 Inherited(source)
00092 {
00093 }
00094
00095 TileCameraDecorator::~TileCameraDecorator(void)
00096 {
00097 }
00098
00099 void TileCameraDecorator::changed(BitVector whichField, UInt32 origin)
00100 {
00101 Inherited::changed(whichField, origin);
00102 }
00103
00108 void TileCameraDecorator::setSize( Real32 left, Real32 bottom, Real32 right,
00109 Real32 top )
00110 {
00111 _sfLeft.setValue( left );
00112 _sfRight.setValue( right );
00113 _sfBottom.setValue( bottom );
00114 _sfTop.setValue( top );
00115 }
00116
00117 void TileCameraDecorator::getProjection( Matrix &result,
00118 UInt32 width, UInt32 height)
00119 {
00120 if(width == 0 || height == 0)
00121 {
00122 result.setIdentity();
00123 return;
00124 }
00125
00126 CameraPtr camera = getDecoratee();
00127 if(camera == NullFC)
00128 {
00129 FWARNING(("TileCameraDecorator::getProjection: no decoratee!\n"));
00130 result.setIdentity();
00131 return;
00132 }
00133
00134 if(getFullWidth() != 0)
00135 width = getFullWidth();
00136
00137 if(getFullHeight() != 0)
00138 height = getFullHeight();
00139
00140 camera->getProjection(result, width, height);
00141
00142 Real32 left = getLeft(),
00143 right = getRight(),
00144 top = getTop(),
00145 bottom = getBottom();
00146
00147 if(left < 0)
00148 left = -left / width;
00149
00150 if(right < 0)
00151 right = -right / width;
00152
00153 if(top < 0)
00154 top = -top / height;
00155
00156 if(bottom < 0)
00157 bottom = -bottom / height;
00158
00159
00160 Real32 xs = 1.f / (right - left),
00161 ys = 1.f / (top - bottom);
00162 Matrix sm( xs, 0, 0, -(left*2-1)*xs-1,
00163 0, ys, 0, -(bottom*2-1)*ys-1,
00164 0, 0, 1, 0,
00165 0, 0, 0, 1);
00166
00167 result.multLeft(sm);
00168 }
00169
00172 void TileCameraDecorator::getDecoration(Matrix &result,
00173 UInt32 width, UInt32 height)
00174 {
00175 if(width == 0 || height == 0)
00176 {
00177 result.setIdentity();
00178 return;
00179 }
00180
00181 CameraPtr camera = getDecoratee();
00182 if(camera == NullFC)
00183 {
00184 FWARNING(("TileCameraDecorator::getProjection: no decoratee!\n"));
00185 result.setIdentity();
00186 return;
00187 }
00188
00189 if(getFullWidth() != 0)
00190 width = getFullWidth();
00191
00192 if(getFullHeight() != 0)
00193 height = getFullHeight();
00194
00195
00196 camera->getDecoration(result, width, height);
00197
00198 Real32 left = getLeft(),
00199 right = getRight(),
00200 top = getTop(),
00201 bottom = getBottom();
00202
00203 if(left < 0)
00204 left = -left / width;
00205
00206 if(right < 0)
00207 right = -right / width;
00208
00209 if(top < 0)
00210 top = -top / height;
00211
00212 if(bottom < 0)
00213 bottom = -bottom / height;
00214
00215
00216 Real32 xs = 1.f / (right - left),
00217 ys = 1.f / (top - bottom);
00218 Matrix sm( xs, 0, 0, -(left*2-1)*xs-1,
00219 0, ys, 0, -(bottom*2-1)*ys-1,
00220 0, 0, 1, 0,
00221 0, 0, 0, 1);
00222
00223 result.multLeft(sm);
00224 }
00225
00226
00227
00228 void TileCameraDecorator::dump( UInt32 OSG_CHECK_ARG(uiIndent),
00229 const BitVector OSG_CHECK_ARG(bvFlags )) const
00230 {
00231 SLOG << "Dump TileCameraDecorator NI" << std::endl;
00232 }
00233
00234
00235
00236
00237 #ifdef __sgi
00238 #pragma set woff 1174
00239 #endif
00240
00241 #ifdef OSG_LINUX_ICC
00242 #pragma warning( disable : 177 )
00243 #endif
00244
00245 namespace
00246 {
00247 static char cvsid_cpp[] = "@(#)$Id: $";
00248 static char cvsid_hpp[] = OSGTILECAMERADECORATOR_HEADER_CVSID;
00249 static char cvsid_inl[] = OSGTILECAMERADECORATOR_INLINE_CVSID;
00250 }