Changeset 13855

Show
Ignore:
Timestamp:
07/04/14 18:55:34 (7 days ago)
Author:
robert
Message:

Release OpenSceneGraph-3.2.1

Location:
OpenSceneGraph/trunk
Files:
10 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgmanipulator/osgmanipulator.cpp

    r13019 r13855  
    107107        osgManipulator::TrackballDragger* d = new osgManipulator::TrackballDragger(); 
    108108        d->setupDefaultGeometry(); 
     109        d->setAxisLineWidth(5.0f); 
     110        d->setPickCylinderHeight(0.1f); 
    109111        dragger = d; 
    110112    } 
     
    125127        osgManipulator::TranslateAxisDragger* d = new osgManipulator::TranslateAxisDragger(); 
    126128        d->setupDefaultGeometry(); 
     129        d->setAxisLineWidth(5.0f); 
     130        d->setPickCylinderRadius(0.05f); 
     131        d->setConeHeight(0.2f); 
    127132        dragger = d; 
    128133    } 
  • OpenSceneGraph/trunk/include/osgManipulator/ScaleAxisDragger

    r9899 r13855  
    1717 
    1818#include <osgManipulator/Scale1DDragger> 
     19#include <osg/ShapeDrawable> 
     20#include <osg/Geometry> 
     21#include <osg/LineWidth> 
    1922 
    2023namespace osgManipulator { 
     
    3437        void setupDefaultGeometry(); 
    3538 
     39        /** Sets the width of the axis lines in pixels. */ 
     40        void setAxisLineWidth(float linePixelWidth); 
     41 
     42        /** Retrieves the width of the axis lines in pixels. */ 
     43        float getAxisLineWidth() const { return _axisLineWidth; } 
     44 
     45        /** Sets the size of the boxes. */ 
     46        void setBoxSize(float size); 
     47 
     48        /** Retrieves the size of the boxes. */ 
     49        float getBoxSize() const { return _boxSize; } 
     50 
    3651    protected: 
    3752 
     
    4156        osg::ref_ptr< Scale1DDragger >        _yDragger; 
    4257        osg::ref_ptr< Scale1DDragger >        _zDragger; 
     58 
     59        float _boxSize; 
     60        float _axisLineWidth; 
     61 
     62        osg::ref_ptr<osg::Geode> _lineGeode; 
     63        osg::ref_ptr<osg::LineWidth> _lineWidth; 
     64        osg::ref_ptr<osg::Box> _box; 
    4365}; 
    4466 
  • OpenSceneGraph/trunk/include/osgManipulator/TrackballDragger

    r9899 r13855  
    1818#include <osgManipulator/RotateCylinderDragger> 
    1919#include <osgManipulator/RotateSphereDragger> 
     20#include <osg/ShapeDrawable> 
     21#include <osg/Geometry> 
     22#include <osg/LineWidth> 
    2023 
    2124namespace osgManipulator { 
     
    3538        void setupDefaultGeometry(); 
    3639 
     40        /** Sets the width of the axis lines in pixels. */ 
     41        void setAxisLineWidth(float linePixelWidth); 
     42 
     43        /** Retrieves the width of the axis lines in pixels. */ 
     44        float getAxisLineWidth() const { return _axisLineWidth; } 
     45 
     46        /** Sets the height of the cylinders representing the axis lines for picking. */ 
     47        void setPickCylinderHeight(float pickCylinderHeight); 
     48 
     49        /** Retrieves the height of the cylinders representing the axis lines for picking. */ 
     50        float getPickCylinderHeight() const { return _pickCylinderHeight; } 
     51 
    3752    protected: 
    3853 
     
    4358        osg::ref_ptr<RotateCylinderDragger> _zDragger; 
    4459        osg::ref_ptr<RotateSphereDragger>   _xyzDragger; 
     60 
     61        float _axisLineWidth; 
     62        float _pickCylinderHeight; 
     63 
     64        osg::ref_ptr<osg::Geode> _geode; 
     65        osg::ref_ptr<osg::Cylinder> _cylinder; 
     66        osg::ref_ptr<osg::LineWidth> _lineWidth; 
    4567}; 
    4668 
  • OpenSceneGraph/trunk/include/osgManipulator/TranslateAxisDragger

    r9899 r13855  
    1717 
    1818#include <osgManipulator/Translate1DDragger> 
     19#include <osg/ShapeDrawable> 
     20#include <osg/Geometry> 
     21#include <osg/LineWidth> 
    1922 
    2023namespace osgManipulator { 
     
    3437        void setupDefaultGeometry(); 
    3538 
     39        /** Sets the width of the axis lines in pixels. */ 
     40        void setAxisLineWidth(float linePixelWidth); 
     41 
     42        /** Retrieves the width of the axis lines in pixels. */ 
     43        float getAxisLineWidth() const { return _axisLineWidth; } 
     44 
     45        /** Sets the radius of the cylinders representing the axis lines for picking. */ 
     46        void setPickCylinderRadius(float pickCylinderRadius); 
     47 
     48        /** Retrieves the radius of the cylinders representing the axis lines for picking. */ 
     49        float getPickCylinderRadius() const { return _pickCylinderRadius; } 
     50 
     51        /** Sets the height of the cones. */ 
     52        void setConeHeight(float radius); 
     53 
     54        /** Retrieves the height of the cones. */ 
     55        float getConeHeight() const { return _coneHeight; } 
     56 
    3657    protected: 
    3758 
     
    4162        osg::ref_ptr< Translate1DDragger >  _yDragger; 
    4263        osg::ref_ptr< Translate1DDragger >  _zDragger; 
     64 
     65        float _coneHeight; 
     66        float _axisLineWidth; 
     67        float _pickCylinderRadius; 
     68 
     69        osg::ref_ptr<osg::Geode> _lineGeode; 
     70        osg::ref_ptr<osg::Cylinder> _cylinder; 
     71        osg::ref_ptr<osg::LineWidth> _lineWidth; 
     72        osg::ref_ptr<osg::Cone> _cone; 
    4373}; 
    4474 
  • OpenSceneGraph/trunk/src/osgManipulator/ScaleAxisDragger.cpp

    r13041 r13855  
    3636    addDragger(_zDragger.get()); 
    3737 
     38    _axisLineWidth = 2.0f; 
     39    _boxSize = 0.05f; 
     40 
    3841    setParentDragger(getParentDragger()); 
    3942} 
     
    4649{ 
    4750    // Create a line. 
    48     osg::Geode* lineGeode = new osg::Geode; 
     51    _lineGeode = new osg::Geode; 
    4952    { 
    5053        osg::Geometry* geometry = new osg::Geometry(); 
     
    5760        geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,2)); 
    5861 
    59         lineGeode->addDrawable(geometry); 
     62        _lineGeode->addDrawable(geometry); 
    6063    } 
    6164 
    6265    // Turn of lighting for line and set line width. 
    6366    { 
    64         osg::LineWidth* linewidth = new osg::LineWidth(); 
    65         linewidth->setWidth(2.0f); 
    66         lineGeode->getOrCreateStateSet()->setAttributeAndModes(linewidth, osg::StateAttribute::ON); 
    67         lineGeode->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF); 
     67        _lineWidth = new osg::LineWidth(); 
     68        _lineWidth->setWidth(_axisLineWidth); 
     69        _lineGeode->getOrCreateStateSet()->setAttributeAndModes(_lineWidth, osg::StateAttribute::ON); 
     70        _lineGeode->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF); 
    6871    } 
    6972 
    7073    // Add line to all the individual 1D draggers. 
    71     _xDragger->addChild(lineGeode); 
    72     _yDragger->addChild(lineGeode); 
    73     _zDragger->addChild(lineGeode); 
     74    _xDragger->addChild(_lineGeode); 
     75    _yDragger->addChild(_lineGeode); 
     76    _zDragger->addChild(_lineGeode); 
    7477 
    7578    osg::Geode* geode = new osg::Geode; 
    7679 
    7780    // Create a box. 
    78     geode->addDrawable(new osg::ShapeDrawable(new osg::Box(osg::Vec3(1.0f,0.0f,0.0f), 0.05))); 
     81    _box = new osg::Box(osg::Vec3(1.0f,0.0f,0.0f), _boxSize); 
     82    geode->addDrawable(new osg::ShapeDrawable(_box)); 
     83 
     84    // This ensures correct lighting for scaled draggers. 
     85#if !defined(OSG_GLES2_AVAILABLE) 
     86    geode->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON); 
     87#endif 
    7988 
    8089    // Add geode to all 1D draggers. 
     
    100109    _zDragger->setColor(osg::Vec4(0.0f,0.0f,1.0f,1.0f)); 
    101110} 
     111 
     112void ScaleAxisDragger::setAxisLineWidth(float linePixelWidth) 
     113{ 
     114    _axisLineWidth = linePixelWidth; 
     115    if (_lineWidth.valid()) 
     116        _lineWidth->setWidth(linePixelWidth); 
     117} 
     118 
     119void ScaleAxisDragger::setBoxSize(float size) 
     120{ 
     121    _boxSize = size; 
     122    if (_box.valid()) 
     123        _box->setHalfLengths(osg::Vec3(size * 0.5f, size * 0.5f, size * 0.5f)); 
     124} 
  • OpenSceneGraph/trunk/src/osgManipulator/TrackballDragger.cpp

    r13566 r13855  
    2929{ 
    3030 
    31 osg::Geometry* createCircleGeometry(float radius, unsigned int numSegments) 
    32 { 
    33     const float angleDelta = 2.0f*osg::PI/(float)numSegments; 
    34     const float r = radius; 
    35     float angle = 0.0f; 
    36     osg::Vec3Array* vertexArray = new osg::Vec3Array(numSegments); 
    37     osg::Vec3Array* normalArray = new osg::Vec3Array(numSegments); 
    38     for(unsigned int i = 0; i < numSegments; ++i,angle+=angleDelta) 
     31    osg::Geometry* createCircleGeometry(float radius, unsigned int numSegments) 
    3932    { 
    40         float c = cosf(angle); 
    41         float s = sinf(angle); 
    42         (*vertexArray)[i].set(c*r,s*r,0.0f); 
    43         (*normalArray)[i].set(c,s,0.0f); 
     33        const float angleDelta = 2.0f*osg::PI/(float)numSegments; 
     34        const float r = radius; 
     35        float angle = 0.0f; 
     36        osg::Vec3Array* vertexArray = new osg::Vec3Array(numSegments); 
     37        osg::Vec3Array* normalArray = new osg::Vec3Array(numSegments); 
     38        for(unsigned int i = 0; i < numSegments; ++i,angle+=angleDelta) 
     39        { 
     40            float c = cosf(angle); 
     41            float s = sinf(angle); 
     42            (*vertexArray)[i].set(c*r,s*r,0.0f); 
     43            (*normalArray)[i].set(c,s,0.0f); 
     44        } 
     45        osg::Geometry* geometry = new osg::Geometry(); 
     46        geometry->setVertexArray(vertexArray); 
     47        geometry->setNormalArray(normalArray, osg::Array::BIND_PER_VERTEX); 
     48        geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,0,vertexArray->size())); 
     49        return geometry; 
    4450    } 
    45     osg::Geometry* geometry = new osg::Geometry(); 
    46     geometry->setVertexArray(vertexArray); 
    47     geometry->setNormalArray(normalArray, osg::Array::BIND_PER_VERTEX); 
    48     geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINE_LOOP,0,vertexArray->size())); 
    49     return geometry; 
    50 } 
    5151 
    5252} 
     
    103103    } 
    104104 
     105    _axisLineWidth = 2.0f; 
     106    _pickCylinderHeight = 0.15f; 
     107 
    105108    setParentDragger(getParentDragger()); 
    106109} 
     
    112115void TrackballDragger::setupDefaultGeometry() 
    113116{ 
    114     osg::Geode* geode = new osg::Geode; 
     117    _geode = new osg::Geode; 
    115118    { 
    116119        osg::TessellationHints* hints = new osg::TessellationHints; 
     
    119122        hints->setCreateBackFace(false); 
    120123 
    121         osg::Cylinder* cylinder = new osg::Cylinder; 
    122         cylinder->setHeight(0.15f); 
    123         osg::ShapeDrawable* cylinderDrawable = new osg::ShapeDrawable(cylinder,hints); 
    124         geode->addDrawable(cylinderDrawable); 
     124        _cylinder = new osg::Cylinder; 
     125        _cylinder->setHeight(_pickCylinderHeight); 
     126        osg::ShapeDrawable* cylinderDrawable = new osg::ShapeDrawable(_cylinder, hints); 
     127        _geode->addDrawable(cylinderDrawable); 
    125128        setDrawableToAlwaysCull(*cylinderDrawable); 
    126         geode->addDrawable(createCircleGeometry(1.0f, 100)); 
     129        _geode->addDrawable(createCircleGeometry(1.0f, 100)); 
    127130    } 
    128131 
     
    131134        osg::PolygonMode* polymode = new osg::PolygonMode; 
    132135        polymode->setMode(osg::PolygonMode::FRONT_AND_BACK,osg::PolygonMode::LINE); 
    133         geode->getOrCreateStateSet()->setAttributeAndModes(polymode,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON); 
    134         geode->getOrCreateStateSet()->setAttributeAndModes(new osg::LineWidth(2.0f),osg::StateAttribute::ON); 
     136        _geode->getOrCreateStateSet()->setAttributeAndModes(polymode,osg::StateAttribute::OVERRIDE|osg::StateAttribute::ON); 
     137        _lineWidth = new osg::LineWidth(_axisLineWidth); 
     138        _geode->getOrCreateStateSet()->setAttributeAndModes(_lineWidth, osg::StateAttribute::ON); 
    135139 
    136         #if !defined(OSG_GLES2_AVAILABLE) 
    137             geode->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON); 
    138         #endif 
     140#if !defined(OSG_GLES2_AVAILABLE) 
     141        _geode->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON); 
     142#endif 
    139143 
    140144    } 
    141145 
    142146    // Add line to all the individual 1D draggers. 
    143     _xDragger->addChild(geode); 
    144     _yDragger->addChild(geode); 
    145     _zDragger->addChild(geode); 
     147    _xDragger->addChild(_geode); 
     148    _yDragger->addChild(_geode); 
     149    _zDragger->addChild(_geode); 
    146150 
    147151 
     
    173177    } 
    174178} 
     179 
     180void TrackballDragger::setAxisLineWidth(float linePixelWidth) 
     181{ 
     182    _axisLineWidth = linePixelWidth; 
     183    if (_lineWidth.valid()) 
     184        _lineWidth->setWidth(linePixelWidth); 
     185} 
     186void TrackballDragger::setPickCylinderHeight(float pickCylinderHeight) 
     187{ 
     188    _pickCylinderHeight = pickCylinderHeight; 
     189    if (_cylinder.valid()) 
     190        _cylinder->setHeight(pickCylinderHeight); 
     191} 
  • OpenSceneGraph/trunk/src/osgManipulator/TranslateAxisDragger.cpp

    r13041 r13855  
    3636    addDragger(_zDragger.get()); 
    3737 
     38    _axisLineWidth = 2.0f; 
     39    _pickCylinderRadius = 0.015f; 
     40    _coneHeight = 0.1f; 
     41 
    3842    setParentDragger(getParentDragger()); 
    3943} 
     
    4650{ 
    4751    // Create a line. 
    48     osg::Geode* lineGeode = new osg::Geode; 
     52    _lineGeode = new osg::Geode; 
    4953    { 
    5054        osg::Geometry* geometry = new osg::Geometry(); 
     
    5761        geometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::LINES,0,2)); 
    5862 
    59         lineGeode->addDrawable(geometry); 
     63        _lineGeode->addDrawable(geometry); 
    6064    } 
    6165 
    6266    // Turn of lighting for line and set line width. 
    6367    { 
    64         osg::LineWidth* linewidth = new osg::LineWidth(); 
    65         linewidth->setWidth(2.0f); 
    66         lineGeode->getOrCreateStateSet()->setAttributeAndModes(linewidth, osg::StateAttribute::ON); 
    67         lineGeode->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF); 
     68        _lineWidth = new osg::LineWidth(); 
     69        _lineWidth->setWidth(_axisLineWidth); 
     70        _lineGeode->getOrCreateStateSet()->setAttributeAndModes(_lineWidth, osg::StateAttribute::ON); 
     71        _lineGeode->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); 
    6872    } 
    6973 
    7074    // Add line to all the individual 1D draggers. 
    71     _xDragger->addChild(lineGeode); 
    72     _yDragger->addChild(lineGeode); 
    73     _zDragger->addChild(lineGeode); 
     75    _xDragger->addChild(_lineGeode); 
     76    _yDragger->addChild(_lineGeode); 
     77    _zDragger->addChild(_lineGeode); 
    7478 
    7579    osg::Geode* geode = new osg::Geode; 
     
    7781    // Create a cone. 
    7882    { 
    79         osg::Cone* cone = new osg::Cone (osg::Vec3(0.0f, 0.0f, 1.0f), 0.025f, 0.10f); 
    80         geode->addDrawable(new osg::ShapeDrawable(cone)); 
     83        _cone = new osg::Cone (osg::Vec3(0.0f, 0.0f, 1.0f), _coneHeight * 0.25f, _coneHeight); 
     84        osg::ShapeDrawable* coneDrawable = new osg::ShapeDrawable(_cone); 
     85        // coneDrawable->setColor(osg::Vec4(0.0f,0.0f,1.0f,1.0f)); 
     86        geode->addDrawable(coneDrawable); 
     87 
     88        // This ensures correct lighting for scaled draggers. 
     89#if !defined(OSG_GLES2_AVAILABLE) 
     90        geode->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON); 
     91#endif 
    8192    } 
    8293 
    8394    // Create an invisible cylinder for picking the line. 
    8495    { 
    85         osg::Cylinder* cylinder = new osg::Cylinder (osg::Vec3(0.0f,0.0f,0.5f), 0.015f, 1.0f); 
    86         osg::Drawable* geometry = new osg::ShapeDrawable(cylinder); 
     96        _cylinder = new osg::Cylinder (osg::Vec3(0.0f,0.0f,0.5f), _pickCylinderRadius, 1.0f); 
     97        osg::Drawable* geometry = new osg::ShapeDrawable(_cylinder); 
    8798        setDrawableToAlwaysCull(*geometry); 
    8899        geode->addDrawable(geometry); 
     
    111122    _zDragger->setColor(osg::Vec4(0.0f,0.0f,1.0f,1.0f)); 
    112123} 
     124 
     125void TranslateAxisDragger::setAxisLineWidth(float linePixelWidth) 
     126{ 
     127    _axisLineWidth = linePixelWidth; 
     128    if (_lineWidth.valid()) 
     129        _lineWidth->setWidth(linePixelWidth); 
     130} 
     131void TranslateAxisDragger::setPickCylinderRadius(float pickCylinderRadius) 
     132{ 
     133    _pickCylinderRadius = pickCylinderRadius; 
     134    if (_cylinder.valid()) 
     135        _cylinder->setRadius(pickCylinderRadius); 
     136} 
     137 
     138void TranslateAxisDragger::setConeHeight(float height) 
     139{ 
     140    _coneHeight = height; 
     141    if (_cone.valid()) 
     142    { 
     143        _cone->setRadius(0.25f * height); 
     144        _cone->setHeight(height); 
     145    } 
     146} 
  • OpenSceneGraph/trunk/src/osgWrappers/serializers/osgManipulator/ScaleAxisDragger.cpp

    r12292 r13855  
    1010                         "osgManipulator::ScaleAxisDragger" )  // No need to contain CompositeDragger here 
    1111{ 
     12    ADD_FLOAT_SERIALIZER(AxisLineWidth, 2.0f); 
     13    ADD_FLOAT_SERIALIZER(BoxSize, 0.05f); 
    1214} 
  • OpenSceneGraph/trunk/src/osgWrappers/serializers/osgManipulator/TrackballDragger.cpp

    r12292 r13855  
    1010                         "osgManipulator::TrackballDragger" )  // No need to contain CompositeDragger here 
    1111{ 
     12    ADD_FLOAT_SERIALIZER(AxisLineWidth, 2.0f); 
     13    ADD_FLOAT_SERIALIZER(PickCylinderHeight, 0.15f); 
    1214} 
  • OpenSceneGraph/trunk/src/osgWrappers/serializers/osgManipulator/TranslateAxisDragger.cpp

    r12292 r13855  
    1010                         "osgManipulator::TranslateAxisDragger" )  // No need to contain CompositeDragger here 
    1111{ 
     12    ADD_FLOAT_SERIALIZER(AxisLineWidth, 2.0f); 
     13    ADD_FLOAT_SERIALIZER(PickCylinderRadius, 0.015f); 
     14    ADD_FLOAT_SERIALIZER(ConeHeight, 0.1f); 
    1215}