Changeset 14059

Show
Ignore:
Timestamp:
04/14/14 18:16:22 (5 days ago)
Author:
robert
Message:

Fixed comment

Location:
OpenSceneGraph/trunk
Files:
2 modified

Legend:

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

    r14047 r14059  
    9999    if ( !vertical ) 
    100100    { 
    101         sb->setPosition( osg::Vec3(0.5f,-0.5f,0)); 
     101        sb->setPosition( osg::Vec3(0.5f,0.5f,0)); 
    102102    } 
    103103 
     
    146146 
    147147    osg::Group* group = new osg::Group; 
    148     group->addChild(createScalarBar(true)); 
    149     group->addChild(createScalarBar(false)); 
     148 
    150149    group->addChild(createScalarBar_HUD()); 
     150 
     151    // rotate the scalar from XY plane to XZ so we see them viewing it with the default camera manipulators that look along the Y axis, with Z up. 
     152    osg::MatrixTransform* transform = new osg::MatrixTransform; 
     153    group->addChild(transform); 
     154    transform->setMatrix(osg::Matrix::rotate(osg::inDegrees(90.0),1.0,0.0,0.0)); 
     155    transform->addChild(createScalarBar(true)); 
     156    transform->addChild(createScalarBar(false)); 
    151157 
    152158    // add model to viewer. 
  • OpenSceneGraph/trunk/src/osgSim/ScalarBar.cpp

    r14047 r14059  
    135135    else 
    136136    { 
    137         matrix = osg::Matrix::rotate(osg::DegreesToRadians(90.0f),0.0f,0.0f,-1.0f) * osg::Matrix::translate(_position); 
     137        matrix = osg::Matrix::rotate(osg::DegreesToRadians(90.0f),0.0f,0.0f,1.0f) * osg::Matrix::translate(_position); 
    138138    } 
    139139 
     
    207207    float labelIncr = (_numLabels>0) ? (_stc->getMax()-_stc->getMin())/(_numLabels-1) : 0.0f; 
    208208    float labelxIncr = (_numLabels>0) ? (_width)/(_numLabels-1) : 0.0f; 
    209     const float labely = arOffset + characterSize*CHARACTER_OFFSET_FACTOR; 
     209    const float labelStickStartY = _orientation==HORIZONTAL ? arOffset : 0; 
     210    const float labelY = labelStickStartY + 
     211        (_orientation==HORIZONTAL ?  characterSize : -characterSize) * CHARACTER_OFFSET_FACTOR; 
     212 
    210213 
    211214    for(i=0; i<_numLabels; ++i) 
     
    218221        text->setText(_sp->printScalar(_stc->getMin()+(i*labelIncr))); 
    219222 
    220         text->setPosition(osg::Vec3((i*labelxIncr), labely, 0.0f)*matrix); 
     223        text->setPosition(osg::Vec3((i*labelxIncr), labelY, 0.0f)*matrix); 
    221224        text->setAlignment( (_orientation==HORIZONTAL) ? osgText::Text::CENTER_BASE_LINE : osgText::Text::LEFT_CENTER); 
    222225 
     
    241244        if ( _orientation==HORIZONTAL ) 
    242245        { 
    243             const float titleY = (_numLabels>0) ? labely + characterSize : labely; 
     246            const float titleY = (_numLabels>0) ? labelY + characterSize : labelY; 
    244247            titlePos = osg::Vec3((_width/2.0f), titleY, 0.0f); 
    245248        } 
    246249        else 
    247250        { 
    248             titlePos = osg::Vec3( 0, arOffset/2, 0 ); 
     251            titlePos = osg::Vec3(_width+characterSize*0.5, arOffset*0.5, 0 ); 
    249252        } 
    250  
    251         float titleY = (_numLabels>0) ? labely + characterSize : labely; 
    252253 
    253254        // Position the title at the middle of the bar above any labels. 
     
    280281    for(i=0; i<_numLabels; ++i) 
    281282    { 
    282         const osg::Vec3 p1(osg::Vec3((i*labelxIncr), arOffset, 0.0f)*matrix); 
    283         const osg::Vec3 p2(osg::Vec3((i*labelxIncr), labely, 0.0f)*matrix); 
     283        const osg::Vec3 p1(osg::Vec3((i*labelxIncr), labelStickStartY, 0.0f)*matrix); 
     284        const osg::Vec3 p2(osg::Vec3((i*labelxIncr), labelY, 0.0f)*matrix); 
    284285        annotVertices->push_back( p1 ); 
    285286        annotVertices->push_back( p2 );