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 \*---------------------------------------------------------------------------*/
40 #ifndef _OSGMAKETRANSPARENTGRAPHOP_H_
41 #define _OSGMAKETRANSPARENTGRAPHOP_H_
49 #include "OSGGraphOp.h"
50 #include "OSGUtilDef.h"
51 #include "OSGAction.h"
52 #include "OSGMaterialDrawable.h"
53 #include "OSGMaterialGroup.h"
57 /*! \ingroup GrpUtilGraphOp
58 \ingroup GrpLibOSGUtil
61 class OSG_UTIL_DLLMAPPING MakeTransparentGraphOp
: public GraphOp
66 /*---------------------------------------------------------------------*/
70 typedef GraphOp Inherited
;
71 typedef MakeTransparentGraphOp Self
;
73 OSG_GEN_INTERNAL_MEMOBJPTR(MakeTransparentGraphOp
);
80 MaterialObject(MaterialDrawable
*md
)
86 MaterialObject(MaterialGroup
*mg
)
92 Material
*getMaterial(void)
94 return (_md
!= NULL
? _md
->getMaterial() : _mg
->getMaterial());
97 void setMaterial(Material
*mat
)
101 _md
->setMaterial(mat
);
105 _mg
->setMaterial(mat
);
110 MaterialDrawable
*_md
;
115 /*---------------------------------------------------------------------*/
116 /*! \name Classname */
119 static const char *getClassname(void) { return "MakeTransparentGraphOp"; };
122 /*---------------------------------------------------------------------*/
123 /*! \name Constructors */
126 static ObjTransitPtr
create(void);
128 virtual GraphOpTransitPtr
clone (void);
131 /*---------------------------------------------------------------------*/
132 /*! \name Main methods */
135 virtual bool traverse(Node
*node
);
138 /*---------------------------------------------------------------------*/
139 /*! \name Parameters */
142 void setParams(const std::string params
);
144 std::string
usage(void);
147 /*========================= PROTECTED ===============================*/
151 /*---------------------------------------------------------------------*/
152 /*! \name Constructors/Destructor */
155 MakeTransparentGraphOp(const char* name
= "MakeTransparent");
156 virtual ~MakeTransparentGraphOp(void );
159 /*========================== PRIVATE ================================*/
163 Action::ResultE
traverseEnter(Node
* const node
);
164 Action::ResultE
traverseLeave(Node
* const node
, Action::ResultE res
);
166 void addObject (MaterialObject m
);
167 void applyTransparency(Material
*m
);
169 typedef std::list
<MaterialObject
> MaterialObjectList
;
170 typedef std::map
<MaterialUnrecPtr
, MaterialObjectList
> MaterialObjectMap
;
172 MaterialObjectMap _materialMap
;
173 Real32 _transparency
;
176 OSG_GEN_MEMOBJPTR(MakeTransparentGraphOp
);