1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
7 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
9 \*---------------------------------------------------------------------------*/
10 /*---------------------------------------------------------------------------*\
13 * This library is free software; you can redistribute it and/or modify it *
14 * under the terms of the GNU Library General Public License as published *
15 * by the Free Software Foundation, version 2. *
17 * This library is distributed in the hope that it will be useful, but *
18 * WITHOUT ANY WARRANTY; without even the implied warranty of *
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
20 * Library General Public License for more details. *
22 * You should have received a copy of the GNU Library General Public *
23 * License along with this library; if not, write to the Free Software *
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
26 \*---------------------------------------------------------------------------*/
27 /*---------------------------------------------------------------------------*\
35 \*---------------------------------------------------------------------------*/
37 //---------------------------------------------------------------------------
39 //---------------------------------------------------------------------------
43 /***************************************************************************\
45 \***************************************************************************/
47 /*-------------------------------------------------------------------------*\
49 \*-------------------------------------------------------------------------*/
52 void Geometry::invalidateDlistCache(void)
54 Window::refreshGLObject( getClassicGLId() );
55 Window::refreshGLObject( getAttGLId() );
59 Int32 Geometry::getClassicGLId(void) const
61 return Inherited::getClassicGLId();
65 Int32 Geometry::getAttGLId(void) const
67 return Inherited::getAttGLId();
71 /*------------------------------ access -----------------------------------*/
73 //--------------------------
75 //--------------------------
78 GeoIntegralProperty *Geometry::getTypes(void) const
80 return _sfTypes.getValue();
84 GeoIntegralProperty *Geometry::getLengths(void) const
86 return _sfLengths.getValue();
90 GeoVectorProperty *Geometry::getPositions(void) const
92 return getProperty(PositionsIndex);
96 GeoVectorProperty *Geometry::getNormals(void) const
98 return getProperty(NormalsIndex);
102 GeoVectorProperty *Geometry::getColors(void) const
104 return getProperty(ColorsIndex);
108 GeoVectorProperty *Geometry::getSecondaryColors(void) const
110 return getProperty(SecondaryColorsIndex);
114 GeoVectorProperty *Geometry::getTexCoords(void) const
116 return getProperty(TexCoordsIndex);
120 GeoVectorProperty *Geometry::getTexCoords1(void) const
122 return getProperty(TexCoords1Index);
126 GeoVectorProperty *Geometry::getTexCoords2(void) const
128 return getProperty(TexCoords2Index);
132 GeoVectorProperty *Geometry::getTexCoords3(void) const
134 return getProperty(TexCoords3Index);
138 GeoVectorProperty *Geometry::getTexCoords4(void) const
140 return getProperty(TexCoords4Index);
144 GeoVectorProperty *Geometry::getTexCoords5(void) const
146 return getProperty(TexCoords5Index);
150 GeoVectorProperty *Geometry::getTexCoords6(void) const
152 return getProperty(TexCoords6Index);
156 GeoVectorProperty *Geometry::getTexCoords7(void) const
158 return getProperty(TexCoords7Index);
164 void Geometry::setPositions(GeoVectorProperty * const value)
166 setProperty(value, PositionsIndex);
170 void Geometry::setNormals(GeoVectorProperty * const value)
172 setProperty(value, NormalsIndex);
176 void Geometry::setColors(GeoVectorProperty * const value)
178 setProperty(value, ColorsIndex);
182 void Geometry::setSecondaryColors(GeoVectorProperty * const value)
184 setProperty(value, SecondaryColorsIndex);
188 void Geometry::setTexCoords(GeoVectorProperty * const value)
190 setProperty(value, TexCoordsIndex);
194 void Geometry::setTexCoords1(GeoVectorProperty * const value)
196 setProperty(value, TexCoords1Index);
200 void Geometry::setTexCoords2(GeoVectorProperty * const value)
202 setProperty(value, TexCoords2Index);
206 void Geometry::setTexCoords3(GeoVectorProperty * const value)
208 setProperty(value, TexCoords3Index);
212 void Geometry::setTexCoords4(GeoVectorProperty * const value)
214 setProperty(value, TexCoords4Index);
218 void Geometry::setTexCoords5(GeoVectorProperty * const value)
220 setProperty(value, TexCoords5Index);
224 void Geometry::setTexCoords6(GeoVectorProperty * const value)
226 setProperty(value, TexCoords6Index);
230 void Geometry::setTexCoords7(GeoVectorProperty * const value)
232 setProperty(value, TexCoords7Index);
236 /*! Set the vertex properties at index.
237 * \param value The vertex attribute buffer to assign to index.
238 * \param index The index of the OpenGL vertex attribute to set.
241 void Geometry::setProperty(GeoVectorProperty * const value, UInt16 index)
243 editMField(PropertiesFieldMask, _mfProperties);
245 while(_mfProperties.size() <= index)
247 _mfProperties.push_back(NULL);
251 0x0000 != (value->getUsage() & GeoProperty::UsageSystemSet))
256 value->setUsage(GeoProperty::UsageObjectSpace |
257 GeoProperty::UsageSystemSet );
261 value->setUsage(GeoProperty::UsageTangentSpace |
262 GeoProperty::UsageSystemSet );
266 case SecondaryColorsIndex:
267 value->setUsage(GeoProperty::UsageColorSpace |
268 GeoProperty::UsageSystemSet );
272 case TexCoords1Index:
273 case TexCoords2Index:
274 case TexCoords3Index:
275 case TexCoords4Index:
276 case TexCoords5Index:
277 case TexCoords6Index:
278 case TexCoords7Index:
279 value->setUsage(GeoProperty::UsageParameterSpace |
280 GeoProperty::UsageSystemSet );
284 value->setUsage(GeoProperty::UsageUnspecified |
285 GeoProperty::UsageSystemSet );
289 _mfProperties.replace(index, value);
292 /*! Return the vertext property data stored at index. */
294 GeoVectorProperty *Geometry::getProperty(UInt16 index) const
296 if(_mfProperties.size() <= index)
299 return _mfProperties[index];
302 /*! Add index array for the vertex data attribute at index.
303 * \param value The list of indices to use.
304 * \param index The index of the vertex attribute data
307 void Geometry::setIndex(GeoIntegralProperty * const value, UInt16 index)
309 editMField(PropIndicesFieldMask, _mfPropIndices);
311 while(_mfPropIndices.size() <= index)
313 _mfPropIndices.push_back(NULL);
316 _mfPropIndices.replace(index, value);
319 /*! Return the list of indices currently being used for the vertex attributes
323 GeoIntegralProperty *Geometry::getIndex(UInt16 index) const
325 if(_mfPropIndices.size() <= index)
328 GeoIntegralProperty *p =
329 dynamic_cast<GeoIntegralProperty *>(_mfPropIndices[index]);
335 void Geometry::setMaterial(Material * const value)
337 Inherited::setMaterial(value);
341 inline Geometry::PumpGroupStorage &Geometry::getPumpGroupStorage(void)
346 /*----------------- Property/Index MField Changes -----------------*/
348 inline void Geometry::resizeProperties(size_t newsize)
350 editMField(PropertiesFieldMask, _mfProperties);
352 _mfProperties.resize(newsize);
355 inline void Geometry::reserveProperties(size_t newsize)
357 editMField(PropertiesFieldMask, _mfProperties);
359 _mfProperties.reserve(newsize);
362 inline void Geometry::resizePropIndices(size_t newsize)
364 editMField(PropIndicesFieldMask, _mfPropIndices);
366 _mfPropIndices.resize(newsize, NULL);
369 inline void Geometry::reservePropIndices(size_t newsize)
371 editMField(PropIndicesFieldMask, _mfPropIndices);
373 _mfPropIndices.resize(newsize);
376 /*---------------- Backwards Compatibility Helpers ----------------*/
378 /*! Set all indices to the same value for all vertex attributes.
380 inline void Geometry::setIndices(GeoIntegralProperty * const value)
382 for(UInt16 i = 0; i < MaxAttribs; ++i)
386 /*! Return the indices of the first set of vertex attributes.
387 * Use in combination with setIndices.
389 inline GeoIntegralProperty *Geometry::getIndices(void)
395 UInt32 Geometry::getFuncIdDrawElementsInstanced(void)
397 return FuncIdDrawElementsInstanced;
401 UInt32 Geometry::getFuncIdDrawArraysInstanced(void)
403 return FuncIdDrawArraysInstanced;