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 static const Int32 TransparencyAutoDetection; 00080 static const Int32 TransparencyForceTransparent; 00081 static const Int32 TransparencyForceOpaque; 00082 00084 /*---------------------------------------------------------------------*/ 00088 virtual void changed(BitVector whichField, 00089 UInt32 origin ); 00090 00092 /*---------------------------------------------------------------------*/ 00096 virtual void dump( UInt32 uiIndent = 0, 00097 const BitVector bvFlags = 0) const; 00098 00100 /*---------------------------------------------------------------------*/ 00104 // TODO: switch geo to functor too, remove makeState, replace by rebuild 00105 00106 typedef TypedFunctor1Base<Action::ResultE, 00107 PtrCallArg<DrawActionBase> > DrawFunctor; 00108 00109 virtual void draw (DrawFunctor& func, 00110 DrawActionBase * action )= 0; 00111 00112 virtual void draw (Geometry* geo, 00113 DrawActionBase * action )= 0; 00114 00115 virtual StatePtr makeState (void) = 0; 00116 00117 virtual void rebuildState (void) = 0; 00118 00119 virtual StatePtr getState (UInt32 index = 0); 00120 virtual bool isMultiPass (void) const; 00121 virtual UInt32 getNPasses (void) const; 00122 00123 virtual bool isTransparent (void) const = 0; 00124 00125 virtual Int32 getRealSortKey(void) const; 00126 00128 /*---------------------------------------------------------------------*/ 00132 virtual bool operator < (const Material &other) const; 00133 00134 virtual bool operator == (const Material &other) const; 00135 virtual bool operator != (const Material &other) const; 00136 00138 /*========================= PROTECTED ===============================*/ 00139 protected: 00140 00141 00142 StatePtr _pState; // !!! TODO is that MT safe? 00143 // Yes, but not efficient. Every material has as many States as there 00144 // are aspects, each of which itself is threadsafe (i.e. multibuffered). 00145 // A single State per Material would be better. I'm just not sure how to 00146 // initialize it. :( DR 00147 // Actually, no, it isn't!!! Multiple materials updating the same aspect 00148 // in different threads make this crash!!! DR 00149 00150 00151 // Make sure the state is deleted 00152 #if defined(OSG_FIXED_MFIELDSYNC) 00153 virtual void onDestroyAspect(UInt32 uiId, UInt32 uiAspect); 00154 #endif 00155 00156 /*---------------------------------------------------------------------*/ 00160 Material(void); 00161 Material(const Material &source); 00162 00164 /*---------------------------------------------------------------------*/ 00168 virtual ~Material(void); 00169 00171 /*========================== PRIVATE ================================*/ 00172 private: 00173 00174 typedef MaterialBase Inherited; 00175 00176 friend class FieldContainer; 00177 friend class MaterialBase; 00178 00179 static void initMethod( void ); 00180 00181 // prohibit default functions (move to 'public' if you need one) 00182 void operator =(const Material &source); 00183 }; 00184 00185 typedef Material *MaterialP; 00186 00187 extern OSG_SYSTEMLIB_DLLMAPPING MaterialPtr NullMaterial; 00188 00189 OSG_END_NAMESPACE 00190 00191 #include <OSGMaterialBase.inl> 00192 #include <OSGMaterial.inl> 00193 00194 #define OSGMATERIAL_HEADER_CVSID "@(#)$Id:$" 00195 00196 #endif /* _OSGMATERIAL_H_ */
1.5.5