Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

OSGTileCameraDecorator.cpp

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002  *                                OpenSG                                     *
00003  *                                                                           *
00004  *                                                                           *
00005  *             Copyright (C) 2000-2002 by the OpenSG Forum                   *
00006  *                                                                           *
00007  *                            www.opensg.org                                 *
00008  *                                                                           *
00009  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
00010  *                                                                           *
00011 \*---------------------------------------------------------------------------*/
00012 /*---------------------------------------------------------------------------*\
00013  *                                License                                    *
00014  *                                                                           *
00015  * This library is free software; you can redistribute it and/or modify it   *
00016  * under the terms of the GNU Library General Public License as published    *
00017  * by the Free Software Foundation, version 2.                               *
00018  *                                                                           *
00019  * This library is distributed in the hope that it will be useful, but       *
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of                *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU         *
00022  * Library General Public License for more details.                          *
00023  *                                                                           *
00024  * You should have received a copy of the GNU Library General Public         *
00025  * License along with this library; if not, write to the Free Software       *
00026  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                 *
00027  *                                                                           *
00028 \*---------------------------------------------------------------------------*/
00029 /*---------------------------------------------------------------------------*\
00030  *                                Changes                                    *
00031  *                                                                           *
00032  *                                                                           *
00033  *                                                                           *
00034  *                                                                           *
00035  *                                                                           *
00036  *                                                                           *
00037 \*---------------------------------------------------------------------------*/
00038 
00039 //---------------------------------------------------------------------------
00040 //  Includes
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  *                            Description                                  *
00057 \***************************************************************************/
00058 
00071 /***************************************************************************\
00072  *                           Class methods                                 *
00073 \***************************************************************************/
00074 
00075 void TileCameraDecorator::initMethod (void)
00076 {
00077 }
00078 
00079 /***************************************************************************\
00080  *                           Instance methods                              *
00081 \***************************************************************************/
00082 
00083 /*------------- constructors & destructors --------------------------------*/
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     if(getFullWidth() != 0)
00127         width = getFullWidth();
00128     
00129     if(getFullHeight() != 0)
00130         height = getFullHeight();
00131         
00132     getDecoratee()->getProjection(result, width, height);
00133     
00134     Real32 left   = getLeft(),
00135            right  = getRight(),
00136            top    = getTop(),
00137            bottom = getBottom();
00138            
00139     if(left < 0)
00140         left = -left / width;
00141         
00142     if(right < 0)
00143         right = -right / width;
00144         
00145     if(top < 0)
00146         top = -top / height;
00147         
00148     if(bottom < 0)
00149         bottom = -bottom / height;
00150 
00151     // scale the wanted part from the projection matrix
00152     Real32  xs = 1.f / (right - left),
00153             ys = 1.f / (top - bottom);
00154     Matrix sm(  xs, 0, 0, -(left*2-1)*xs-1,  
00155                 0, ys, 0, -(bottom*2-1)*ys-1,  
00156                 0, 0, 1, 0, 
00157                 0, 0, 0, 1);
00158     
00159     result.multLeft(sm);
00160 }                                       
00161 
00162 /*------------------------------- dump ----------------------------------*/
00163 
00164 void TileCameraDecorator::dump(      UInt32    OSG_CHECK_ARG(uiIndent), 
00165                                const BitVector OSG_CHECK_ARG(bvFlags )) const
00166 {
00167     SLOG << "Dump TileCameraDecorator NI" << std::endl;
00168 }
00169 
00170 /*-------------------------------------------------------------------------*/
00171 /*                              cvs id's                                   */
00172 
00173 #ifdef __sgi
00174 #pragma set woff 1174
00175 #endif
00176 
00177 #ifdef OSG_LINUX_ICC
00178 #pragma warning( disable : 177 )
00179 #endif
00180 
00181 namespace
00182 {
00183     static char cvsid_cpp[] = "@(#)$Id: $";
00184     static char cvsid_hpp[] = OSGTILECAMERADECORATOR_HEADER_CVSID;
00185     static char cvsid_inl[] = OSGTILECAMERADECORATOR_INLINE_CVSID;
00186 }

Generated on Thu Aug 25 04:11:39 2005 for OpenSG by  doxygen 1.4.3