Show
Ignore:
Timestamp:
11/02/05 16:23:54 (9 years ago)
Author:
robert
Message:

Added handling of CameraNode? into PickVisitor? in src/osgProducer/Viewer.cpp. This
is unlikely to be the final solution, but does at least fix part of the problem of handling
picking HUD's underneath CameraNodes?.

Files:
1 modified

Legend:

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

    r3995 r4662  
    2626#include <osg/Projection> 
    2727#include <osg/MatrixTransform> 
     28#include <osg/CameraNode> 
    2829#include <osg/io_utils> 
    2930 
     
    109110 
    110111osg::Node* createHUD(osgText::Text* updateText) 
    111 {    // create the hud. derived from osgHud.cpp 
     112{ 
     113 
     114    // create the hud. derived from osgHud.cpp 
    112115    // adds a set of quads, each in a separate Geode - which can be picked individually 
    113116    // eg to be used as a menuing/help system! 
    114117    // Can pick texts too! 
    115     osg::MatrixTransform* modelview_abs = new osg::MatrixTransform; 
    116     modelview_abs->setReferenceFrame(osg::Transform::ABSOLUTE_RF); 
    117     modelview_abs->setMatrix(osg::Matrix::identity()); 
    118      
    119     osg::Projection* projection = new osg::Projection; 
    120     projection->setMatrix(osg::Matrix::ortho2D(0,1280,0,1024)); 
    121     projection->addChild(modelview_abs); 
    122      
     118 
     119    osg::CameraNode* hudCamera = new osg::CameraNode; 
     120    hudCamera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); 
     121    hudCamera->setProjectionMatrixAsOrtho2D(0,1280,0,1024); 
     122    hudCamera->setViewMatrix(osg::Matrix::identity()); 
     123    hudCamera->setRenderOrder(osg::CameraNode::POST_RENDER); 
     124    hudCamera->setClearMask(GL_DEPTH_BUFFER_BIT); 
    123125     
    124126    std::string timesFont("fonts/times.ttf"); 
     
    134136        stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF); 
    135137        geode->setName("simple"); 
    136         modelview_abs->addChild(geode); 
     138        hudCamera->addChild(geode); 
    137139         
    138140        osgText::Text* text = new  osgText::Text; 
     
    173175        quad->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,4)); 
    174176        geode->addDrawable(quad); 
    175         modelview_abs->addChild(geode); 
     177        hudCamera->addChild(geode); 
    176178         
    177179        position += delta; 
     
    187189        geode->setName("The text label"); 
    188190        geode->addDrawable( updateText ); 
    189         modelview_abs->addChild(geode); 
     191        hudCamera->addChild(geode); 
    190192         
    191193        updateText->setCharacterSize(20.0f); 
     
    198200    }     
    199201     
    200     return projection; 
     202    return hudCamera; 
    201203 
    202204}