For an example of use of Fog have a look at the osgprecipitation
example and the osgParticle code behind it.
On Nov 13, 2007 10:01 AM, Elbers, H.P. <[EMAIL PROTECTED]> wrote:
> Hi Robert,
>
> Thank you for responding. I've been experimenting for hours, with the
> 'opengl programming guide' on my desk, but no luck.
>
> In my small test program the initial view distance to the centre of my
> scene is about 250.
>
> I would expect the following to work but is does NOT:
> fog->setMode(Fog::LINEAR);
> fog->setStart(200.f); fog->setEnd(300.f);
>
> The fog looks 'ok' on my example when I use negative start/end values
> (but I dont understand why it works):
> fog->setMode(Fog::LINEAR);
> fog->setStart(-200.f);
>
> For the exponential mode I would expect this to work, but it does not
> (nor does any other density)
> fog->setMode(Fog::EXP);
> fog->setDensity(.00277); // e^(-250. * .00277) = .5
>
> Any clue? any hint? A simple working example (code or osg-file)?
> anybody?
>
> Thanks,
> Hans,
>
>
> > Hi Hans,
> >
> > Fog most likely will be working correctly, just the values
> > involved need tweaking. The best thing to do is read up on
> > OpenGL Fog settings, the OSG just passes the settings it has
> > on to OpenGL. osg::Fog is effectively glFog, all the
> > variable and naming conventions are the same.
> >
> > Robert.
> >
> > On Nov 12, 2007 12:25 PM, Elbers, H.P. <[EMAIL PROTECTED]> wrote:
> > >
> > >
> > > Hello All,
> > >
> > > I'm new to osg, and trying to use Fog...
> > >
> > > I get no fog at all, unless I use LINEAR mode with negative
> > start and
> > > end values, wich I find strange: I would expect that
> > positive values
> > > are required. If I try EXP mode, I cannot get any fog at al.
> > >
> > > Am I overlooking something obvious?
> > > Please help!
> > >
> > > Hans Elbers
> > >
> > > ==========================================================
> > > I'm using OSG 2.2 on linux, installed in a default way.
> > > Here is a small test example (with red fog):
> > >
> > > I compile like this:
> > > g++ -c -g main.cpp -o main.o
> > > g++ -o osgtest -g main.o -losg -losgViewer -losgSim
> > >
> > > main.cpp:
> > > ==========================================================
> > > #include <osg/Group>
> > > #include <osg/Fog>
> > > #include <osgDB/ReadFile>
> > > #include <osg/MatrixTransform>
> > > #include <osg/PositionAttitudeTransform> #include
> > <osgViewer/Viewer>
> > > #include <osgGA/TrackballManipulator>
> > >
> > > using namespace osg;
> > > using namespace std;
> > >
> > > int main(int argc, char *argv[]) {
> > > osgViewer::Viewer viewer;
> > > Group *world = new Group();
> > >
> > > StateSet *state= world->getOrCreateStateSet();
> > >
> > > Fog *fog =
> > dynamic_cast<Fog*>(state->getAttribute(StateAttribute::FOG));
> > > if (!fog) fog = new Fog;
> > > fog->setColor(osg::Vec4(1.,0.,0., 1.));
> > > fog->setDensity(0.15f);
> > >
> > > // ====> FOG works !?!?!
> > > fog->setMode(Fog::LINEAR); fog->setStart(-200.f);
> > > fog->setEnd(-300.f);
> > >
> > > // ====> NO FOG !?!?!?
> > > //fog->setMode(Fog::LINEAR); fog->setStart(200.f);
> > fog->setEnd(300.f);
> > > //fog->setMode(Fog::EXP); fog->setStart(200.f);
> > fog->setEnd(300.f);
> > >
> > > state->setAttributeAndModes(fog,StateAttribute::ON);
> > >
> > > Node *obj = osgDB::readNodeFile("obj.osg");
> > > if (obj) for (int i=-5; i<=5; i++) for (int j=-5; j<=5; j++) {
> > > PositionAttitudeTransform *T = new PositionAttitudeTransform();
> > > world->addChild(T);
> > > T->setPosition(Vec3(10.*i, 10.*j, 0.));
> > > T->addChild(obj);
> > > }
> > >
> > > viewer.setSceneData(world);
> > > osgGA::TrackballManipulator *manip = new
> > osgGA::TrackballManipulator();
> > > viewer.setCameraManipulator(manip);
> > > viewer.realize();
> > >
> > > viewer.run();
> > > }
> > > ==========================================================
> > >
> > >
> > > obj.osg contains a small cube:
> > > ==========================================================
> > > Group {
> > > UniqueID Group_0
> > > DataVariance UNSPECIFIED
> > > name "root"
> > > nodeMask 0xffffffff
> > > cullingActive TRUE
> > > num_children 1
> > > Geode {
> > > UniqueID Geode_7
> > > DataVariance UNSPECIFIED
> > > name "geode19"
> > > nodeMask 0xffffffff
> > > cullingActive TRUE
> > > num_drawables 1
> > > ShapeDrawable {
> > > UniqueID ShapeDrawable_8
> > > DataVariance UNSPECIFIED
> > > Box {
> > > DataVariance UNSPECIFIED
> > > Center 0 0 0
> > > HalfLengths .5 .5 .5
> > > Rotation 0 0 0 1
> > > }
> > > useDisplayList FALSE
> > > useVertexBufferObjects TRUE
> > > color 1 1 1 1
> > > }
> > > }
> > > }
> > > ==========================================================
> > > _______________________________________________
> > > osg-users mailing list
> > > [email protected]
> > >
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.
> > > org
> > >
> > >
> > _______________________________________________
> > osg-users mailing list
> > [email protected]
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-opensce
> negraph.org
> >
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org