def viewer(scene=None, background=(1.0, 1.0, 1.0)): """viewer(scene=None,background=(1.0,1.0,1.0)): starts a standalone coin viewer with the contents of the given scene""" # Initialize Coin. This returns a main window to use from pivy import sogui win = sogui.SoGui.init() if win == None: print("Unable to create a SoGui window") return win.setBackgroundColor( coin.SbColor(background[0], background[1], background[2])) if not scene: # build a quick default scene mat = coin.SoMaterial() mat.diffuseColor = (1.0, 0.0, 0.0) # Make a scene containing a red cone scene = coin.SoSeparator() scene.addChild(mat) scene.addChild(coin.SoCone()) # ref the scene so it doesn't get garbage-collected scene.ref() # Create a viewer in which to see our scene graph viewer = sogui.SoGuiExaminerViewer(win) # Put our scene into viewer, change the title viewer.setSceneGraph(scene) viewer.setTitle("Coin viewer") viewer.show() sogui.SoGui.show(win) # Display main window sogui.SoGui.mainLoop() # Main Coin event loop
def main(): from pivy import sogui #from pivy import soqt as sogui win = sogui.SoGui.init() world = coin.SoSeparator() cube_lv = make_mother_daughter() world.addChild(cube_lv) view = sogui.SoGuiExaminerViewer(win) view.setSceneGraph(world) view.setTitle("Test") view.show() view.viewAll() sogui.SoGui.show(win) sogui.SoGui.mainLoop()
def viewer(scene=None,background=(1.0,1.0,1.0),lightdir=None): """viewer(scene=None,background=(1.0,1.0,1.0),lightdir=None): starts a standalone coin viewer with the contents of the given scene. You can give a background color, and optionally a light direction as a (x,y,z) tuple. In this case, a directional light will be added and shadows will be turned on. This might not work with some 3D drivers.""" # Initialize Coin. This returns a main window to use from pivy import coin from pivy import sogui win = sogui.SoGui.init() if win is None: print("Unable to create a SoGui window") return win.setBackgroundColor(coin.SbColor(background[0],background[1],background[2])) if not scene: # build a quick default scene mat = coin.SoMaterial() mat.diffuseColor = (1.0, 0.0, 0.0) # Make a scene containing a red cone scene = coin.SoSeparator() scene.addChild(mat) scene.addChild(coin.SoCone()) if lightdir: scene = embedLight(scene,lightdir) # ref the scene so it doesn't get garbage-collected scene.ref() # Create a viewer in which to see our scene graph viewer = sogui.SoGuiExaminerViewer(win) # Put our scene into viewer, change the title viewer.setSceneGraph(scene) viewer.setTitle("Coin viewer") viewer.show() sogui.SoGui.show(win) # Display main window sogui.SoGui.mainLoop() # Main Coin event loop