Hi Martin,

2009/8/15 Mamu <ma...@gmx.de>:
> My guess is that you need to call the base class constructor like this:
>
> class WithInitNodeVisitor(osg.NodeVisitor):
>    def __init__(self):
>        osg.NodeVisitor.__init__(self)   #<-- !!

you guessed right, thanks! Now, my example does not fail anymore, but
does not visit any node either...

I attached a new version of the test case, in case someone has the
time to help. Maybe my `apply` method is not taken into account by the
`accept` one?

Also, I could not find the source code of the finding nodes tutorial
[1]. It's written "The source code is available [here]." but "here' is
not a link. Any idea where it could be ?

[1] 
http://www.openscenegraph.org/projects/osg/wiki/Support/Tutorials/FindingNodes

Thank you again for your help

Cheers,
SB
# coding=utf-8
import osg

class MyNodeVisitor(osg.NodeVisitor):
    def __init__(self):
        osg.NodeVisitor.__init__(self, osg.NodeVisitor.NODE_VISITOR,
                                 osg.NodeVisitor.TRAVERSE_ALL_CHILDREN)
        self._names = []

    def apply(self, node):
        print node.getName()
        self._names.append(node.getName())
        self.traverse(node)

def test():
    print 'running test'
    root = osg.Group()
    root.setName('root')
    child = osg.Group()
    child.setName('child')
    root.addChild(child)
    grandchild = osg.Group()
    grandchild.setName('child')
    child.addChild(grandchild)
    
    nv = MyNodeVisitor()
    root.accept(nv)
    print nv._names

if __name__ == "__main__":
    test()

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

Reply via email to