Show
Ignore:
Timestamp:
05/06/03 20:04:27 (12 years ago)
Author:
robert
Message:

Aded extra constructors to BlendFunc? and Depth to help set them up convieniently.

Added a background quad to osghud.

Files:
1 modified

Legend:

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

    r1928 r1937  
    2121#include <osg/Depth> 
    2222#include <osg/Projection> 
     23#include <osg/PolygonOffset> 
    2324#include <osg/MatrixTransform> 
    2425 
     
    3031    osg::Geode* geode = new osg::Geode(); 
    3132     
    32     std::string timesFont("fonts/times.ttf"); 
     33    std::string timesFont("fonts/arial.ttf"); 
    3334 
    3435    // turn lighting off for the text and disable depth test to ensure its always ontop. 
    3536    osg::StateSet* stateset = geode->getOrCreateStateSet(); 
    3637    stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF); 
    37     stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF); 
     38    //stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF); 
     39    stateset->setAttribute(new osg::Depth(osg::Depth::LESS,0.0,0.0001)); 
    3840 
    3941    osg::Vec3 position(150.0f,800.0f,0.0f); 
     
    9597         
    9698        position += delta; 
    97     }     
     99    }  
     100     
     101     
     102     
     103    { 
     104        osg::BoundingBox bb; 
     105        for(unsigned int i=0;i<geode->getNumDrawables();++i) 
     106        { 
     107            bb.expandBy(geode->getDrawable(i)->getBound()); 
     108        } 
     109 
     110        osg::Geometry* geom = new osg::Geometry; 
     111 
     112        osg::Vec3Array* vertices = new osg::Vec3Array; 
     113        float depth = bb.zMin()-0.1; 
     114        vertices->push_back(osg::Vec3(bb.xMin(),bb.yMax(),depth)); 
     115        vertices->push_back(osg::Vec3(bb.xMin(),bb.yMin(),depth)); 
     116        vertices->push_back(osg::Vec3(bb.xMax(),bb.yMin(),depth)); 
     117        vertices->push_back(osg::Vec3(bb.xMax(),bb.yMax(),depth)); 
     118        geom->setVertexArray(vertices); 
     119 
     120        osg::Vec3Array* normals = new osg::Vec3Array; 
     121        normals->push_back(osg::Vec3(0.0f,0.0f,1.0f)); 
     122        geom->setNormalArray(normals); 
     123        geom->setNormalBinding(osg::Geometry::BIND_OVERALL); 
     124 
     125        osg::Vec4Array* colors = new osg::Vec4Array; 
     126        colors->push_back(osg::Vec4(1.0f,1.0,0.8f,0.2f)); 
     127        geom->setColorArray(colors); 
     128        geom->setColorBinding(osg::Geometry::BIND_OVERALL); 
     129 
     130        geom->addPrimitiveSet(new osg::DrawArrays(GL_QUADS,0,4)); 
     131         
     132        osg::StateSet* stateset = geom->getOrCreateStateSet(); 
     133        stateset->setMode(GL_BLEND,osg::StateAttribute::ON); 
     134        //stateset->setAttribute(new osg::PolygonOffset(1.0f,1.0f),osg::StateAttribute::ON); 
     135        stateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); 
     136 
     137        geode->addDrawable(geom); 
     138    } 
    98139 
    99140    // create the hud. 
     
    167208    // create the windows and run the threads. 
    168209    viewer.realize(); 
     210 
     211    // set all the sceneview's up so that their left and right add cull masks are set up. 
     212    for(osgProducer::OsgCameraGroup::SceneHandlerList::iterator itr=viewer.getSceneHandlerList().begin(); 
     213        itr!=viewer.getSceneHandlerList().end(); 
     214        ++itr) 
     215    { 
     216        osgUtil::SceneView* sceneview = itr->get(); 
     217        sceneview->setComputeNearFarMode(osgUtil::CullVisitor::DO_NOT_COMPUTE_NEAR_FAR); 
     218    } 
     219 
    169220 
    170221    while( !viewer.done() )