#include <OSGGeoBuilder.h>
Public Member Functions | |
Con/Destructors | |
| GeoBuilder (void) | |
| ~GeoBuilder () | |
| void | reset (void) |
Property Access | |
| template<class Type> | |
| UInt32 | vertex (Type data) |
| template<class Type> | |
| void | normal (Type data) |
| template<class Type> | |
| void | color (Type data) |
| template<class Type> | |
| void | texcoord (UInt16 unit, Type data) |
| template<class Type> | |
| UInt32 | prop (UInt16 index, Type data) |
| template<class VType, class NType> | |
| UInt32 | fullVertex (VType vert, NType norm) |
| template<class VType, class NType, class CType> | |
| UInt32 | fullVertex (VType vert, NType norm, CType col) |
| template<class VType, class NType, class CType, class TType> | |
| UInt32 | fullVertex (VType vert, NType norm, CType col, TType tc) |
Face Creation | |
| void | begin (UInt32 type) |
| void | index (UInt32 index) |
| void | end (void) |
| void | line (UInt32 start) |
| void | line (UInt32 i1, UInt32 i2) |
| void | tri (UInt32 start) |
| void | tri (UInt32 i1, UInt32 i2, UInt32 i3) |
| void | quad (UInt32 start) |
| void | quad (UInt32 i1, UInt32 i2, UInt32 i3, UInt32 i4) |
Object Access | |
| GeometryPtr | getGeometry (void) |
Protected Member Functions | |
Property Helper | |
| GeoVectorPropertyPtr | getProperty (UInt32 index) |
| UInt32 | finishVertex (void) |
| void | addType (Int32 type) |
| void | addLength (UInt32 length) |
Private Attributes | |
| GeometryPtr | _geo |
| UInt32 | _actLen |
| Int32 | _actType |
Static Private Attributes | |
| static char * | _defaultPropTypes [Geometry::MaxAttribs] |
Definition at line 53 of file OSGGeoBuilder.h.
| GeoBuilder::GeoBuilder | ( | void | ) |
| GeoBuilder::~GeoBuilder | ( | ) |
| void GeoBuilder::reset | ( | void | ) |
Definition at line 100 of file OSGGeoBuilder.cpp.
References _actLen, _actType, _geo, OSG::addRef(), OSG::GeometryBase::create(), OSG::getDefaultMaterial(), NullFC, and OSG::subRef().
Referenced by GeoBuilder().
00101 { 00102 if(_geo != NullFC) 00103 subRef(_geo); 00104 00105 _geo = Geometry::create(); 00106 addRef(_geo); 00107 00108 MaterialPtr mat = getDefaultMaterial(); 00109 00110 _geo->setMaterial(mat); 00111 00112 _actLen = 0; 00113 _actType = -1; 00114 }
| UInt32 OSG::GeoBuilder::vertex | ( | Type | data | ) | [inline] |
Definition at line 73 of file OSGGeoBuilder.h.
00074 { 00075 getProperty(Geometry::PositionsIndex)->addValue(data); 00076 00077 return finishVertex(); 00078 }
| void OSG::GeoBuilder::normal | ( | Type | data | ) | [inline] |
Definition at line 81 of file OSGGeoBuilder.h.
00082 { 00083 getProperty(Geometry::NormalsIndex)->addValue(data); 00084 }
| void OSG::GeoBuilder::color | ( | Type | data | ) | [inline] |
Definition at line 87 of file OSGGeoBuilder.h.
00088 { 00089 getProperty(Geometry::ColorsIndex)->addValue(data); 00090 }
| void OSG::GeoBuilder::texcoord | ( | UInt16 | unit, | |
| Type | data | |||
| ) | [inline] |
Definition at line 93 of file OSGGeoBuilder.h.
00094 { 00095 getProperty(Geometry::TexCoordsIndex + unit)->addValue(data); 00096 }
| UInt32 OSG::GeoBuilder::prop | ( | UInt16 | index, | |
| Type | data | |||
| ) | [inline] |
Definition at line 99 of file OSGGeoBuilder.h.
00100 { 00101 getProperty(index)->addValue(data); 00102 00103 if(index == 0) 00104 return finishVertex(); 00105 else 00106 return 0; 00107 }
| UInt32 OSG::GeoBuilder::fullVertex | ( | VType | vert, | |
| NType | norm | |||
| ) | [inline] |
| UInt32 OSG::GeoBuilder::fullVertex | ( | VType | vert, | |
| NType | norm, | |||
| CType | col | |||
| ) | [inline] |
| UInt32 OSG::GeoBuilder::fullVertex | ( | VType | vert, | |
| NType | norm, | |||
| CType | col, | |||
| TType | tc | |||
| ) | [inline] |
| void GeoBuilder::begin | ( | UInt32 | type | ) |
| void GeoBuilder::index | ( | UInt32 | index | ) |
Definition at line 192 of file OSGGeoBuilder.cpp.
References _actType, _geo, FWARNING, and NullFC.
Referenced by finishVertex(), line(), quad(), and tri().
00193 { 00194 if(_actType == -1) 00195 { 00196 FWARNING(("GeoBuilder::index: called outside begin/end block!\n")); 00197 return; 00198 } 00199 00200 if(_geo->getIndices() == NullFC) 00201 { 00202 GeoIntegralPropertyPtr i = GeoUInt32Property::create(); 00203 _geo->setIndices(i); 00204 } 00205 00206 _geo->getIndices()->push_back(index); 00207 }
| void GeoBuilder::end | ( | void | ) |
| void GeoBuilder::line | ( | UInt32 | start | ) |
| void GeoBuilder::line | ( | UInt32 | i1, | |
| UInt32 | i2 | |||
| ) |
| void GeoBuilder::tri | ( | UInt32 | start | ) |
| void GeoBuilder::tri | ( | UInt32 | i1, | |
| UInt32 | i2, | |||
| UInt32 | i3 | |||
| ) |
| void GeoBuilder::quad | ( | UInt32 | start | ) |
| void GeoBuilder::quad | ( | UInt32 | i1, | |
| UInt32 | i2, | |||
| UInt32 | i3, | |||
| UInt32 | i4 | |||
| ) |
| GeometryPtr GeoBuilder::getGeometry | ( | void | ) |
Definition at line 307 of file OSGGeoBuilder.cpp.
References _geo.
00308 { 00309 return _geo; 00310 }
| GeoVectorPropertyPtr GeoBuilder::getProperty | ( | UInt32 | index | ) | [protected] |
Definition at line 117 of file OSGGeoBuilder.cpp.
References _defaultPropTypes, _geo, NullFC, and OSG::SingletonHolder< SingletonT >::the().
00118 { 00119 GeoVectorPropertyPtr att; 00120 00121 if(index >= _geo->getProperties().size() || 00122 _geo->getProperty(index) == NullFC) 00123 { 00124 att = dynamic_cast<GeoVectorPropertyPtr>( 00125 FieldContainerFactory::the()->createContainer( 00126 _defaultPropTypes[index])); 00127 00128 _geo->setProperty(att, index); 00129 } 00130 else 00131 { 00132 att = _geo->getProperty(index); 00133 } 00134 00135 return att; 00136 }
| UInt32 GeoBuilder::finishVertex | ( | void | ) | [protected] |
Definition at line 140 of file OSGGeoBuilder.cpp.
References _actLen, _actType, _geo, index(), NullFC, and OSG::Geometry::PositionsIndex.
00141 { 00142 UInt32 possize = _geo->getProperty(Geometry::PositionsIndex)->size(); 00143 00144 for(UInt16 i = 1; i < _geo->getProperties().size(); ++i) 00145 { 00146 if(_geo->getProperty(i) != NullFC) 00147 { 00148 GeoVectorProperty::MaxTypeT val; 00149 00150 _geo->getProperty(i)->getValue(val, 00151 _geo->getProperty(i)->size() - 1); 00152 00153 for(UInt32 propsize = _geo->getProperty(i)->size(); 00154 propsize < possize; 00155 ++propsize) 00156 { 00157 _geo->getProperty(i)->addValue(val); 00158 } 00159 } 00160 } 00161 00162 // Are we in a begin/end loop? Then add current vertex to index 00163 if(_actType != -1) 00164 index(possize - 1); 00165 00166 _actLen++; 00167 return possize - 1; 00168 }
| void GeoBuilder::addType | ( | Int32 | type | ) | [protected] |
| void GeoBuilder::addLength | ( | UInt32 | length | ) | [protected] |
GeometryPtr OSG::GeoBuilder::_geo [private] |
Definition at line 178 of file OSGGeoBuilder.h.
Referenced by addLength(), addType(), finishVertex(), getGeometry(), getProperty(), index(), reset(), and ~GeoBuilder().
UInt32 OSG::GeoBuilder::_actLen [private] |
Definition at line 180 of file OSGGeoBuilder.h.
Referenced by begin(), end(), finishVertex(), line(), quad(), reset(), and tri().
Int32 OSG::GeoBuilder::_actType [private] |
Definition at line 181 of file OSGGeoBuilder.h.
Referenced by begin(), end(), finishVertex(), index(), and reset().
char * GeoBuilder::_defaultPropTypes [static, private] |
Initial value:
{
"GeoPnt3fProperty",
"GeoVec3fProperty",
"GeoVec3fProperty",
"GeoColor4fProperty",
"GeoColor4fProperty",
"GeoVec3fProperty",
"GeoVec3fProperty",
"GeoVec3fProperty",
"GeoVec2fProperty",
"GeoVec2fProperty",
"GeoVec2fProperty",
"GeoVec2fProperty",
"GeoVec2fProperty",
"GeoVec2fProperty",
"GeoVec2fProperty",
"GeoVec2fProperty",
}
Definition at line 183 of file OSGGeoBuilder.h.
Referenced by getProperty().