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 \*---------------------------------------------------------------------------*/
42 #include "OSGConfig.h"
44 #include "OSGMaterialGroup.h"
45 #include "OSGRenderAction.h"
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 /*-------------------------------------------------------------------------*/
57 void MaterialGroup::changed(ConstFieldMaskArg whichField
,
61 Inherited::changed(whichField
, origin
, details
);
64 /*-------------------------------------------------------------------------*/
67 void MaterialGroup::dump( UInt32 uiIndent
,
68 const BitVector bvFlags
) const
70 Inherited::dump(uiIndent
, bvFlags
);
73 /*-------------------------------------------------------------------------*/
76 MaterialGroup::MaterialGroup(void) :
81 MaterialGroup::MaterialGroup(const MaterialGroup
&source
) :
86 /*-------------------------------------------------------------------------*/
89 MaterialGroup::~MaterialGroup(void)
93 /*-------------------------------------------------------------------------*/
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
)
108 if(pAction
!= NULL
&&
109 this->getMaterial() != NULL
)
111 pAction
->overrideMaterial(this->getMaterial(),
112 pAction
->getActNode());
118 Action::ResultE
MaterialGroup::renderLeave(Action
*action
)
120 RenderAction
*pAction
=
121 dynamic_cast<RenderAction
*>(action
);
125 pAction
->overrideMaterial(NULL
, pAction
->getActNode());
128 return Group::renderLeave(action
);
131 /*-------------------------------------------------------------------------*/
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
));