*** empty log message ***
This commit is contained in:
parent
9fd1706e3c
commit
e50ce2784f
@ -4,6 +4,7 @@
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Texture>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/Depth>
|
||||
#include <osg/StateSet>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
@ -15,7 +16,7 @@ Node *makeBase( void )
|
||||
int i, c;
|
||||
float theta;
|
||||
float ir, ori;
|
||||
ir = 6.0;
|
||||
ir = 0.0;
|
||||
ori = 20.0;
|
||||
|
||||
Vec3 *coords = new Vec3[38];
|
||||
@ -85,6 +86,15 @@ Node *makeBase( void )
|
||||
gstate->setAttr( PFSTATE_FOG, fog );
|
||||
*/
|
||||
|
||||
// clear the depth to the far plane.
|
||||
osg::Depth* depth = new osg::Depth;
|
||||
depth->setFunction(osg::Depth::ALWAYS);
|
||||
depth->setRange(1.0,1.0);
|
||||
dstate->setAttributeAndModes(depth,StateAttribute::ON );
|
||||
|
||||
dstate->setRenderBinDetails(-1,"RenderBin");
|
||||
|
||||
|
||||
gset->setStateSet( dstate );
|
||||
|
||||
Geode *geode = new Geode;
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include <osg/Group>
|
||||
#include <osg/Notify>
|
||||
#include <osg/Depth>
|
||||
#include <osg/StateSet>
|
||||
|
||||
#include <osgDB/Registry>
|
||||
#include <osgDB/ReadFile>
|
||||
@ -123,11 +125,19 @@ int main( int argc, char **argv )
|
||||
// no database loaded so automatically create Ed Levin Park..
|
||||
osg::Group* group = new osg::Group;
|
||||
rootnode = group;
|
||||
group->addChild(makeTerrain());
|
||||
group->addChild(makeTank());
|
||||
group->addChild(makeSky());
|
||||
group->addChild(makeBase());
|
||||
group->addChild(makeTrees());
|
||||
|
||||
// the base and sky subgraphs go to set the earth sky of the
|
||||
// model and clear the color and depth buffer for us, by using
|
||||
// osg::Depth, and setting their bin numbers to less than 0,
|
||||
// to force them to draw before the rest of the scene.
|
||||
|
||||
group->addChild(makeSky()); // bin number -2 so drawn first.
|
||||
group->addChild(makeBase()); // bin number -1 so draw second.
|
||||
|
||||
// the rest of the scene drawn after the base and sky above.
|
||||
group->addChild(makeTrees()); // will drop into a transparent, depth sorted bin (1)
|
||||
group->addChild(makeTerrain()); // will drop into default bin - state sorted 0
|
||||
group->addChild(makeTank()); // will drop into default bin - state sorted 0
|
||||
// add the following in the future...
|
||||
// makeGliders
|
||||
// makeClouds
|
||||
@ -139,6 +149,22 @@ int main( int argc, char **argv )
|
||||
osgGLUT::Viewer viewer;
|
||||
viewer.addViewport( rootnode );
|
||||
|
||||
|
||||
osg::StateSet* stateset = rootnode->getStateSet();
|
||||
if (stateset==NULL)
|
||||
{
|
||||
stateset = new osg::StateSet;
|
||||
rootnode->setStateSet(stateset);
|
||||
}
|
||||
|
||||
// set up depth to be inherited by the rest of the scene unless
|
||||
// overrideen.
|
||||
osg::Depth* rootDepth = new osg::Depth;
|
||||
rootDepth->setFunction(osg::Depth::LESS);
|
||||
rootDepth->setRange(0.0,1.0);
|
||||
|
||||
stateset->setAttributeAndModes(rootDepth, osg::StateAttribute::ON );
|
||||
|
||||
unsigned int pos = viewer.registerCameraManipulator(new GliderManipulator());
|
||||
|
||||
// Open window so camera manipulator's warp pointer request will succeed
|
||||
@ -146,6 +172,12 @@ int main( int argc, char **argv )
|
||||
|
||||
viewer.selectCameraManipulator(pos);
|
||||
|
||||
osgUtil::SceneView* sv = viewer.getViewportSceneView(0);
|
||||
|
||||
// switch off the render stages clear mask as we use the earth/sky
|
||||
// to clear it for us, see above.
|
||||
sv->getRenderStage()->setClearMask(0);
|
||||
|
||||
viewer.run();
|
||||
|
||||
return 0;
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <osg/GeoSet>
|
||||
#include <osg/Texture>
|
||||
#include <osg/TexEnv>
|
||||
#include <osg/Depth>
|
||||
#include <osg/StateSet>
|
||||
|
||||
#include <osgDB/ReadFile>
|
||||
@ -96,6 +97,15 @@ Node *makeSky( void )
|
||||
dstate->setAttribute( new TexEnv );
|
||||
dstate->setMode( GL_LIGHTING, StateAttribute::OFF );
|
||||
dstate->setMode( GL_CULL_FACE, StateAttribute::ON );
|
||||
|
||||
|
||||
// clear the depth to the far plane.
|
||||
osg::Depth* depth = new osg::Depth;
|
||||
depth->setFunction(osg::Depth::ALWAYS);
|
||||
depth->setRange(1.0,1.0);
|
||||
dstate->setAttributeAndModes(depth,StateAttribute::ON );
|
||||
|
||||
dstate->setRenderBinDetails(-2,"RenderBin");
|
||||
|
||||
gset->setStateSet( dstate );
|
||||
|
||||
|
@ -301,7 +301,8 @@ int main( int argc, char **argv )
|
||||
osg::ColorMask* rootColorMask = new osg::ColorMask;
|
||||
rootColorMask->setMask(true,true,true,true);
|
||||
|
||||
// set up depth so all writing to depth goes to maximum depth.
|
||||
// set up depth to be inherited by the rest of the scene unless
|
||||
// overrideen. this is overridden in bin 3.
|
||||
osg::Depth* rootDepth = new osg::Depth;
|
||||
rootDepth->setFunction(osg::Depth::LESS);
|
||||
rootDepth->setRange(0.0,1.0);
|
||||
|
Loading…
Reference in New Issue
Block a user