fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / NodeCores / Groups / Base / OSGMaterialGroup.cpp
blob643fa357a08b20fd12e5c0ccafc77cae4f411639
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 #include <cstdlib>
40 #include <cstdio>
42 #include "OSGConfig.h"
44 #include "OSGMaterialGroup.h"
45 #include "OSGRenderAction.h"
47 OSG_USING_NAMESPACE
49 // Documentation for this class is emited in the
50 // OSGMaterialGroupBase.cpp file.
51 // To modify it, please change the .fcd file (OSGMaterialGroup.fcd) and
52 // regenerate the base file.
54 /*-------------------------------------------------------------------------*/
55 /* Sync */
57 void MaterialGroup::changed(ConstFieldMaskArg whichField,
58 UInt32 origin,
59 BitVector details)
61 Inherited::changed(whichField, origin, details);
64 /*-------------------------------------------------------------------------*/
65 /* Dump */
67 void MaterialGroup::dump( UInt32 uiIndent,
68 const BitVector bvFlags) const
70 Inherited::dump(uiIndent, bvFlags);
73 /*-------------------------------------------------------------------------*/
74 /* Constructors */
76 MaterialGroup::MaterialGroup(void) :
77 Inherited()
81 MaterialGroup::MaterialGroup(const MaterialGroup &source) :
82 Inherited(source)
86 /*-------------------------------------------------------------------------*/
87 /* Destructor */
89 MaterialGroup::~MaterialGroup(void)
93 /*-------------------------------------------------------------------------*/
94 /* Render */
96 Action::ResultE MaterialGroup::renderEnter(Action *action)
98 RenderAction *pAction =
99 dynamic_cast<RenderAction *>(action);
101 Action::ResultE r = Group::renderEnter(action);
103 // ok all children are culled away so we leave
104 // immediately and don't set the material!
105 if(r == Action::Skip)
106 return r;
108 if(pAction != NULL &&
109 this->getMaterial() != NULL )
111 pAction->overrideMaterial(this->getMaterial(),
112 pAction->getActNode());
115 return r;
118 Action::ResultE MaterialGroup::renderLeave(Action *action)
120 RenderAction *pAction =
121 dynamic_cast<RenderAction *>(action);
123 if(pAction != NULL)
125 pAction->overrideMaterial(NULL, pAction->getActNode());
128 return Group::renderLeave(action);
131 /*-------------------------------------------------------------------------*/
132 /* Init */
134 void MaterialGroup::initMethod(InitPhase ePhase)
136 Inherited::initMethod(ePhase);
138 if(ePhase == TypeObject::SystemPost)
140 RenderAction::registerEnterDefault(
141 MaterialGroup::getClassType(),
142 reinterpret_cast<Action::Callback>(&MaterialGroup::renderEnter));
144 RenderAction::registerLeaveDefault(
145 MaterialGroup::getClassType(),
146 reinterpret_cast<Action::Callback>(&MaterialGroup::renderLeave));