And we pack them into a new SoSeparator for convenience. This is the full script:
Code: Select all
from pivy import coin
root = Gui.ActiveDocument.ActiveView.getSceneGraph()
nodes = [node for node in root.getChildren() if isinstance(node, coin.SoSeparator]
newnode = coin.SoSeparator()
for node in nodes:
newnode.addChild(node) # pack them all into a separator, for convenience
import OfflineRenderingUtils
cam = FreeCADGui.ActiveDocument.ActiveView.getCamera() # gather the camera position
rn = OfflineRenderingUtils.embedLight(newnode,(1,1,-1)) # embed the wholescene in a ShadowGroup, add directional light
light = rn.getChild(0) # get a ref to the directional light for later
v = FreeCADGui.createViewer() # create an empty 3D view in FreeCAD
v.setCamera(cam) # set the camera
vv = v.getViewer().setSceneGraph(rn) # set our scene as its scenegraph
light.direction = (-1,-1,-1) # change light direction