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 //---------------------------------------------------------------------------
45 #include <boost/bind.hpp>
47 #include "OSGConfig.h"
50 #include "OSGWindow.h"
52 #include "OSGGeoInstancer.h"
53 #include "OSGDrawEnv.h"
55 #include "OSGGLFuncProtos.h"
57 #include "OSGConceptPropertyChecks.h"
58 #include "OSGIntersectAction.h"
59 #include "OSGGeometry.h"
60 #include "OSGRenderAction.h"
64 // Documentation for this class is emited in the
65 // OSGGeoInstancerBase.cpp file.
66 // To modify it, please change the .fcd file (OSGGeoInstancer.fcd) and
67 // regenerate the base file.
70 /***************************************************************************\
72 \***************************************************************************/
74 /***************************************************************************\
76 \***************************************************************************/
78 void GeoInstancer::initMethod(InitPhase ePhase
)
80 Inherited::initMethod(ePhase
);
82 if(ePhase
== TypeObject::SystemPost
)
84 IntersectAction::registerEnterDefault(
86 reinterpret_cast<Action::Callback
>(&GeoInstancer::intersectEnter
));
88 RenderAction::registerEnterDefault(
90 reinterpret_cast<Action::Callback
>(
91 &MaterialDrawable::renderEnter
));
93 RenderAction::registerLeaveDefault(
95 reinterpret_cast<Action::Callback
>(
96 &MaterialDrawable::renderLeave
));
101 /***************************************************************************\
103 \***************************************************************************/
105 /*-------------------------------------------------------------------------*\
107 \*-------------------------------------------------------------------------*/
109 /*----------------------- constructors & destructors ----------------------*/
111 GeoInstancer::GeoInstancer(void) :
116 GeoInstancer::GeoInstancer(const GeoInstancer
&source
) :
121 GeoInstancer::~GeoInstancer(void)
126 /*------------------------- Chunk Class Access ---------------------------*/
128 /*----------------------------- class specific ----------------------------*/
130 void GeoInstancer::changed(ConstFieldMaskArg whichField
,
134 Inherited::changed(whichField
, origin
, details
);
137 void GeoInstancer::dump( UInt32
,
138 const BitVector
) const
140 SLOG
<< "GeoInstancer:" << std::endl
;
143 /*------------------------------ State ------------------------------------*/
146 /*-------------------------- Comparison -----------------------------------*/
148 const SFUnrecMaterialPtr
*GeoInstancer::getSFMaterial (void) const
150 if(_sfBaseGeometry
.getValue() != NULL
)
152 return _sfBaseGeometry
.getValue()->getSFMaterial();
158 SFUnrecMaterialPtr
*GeoInstancer::editSFMaterial(void)
160 if(_sfBaseGeometry
.getValue() != NULL
)
162 return _sfBaseGeometry
.getValue()->editSFMaterial();
168 Material
*GeoInstancer::getMaterial(void) const
170 if(_sfBaseGeometry
.getValue() != NULL
)
172 return _sfBaseGeometry
.getValue()->getMaterial();
178 void GeoInstancer::setMaterial(Material
* const value
)
180 if(_sfBaseGeometry
.getValue() != NULL
)
182 return _sfBaseGeometry
.getValue()->setMaterial(value
);
186 void GeoInstancer::drawPrimitives(DrawEnv
*pEnv
)
188 if(_sfBaseGeometry
.getValue() == NULL
)
191 _sfBaseGeometry
.getValue()->drawPrimitives(pEnv
,
192 _sfNumInstances
.getValue());
195 Action::ResultE
GeoInstancer::intersectEnter(Action
*action
)
197 if(_sfBaseGeometry
.getValue() == NULL
)
198 return Action::Continue
;
200 return _sfBaseGeometry
.getValue()->intersectEnter(action
);
202 return Action::Continue
;
205 void GeoInstancer::adjustVolume(Volume
&volume
)
207 if(_sfBaseGeometry
.getValue() == NULL
)
210 _sfBaseGeometry
.getValue()->adjustVolume(volume
);
213 void GeoInstancer::fill(DrawableStatsAttachment
*pStat
)
217 GetFieldHandlePtr
GeoInstancer::getHandleMaterial(void) const
219 if(_sfBaseGeometry
.getValue() != NULL
)
221 return _sfBaseGeometry
.getValue()->getHandleMaterial();
224 return GetFieldHandlePtr();
227 EditFieldHandlePtr
GeoInstancer::editHandleMaterial(void)
229 if(_sfBaseGeometry
.getValue() != NULL
)
231 return _sfBaseGeometry
.getValue()->editHandleMaterial();
234 return EditFieldHandlePtr();