This is by design. The
node.getVisible() command returns the visible flag of the node. It does not take into account the visible flag of any parents.
You can use the
node.getParents() command to determine the visibility state taking into account all parent nodes. Example:
Code:
import viz
import vizact
viz.go()
group1 = viz.addGroup()
group2 = viz.addGroup(parent=group1)
ball = viz.addChild('beachball.osgb',parent=group2,pos=(0,1.8,2))
label = viz.addText('',parent=viz.ORTHO,fontSize=50,pos=(10,10,0))
def isNodeActuallyVisible(node):
if not node.getVisible():
return False
parents = node.getParents()
if parents:
return any(isNodeActuallyVisible(p) for p in parents)
return True
def UpdateLabel():
if isNodeActuallyVisible(ball):
label.message('visible')
else:
label.message('not visible')
vizact.ontimer(0,UpdateLabel)
vizact.onkeydown('1',group1.visible,viz.TOGGLE)
vizact.onkeydown('2',group2.visible,viz.TOGGLE)
vizact.onkeydown('3',ball.visible,viz.TOGGLE)