OSGTransformChunk.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 #include <cstdlib>
00044 #include <cstdio>
00045
00046 #include "OSGConfig.h"
00047
00048 #include "OSGGL.h"
00049
00050 #include "OSGTransformChunk.h"
00051
00052 OSG_USING_NAMESPACE
00053
00054 // Documentation for this class is emited in the
00055 // OSGTransformChunkBase.cpp file.
00056 // To modify it, please change the .fcd file (OSGTransformChunk.fcd) and
00057 // regenerate the base file.
00058
00059 /***************************************************************************\
00060  *                           Class variables                               *
00061 \***************************************************************************/
00062
00063 StateChunkClass TransformChunk::_class("Transform", 1, 200);
00064
00065 /***************************************************************************\
00066  *                           Class methods                                 *
00067 \***************************************************************************/
00068
00069 void TransformChunk::initMethod(InitPhase ePhase)
00070 {
00071     Inherited::initMethod(ePhase);
00072 }
00073
00074 /***************************************************************************\
00075  *                           Instance methods                              *
00076 \***************************************************************************/
00077
00078 /*-------------------------------------------------------------------------*\
00079  -  private                                                                 -
00080 \*-------------------------------------------------------------------------*/
00081
00082 TransformChunk::TransformChunk(void) :
00083     Inherited()
00084 {
00085 }
00086
00087 TransformChunk::TransformChunk(const TransformChunk &source) :
00088     Inherited(source)
00089 {
00090 }
00091
00092 TransformChunk::~TransformChunk(void)
00093 {
00094 }
00095
00096 /*------------------------- Chunk Class Access ---------------------------*/
00097
00098 const StateChunkClass *TransformChunk::getClass(void) const
00099 {
00100     return &_class;
00101 }
00102
00103 /*------------------------------- Sync -----------------------------------*/
00104
00105 void TransformChunk::changed(ConstFieldMaskArg whichField,
00106                              UInt32            origin,
00107                              BitVector         details)
00108 {
00109     Inherited::changed(whichField, origin, details);
00110 }
00111
00112 /*------------------------------ Output ----------------------------------*/
00113
00114 void TransformChunk::dump(      UInt32    OSG_CHECK_ARG(uiIndent),
00115                           const BitVector OSG_CHECK_ARG(bvFlags )) const
00116 {
00117     SLOG << "Dump TransformChunk NI" << std::endl;
00118 }
00119
00120
00121 /*------------------------------ State ------------------------------------*/
00122
00123 void TransformChunk::activate(DrawEnv *,  UInt32)
00124 {
00125     glPushMatrix();
00126     glMultMatrixf( getMatrix().getValues() );
00127 }
00128
00129 void TransformChunk::changeFrom(DrawEnv *,  StateChunk *old, UInt32)
00130 {
00131     // change from me to me?
00132     // this assumes I haven't changed in the meantime. 
00133     // is that a valid assumption?
00134
00135     if(old == this)
00136         return;
00137
00138     glPopMatrix();
00139     glPushMatrix();
00140     glMultMatrixf( getMatrix().getValues() );
00141 }
00142
00143 void TransformChunk::deactivate(DrawEnv *,  UInt32)
00144 {
00145     glPopMatrix();
00146 }
00147
00148 /*-------------------------- Comparison -----------------------------------*/
00149
00150 Real32 TransformChunk::switchCost(StateChunk *OSG_CHECK_ARG(chunk))
00151 {
00152     return 0;
00153 }
00154
00155 bool TransformChunk::operator < (const StateChunk &other) const
00156 {
00157     return this < &other;
00158 }
00159
00160 bool TransformChunk::operator == (const StateChunk &other) const
00161 {
00162     TransformChunk const *tother = dynamic_cast<TransformChunk const*>(&other);
00163
00164     if ( !tother )
00165         return false;
00166
00167     if(tother == this)
00168         return true;
00169
00170     return getMatrix().equals( tother->getMatrix(), Eps );
00171 }
00172
00173 bool TransformChunk::operator != (const StateChunk &other) const
00174 {
00175     return ! (*this == other);
00176 }