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 #ifndef _OSGGEOBUILDER_H_
40 #define _OSGGEOBUILDER_H_
45 #include "OSGGeoProperties.h"
46 #include "OSGGeometry.h"
50 /*! \brief A helper class to simplify building geometry.
51 \ingroup GrpDrawablesGeometryUtils
55 class OSG_DRAWABLE_DLLMAPPING GeoBuilder
57 /*========================== PUBLIC =================================*/
59 /*---------------------------------------------------------------------*/
60 /*! \name Con/Destructors */
70 /*---------------------------------------------------------------------*/
71 /*! \name Property Access */
75 UInt32
vertex(Type data
)
77 getProperty(Geometry::PositionsIndex
)->addValue(data
);
79 return finishVertex();
83 void normal(Type data
)
85 getProperty(Geometry::NormalsIndex
)->addValue(data
);
91 getProperty(Geometry::ColorsIndex
)->addValue(data
);
95 void texcoord(UInt16 unit
, Type data
)
97 getProperty(Geometry::TexCoordsIndex
+ unit
)->addValue(data
);
100 template <class Type
>
101 UInt32
prop(UInt16 propIndex
, Type data
)
103 getProperty(propIndex
)->addValue(data
);
106 return finishVertex();
111 template <class VType
, class NType
>
112 UInt32
fullVertex(VType vert
, NType norm
)
118 template <class VType
, class NType
, class CType
>
119 UInt32
fullVertex(VType vert
, NType norm
, CType col
)
126 template <class VType
, class NType
, class CType
, class TType
>
127 UInt32
fullVertex(VType vert
, NType norm
, CType col
, TType tc
)
136 /*---------------------------------------------------------------------*/
137 /*! \name Face Creation */
140 void begin(UInt32 type
);
142 void index(UInt32 newIndex
);
146 void line(UInt32 start
);
147 void line(UInt32 i1
, UInt32 i2
);
149 void tri(UInt32 start
);
150 void tri(UInt32 i1
, UInt32 i2
, UInt32 i3
);
152 void quad(UInt32 start
);
153 void quad(UInt32 i1
, UInt32 i2
, UInt32 i3
, UInt32 i4
);
156 /*---------------------------------------------------------------------*/
157 /*! \name Object Access */
160 Geometry
*getGeometry(void);
163 /*========================= PROTECTED ===============================*/
165 /*---------------------------------------------------------------------*/
166 /*! \name Property Helper */
169 GeoVectorProperty
*getProperty(UInt32 index
);
171 UInt32
finishVertex(void);
173 void addType(Int32 type
);
174 void addLength(UInt32 length
);
177 /*========================== PRIVATE ================================*/
180 GeometryUnrecPtr _geo
;
185 static const char* _defaultPropTypes
[Geometry::MaxAttribs
];
190 #include "OSGGeoBuilder.inl"
192 #endif /* _OSGGEOBUILDER_H_ */