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

OSGMaterialDrawable.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 <stdlib.h>
00044 #include <stdio.h>
00045 
00046 #include <OSGConfig.h>
00047 
00048 #include "OSGMaterialDrawable.h"
00049 
00050 #include <OSGDrawAction.h>
00051 #include <OSGRenderAction.h>
00052 #include <OSGIntersectAction.h>
00053 #include <OSGSimpleGeometry.h>
00054 
00055 OSG_USING_NAMESPACE
00056 
00061 /*----------------------- constructors & destructors ----------------------*/
00062 
00064 
00065 MaterialDrawable::MaterialDrawable(void) :
00066     Inherited()
00067 {
00068 }
00069 
00071 
00072 MaterialDrawable::MaterialDrawable(const MaterialDrawable &source) :
00073     Inherited(source)
00074 {
00075 }
00076 
00078 
00079 MaterialDrawable::~MaterialDrawable(void)
00080 {
00081 }
00082 
00083 /*----------------------------- class specific ----------------------------*/
00084 
00086 
00087 Action::ResultE MaterialDrawable::drawPrimitives (DrawActionBase *)
00088 {
00089   FWARNING (("You should overload drawPrimitives in your code\n"));
00090 
00091   return Action::Continue;
00092 }
00093 
00094 Action::ResultE MaterialDrawable::renderActionHandler(Action *action)
00095 {
00096     RenderAction *a = dynamic_cast<RenderAction *>(action);
00097 
00098     Material::DrawFunctor func;
00099     func = osgTypedMethodFunctor1ObjPtr(this, 
00100                                         &MaterialDrawable::drawPrimitives);
00101 
00102     Material* m = a->getMaterial();
00103 
00104     if(m == NULL)
00105     {
00106         if(getMaterial() != NullFC)
00107         {
00108             m = getMaterial().getCPtr();
00109         }
00110         else
00111         {
00112             m = getDefaultMaterial().getCPtr();
00113             FNOTICE(("MaterialDrawable::render: no Material!?!\n"));
00114         }
00115     }
00116 
00117     a->dropFunctor(func, m);
00118 
00119     return Action::Continue;
00120 }
00121 
00122 Action::ResultE MaterialDrawable::drawActionHandler(Action * action )
00123 {
00124     DrawAction *a = dynamic_cast<DrawAction*>(action);
00125     Material::DrawFunctor func;
00126 
00127     func=osgTypedMethodFunctor1ObjPtr(&(*this), 
00128                                       &MaterialDrawable::drawPrimitives);
00129 
00130     if(a->getMaterial() != NULL)
00131     {
00132         a->getMaterial()->draw(func, a);
00133     }
00134     else if ( getMaterial() != NullFC )
00135     {
00136         getMaterial()->draw( func, a );
00137     }
00138     else
00139     {
00140         getDefaultMaterial()->draw( func, a );
00141         FWARNING(("MaterialDrawable::draw:: no material!\n"));;
00142     }
00143     return Action::Continue;
00144 }
00145     
00146 
00147 void MaterialDrawable::initMethod (void)
00148 {
00149 }
00150 
00152 
00153 void MaterialDrawable::changed(BitVector whichField, UInt32 origin)
00154 {
00155     Inherited::changed(whichField, origin);
00156 }
00157 
00159 
00160 void MaterialDrawable::dump(      UInt32    , 
00161                          const BitVector ) const
00162 {
00163     SLOG << "Dump MaterialDrawable NI" << std::endl;
00164 }
00165 
00166 
00167 /*------------------------------------------------------------------------*/
00168 /*                              cvs id's                                  */
00169 
00170 #ifdef OSG_SGI_CC
00171 #pragma set woff 1174
00172 #endif
00173 
00174 #ifdef OSG_LINUX_ICC
00175 #pragma warning( disable : 177 )
00176 #endif
00177 
00178 namespace
00179 {
00180     static Char8 cvsid_cpp       [] = "@(#)$Id: OSGMaterialDrawable.cpp,v 1.7 2003/11/01 01:57:26 vossg Exp $";
00181     static Char8 cvsid_hpp       [] = OSGMATERIALDRAWABLEBASE_HEADER_CVSID;
00182     static Char8 cvsid_inl       [] = OSGMATERIALDRAWABLEBASE_INLINE_CVSID;
00183 
00184     static Char8 cvsid_fields_hpp[] = OSGMATERIALDRAWABLEFIELDS_HEADER_CVSID;
00185 }
00186 
00187 #ifdef __sgi
00188 #pragma reset woff 1174
00189 #endif
00190 

Generated on Thu Aug 25 04:07:22 2005 for OpenSG by  doxygen 1.4.3