[osg-users] design issues

Trajce Nikolov NICK trajce.nikolov.nick at gmail.com
Thu Nov 3 04:40:41 PDT 2016


Thanks Robert,

I am aware of it, it is already used in my second snippet. Here it is: (is
it done properly?)


   1. void MyCullVisitor::apply(osg::LightSource& node)
   2. {
   3.
   4.     osg::Matrixd inverseViewMatrix = osg::Matrixd::inverse(
   getCurrentCamera()->getViewMatrix());
   5.     osg::Matrixd worldMatrix = inverseViewMatrix * (*
   getModelViewMatrix());
   6.
   7.     osg::Vec3d pos(node.getLight()->getPosition().x(), node.getLight()
   ->getPosition().y(), node.getLight()->getPosition().z());
   8.     worldMatrix = osg::Matrixd::translate(pos) * worldMatrix;
   9.
   10.     node.setUserValue("WorldMatrix", worldMatrix);
   11.     if (node.getLight()->getLightNum() == 0)
   12.     {
   13.         osgUtil::CullVisitor::apply(node);
   14.     }
   15. }


On Thu, Nov 3, 2016 at 9:14 AM, Robert Osfield <robert.osfield at gmail.com>
wrote:

> Hi Nick,
>
> The osgUtil::CullVisitor has the maintains a stack of ModelViewMatrix
> that it accumulates through the the scene graph traversal, you should
> just need to get the top of this stack using
> cullVisitor->getModelViewMatrix().
>
> Robert.
>
> On 2 November 2016 at 22:25, Trajce Nikolov NICK
> <trajce.nikolov.nick at gmail.com> wrote:
> > Hi Community,
> >
> > I am trying to optimize the rendering. Getting huge update numbers.
> >
> > The story is this:
> > My scene has huge number of lights, some are static (streetlights) some
> > dynamic (a car). The lighting engine needs the World matrix of a
> LightSource
> > and the ViewMatrix (which is the same as the World inverse just with some
> > extra rotation). In my code after the update before the rendering
> traversal
> > I am updating these matrices each frame and I am about to place this
> code in
> > my custom CullVisitor (which traverse the scene anyway but only the
> active
> > children).
> >
> > Here is my approach at the moment: list of light entities and here is
> how I
> > am computing these:
> > http://pastebin.com/0A64sc7Y
> > Simply getting the NodePath and computing the world matrix from this node
> > path. This seams to be costly
> >
> > I am after wiser optimization, to place this in my CullVistor: Here is
> the
> > snippet:
> > http://pastebin.com/6dQnih8N
> >
> > These snippets are simple and I would like to ask if this is more proper
> > way, which it seams to me since I will gain more performance by updating
> > only the culled and active nodes. Also the math in the cull visitor.
> >
> > Thanks a lot for any hints, ideas. As always :-)
> >
> > Cheers,
> > Nick
> >
> > --
> > trajce nikolov nick
> >
> > _______________________________________________
> > osg-users mailing list
> > osg-users at lists.openscenegraph.org
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-
> openscenegraph.org
> >
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
trajce nikolov nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20161103/152f4c57/attachment-0003.htm>


More information about the osg-users mailing list