Changeset 334

Show
Ignore:
Timestamp:
10/21/06 07:49:49 (2 years ago)
Author:
cneumann
Message:

changed: whitespace/formatting cleanup, a bit more documentation

moved teapot helper functions/data to anonymous namespace

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Source/System/NodeCores/Drawables/Geometry/Util/OSGSimpleGeometry.cpp

    r218 r334  
    6666// The Simple Geometry creation functions 
    6767 
    68 /*! \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
    69     makePlane creates a plane in the x/y plane. It spans the [-\a xsize /2,\a 
    70     xsize /2]x [-\a ysize /2,\a ysize/2] area and is subdivided into \a hor *  
     68/*! Creates a plane in the x/y plane. It spans the [-\a xsize /2,\a 
     69    xsize /2] x [-\a ysize /2,\a ysize/2] area and is subdivided into \a hor * 
    7170    \a vert quads. 
    72 */ 
    73  
     71 
     72    \param[in] xsize Length of plane edge in x direction. 
     73    \param[in] ysize Length of plane edge in y direction. 
     74    \param[in] hor Number of quads in x direction. 
     75    \param[in] vert Number of quads in y direction. 
     76    \return NodePtr to a newly created Node with a Geometry core. 
     77 
     78    \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
     79 */ 
    7480NodePtr makePlane(Real32 xsize, Real32 ysize, UInt16 hor, UInt16 vert) 
    7581{ 
    7682    GeometryPtr pGeo = makePlaneGeo(xsize, ysize, hor, vert); 
    77   
     83 
    7884    if(pGeo == NullFC) 
    7985    { 
    8086        return NullFC; 
    8187    } 
    82      
     88 
    8389    NodePtr node = Node::create(); 
    8490 
     
    8894} 
    8995 
    90 /*! \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
    91     Create the Geometry Core for used by OSG::makePlane.  
    92 */ 
    93  
    94 GeometryPtr makePlaneGeo(Real32 xsize, Real32 ysize,  
     96/*! Create the Geometry core used by OSG::makePlane. 
     97 
     98    \param[in] xsize Length of plane edge in x direction. 
     99    \param[in] ysize Length of plane edge in y direction. 
     100    \param[in] hor Number of quads in x direction. 
     101    \param[in] vert Number of quads in y direction. 
     102    \return GeometryPtr to a newly created Geometry core. 
     103 
     104    \sa OSG::makePlane 
     105 
     106    \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
     107 */ 
     108GeometryPtr makePlaneGeo(Real32 xsize, Real32 ysize, 
    95109                         UInt16 hor,   UInt16 vert) 
    96110{ 
     
    101115        return NullFC; 
    102116    } 
    103      
     117 
    104118    GeoPnt3fPropertyPtr  pnts  = GeoPnt3fProperty ::create(); 
    105119    GeoVec3fPropertyPtr  norms = GeoVec3fProperty ::create(); 
    106120    GeoVec2fPropertyPtr  tex   = GeoVec2fProperty ::create(); 
    107     GeoUInt32PropertyPtr index = GeoUInt32Property::create();    
    108     GeoUInt32PropertyPtr lens  = GeoUInt32Property::create();   
    109     GeoUInt8PropertyPtr  types = GeoUInt8Property ::create();      
    110      
     121    GeoUInt32PropertyPtr index = GeoUInt32Property::create(); 
     122    GeoUInt32PropertyPtr lens  = GeoUInt32Property::create(); 
     123    GeoUInt8PropertyPtr  types = GeoUInt8Property ::create(); 
     124 
    111125    UInt16 x,y; 
    112126    Real32 xstep,ystep; 
     
    120134    GeoVec2fProperty::StoredFieldType *tx = tex ->editFieldPtr(); 
    121135 
    122      
    123136    for(y = 0; y <= vert; y++) 
    124137    { 
     
    132145 
    133146    // create the faces 
    134      
     147 
    135148    GeoUInt32Property::StoredFieldType *i = index->editFieldPtr(); 
    136149    GeoUInt32Property::StoredFieldType *l = lens ->editFieldPtr(); 
     
    141154        t->push_back(GL_TRIANGLE_STRIP); 
    142155        l->push_back(2 * (hor + 1)); 
    143          
     156 
    144157        for(x = 0; x <= hor; x++) 
    145158        { 
     
    149162    } 
    150163 
    151     
    152164    // create the geometry 
    153      
     165 
    154166    GeometryPtr geo = Geometry::create(); 
    155167 
     
    161173    geo->setTypes(types); 
    162174    geo->setLengths(lens); 
    163      
     175 
    164176    return geo; 
    165177} 
    166178 
    167 /*! \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
    168     makeCone creates a cone. It's center sits in the origin of the x/z plane.  
    169     It's radius is \a radius and the base is subdivided into \a sides parts. 
     179/*! Creates a cone. It's center is in the origin and the bottom is parallel to 
     180    the x/y plane. 
     181    It's radius is \a botradius and the base is subdivided into \a sides parts. 
    170182 
    171183    Each part of the cone (bottom cap, sides) can be enabled or disabled. 
    172184 
     185    \param[in] height Height of the cone. 
     186    \param[in] botradius Radius if the bottom. 
     187    \param[in] sides Number of sides the base is subdivided into. 
     188    \param[in] doSide If true side faces are created. 
     189    \param[in] doBttom If true bottom faces are created. 
     190    \return NodePtr to a newly created Node with a Geometry core. 
     191 
     192    \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
    173193*/ 
    174  
    175 NodePtr makeCone(Real32 height,  
    176                  Real32 botradius,  
    177                  UInt16 sides,  
    178                  bool   doSide,  
     194NodePtr makeCone(Real32 height, 
     195                 Real32 botradius, 
     196                 UInt16 sides, 
     197                 bool   doSide, 
    179198                 bool   doBottom) 
    180199{ 
    181     return makeConicalFrustum(height,  
    182                               0,  
    183                               botradius,  
    184                               sides,  
    185                               doSide,  
    186                               false,  
     200    return makeConicalFrustum(height, 
     201                              0, 
     202                              botradius, 
     203                              sides, 
     204                              doSide, 
     205                              false, 
    187206                              doBottom); 
    188207} 
    189208 
    190 /*! \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
    191     Create the Geometry Core for used by OSG::makeCone.  
     209/*! Create the Geometry Core used by OSG::makeCone. 
     210 
     211    \param[in] height Height of the cone. 
     212    \param[in] botradius Radius if the bottom. 
     213    \param[in] sides Number of sides the base is subdivided into. 
     214    \param[in] doSide If true side faces are created. 
     215    \param[in] doBttom If true bottom faces are created. 
     216    \return GeometryPtr to a newly created Geometry core. 
     217 
     218    \sa OSG::makeCone 
     219 
     220    \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
    192221*/ 
    193  
    194 GeometryPtr makeConeGeo(Real32 height,  
    195                         Real32 botradius,  
    196                         UInt16 sides,  
    197                         bool   doSide,  
     222GeometryPtr makeConeGeo(Real32 height, 
     223                        Real32 botradius, 
     224                        UInt16 sides, 
     225                        bool   doSide, 
    198226                        bool   doBottom) 
    199227{ 
    200     return makeConicalFrustumGeo(height,  
    201                                  0,  
    202                                  botradius,  
    203                                  sides,  
    204                                  doSide,  
    205                                  false,  
     228    return makeConicalFrustumGeo(height, 
     229                                 0, 
     230                                 botradius, 
     231                                 sides, 
     232                                 doSide, 
     233                                 false, 
    206234                                 doBottom); 
    207235} 
    208236 
    209 /*! \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
    210     makeCylinder creates a cylinder. It's center sits in the origin of the  
    211     x/z plane. It's radius is \a radius and the base is subdivided into \a 
    212     sides parts. 
     237/*! Creates a cylinder. It's center is in the origin with top and bottom 
     238    parallel to the x/y plane. It's radius is \a radius and the base is 
     239    subdivided into \a sides parts. 
    213240 
    214241    Each part of the cylinder (top cap, bottom cap, sides) can be enabled or 
    215242    disabled. 
    216243 
     244    \param[in] height Height of the cylinder. 
     245    \param[in] radius Radius of the cylinder. 
     246    \param[in] sides Number of sides the base is subdivided into. 
     247    \param[in] doSide If true, side faces are created. 
     248    \param[in] doTop If true, top cap faces are created. 
     249    \param[in] doBttom If true, bottom cap faces are created. 
     250    \return NodePtr to a newly created Node with a Geometry core. 
     251 
     252    \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
    217253*/ 
    218  
    219 NodePtr makeCylinder(Real32 height,  
     254NodePtr makeCylinder(Real32 height, 
    220255                     Real32 radius, 
    221                      UInt16 sides,  
    222                      bool   doSide,  
    223                      bool   doTop,  
     256                     UInt16 sides, 
     257                     bool   doSide, 
     258                     bool   doTop, 
    224259                     bool   doBottom) 
    225260{ 
    226     return makeConicalFrustum(height,  
    227                               radius,  
    228                               radius,  
    229                               sides,  
    230                               doSide,  
    231                               doTop,  
     261    return makeConicalFrustum(height, 
     262                              radius, 
     263                              radius, 
     264                              sides, 
     265                              doSide, 
     266                              doTop, 
    232267                              doBottom); 
    233268} 
    234269 
    235 /*! \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
    236     Create the Geometry Core for used by OSG::makeCylinder.  
     270/*! Create the Geometry Core used by OSG::makeCylinder. 
     271 
     272    \param[in] height Height of the cylinder. 
     273    \param[in] radius Radius of the cylinder. 
     274    \param[in] sides Number of sides the base is subdivided into. 
     275    \param[in] doSide If true, side faces are created. 
     276    \param[in] doTop If true, top cap faces are created. 
     277    \param[in] doBttom If true, bottom cap faces are created. 
     278    \return GeometryPtr to a newly created Geometry core. 
     279 
     280    \sa OSG::makeCylinder 
     281 
     282    \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
    237283*/ 
    238  
    239 GeometryPtr makeCylinderGeo(Real32 height,  
     284GeometryPtr makeCylinderGeo(Real32 height, 
    240285                            Real32 radius, 
    241                             UInt16 sides,  
    242                             bool   doSide,  
    243                             bool   doTop,  
     286                            UInt16 sides, 
     287                            bool   doSide, 
     288                            bool   doTop, 
    244289                            bool   doBottom) 
    245290{ 
    246     return makeConicalFrustumGeo(height,  
    247                                  radius,  
    248                                  radius,  
    249                                  sides,  
    250                                  doSide,  
    251                                  doTop,  
     291    return makeConicalFrustumGeo(height, 
     292                                 radius, 
     293                                 radius, 
     294                                 sides, 
     295                                 doSide, 
     296                                 doTop, 
    252297                                 doBottom); 
    253298} 
    254299 
    255300 
    256 /*! \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
    257     makeConicalFrustum creates a conical frustum. It's center sits in the 
    258     origin of the x/z plane.  It's height is \a height and the base is 
    259     subdivided into \a sides parts. The top radius is \a topradius, the bottom 
    260     radius \a botradius. 
     301/*! Creates a conical frustum. It's center is in the origin with top and bottom 
     302    parallel to the x/y plane. The height is \a height and the base is 
     303    subdivided into \a sides parts. The top radius is \a topradius, while the 
     304    bottom radius is \a botradius. 
    261305 
    262306    Each part of the frustum (top cap, bottom cap, sides) can be enabled or 
    263     disabled. Caps forradius 0 are automatically disabled. 
    264  
    265 */ 
    266  
    267 NodePtr makeConicalFrustum(Real32 height,  
    268                            Real32 topradius,  
    269                            Real32 botradius,  
    270                            UInt16 sides,  
    271                            bool   doSide,  
    272                            bool   doTop,  
     307    disabled. Caps for radii 0 are automatically disabled. 
     308 
     309    \param[in] height Height of the conical frustum. 
     310    \param[in] topradius Radius at the top of the conical frustum. 
     311    \param[in] botradius Radius at the bottom of the conical frustum. 
     312    \param[in] sides Number of sides the base is subdivided into. 
     313    \param[in] doSide If true, side faces are created. 
     314    \param[in] doTop If true, top cap faces are created. 
     315    \param[in] doBttom If true, bottom cap faces are created. 
     316    \return NodePtr to a newly created Node with a Geometry core. 
     317 
     318    \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
     319 */ 
     320NodePtr makeConicalFrustum(Real32 height, 
     321                           Real32 topradius, 
     322                           Real32 botradius, 
     323                           UInt16 sides, 
     324                           bool   doSide, 
     325                           bool   doTop, 
    273326                           bool   doBottom) 
    274327{ 
    275     GeometryPtr pGeo = makeConicalFrustumGeo(height,  
    276                                              topradius,  
     328    GeometryPtr pGeo = makeConicalFrustumGeo(height, 
     329                                             topradius, 
    277330                                             botradius, 
    278                                              sides,  
    279                                              doSide,  
    280                                              doTop,  
     331                                             sides, 
     332                                             doSide, 
     333                                             doTop, 
    281334                                             doBottom); 
    282335 
     
    285338        return NullFC; 
    286339    } 
    287      
     340 
    288341    NodePtr node = Node::create(); 
    289342 
     
    293346} 
    294347 
    295 /*! \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
    296     Create the Geometry Core for used by OSG::makeConicalFrustum.  
    297 */ 
    298  
    299 GeometryPtr makeConicalFrustumGeo(Real32 height,  
    300                                   Real32 topradius,  
    301                                   Real32 botradius,  
    302                                   UInt16 sides,  
    303                                   bool   doSide,  
    304                                   bool   doTop,  
     348/*! Create the Geometry Core used by OSG::makeConicalFrustum. 
     349 
     350    \param[in] height Height of the conical frustum. 
     351    \param[in] topradius Radius at the top of the conical frustum. 
     352    \param[in] botradius Radius at the bottom of the conical frustum. 
     353    \param[in] sides Number of sides the base is subdivided into. 
     354    \param[in] doSide If true, side faces are created. 
     355    \param[in] doTop If true, top cap faces are created. 
     356    \param[in] doBttom If true, bottom cap faces are created. 
     357    \return GeometryPtr to a newly created Geometry core. 
     358 
     359    \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
     360 */ 
     361GeometryPtr makeConicalFrustumGeo(Real32 height, 
     362                                  Real32 topradius, 
     363                                  Real32 botradius, 
     364                                  UInt16 sides, 
     365                                  bool   doSide, 
     366                                  bool   doTop, 
    305367                                  bool   doBottom) 
    306368{ 
    307369    if(height <= 0 || topradius < 0 || botradius < 0 || sides < 3) 
    308370    { 
    309         SWARNING << "makeConicalFrustum: illegal parameters height=" << height  
    310                  << ", topradius=" << topradius  
    311                  << ", botradius=" << botradius  
    312                  << ", sides=" << sides  
     371        SWARNING << "makeConicalFrustum: illegal parameters height=" << height 
     372                 << ", topradius=" << topradius 
     373                 << ", botradius=" << botradius 
     374                 << ", sides=" << sides 
    313375                 << std::endl; 
    314376        return NullFC; 
    315377    } 
    316      
     378 
    317379    GeoPnt3fPropertyPtr  pnts  = GeoPnt3fProperty ::create(); 
    318380    GeoVec3fPropertyPtr  norms = GeoVec3fProperty ::create(); 
    319381    GeoVec2fPropertyPtr  tex   = GeoVec2fProperty ::create(); 
    320     GeoUInt32PropertyPtr index = GeoUInt32Property::create();    
    321     GeoUInt32PropertyPtr lens  = GeoUInt32Property::create();   
    322     GeoUInt8PropertyPtr  types = GeoUInt8Property ::create();      
    323      
     382    GeoUInt32PropertyPtr index = GeoUInt32Property::create(); 
     383    GeoUInt32PropertyPtr lens  = GeoUInt32Property::create(); 
     384    GeoUInt8PropertyPtr  types = GeoUInt8Property ::create(); 
     385 
    324386    Int16  j; 
    325387    Real32 delta = 2.f * Pi / sides; 
     
    327389    Real32 incl = (botradius - topradius) / height; 
    328390    Real32 nlen = 1.f / osgSqrt(1 + incl * incl); 
    329      
     391 
    330392    // vertices 
    331393 
     
    335397 
    336398    // faces 
    337      
     399 
    338400    GeoUInt32Property::StoredFieldType *i  = index->editFieldPtr(); 
    339401    GeoUInt32Property::StoredFieldType *l  = lens ->editFieldPtr(); 
    340402    GeoUInt8Property::StoredFieldType  *t  = types->editFieldPtr(); 
    341403 
    342     //  
    343      
    344404    if(doSide) 
    345405    { 
    346406        UInt32 baseindex = p->size(); 
    347          
     407 
    348408        for(j = 0; j <= sides; j++) 
    349409        { 
    350410            beta = j * delta; 
    351411            x    =  osgSin(beta); 
    352             z    = -osgCos(beta);          
     412            z    = -osgCos(beta); 
    353413 
    354414            p->push_back(Pnt3f(x * topradius, height/2, z * topradius)); 
     
    356416            tx->push_back(Vec2f(1.f - j / (Real32) sides, 1)); 
    357417        } 
    358          
     418 
    359419        for(j = 0; j <= sides; j++) 
    360420        { 
    361421            beta = j * delta; 
    362422            x    =  osgSin(beta); 
    363             z    = -osgCos(beta);          
     423            z    = -osgCos(beta); 
    364424 
    365425            p->push_back(Pnt3f(x * botradius, -height/2, z * botradius)); 
     
    371431        l->push_back(2 * (sides + 1)); 
    372432 
    373         for(j = 0; j <= sides; j++)  
     433        for(j = 0; j <= sides; j++) 
    374434        { 
    375435                i->push_back(baseindex + sides + 1 + j); 
     
    377437        } 
    378438    } 
    379      
     439 
    380440    if(doTop && topradius > 0) 
    381441    { 
    382442        UInt32 baseindex = p->size(); 
    383          
     443 
    384444        // need to duplicate the points fornow, as we don't have multi-index geo yet 
    385          
     445 
    386446        for(j = sides - 1; j >= 0; j--) 
    387447        { 
    388448            beta = j * delta; 
    389449            x    =  topradius * osgSin(beta); 
    390             z    = -topradius * osgCos(beta);         
     450            z    = -topradius * osgCos(beta); 
    391451 
    392452            p->push_back(Pnt3f(x, height/2, z)); 
     
    398458        l->push_back(sides); 
    399459 
    400         for(j = 0; j < sides; j++)  
     460        for(j = 0; j < sides; j++) 
    401461        { 
    402462            i->push_back(baseindex + j); 
    403463        } 
    404464    } 
    405      
     465 
    406466    if(doBottom && botradius > 0 ) 
    407467    { 
    408468        UInt32 baseindex = p->size(); 
    409          
     469 
    410470        // need to duplicate the points fornow, as we don't have multi-index geo yet 
    411          
     471 
    412472        for(j = sides - 1; j >= 0; j--) 
    413473        { 
    414474            beta = j * delta; 
    415475            x    =  botradius * osgSin(beta); 
    416             z    = -botradius * osgCos(beta);       
     476            z    = -botradius * osgCos(beta); 
    417477 
    418478            p->push_back(Pnt3f(x, -height/2, z)); 
     
    424484        l->push_back(sides); 
    425485 
    426         for(j = 0; j < sides; j++)  
     486        for(j = 0; j < sides; j++) 
    427487        { 
    428488            i->push_back(baseindex + sides - 1 - j); 
    429489        } 
    430490    } 
    431      
     491 
    432492    // create the geometry 
    433      
     493 
    434494    GeometryPtr geo = Geometry::create(); 
    435495 
     
    445505} 
    446506 
    447 /*! \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
    448     makeTorus creates a torus in the x/y plane. Sides are the number of 
    449     subdivisions forthe inner radius, rings forthe outer. 
    450  
    451 */ 
    452  
    453 NodePtr makeTorus(Real32 innerRadius, Real32 outerRadius, UInt16 sides,  
     507/*! Creates a torus in the x/y plane. The number of subdivisions for 
     508    the inner radius is \a sides, for the outer radius it is \a rings. 
     509 
     510    \param[in] innerRadius Inner radius of the torus. 
     511    \param[in] outerRadius Outer radius of the torus. 
     512    \param[in] sides Number of subdivisions along the inner radius. 
     513    \param[in] rings Number of subdivisions along the outer radius. 
     514    \return NodePtr to a newly created Node with a Geometry core. 
     515 
     516    \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
     517 */ 
     518NodePtr makeTorus(Real32 innerRadius, Real32 outerRadius, UInt16 sides, 
    454519                  UInt16 rings) 
    455520{ 
    456521    GeometryPtr pGeo = makeTorusGeo(innerRadius, outerRadius, sides, rings); 
    457   
     522 
    458523    if(pGeo == NullFC) 
    459524    { 
    460525        return NullFC; 
    461526    } 
    462      
     527 
    463528    NodePtr node = Node::create(); 
    464529 
     
    468533} 
    469534 
    470 /*! \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
    471     Create the Geometry Core for used by OSG::makeTorus.  
    472 */ 
    473  
    474 GeometryPtr makeTorusGeo(Real32 innerRadius, Real32 outerRadius, UInt16 sides,  
     535/*! Create the Geometry Core used by OSG::makeTorus. 
     536 
     537    \param[in] innerRadius Inner radius of the torus. 
     538    \param[in] outerRadius Outer radius of the torus. 
     539    \param[in] sides Number of subdivisions along the inner radius. 
     540    \param[in] rings Number of subdivisions along the outer radius. 
     541    \return GeometryPtr to a newly created Geometry core. 
     542 
     543    \sa OSG::makeTorus 
     544 
     545    \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
     546 */ 
     547GeometryPtr makeTorusGeo(Real32 innerRadius, Real32 outerRadius, UInt16 sides, 
    475548                         UInt16 rings) 
    476549{ 
    477550    if(innerRadius <= 0 || outerRadius <= 0 || sides < 3 || rings < 3) 
    478551    { 
    479         SWARNING << "makeTorus: illegal parameters innerRadius=" << innerRadius  
    480                  << ", outerRadius=" << outerRadius  
    481                  << ", sides=" << sides  
    482                  << ", rings=" << rings  
     552        SWARNING << "makeTorus: illegal parameters innerRadius=" << innerRadius 
     553                 << ", outerRadius=" << outerRadius 
     554                 << ", sides=" << sides 
     555                 << ", rings=" << rings 
    483556                 << std::endl; 
    484557        return NullFC; 
    485558    } 
    486      
     559 
    487560    GeoPnt3fPropertyPtr  pnts  = GeoPnt3fProperty ::create(); 
    488561    GeoVec3fPropertyPtr  norms = GeoVec3fProperty ::create(); 
    489562    GeoVec2fPropertyPtr  tex   = GeoVec2fProperty ::create(); 
    490     GeoUInt32PropertyPtr index = GeoUInt32Property::create();    
    491     GeoUInt32PropertyPtr lens  = GeoUInt32Property::create();   
    492     GeoUInt8PropertyPtr  types = GeoUInt8Property ::create();      
    493      
     563    GeoUInt32PropertyPtr index = GeoUInt32Property::create(); 
     564    GeoUInt32PropertyPtr lens  = GeoUInt32Property::create(); 
     565    GeoUInt8PropertyPtr  types = GeoUInt8Property ::create(); 
     566 
    494567    UInt16 a, b; 
    495568    Real32 theta, phi; 
     
    506579    sideDelta = 2.f * Pi / sides; 
    507580 
    508     for(a = 0, theta = 0.0; a <= rings; a++, theta += ringDelta)  
     581    for(a = 0, theta = 0.0; a <= rings; a++, theta += ringDelta) 
    509582    { 
    510583        cosTheta = osgCos(theta); 
    511584        sinTheta = osgSin(theta); 
    512585 
    513         for(b = 0, phi = 0; b <= sides; b++, phi += sideDelta)  
     586        for(b = 0, phi = 0; b <= sides; b++, phi += sideDelta) 
    514587        { 
    515588            GLfloat cosPhi, sinPhi, dist; 
     
    519592            dist   = outerRadius + innerRadius * cosPhi; 
    520593 
    521             n->push_back(Vec3f(cosTheta * cosPhi,  
    522                               -sinTheta * cosPhi,  
     594            n->push_back(Vec3f(cosTheta * cosPhi, 
     595                              -sinTheta * cosPhi, 
    523596                              sinPhi)); 
    524             p->push_back(Pnt3f(cosTheta * dist,  
    525                               -sinTheta * dist,  
     597            p->push_back(Pnt3f(cosTheta * dist, 
     598                              -sinTheta * dist, 
    526599                              innerRadius * sinPhi)); 
    527600            tx->push_back(Vec2f(- a / (Real32) rings, b / (Real32)sides)); 
    528601        } 
    529     }    
     602    } 
    530603 
    531604    // create the faces 
    532      
     605 
    533606    GeoUInt32Property::StoredFieldType *i  = index->editFieldPtr(); 
    534607    GeoUInt32Property::StoredFieldType *l  = lens ->editFieldPtr(); 
    535608    GeoUInt8Property::StoredFieldType  *t  = types->editFieldPtr(); 
    536609 
    537     for(a = 0; a < sides; a++)  
     610    for(a = 0; a < sides; a++) 
    538611    { 
    539612        t->push_back(GL_TRIANGLE_STRIP); 
    540613        l->push_back((rings + 1) * 2); 
    541          
     614 
    542615        for(b = 0; b <= rings; b++) 
    543616        { 
     
    548621 
    549622    // create the geometry 
    550      
     623 
    551624    GeometryPtr geo = Geometry::create(); 
    552625 
     
    558631    geo->setTypes(types); 
    559632    geo->setLengths(lens); 
    560      
     633 
    561634    return geo; 
    562635} 
     
    564637#if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV) 
    565638 
    566 Real32 setVecLen(Vec3f &vec, Real32 length)  
     639/*! Scale the vector \a vec to the given \a length. If \a vec is degenerate, 
     640    i.e. has length 0 it is not changed. 
     641 
     642    \param[in,out] vec The vector to scale. 
     643    \param[in] length Length to scale \a vec to. 
     644    \return The \a length argument. 
     645 */ 
     646Real32 setVecLen(Vec3f &vec, Real32 length) 
    567647{ 
    568648    Real32 len = vec.length(); 
    569     if(len == 0.0)  
     649    if(len == 0.0) 
    570650    { 
    571651        len = 1; 
    572     }  
    573     else  
     652    } 
     653    else 
    574654    { 
    575655        len = length / len; 
    576656    } 
    577657    vec *= len; 
    578      
     658 
    579659    return length; 
    580660} 
     
    584664    const Real32 TwoPi  = 6.283185307179586; 
    585665    const Real32 HalfPi = 1.570796326794897; 
    586      
     666 
    587667    Real32 phi = osgATan2(-n[2], n[0]) - HalfPi; 
    588668 
     
    590670        phi += TwoPi; 
    591671    phi /= TwoPi; 
    592      
     672 
    593673    return phi; 
    594674} 
     
    617697} 
    618698 
    619 void subdivideTriangle( UInt32 i1,  
    620                         UInt32 i2,  
     699void subdivideTriangle( UInt32 i1, 
     700                        UInt32 i2, 
    621701                        UInt32 i3, 
    622                         Int32 depth,  
     702                        Int32 depth, 
    623703                        GeoPnt3fProperty::StoredFieldType  *p, 
    624704                        GeoVec3fProperty::StoredFieldType  *n, 
     
    626706                        GeoUInt32Property::StoredFieldType *i, 
    627707                        GeoUInt32Property::StoredFieldType *tci, 
    628                         UInt32& z, Real32 radius )  
    629 {    
    630     if (depth == 0)  
     708                        UInt32& z, Real32 radius ) 
     709{ 
     710    if (depth == 0) 
    631711    { 
    632712        i->push_back(i1); 
     
    636716        i->push_back(i3); 
    637717        tci->push_back(i3); 
    638                              
    639         return;          
     718 
     719        return; 
    640720    } 
    641721 
     
    648728    v23 = v2 + (v3 - v2) * .5f; 
    649729    v31 = v3 + (v1 - v3) * .5f; 
    650      
     730 
    651731    v12 /= 2.0f; 
    652732    v23 /= 2.0f; 
    653733    v31 /= 2.0f; 
    654      
     734 
    655735    UInt32 i12 = z++, i23 = z++, i31 = z++; 
    656736 
     
    658738    addPoint(v23,i23,radius,p,n,tx); 
    659739    addPoint(v31,i31,radius,p,n,tx); 
    660      
     740 
    661741    subdivideTriangle( i1, i12, i31, depth - 1, p,n,tx,i,tci, z, radius); 
    662742    subdivideTriangle( i2, i23, i12, depth - 1, p,n,tx,i,tci, z, radius); 
     
    667747#endif            // exclude from doc 
    668748 
    669 /*! \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
    670     makeSphere creates a sphere centered in the origin. It is created by 
     749/*! Creates a sphere centered in the origin. It is created by 
    671750    recursive subdivision of an icosahedron, with \a depth giving the number 
    672751    of subdivisions and \a radius being the radius. 
    673752 
    674 */ 
    675  
     753    \param[in] depth Number of recursive subdivisions to perform. 
     754    \param[in] radius Radius of sphere. 
     755    \return NodePtr to a newly created Node with a Geometry core. 
     756 
     757    \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
     758 */ 
    676759NodePtr makeSphere(UInt16 depth, Real32 radius) 
    677 {    
     760{ 
    678761    GeometryPtr pGeo = makeSphereGeo(depth, radius); 
    679762 
     
    686769 
    687770    node->setCore(pGeo); 
    688          
     771 
    689772    return node; 
    690773} 
    691774 
    692 /*! \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
    693     Create the Geometry Core for used by OSG::makeSphere.  
    694 */ 
    695  
     775/*! Create the Geometry Core for used by OSG::makeSphere. 
     776 
     777    \param[in] depth Number of recursive subdivisions to perform. 
     778    \param[in] radius Radius of sphere. 
     779    \return GeometryPtr to a newly created Geometry core. 
     780 
     781    \sa OSG::makeSphere 
     782 
     783    \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
     784 */ 
    696785GeometryPtr makeSphereGeo(UInt16 depth, Real32 radius) 
    697786{ 
     
    703792    GeoVec3fPropertyPtr  norms   = GeoVec3fProperty ::create(); 
    704793    GeoVec2fPropertyPtr  tex     = GeoVec2fProperty ::create(); 
    705     GeoUInt32PropertyPtr index   = GeoUInt32Property::create();    
    706     GeoUInt32PropertyPtr tcindex = GeoUInt32Property::create();    
    707     GeoUInt32PropertyPtr lens    = GeoUInt32Property::create();   
    708     GeoUInt8PropertyPtr  types   = GeoUInt8Property ::create();      
     794    GeoUInt32PropertyPtr index   = GeoUInt32Property::create(); 
     795    GeoUInt32PropertyPtr tcindex = GeoUInt32Property::create(); 
     796    GeoUInt32PropertyPtr lens    = GeoUInt32Property::create(); 
     797    GeoUInt8PropertyPtr  types   = GeoUInt8Property ::create(); 
    709798 
    710799    UInt32              j,z; 
    711     
     800 
    712801    static Vec3f v[12] = {  Vec3f(-X, 0.,  Z), 
    713802                            Vec3f( X, 0.,  Z), 
     
    730819    for (j=0; j<12; j++) 
    731820        mat.mult(v[j]); 
    732                  
     821 
    733822    Int32 tr[20][3] = { {1,4,0},  {4,9,0},  {4,5,9},  {8,5,4},  {1,8,4}, 
    734823                        {1,10,8}, {10,3,8}, {8,3,5},  {3,2,5},  {3,7,2}, 
    735824                        {3,10,7}, {10,6,7}, {6,11,7}, {6,0,11}, {6,1,0}, 
    736                         {10,1,6}, {11,0,9}, {2,11,9}, {5,2,9},  {11,2,7} };                   
    737                  
     825                        {10,1,6}, {11,0,9}, {2,11,9}, {5,2,9},  {11,2,7} }; 
     826 
    738827    GeoPnt3fProperty::StoredFieldType  *p  = pnts ->editFieldPtr(); 
    739828    GeoVec3fProperty::StoredFieldType  *n  = norms->editFieldPtr(); 
     
    751840    i->reserve (estimatedSize); 
    752841    tci->reserve (estimatedSize); 
    753     
    754     // add the initial points to the fields      
    755     for (j=0; j<12; j++)  
     842 
     843    // add the initial points to the fields 
     844    for (j=0; j<12; j++) 
    756845    { 
    757846        Vec3f pnt = v[j]; 
    758847        Vec3f norm = v[j]; 
    759          
     848 
    760849        setVecLen(pnt, radius); 
    761850        norm.normalize(); 
    762          
     851 
    763852        p->push_back(pnt.addToZero()); 
    764853        n->push_back(norm); 
     
    774863        tx->push_back(texCoord); 
    775864    } 
    776      
     865 
    777866    // subdivide the triangles 
    778867    z=12; 
    779     for(j=0; j<20; j++)  
    780     { 
    781         subdivideTriangle(tr[j][0], tr[j][1], tr[j][2],  
     868    for(j=0; j<20; j++) 
     869    { 
     870        subdivideTriangle(tr[j][0], tr[j][1], tr[j][2], 
    782871                          depth, p, n, tx, i, tci, z, radius); 
    783872    } 
     
    785874    types->push_back(GL_TRIANGLES); 
    786875    lens->push_back(i->size()); 
    787      
     876 
    788877    // create the geometry 
    789878    GeometryPtr geo = Geometry::create(); 
    790879 
    791     
    792880    geo->setMaterial(getDefaultMaterial()); 
    793881    geo->setPositions(pnts); 
     
    823911                { 
    824912                    Real32 theta = ti.getTexCoords(i).y(); 
    825                     
    826                     if( !(q[0][0] <= -Eps ||  
    827                           q[1][0] <= -Eps ||  
     913 
     914                    if( !(q[0][0] <= -Eps || 
     915                          q[1][0] <= -Eps || 
    828916                          q[2][0] <= -Eps  ) ) 
    829917                    { 
     
    832920                        if(osgAbs(osgAbs(norm[1]) - 1) <= Eps) 
    833921                            texCoord[0] = 0.5; 
    834      
     922 
    835923                        tex->push_back(texCoord); 
    836      
     924 
    837925                        tcindex->setValue( tex->size() - 1, ti.getTexCoordsIndex(i)); 
    838926                    } 
     
    843931                        if (osgAbs(osgAbs(norm[1]) - 1) <= Eps) 
    844932                            texCoord[0] = 0.5; 
    845      
     933 
    846934                        tex->push_back(texCoord); 
    847      
     935 
    848936                        index->setValue( tex->size() - 1, ti.getTexCoordsIndex(i)); 
    849937                    } 
     
    852940        } 
    853941    } 
    854      
     942 
    855943    endEditCP(geo); 
    856944#endif 
     
    859947} 
    860948 
    861 /*! \ingroup GrpSystemDrawablesGeometrySimpleGeometry 
    862     makeLatLongSphere creates a sphere in the origin and divided in latitude 
    863     and longitude. \a radius is the radius of the sphere, \a latres and \a 
    864     longres are the number of subdivisions along the latitudes and longitudes. 
    865  
    866 */ 
    867  
     949/*! Creates a sphere centered in the origin and divided in latitude 
     950    and longitude. \a radius is the radius of the sphere, \a latres and 
     951    \a longres are the number of subdivisions along the latitudes and longitudes. 
     952 
     953    \param[in] latres Number of subdivisions along latitudes. 
     954    \param[in] longres Number of subdivisions along longitudes. 
     955    \param[in] radius Radius of sphere. 
     956    \return NodePtr to a newly created Node with a Geometry core. 
     957