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

OSGMaterial.h

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 #ifndef _OSGMATERIAL_H_
00041 #define _OSGMATERIAL_H_
00042 #ifdef __sgi
00043 #pragma once
00044 #endif
00045 
00046 #include <OSGConfig.h>
00047 #include <OSGTypedFunctors.h>
00048 #include <OSGAction.h>
00049 #include <OSGMaterialBase.h>
00050 #include <OSGState.h>
00051 
00052 OSG_BEGIN_NAMESPACE
00053 
00054 
00055 class Geometry;
00056 class DrawActionBase;
00057 
00062 class OSG_SYSTEMLIB_DLLMAPPING Material : public MaterialBase
00063 {
00064     /*==========================  PUBLIC  =================================*/
00065   public:
00066 
00067     /*---------------------------------------------------------------------*/
00071     static const char *getClassname(void) { return "Material"; };
00072 
00074     /*---------------------------------------------------------------------*/
00078     static const Int32 NoStateSorting;
00079 
00081     /*---------------------------------------------------------------------*/
00085     virtual void changed(BitVector whichField,
00086                          UInt32    origin    );
00087 
00089     /*---------------------------------------------------------------------*/
00093     virtual void dump(      UInt32    uiIndent = 0,
00094                       const BitVector bvFlags  = 0) const;
00095 
00097     /*---------------------------------------------------------------------*/
00101     // TODO: switch geo to functor too, remove makeState, replace by rebuild
00102     
00103     typedef TypedFunctor1Base<Action::ResultE, 
00104                               PtrCallArg<DrawActionBase> > DrawFunctor;
00105 
00106     virtual void       draw          (DrawFunctor& func,
00107                                       DrawActionBase * action )= 0;
00108 
00109     virtual void       draw          (Geometry* geo,
00110                                       DrawActionBase * action )= 0;
00111 
00112     virtual StatePtr   makeState     (void)                    = 0;
00113 
00114     virtual void       rebuildState  (void)                    = 0;
00115 
00116             StatePtr   getState      (void);
00117 
00118     virtual bool       isTransparent (void) const              = 0;
00119 
00121     /*---------------------------------------------------------------------*/
00125     virtual bool operator <  (const Material &other) const;
00126 
00127     virtual bool operator == (const Material &other) const;
00128     virtual bool operator != (const Material &other) const;
00129 
00131     /*=========================  PROTECTED  ===============================*/
00132   protected:
00133 
00134 
00135     StatePtr _pState;  // !!! TODO is that MT safe?
00136     // Yes, but not efficient. Every material has as many States as there
00137     // are aspects, each of which itself is threadsafe (i.e. multibuffered).
00138     // A single State per Material would be better. I'm just not sure how to
00139     // initialize it. :( DR
00140     // Actually, no, it isn't!!! Multiple materials updating the same aspect 
00141     // in different threads make this crash!!! DR
00142     
00143     /*---------------------------------------------------------------------*/
00147     Material(void);
00148     Material(const Material &source);
00149 
00151     /*---------------------------------------------------------------------*/
00155     virtual ~Material(void);
00156 
00158     /*==========================  PRIVATE  ================================*/
00159   private:
00160 
00161     typedef MaterialBase Inherited;
00162 
00163     friend class FieldContainer;
00164     friend class MaterialBase;
00165 
00166     static void initMethod( void );
00167 
00168     // prohibit default functions (move to 'public' if you need one)
00169     void operator =(const Material &source);
00170 };
00171 
00172 typedef Material *MaterialP;
00173 
00174 extern OSG_SYSTEMLIB_DLLMAPPING MaterialPtr NullMaterial;
00175 
00176 OSG_END_NAMESPACE
00177 
00178 #include <OSGMaterialBase.inl>
00179 #include <OSGMaterial.inl>
00180 
00181 #define OSGMATERIAL_HEADER_CVSID "@(#)$Id:$"
00182 
00183 #endif /* _OSGMATERIAL_H_ */

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