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"
48 #include "OSGSwitchMaterial.h"
52 // Documentation for this class is emited in the
53 // OSGSwitchMaterialBase.cpp file.
54 // To modify it, please change the .fcd file (OSGSwitchMaterial.fcd) and
55 // regenerate the base file.
57 /***************************************************************************\
59 \***************************************************************************/
61 /***************************************************************************\
63 \***************************************************************************/
65 void SwitchMaterial::initMethod(InitPhase ePhase
)
67 Inherited::initMethod(ePhase
);
71 /***************************************************************************\
73 \***************************************************************************/
75 /*-------------------------------------------------------------------------*\
77 \*-------------------------------------------------------------------------*/
79 /*----------------------- constructors & destructors ----------------------*/
81 SwitchMaterial::SwitchMaterial(void) :
86 SwitchMaterial::SwitchMaterial(const SwitchMaterial
&source
) :
91 SwitchMaterial::~SwitchMaterial(void)
95 /*----------------------------- class specific ----------------------------*/
97 void SwitchMaterial::changed(ConstFieldMaskArg whichField
,
101 Inherited::changed(whichField
, origin
, details
);
104 void SwitchMaterial::addMaterial(Material
*mat
)
109 pushToMaterials(mat
);
112 void SwitchMaterial::subMaterial(Material
*mat
)
117 removeObjFromMaterials(mat
);
120 bool SwitchMaterial::hasMaterial(Material
*mat
) const
124 for(i
= 0; i
< _mfMaterials
.size(); ++i
)
126 if(_mfMaterials
[i
] == mat
)
133 Material
*SwitchMaterial::getMaterial(UInt32 index
) const
135 if(index
>= _mfMaterials
.size())
137 FWARNING(("SwitchMaterial::getMaterial : index %u out of range\n",
143 return _mfMaterials
[index
];
146 Material
*SwitchMaterial::getCurrentMaterial(void) const
148 UInt32 choice
= getChoice();
150 if(choice
>= _mfMaterials
.size())
152 FWARNING(("SwitchMaterial::getCurrentMaterial : current choice %u "
153 "out of range\n", choice
));
157 return _mfMaterials
[choice
];
161 /*! Check if the Material (i.e. any of its materials) is transparent..
164 bool SwitchMaterial::isTransparent(void) const
166 UInt32 choice
= getChoice();
168 if(choice
>= _mfMaterials
.size())
170 if(!_mfMaterials
.empty())
172 SWARNING
<< "SwitchMaterial::isTransparent: choice index out "
180 if(_mfMaterials
[choice
] != NULL
)
181 return _mfMaterials
[choice
]->isTransparent();
186 /*! Check if the Material (i.e. any of its materials) is transparent..
188 PrimeMaterial
*SwitchMaterial::finalize( MaterialMapKey oKey
,
189 const StateOverride
*pOverrides
,
192 UInt32 choice
= getChoice();
194 if(choice
>= _mfMaterials
.size())
196 if(!_mfMaterials
.empty())
198 SWARNING
<< "SwitchMaterial::finalize choice index out "
206 if(_mfMaterials
[choice
] != NULL
)
207 return _mfMaterials
[choice
]->finalize(oKey
, pOverrides
, pWin
);
212 void SwitchMaterial::dump( UInt32
,
213 const BitVector
) const
215 SLOG
<< "Dump SwitchMaterial NI" << std::endl
;