First time posting to the list, so please bear with me...

I'm currently trying to attach a lightsource node to the front end of
an aircraft model in the application I'm working on that acts as a
spotlight (to simulate landing lights/head lights).
Even though I am setting the stateset up how (I think) I am supposed
to, as such:

lightNode->setStateSetModes(*root->getOrCreateStateSet(),osg::StateAttribute::ON);

The spotlight is only affecting the plane model (and some billboards
way off in the background if I aim it at them), and not the runway. I
even went as far as to make a nodeVisitor
and traverse the entire scene graph calling the light source's
setStateSetModes() on every osg::Node in it, no dice.

I can think of a couple weird things we do that might affect things
since I'm not sure how they interact with LightSource nodes:

1) My terrain is drawn in renderbin 1, aircraft shadows in renderbin
3, and aircraft in renderbin 9. Due to some complications with our
application, we can't use the osgShadow nodekit
so we're using plain old projected shadows for now. The terrain in
renderbin 1 puts 1s into the stencil buffer and the shadows in
renderbin 3 only draw where the stencil buffer is 1
and reset it back to zero, to prevent a pixel from being shadowed
twice. The shadow pass is implemented by having an
osg::MatrixTransform with the shadow projection matrix
for light 0 (the sun) which has as its child the group node containing
all the aircraft in the scene. Do I have to worry about the renderbin
that the lightsource is in?

2) To prevent the osgSim::LightPoints on the aircraft (as well as text
labels and other junk) from being drawn as shadows, I unset the
highest bit of the nodemask for the objects I don't
want drawn and then I modify the cull visitor's mask with a callback
when it passes through my shadow matrix to only have the highest bit
set. The group the osg::LightSource is
under does not have its highest bit set, but it should still get
visited when the aircraft group gets visited (as evidenced by the fact
that it does light up the aircraft it is attached to)...
Am I not understanding some default magic about bits in nodemasks?

At this point I'm lost. I'm still not sure how things like render bins
and nodemasks affect lightsources in the scene graph, but maybe I'm
barking up the wrong tree worrrying about that.
Anything obvious it seems I've missed? If more info is needed, please
let me know, and I'll go into as much detail as possible.

Thanks!
-Chris B
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to