1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
46 #include "OSGConfig.h"
49 #include "OSGMaterial.h"
50 #include "OSGSimpleMaterial.h"
54 // Documentation for this class is emited in the
55 // OSGMaterialBase.cpp file.
56 // To modify it, please change the .fcd file (OSGMaterial.fcd) and
57 // regenerate the base file.
59 /***************************************************************************\
61 \***************************************************************************/
63 const Int32
Material::NoStateSorting
= 0x7fffffff;
64 const Int32
Material::TransparencyAutoDetection
= 0;
65 const Int32
Material::TransparencyForceTransparent
= 1;
66 const Int32
Material::TransparencyForceOpaque
= 2;
68 /***************************************************************************\
70 \***************************************************************************/
72 /*-------------------------------------------------------------------------*\
74 \*-------------------------------------------------------------------------*/
76 void Material::initMethod(InitPhase ePhase
)
78 Inherited::initMethod(ePhase
);
81 void Material::resolveLinks(void)
83 Inherited::resolveLinks();
86 /***************************************************************************\
88 \***************************************************************************/
90 /*-------------------------------------------------------------------------*\
92 \*-------------------------------------------------------------------------*/
95 /*------------- constructors & destructors --------------------------------*/
97 Material::Material(void) :
102 Material::Material(const Material
&source
) :
107 Material::~Material(void)
112 void Material::changed(ConstFieldMaskArg whichField
,
116 Inherited::changed(whichField
, origin
, details
);
119 /*------------------------------- dump ----------------------------------*/
121 void Material::dump( UInt32
,
122 const BitVector
) const
124 SLOG
<< "Material::dump called: NIY!" << std::endl
;
125 // Inherited::dump(uiIndent, bvFlags);
128 Action::ResultE
Material::renderEnter(NodeCore
* const pCore
,
131 return Action::Continue
;
134 Action::ResultE
Material::renderLeave(NodeCore
* const pCore
,
137 return Action::Continue
;
140 /*-------------------------- comparison -----------------------------------*/
143 bool Material::operator < (const Material
&other
) const
145 return this < &other
;
148 bool Material::operator == (const Material
&other
) const
150 return _pState
== other
._pState
;
153 bool Material::operator != (const Material
&other
) const
155 return ! (*this == other
);
160 /***************************************************************************\
162 \***************************************************************************/
164 #if defined(OSG_WIN32_ICL) && !defined(OSG_CHECK_FIELDSETARG)
165 #pragma warning (disable : 383)
170 static bool subRefDefaultMaterial (void);
171 static bool subRefDefaultUnlitMaterial(void);
174 /*! \ingroup GrpSystemDrawablesGeometrySimpleGeometry
175 Stores the default material used by the Simple Geometry.
177 static SimpleMaterialMTRecPtr _defaultMaterial
;
179 /*! \ingroup GrpSystemDrawablesGeometrySimpleGeometry
180 Access the default Material for Simple Geometry. Also useful whenever
181 an arbitrary material is needed.
184 PrimeMaterial
*getDefaultMaterial(void)
186 if(_defaultMaterial
== NULL
)
188 _defaultMaterial
= SimpleMaterial::create();
190 _defaultMaterial
->setDiffuse (Color3f(.7f
,.7f
,.5f
));
191 _defaultMaterial
->setAmbient (Color3f(0.1f
,0.1f
,0.1f
));
192 _defaultMaterial
->setSpecular (Color3f(1.f
,1.f
,1.f
));
193 _defaultMaterial
->setShininess(20.f
);
195 addPreFactoryExitFunction(subRefDefaultMaterial
);
197 _defaultMaterial
->rebuildState();
200 return _defaultMaterial
;
203 /*! \ingroup GrpSystemDrawablesGeometrySimpleGeometry
204 Stores the default unlit material.
206 static SimpleMaterialMTRecPtr _defaultUnlitMaterial
;
208 /*! \ingroup GrpSystemDrawablesGeometrySimpleGeometry
209 Access the default unlit Material. Useful whenever
210 an arbitrary unlit material is needed.
213 PrimeMaterial
*getDefaultUnlitMaterial(void)
215 if(_defaultUnlitMaterial
== NULL
)
217 _defaultUnlitMaterial
= SimpleMaterial::create();
219 _defaultUnlitMaterial
->setDiffuse(Color3f(1.f
,1.f
,.5f
));
220 _defaultUnlitMaterial
->setLit(false);
222 addPreFactoryExitFunction(subRefDefaultUnlitMaterial
);
224 _defaultUnlitMaterial
->rebuildState();
227 return _defaultUnlitMaterial
;
230 bool subRefDefaultMaterial (void)
232 // _defaultMaterial = NULL;
233 _defaultMaterial
.shutdownSetNull();
238 bool subRefDefaultUnlitMaterial(void)
240 // _defaultUnlitMaterial = NULL;
241 _defaultUnlitMaterial
.shutdownSetNull();