fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / Material / Base / OSGMaterial.cpp
blob43b36ddd78aa888180c31e39b13505f0227238dd
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
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. *
18 * *
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. *
23 * *
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. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
40 // Includes
41 //---------------------------------------------------------------------------
43 #include <cstdlib>
44 #include <cstdio>
46 #include "OSGConfig.h"
48 #include "OSGGL.h"
49 #include "OSGMaterial.h"
50 #include "OSGSimpleMaterial.h"
52 OSG_USING_NAMESPACE
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 /***************************************************************************\
60 * Class variables *
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 /***************************************************************************\
69 * Class methods *
70 \***************************************************************************/
72 /*-------------------------------------------------------------------------*\
73 - private -
74 \*-------------------------------------------------------------------------*/
76 void Material::initMethod(InitPhase ePhase)
78 Inherited::initMethod(ePhase);
81 void Material::resolveLinks(void)
83 Inherited::resolveLinks();
86 /***************************************************************************\
87 * Instance methods *
88 \***************************************************************************/
90 /*-------------------------------------------------------------------------*\
91 - public -
92 \*-------------------------------------------------------------------------*/
95 /*------------- constructors & destructors --------------------------------*/
97 Material::Material(void) :
98 Inherited()
102 Material::Material(const Material &source) :
103 Inherited(source)
107 Material::~Material(void)
112 void Material::changed(ConstFieldMaskArg whichField,
113 UInt32 origin,
114 BitVector details)
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,
129 Action * pAction)
131 return Action::Continue;
134 Action::ResultE Material::renderLeave(NodeCore * const pCore,
135 Action * pAction)
137 return Action::Continue;
140 /*-------------------------- comparison -----------------------------------*/
142 #if 0
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);
157 #endif
160 /***************************************************************************\
161 * Description *
162 \***************************************************************************/
164 #if defined(OSG_WIN32_ICL) && !defined(OSG_CHECK_FIELDSETARG)
165 #pragma warning (disable : 383)
166 #endif
168 OSG_BEGIN_NAMESPACE
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();
235 return true;
238 bool subRefDefaultUnlitMaterial(void)
240 // _defaultUnlitMaterial = NULL;
241 _defaultUnlitMaterial.shutdownSetNull();
243 return true;
246 OSG_END_NAMESPACE