Show
Ignore:
Timestamp:
10/21/14 17:10:27 (3 days ago)
Author:
robert
Message:

Added shaders to support experimental shader based displacement mapping technique osgTerrain::ShaderTerrain?.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 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}