#!/usr/bin/env python # Copyright (C) 2002-2003 Gideon May (gideon@computer.org) # # Permission to copy, use, sell and distribute this software is granted # provided this copyright notice appears in all copies. # Permission to modify the code and to distribute modified code is granted # provided this copyright notice appears in all copies, and a notice # that the code was modified is included with the copyright notice. # # This software is provided "as is" without express or implied warranty, # and with no claim as to its suitability for any purpose. # -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2003 Robert Osfield # # This application is open source and may be redistributed and/or modified # freely and without restriction, both in commericial and non commericial applications, # as long as this copyright notice is maintained. # # This application is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # import sys from PyOSG import osg from PyOSG import osgDB from PyOSG import osgUtil from PyOSG import osgGLUT from PyOSG import osgGA import OpenGL import OpenGL.GLUT def write_usage(name): print "usage:" print " ",name," [options] infile1 [infile2 ...]" print print "options:" print " -l libraryName - load plugin of name libraryName" print " i.e. -l osgdb_pfb" print " Useful for loading reader/writers which can load" print " other file formats in addition to its extension." print " -e extensionName - load reader/wrter plugin for file extension" print " i.e. -e pfb" print " Useful short hand for specifying full library name as" print " done with -l above, as it automatically expands to" print " the full library name appropriate for each platform." print print " -stereo - switch on stereo rendering, using the default of," print " ANAGLYPHIC or the value set in the OSG_STEREO_MODE " print " environmental variable. See doc/stereo.html for " print " further details on setting up accurate stereo " print " for your system. " print " -stereo ANAGLYPHIC - switch on anaglyphic(red/cyan) stereo rendering." print " -stereo QUAD_BUFFER - switch on quad buffered stereo rendering." print print " -stencil - use a visual with stencil buffer enabled, this " print " also allows the depth complexity statistics mode" print " to be used (press 'p' three times to cycle to it)." print def main(): #initialize the GLUT OpenGL.GLUT.glutInit(sys.argv) if len(sys.argv)<2: write_usage(sys.argv[0]) return 0 # create the commandline args. commandLine = sys.argv[1:] # initialize the viewer. viewer = osgGLUT.Viewer() viewer.setWindowTitle(sys.argv[0]) # configure the viewer from the commandline arguments, and eat any # parameters that have been matched. viewer.readCommandLine(commandLine) # configure the plugin registry from the commandline arguments, and # eat any parameters that have been matched. osgDB.readCommandLine(commandLine) # load the nodes from the commandline arguments. rootnode = osgDB.readNodeFiles(commandLine) if rootnode == None: # write_usage(osg.notify(osg.NOTICE),argv[0]) return 1 # create the vewiports viewer.addViewport( rootnode,0.0,0.0,0.5,0.5) viewer.addViewport( rootnode,0.5,0.0,0.5,0.5) viewer.addViewport( rootnode,0.0,0.5,1.0,0.5) # register trackball, flight and drive. viewer.registerCameraManipulator(osgGA.TrackballManipulator()) viewer.registerCameraManipulator(osgGA.FlightManipulator()) viewer.registerCameraManipulator(osgGA.DriveManipulator()) viewer.open() viewer.run() return 0 if __name__ == "__main__": main()