Changeset 337

Show
Ignore:
Timestamp:
10/21/06 13:42:59 (2 years ago)
Author:
dirk
Message:

Added some stuff to GeoBuilder?

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/Dirk_RenderTraversalWork/Source/System/NodeCores/Drawables/Geometry/Base/OSGGeoBuilder.cpp

    r106 r337  
    8686}; 
    8787 
    88 GeoBuilder::GeoBuilder(void) 
    89 : _geo(), 
    90   _actLen(0), 
    91   _actType(-1) 
    92 
     88GeoBuilder::GeoBuilder(void) : 
     89    _geo() 
     90
     91    reset(); 
     92
     93 
     94GeoBuilder::~GeoBuilder() 
     95
     96    if(_geo != NullFC) 
     97        subRef(_geo); 
     98
     99 
     100void GeoBuilder::reset(void) 
     101
     102    if(_geo != NullFC) 
     103        subRef(_geo); 
     104         
    93105    _geo = Geometry::create(); 
     106    addRef(_geo); 
    94107     
    95108    MaterialPtr mat = getDefaultMaterial(); 
    96109 
    97110    _geo->setMaterial(mat); 
     111 
     112    _actLen = 0; 
     113    _actType = -1;  
    98114} 
    99115 
    100116// Property Helper 
    101      
    102117GeoVectorPropertyPtr GeoBuilder::getProperty(UInt32 index) 
    103118{ 
     
    145160    } 
    146161     
    147     // Are we in a begin/end loop? Then add current vertex TO index 
     162    // Are we in a begin/end loop? Then add current vertex to index 
    148163    if(_actType != -1) 
    149164        addIndex(possize - 1); 
     
    203218    _actLen = 0; 
    204219    _actType = -1;    
     220} 
     221 
     222void GeoBuilder::tri(UInt32 start) 
     223{ 
     224    addType(GL_QUADS); 
     225    addLength(3); 
     226 
     227    addIndex(start    ); 
     228    addIndex(start + 1); 
     229    addIndex(start + 2); 
     230} 
     231 
     232void GeoBuilder::tri(UInt32 i1, UInt32 i2, UInt32 i3) 
     233{ 
     234    addType(GL_TRIANGLES); 
     235    addLength(3); 
     236 
     237    addIndex(i1); 
     238    addIndex(i2); 
     239    addIndex(i3); 
    205240} 
    206241 
  • branches/Dirk_RenderTraversalWork/Source/System/NodeCores/Drawables/Geometry/Base/OSGGeoBuilder.h

    r106 r337  
    6161    GeoBuilder(void); 
    6262     
     63    ~GeoBuilder(); 
     64     
     65    void reset(void); 
     66     
    6367    /*! \}                                                                 */ 
    6468    /*---------------------------------------------------------------------*/ 
     
    8690    } 
    8791     
     92    template <class Type> 
     93    void texcoord(UInt16 unit, Type data) 
     94    { 
     95        getProperty(Geometry::TexCoordsIndex + unit)->addValue(data); 
     96    } 
     97     
     98    template <class Type> 
     99    UInt32 prop(UInt16 index, Type data) 
     100    { 
     101        getProperty(index)->addValue(data); 
     102         
     103        if(index == 0) 
     104            return finishVertex(); 
     105        else 
     106            return 0; 
     107    } 
     108     
    88109    template <class VType, class NType> 
    89110    UInt32 fullVertex(VType vert, NType norm) 
     
    101122    } 
    102123     
     124    template <class VType, class NType, class CType, class TType> 
     125    UInt32 fullVertex(VType vert, NType norm, CType col, TType tc) 
     126    { 
     127        color(col); 
     128        normal(norm); 
     129        texcoord(0, tc); 
     130        return vertex(vert); 
     131    } 
     132     
    103133    /*! \}                                                                 */ 
    104134    /*---------------------------------------------------------------------*/ 
     
    109139     
    110140    void end(void); 
     141     
     142    void tri(UInt32 start); 
     143     
     144    void tri(UInt32 i1, UInt32 i2, UInt32 i3); 
    111145     
    112146    void quad(UInt32 start);