Show
Ignore:
Timestamp:
04/16/08 02:25:04 (8 months ago)
Author:
vossg
Message:

changed: merge manipulator changes from carsten
added : *RefPtr? typedef
fixed : use recorded ref counts for global mats

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Source/Contrib/Manipulators/OSGSimpleGeometryExt.cpp

    r837 r1168  
    5656OSG_BEGIN_NAMESPACE 
    5757 
    58 GeometryPtr makeGridGeo(const Real32   width, 
    59                         const Real32   depth, 
    60                         const Real32   hCellWidth, 
    61                         const Color3f &color     ) 
     58GeometryTransitPtr makeGridGeo(const Real32   width, 
     59                               const Real32   depth, 
     60                               const Real32   hCellWidth, 
     61                               const Color3f &color     ) 
    6262{ 
    6363    Int32       nCols, nRows; 
     
    6767        Color3f(color[0] - 0.4, color[1] - 0.4, color[2] - 0.4); 
    6868 
    69     GeometryPtr           geo     = Geometry::create(); 
    70     GeoPnt3fPropertyPtr   pnts    = GeoPnt3fProperty  ::create(); 
    71     GeoUInt32PropertyPtr  lens    = GeoUInt32Property ::create(); 
    72     GeoUInt8PropertyPtr   types   = GeoUInt8Property  ::create(); 
    73     GeoColor3fPropertyPtr colors  = GeoColor3fProperty::create(); 
     69    GeometryTransitPtr           geo     = Geometry::create(); 
     70    GeoPnt3fPropertyUnrecPtr   pnts    = GeoPnt3fProperty  ::create(); 
     71    GeoUInt32PropertyUnrecPtr  lens    = GeoUInt32Property ::create(); 
     72    GeoUInt8PropertyUnrecPtr   types   = GeoUInt8Property  ::create(); 
     73    GeoColor3fPropertyUnrecPtr colors  = GeoColor3fProperty::create(); 
    7474//    GeoIndicesUI32Ptr  indices = GeoIndicesUI32::create(); 
    75     SimpleMaterialPtr  mat     = SimpleMaterial::create(); 
     75    SimpleMaterialUnrecPtr  mat     = SimpleMaterial::create(); 
    7676 
    7777    Real32 height   (0.0        ); 
     
    156156} 
    157157 
    158 GeometryPtr makeGridBorderGeo(const Real32   width, 
    159                               const Real32   depth, 
    160                               const Color3f &color) 
     158GeometryTransitPtr makeGridBorderGeo(const Real32   width, 
     159                                     const Real32   depth, 
     160                                     const Color3f &color) 
    161161{ 
    162162    const Color3f darkerColor = 
    163163        Color3f( color[0]-0.4, color[1]-0.4, color[2]-0.4 ); 
    164164 
    165     GeometryPtr           geo    = Geometry::create(); 
    166     GeoPnt3fPropertyPtr   pnts   = GeoPnt3fProperty::create(); 
    167     GeoUInt32PropertyPtr  lens   = GeoUInt32Property::create(); 
    168     GeoUInt8PropertyPtr   types  = GeoUInt8Property::create(); 
    169     GeoColor3fPropertyPtr colors = GeoColor3fProperty::create(); 
     165    GeometryTransitPtr           geo    = Geometry::create(); 
     166    GeoPnt3fPropertyUnrecPtr   pnts   = GeoPnt3fProperty::create(); 
     167    GeoUInt32PropertyUnrecPtr  lens   = GeoUInt32Property::create(); 
     168    GeoUInt8PropertyUnrecPtr   types  = GeoUInt8Property::create(); 
     169    GeoColor3fPropertyUnrecPtr colors = GeoColor3fProperty::create(); 
    170170//    GeoIndicesUI32Ptr  indices   = GeoIndicesUI32::create(); 
    171     SimpleMaterialPtr  mat       = SimpleMaterial::create(); 
    172     LineChunkPtr       lineChunk = LineChunk::create(); 
     171    SimpleMaterialUnrecPtr  mat       = SimpleMaterial::create(); 
     172    LineChunkUnrecPtr       lineChunk = LineChunk::create(); 
    173173 
    174174    Real32 height   (0.0        ); 
     
    249249 * The grid has the base color <i>color</i>. 
    250250 */ 
    251 NodePtr makeGrid(const Real32   width, 
    252                  const Real32   depth, 
    253                  const Real32   hCellWidth, 
    254                  const Color3f &color     ) 
    255 { 
    256     NodePtr grpNode    = Node::create(); 
    257     GroupPtr grpCore    = Group::create(); 
    258     NodePtr  gridNode   = Node::create(); 
    259     NodePtr  borderNode = Node::create(); 
     251NodeTransitPtr makeGrid(const Real32   width, 
     252                        const Real32   depth, 
     253                        const Real32   hCellWidth, 
     254                        const Color3f &color     ) 
     255{ 
     256    NodeTransitPtr grpNode    = Node::create(); 
     257    GroupUnrecPtr grpCore    = Group::create(); 
     258    NodeUnrecPtr   gridNode   = Node::create(); 
     259    NodeUnrecPtr   borderNode = Node::create(); 
    260260 
    261261    gridNode->setCore  (makeGridGeo(width, depth, hCellWidth, color)); 
     
    272272 
    273273 
    274 NodePtr makeSelection(NodePtr geoN) 
    275 { 
    276     NodePtr               transN = Node::create(); 
    277     NodePtr               node   = Node::create(); 
    278     ComponentTransformPtr transC = ComponentTransform::create(); 
     274NodeTransitPtr makeSelection(NodePtr geoN) 
     275{ 
     276    NodeTransitPtr             transN = Node::create(); 
     277    NodeUnrecPtr               node   = Node::create(); 
     278    ComponentTransformUnrecPtr transC = ComponentTransform::create(); 
    279279 
    280280    node->setCore(makeSelectionGeo(geoN)); 
     
    283283    transN->addChild(node  ); 
    284284 
    285     addRef(transN); 
    286  
    287285    commitChanges(); 
    288286 
     
    290288} 
    291289 
    292 GeometryPtr makeSelectionGeo(NodePtr geoN) 
     290GeometryTransitPtr makeSelectionGeo(NodePtr geoN) 
    293291{ 
    294292    Pnt3f min, max; 
    295293    geoN->getVolume().getBounds(min, max); 
    296294 
    297     GeometryPtr           geo       = Geometry::create(); 
    298     GeoPnt3fPropertyPtr   newPnts   = GeoPnt3fProperty::create(); 
    299     GeoUInt32PropertyPtr  lens      = GeoUInt32Property::create(); 
    300     GeoUInt8PropertyPtr   types     = GeoUInt8Property::create(); 
    301     GeoColor3fPropertyPtr colors    = GeoColor3fProperty::create(); 
     295    GeometryTransitPtr         geo       = Geometry::create(); 
     296    GeoPnt3fPropertyUnrecPtr   newPnts   = GeoPnt3fProperty::create(); 
     297    GeoUInt32PropertyUnrecPtr  lens      = GeoUInt32Property::create(); 
     298    GeoUInt8PropertyUnrecPtr   types     = GeoUInt8Property::create(); 
     299    GeoColor3fPropertyUnrecPtr colors    = GeoColor3fProperty::create(); 
    302300 
    303301//    GeoIndicesUI32Ptr  indices   = GeoIndicesUI32::create(); 
    304     SimpleMaterialPtr  mat       = SimpleMaterial::create(); 
    305  
    306     LineChunkPtr       lineChunk = LineChunk::create(); 
     302    SimpleMaterialUnrecPtr  mat       = SimpleMaterial::create(); 
     303 
     304    LineChunkUnrecPtr       lineChunk = LineChunk::create(); 
    307305 
    308306    GeometryPtr selGeoC = dynamic_cast<GeometryPtr>(geoN->getCore()); 
     
    350348 
    351349 
    352 PolygonChunkPtr _gayaPolygonChunk; 
     350PolygonChunkUnrecPtr _gayaPolygonChunk; 
    353351 
    354352PolygonChunkPtr getPolygonChunk(const UInt16 faces, 
     
    358356    { 
    359357        _gayaPolygonChunk = PolygonChunk::create(); 
    360  
    361         addRef(_gayaPolygonChunk); 
    362358 
    363359        _gayaPolygonChunk->setCullFace(faces); 
     
    374370} 
    375371 
    376 MaterialChunkPtr _gayaMaterialChunk; 
     372MaterialChunkRecPtr _gayaMaterialChunk; 
    377373 
    378374MaterialChunkPtr getMaterialChunk(const Color4f &ambientColor, 
     
    385381        _gayaMaterialChunk = MaterialChunk::create(); 
    386382 
    387         addRef(_gayaMaterialChunk); 
    388  
    389383        _gayaMaterialChunk->setDiffuse(diffuseColor); 
    390384        _gayaMaterialChunk->setAmbient(ambientColor); 
     
    397391} 
    398392 
    399 ChunkMaterialPtr _gayaSelectionMaterial; 
     393ChunkMaterialRecPtr _gayaSelectionMaterial; 
    400394 
    401395ChunkMaterialPtr getSelectionMaterial() 
     
    404398    { 
    405399        _gayaSelectionMaterial = ChunkMaterial::create(); 
    406  
    407         addRef(_gayaSelectionMaterial); 
    408400 
    409401        _gayaSelectionMaterial->addChunk(getPolygonChunk());