Exemple #1
0
def main(argv):

    
    viewer = osgViewer.Viewer()
    args = osg.ArgumentParser(argv)

    # Make sure we have the minimum args...
    if argc <= 2 :
        osg.notify(osg.FATAL), "usage: ", args[0], " fontfile size1 [size2 ...]"

        return 1


    viewer.addEventHandler( osgGA.StateSetManipulator(viewer.getCamera().getOrCreateStateSet()) )
    viewer.addEventHandler(osgViewer.StatsHandler())
    viewer.addEventHandler(osgViewer.WindowSizeHandler())

    group = osg.Group()
    camera = createOrthoCamera(1280.0, 1024.0)

    # Create the list of desired sizes.
    sizes = Sizes()

    for(int i = 2 i < argc i++)
        if  not args.isNumber(i) : continue

        sizes.push_back(std.atoi(args[i]))
def main(argv):

    
    arguments = osg.ArgumentParser(argv)
    viewer = osgViewer.Viewer(arguments)
    
    tbm = osgGA.TrackballManipulator()

    viewer.setCameraManipulator(tbm)

    viewer.addEventHandler(osgViewer.StatsHandler())
    viewer.addEventHandler(osgViewer.WindowSizeHandler())

    root = osg.Group()
    geode = osg.Geode()

    geode.setStateSet(setupStateSet())

    root.setInitialBound(osg.BoundingSphere(osg.Vec3(10,0,20), 50))
    root.addChild(setupAnimtkNode(geode))
    root.addChild(geode)

    viewer.setSceneData(root)

    # tbm.setDistance(150)

    return viewer.run()
Exemple #3
0
def main(argv):

    

    # use an ArgumentParser object to manage the program arguments.
    arguments = osg.ArgumentParser(argv)

    # construct the viewer.
    viewer = osgViewer.Viewer()

    # add the state manipulator
    viewer.addEventHandler( osgGA.StateSetManipulator(viewer.getCamera().getOrCreateStateSet()) )

    # add stats
    viewer.addEventHandler( osgViewer.StatsHandler() )

    needToSetHomePosition = False

    # read the scene from the list of file specified commandline args.
    scene = osgDB.readNodeFiles(arguments)

    # if one hasn't been loaded create an earth and sun test model.
    if  not scene :
        scene = createScene()
        needToSetHomePosition = True
    # pass the loaded scene graph to the viewer.
    viewer.setSceneData(scene)

    viewer.setCameraManipulator(osgGA.TrackballManipulator)()

    if needToSetHomePosition :
        viewer.getCameraManipulator().setHomePosition(osg.Vec3d(0.0,-5.0*r_earth,0.0),osg.Vec3d(0.0,0.0,0.0),osg.Vec3d(0.0,0.0,1.0))

    zNear = 1.0, zMid=10.0, zFar=1000.0
    if arguments.read("--depth-partition",zNear, zMid, zFar) :
        # set up depth partitioning
        dps = osgViewer.DepthPartitionSettings()
        dps._mode = osgViewer.DepthPartitionSettings.FIXED_RANGE
        dps._zNear = zNear
        dps._zMid = zMid
        dps._zFar = zFar
        viewer.setUpDepthPartition(dps)
    else:
        # set up depth partitioning with default settings
        viewer.setUpDepthPartition()


    return viewer.run()
Exemple #4
0
def main(argv):
    arguments = osg.ArgumentParser(argv)
    viewer = osgViewer.Viewer(arguments)
    hints = osgWidget.GeometryHints(
        osg.Vec3(0.0, 0.0, 0.0), osg.Vec3(1.0, 0.0, 0.0),
        osg.Vec3(0.0, 0.0, 1.0), osg.Vec4(1.0, 1.0, 1.0, 1.0),
        osgWidget.GeometryHints.RESIZE_HEIGHT_TO_MAINTAINCE_ASPECT_RATIO)
    group = osg.Group()
    for i in range(len(argv)):
        if not arguments.isOption(i):
            pdfReader = osgWidget.PdfReader()
            if pdfReader.open(arguments[i], hints):
                group.addChild(pdfReader.get())
                hints.position.x += 1.1
    viewer.setSceneData(group)
    viewer.addEventHandler(osgViewer.StatsHandler())
    return viewer.run()
Exemple #5
0
def main(argv):
    # use an ArgumentParser object to manage the program arguments.
    viewer = osgViewer.Viewer()
#    viewer.setThreadingModel(osgViewer.Viewer.SingleThreaded)

    # read the scene from the list of file specified commandline args.
    loadedModel = osgDB.readNodeFile("cessna.osg")
    if loadedModel == None:
        raise Exception('Could not load model file (is OSG_FILE_PATH set and correct?)')

    # create a transform to spin the model.
    loadedModelTransform = osg.MatrixTransform()
    loadedModelTransform.addChild(loadedModel)

    print loadedModelTransform.getBound()._center
#todo:    nc = osg.AnimationPathCallback(loadedModelTransform.getBound()._center,osg.Vec3(0.0,0.0,1.0),osg.inDegrees(45.0));
#    loadedModelTransform.setUpdateCallback(nc)

    rootNode = osg.Group()
    rootNode.stateSet.dataVariance = osg.Object.DYNAMIC
    rootNode.addChild(createMirroredScene(loadedModelTransform))

    viewer.addEventHandler(osgViewer.HelpHandler())
    viewer.addEventHandler(osgViewer.StatsHandler())
    viewer.addEventHandler(osgGA.StateSetManipulator(rootNode.stateSet))
    viewer.setSceneData(rootNode)
    print "set scene data"

    #hint to tell viewer to request stencil buffer when setting up windows
    # osg.DisplaySettings().setMinimumNumStencilBits(8)
    osg.DisplaySettings.instance().setMinimumNumStencilBits(8);

    osgDB.writeNodeFile(rootNode, "test_reflect.osg");

    viewer.run() #we need run, because that sets up a trackballmanipulator and so we have the correct "look" into the scene.
    return 0
Exemple #6
0
# Create a 1x1 quad in XZ plane
g = osg.createTexturedQuadGeometry(osg.Vec3f(0, 0, 0), osg.Vec3f(1, 0, 0),
                                   osg.Vec3f(0, 0, 1), 0, 0, 1, 1)
g.getColorArray()[0] = osg.Vec4f(1, 1, 1,
                                 0.5)  # change color to semitransparent

# Add it to a geode
geode = osg.Geode()
geode.addDrawable(g)

# Add texture
i = osgDB.readImageFile("Images/osg256.png")
t = osg.Texture2D(i)
s = geode.stateSet
s.setTextureAttributeAndModes(0, t, osg.StateAttribute.Values.ON)

# Make sure blending is active and the geode is in the transparent (depth sorted) bin
s.setRenderingHint(osg.StateSet.TRANSPARENT_BIN)
s.setMode(osg.GL_BLEND, osg.StateAttribute.ON)

# Create viewer, add some standard handlers to it and run it
viewer = osgViewer.Viewer()
viewer.setUpViewInWindow(50, 50, 1024, 768)
viewer.addEventHandler(osgGA.StateSetManipulator(geode.stateSet))
viewer.addEventHandler(osgViewer.HelpHandler())
viewer.addEventHandler(osgViewer.StatsHandler())
viewer.setSceneData(geode)
viewer.run()
del viewer  # To cause the dtor to be called, hence the window to be destroyed.
def main(argv):

    
    arguments = osg.ArgumentParser(argv)

    # construct the viewer.
    viewer = osgViewer.Viewer(arguments)

    # set up camera manipulators
        keyswitchManipulator = osgGA.KeySwitchMatrixManipulator()

        keyswitchManipulator.addMatrixManipulator( ord("1"), "Trackball", osgGA.TrackballManipulator() )
        keyswitchManipulator.addMatrixManipulator( ord("2"), "Flight", osgGA.FlightManipulator() )
        keyswitchManipulator.addMatrixManipulator( ord("3"), "Drive", osgGA.DriveManipulator() )
        keyswitchManipulator.addMatrixManipulator( ord("4"), "Terrain", osgGA.TerrainManipulator() )

        keyForAnimationPath = ord("8")
        animationSpeed = 1.0
        while arguments.read("--speed",animationSpeed)  : 

        pathfile = str()
        while arguments.read("-p",pathfile) :
            apm = osgGA.AnimationPathManipulator(pathfile)
            if apm  or   not apm.valid() :
                apm.setTimeScale(animationSpeed)
                apm.setAnimationCompletedCallback(ReportStatsAnimationCompletedCallback())
                
                num = keyswitchManipulator.getNumMatrixManipulators()
                keyswitchManipulator.addMatrixManipulator( keyForAnimationPath, "Path", apm )
                keyswitchManipulator.selectMatrixManipulator(num)
                ++keyForAnimationPath

        viewer.setCameraManipulator( keyswitchManipulator )

    # set up event handlers 
        viewer.addEventHandler( osgViewer.StatsHandler())
        viewer.addEventHandler( osgViewer.WindowSizeHandler() )
        viewer.addEventHandler( osgGA.StateSetManipulator(viewer.getCamera().getOrCreateStateSet()) )
        viewer.addEventHandler( TexturePoolHandler() )

    ########################################/
    #
    # IncrementalCompileOperation settings
    #
    incrementalCompile = osgUtil.IncrementalCompileOperation()
    viewer.setIncrementalCompileOperation(incrementalCompile)

    if arguments.read("--force")  or  arguments.read("-f") :
        incrementalCompile.assignForceTextureDownloadGeometry()

    if arguments.read("-a") :
        incrementalCompile.setMinimumTimeAvailableForGLCompileAndDeletePerFrame(1)
        incrementalCompile.setConservativeTimeRatio(1)
        incrementalCompile.setMaximumNumOfObjectsToCompilePerFrame(100)
    elif arguments.read("-c") :
        incrementalCompile.setMinimumTimeAvailableForGLCompileAndDeletePerFrame(0.0001)
        incrementalCompile.setConservativeTimeRatio(0.01)
        incrementalCompile.setMaximumNumOfObjectsToCompilePerFrame(1)

    ########################################/
    #
    # SceneGraph processing setup
    #
    sceneGraphProcessor = SceneGraphProcessor(arguments)

    ########################################/
    #
    # Database settings
    #
    timeBetweenMerges = 2.0
    while arguments.read("--interval",timeBetweenMerges) : 

    outputPostfix = str()
    while arguments.read("-o",outputPostfix) :  OSG_NOTICE, "Set ouputPostfix to ", outputPostfix 


    typedef std.vector< str > FileNames
    fileNames = FileNames()
    for(int pos=1pos<arguments.argc()++pos)
        if  not arguments.isOption(pos) :
            fileNames.push_back(arguments[pos])

    if fileNames.empty() :
        OSG_NOTICE, "No files loaded, please specify files on commandline."
        return 1

    # load the models using a paging thread and use the incremental compile operation to
    # manage the compilation of GL objects without breaking frame.

    modelIndex = 0

    databasePagingThread = osg.OperationThread()
    databasePagingOperation = DatabasePagingOperation()

    databasePagingThread = osg.OperationThread()
    databasePagingThread.startThread()


    group = osg.Group()
    viewer.setSceneData(group)

    viewer.realize()

    filename = fileNames[modelIndex++]
    outputFilename =  str() : osgDB: if (outputPostfix.empty()) else getStrippedName(filename)+outputPostfix

    databasePagingOperation = DatabasePagingOperation(
        filename,
        outputFilename,
        sceneGraphProcessor,
        incrementalCompile)

    databasePagingThread.add(databasePagingOperation)


    timeOfLastMerge = viewer.getFrameStamp().getReferenceTime()

    while  not viewer.done() :
        viewer.frame()

        currentTime = viewer.getFrameStamp().getReferenceTime()

        if  not databasePagingOperation  and 
            modelIndex<fileNames.size()  and 
            (currentTime-timeOfLastMerge)>timeBetweenMerges :
            filename = fileNames[modelIndex++]
            outputFilename =  str() : osgDB: if (outputPostfix.empty()) else getStrippedName(filename)+outputPostfix

            databasePagingOperation = DatabasePagingOperation(
                filename,
                outputFilename,
                sceneGraphProcessor,
                incrementalCompile)

            databasePagingThread.add(databasePagingOperation)

        if databasePagingOperation  and  databasePagingOperation._modelReadyToMerge :
            OSG_NOTICE, "Merging subgraph"
            
            timeOfLastMerge = currentTime

            group.removeChildren(0,group.getNumChildren())

            group.addChild(databasePagingOperation._loadedModel)

            viewer.home()

            # we no longer need the paging operation as it's done it's job.
            databasePagingOperation = 0

            viewer.home()
def main(argv):


    
    # use an ArgumentParser object to manage the program arguments.
    arguments = osg.ArgumentParser(argv)

    arguments.getApplicationUsage().addCommandLineOption("--fbo","Use Frame Buffer Object for render to texture, where supported.")
    arguments.getApplicationUsage().addCommandLineOption("--pbuffer-rtt","Use Pixel Buffer for render to texture, where supported.")
    arguments.getApplicationUsage().addCommandLineOption("--nopds", "Don't use packed depth stencil.")
    arguments.getApplicationUsage().addCommandLineOption("--fbo-samples","")
    arguments.getApplicationUsage().addCommandLineOption("--color-samples", "")

    # construct the viewer.
    viewer = osgViewer.Viewer(arguments)

    # add stats
    viewer.addEventHandler( osgViewer.StatsHandler() )

    # if user request help write it out to cout.
    if arguments.read("-h")  or  arguments.read("--help") :
        arguments.getApplicationUsage().write(std.cout)
        return 1

    renderImplementation = osg.Camera.FRAME_BUFFER_OBJECT
    colorSamples = 0, samples = 0
    usePDS = True

    while arguments.read("--fbo") :  renderImplementation = osg.Camera.FRAME_BUFFER_OBJECT 
    while arguments.read("--pbuffer-rtt") :  renderImplementation = osg.Camera.PIXEL_BUFFER_RTT 
    while arguments.read("--nopds") :  usePDS = False  
    while arguments.read("--fbo-samples", samples) : 
    while arguments.read("--color-samples", colorSamples) : 
    

    rootNode = osg.Group()
    rootNode.getOrCreateStateSet().setMode(GL_LIGHTING, osg.StateAttribute.OFF)

    # creates texture to be rendered
    texture = osg.Texture2D()
    texture.setTextureSize(1024, 1024)
    texture.setInternalFormat(GL_RGBA)
    texture.setFilter(osg.Texture2D.MIN_FILTER, osg.Texture2D.LINEAR)
    texture.setFilter(osg.Texture2D.MAG_FILTER, osg.Texture2D.LINEAR)
    texture.setWrap(osg.Texture.WRAP_S, osg.Texture.CLAMP_TO_EDGE)
    texture.setWrap(osg.Texture.WRAP_T, osg.Texture.CLAMP_TO_EDGE)
    texture.setBorderColor(osg.Vec4(0, 0, 0, 0))

    # creates rtt camera
    rttCamera = osg.Camera()
    rttCamera.setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)
    rttCamera.setClearColor(osg.Vec4(0.0, 0.4, 0.5, 0.0))
    rttCamera.setClearStencil(0)
    rttCamera.setReferenceFrame(osg.Transform.ABSOLUTE_RF)
    rttCamera.setViewMatrix(osg.Matrixd.identity())
    rttCamera.setViewport(0, 0, 1024, 1024)
    rttCamera.setRenderOrder(osg.Camera.PRE_RENDER)
    rttCamera.setRenderTargetImplementation(renderImplementation)

    if usePDS :
        rttCamera.attach(osg.Camera.PACKED_DEPTH_STENCIL_BUFFER, GL_DEPTH_STENCIL_EXT)
    else:
        # this doesn't work on NVIDIA/Vista 64bit
        # FBO status = 0x8cd6 (FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT)
        rttCamera.attach(osg.Camera.DEPTH_BUFFER, GL_DEPTH_COMPONENT)
        rttCamera.attach(osg.Camera.STENCIL_BUFFER, GL_STENCIL_INDEX8_EXT)

    rttCamera.attach(osg.Camera.COLOR_BUFFER, texture, 0, 0, False, samples, colorSamples)
    rttCamera.setCullingMode(osg.Camera.VIEW_FRUSTUM_SIDES_CULLING)

    # creates rtt subtree
    g0 = osg.Group()
    g0.addChild(createMask())
    g0.addChild(createGeometry())
    rttCamera.addChild(g0)
    rootNode.addChild(rttCamera)

    # creates textured quad with result
    rootNode.addChild(createTextureQuad(texture))
    
    # add model to the viewer.
    viewer.setSceneData( rootNode )

    return viewer.run()


if __name__ == "__main__":
    main(sys.argv)
def main(argv):

    
    viewer = osgViewer.Viewer()
    
    # Let's get busy not  The WindowManager class is actually an osg.Switch,
    # so you can add it to (ideally) an orthographic camera and have it behave as
    # expected. Note that you create a WindowManager with a NodeMask--it is very important
    # that this be unique for picking to work properly. This also makes it possible to have
    # multiple WindowManagers each operating on their own, unique set of Window objects.
    # The final bool argument is a group of flags that introduce optional functionality
    # for the WindowManager. In our case we include the flags USE_PYTHON and USE_LUA,
    # to demonstrate (and test) their usage. Finally, we pass the temporary WM_NO_BETA_WARN
    # argument, which prevents creating the orange warning window. :) It will be shown
    # in other examples...
    wm = osgWidget.WindowManager(
        viewer,
        1280.0,
        1024.0,
        MASK_2D,
        osgWidget.WindowManager.WM_USE_LUA |
        osgWidget.WindowManager.WM_USE_PYTHON |
        osgWidget.WindowManager.WM_PICK_DEBUG
    )

    # An actual osgWidget.Window is pure virtual, so we've got to use the osgWidget.Box
    # implementation for now. At a later time, support for Tables and other kinds of
    # advanced layout Window types will be added.
    box = osgWidget.Box("box", osgWidget.Box.HORIZONTAL)

    # Now we actually attach our two types of callbacks to the box instance. The first
    # uses the simple function signature, the second uses a bound method, passing "this"
    # as the second argument to the Callback constructor.
    # Object obj

    static str data = "lol ur face not "

    #
#    box.addCallback(osgWidget.Callback(windowClicked, osgWidget.EVENT_MOUSE_PUSH, data))
#    box.addCallback(osgWidget.Callback(windowScrolled, osgWidget.EVENT_MOUSE_SCROLL))
#    box.addCallback(osgWidget.Callback(
#        Object.windowClicked,
#        obj,
#        osgWidget.EVENT_MOUSE_PUSH
#    ))
#    

    box.addCallback(CallbackObject(osgWidget.EVENT_MOUSE_PUSH))

    # Create some of our "testing" Widgets included are two Widget subclasses I made
    # during testing which I've kept around for testing purposes. You'll notice
    # that you cannot move the box using the NullWidget, and that the NotifyWidget
    # is a bit verbose. :)
    widget1 = osgWidget.NotifyWidget("widget1", 300.0, 100.0)
    widget2 = osgWidget.NullWidget("widget2", 400.0, 75.0)
    widget3 = osgWidget.Widget("widget3", 100.0, 100.0)
    # Set the colors of widget1 and widget3 to green.
    widget1.setColor(0.0, 1.0, 0.0, 1.0)
    widget1.setCanFill(True)
    widget3.setColor(0.0, 1.0, 0.0, 1.0)

    widget1.setImage(osgDB.readImageFile("Images/Saturn.TGA"), True)

    # Set the color of widget2, to differentiate it and make it sassy. This is
    # like a poor man's gradient not 
    widget2.setColor(0.9, 0.0, 0.0, 0.9, osgWidget.Widget.LOWER_LEFT)
    widget2.setColor(0.9, 0.0, 0.0, 0.9, osgWidget.Widget.LOWER_RIGHT)
    widget2.setColor(0.0, 0.0, 0.9, 0.9, osgWidget.Widget.UPPER_RIGHT)
    widget2.setColor(0.0, 0.0, 0.9, 0.9, osgWidget.Widget.UPPER_LEFT)

    # Now add our newly created widgets to our box.
    box.addWidget(widget1)
    box.addWidget(widget2)
    box.addWidget(widget3)

    # For maximum efficiency, Windows don't automatically reallocate their geometry
    # and internal positioning every time a widget is added. Thus, we either have to
    # call the WindowManger.resizeAllWindows method or manually call
    # Window.resize when we're ready.
    box.resize()

    # Now, lets clone our existing box and create a copy of of it, also adding that
    # to the WindowManager. This demonstrates the usages of OSG's .clone() support,
    # though that is abstracted by our META_UIObject macro.
    boxCopy = osg.clone(box, "newBox", osg.CopyOp.DEEP_COPY_ALL)

    # Move our copy to make it visible.
    boxCopy.setOrigin(0.0, 125.0)

    boxCopy.getByName("widget1").setColor(0.5, 0.0, 1.0, 1.0)
    boxCopy.getByName("widget3").setColor(0.5, 0.0, 1.0, 1.0)

    # Add the successfully created Box (if we get this far) into the WindowManager, so
    # that they can receive events.
    wm.addChild(box)
    wm.addChild(boxCopy)

    # Now, ask our box to be 100% the width of the WindowManager.
    boxCopy.resizePercent(100.0, 0.0)

    # Here we demonstrate the use of osgWidget/io_utils. This is really only useful for
    # debugging at the moment.
    # print *box, *boxCopy

    # Setup our OSG objects for our scene note the use of the utility function
    # createOrthoCamera, which is just a helper for setting up a proper viewing area.
    # An alternative (and a MUCH easier alternative at that not ) is to
    # simply use the createParentOrthoCamera method of the WindowManager class,
    # which will wrap the calls to createOrthoCamera and addChild for us not  Check out
    # some of the other examples to see this in action...
    group = osg.Group()
    camera = osgWidget.createOrthoCamera(1280.0, 1024.0)
    model = osgDB.readNodeFile("cow.osgt")

    # Add our event handler is this better as a MatrixManipulator? Add a few other
    # helpful ViewerEventHandlers.
    viewer.addEventHandler(osgWidget.MouseHandler(wm))
    viewer.addEventHandler(osgWidget.KeyboardHandler(wm))
    viewer.addEventHandler(osgWidget.ResizeHandler(wm, camera))
    viewer.addEventHandler(osgWidget.CameraSwitchHandler(wm, camera))
    viewer.addEventHandler(osgViewer.StatsHandler())
    viewer.addEventHandler(osgViewer.WindowSizeHandler())
    viewer.addEventHandler(osgGA.StateSetManipulator(
        viewer.getCamera().getOrCreateStateSet()
    ))

    # Set our first non-UI node to be something other than the mask we created our
    # WindowManager with to avoid picking.
    # TODO: Do I need to create a mechanism for doing this automatically, or should
    # that be the responsibility of the users of osgWidget?
    model.setNodeMask(MASK_3D)

    # Add the WindowManager instance to the 2D camera. This isn't strictly necessary,
    # and you can get some cool results putting the WindowManager directly into a
    # 3D scene. This is not necessary if you use WindowManager.createParentOrthoCamera.
    camera.addChild(wm)

    # Add our camera and a testing 3D model to the scene.
    group.addChild(camera)
    group.addChild(model)

    # Here we show how to both run simple strings of code AND run entire files. These
    # assume that you're running the osgwidgetwindow example from the build directory,
    # otherwise you'll need to adjust the file path below in the call to runFile().
    wm.getLuaEngine().eval("window = osgwidget.newWindow()")
    wm.getLuaEngine().runFile("osgWidget/osgwidgetwindow.lua")

    wm.getPythonEngine().eval("import osgwidget")
    wm.getPythonEngine().runFile("osgWidget/osgwidgetwindow.py")

    viewer.setUpViewInWindow(0, 0, 1280, 1024)
    viewer.setSceneData(group)

    #
#    cameras = osgViewer.Viewer.Cameras() 
#    viewer.getCameras(cameras)
#    c = cameras[0]
#    s = osg.Matrix.scale(1.0, -1.0, 1.0)
#    c.setProjectionMatrix(s * c.getProjectionMatrix())
#    

    return viewer.run()
Exemple #10
0
                osgDB.AuthenticationDetails(username, password)
            )

    viewer.setCameraManipulator(osgGA.TrackballManipulator)()

    # add the state manipulator
    viewer.addEventHandler( osgGA.StateSetManipulator(viewer.getCamera().getOrCreateStateSet()) )

    # add the thread model handler
    viewer.addEventHandler(osgViewer.ThreadingHandler)()

    # add the window size toggle handler
    viewer.addEventHandler(osgViewer.WindowSizeHandler)()

    # add the stats handler
    statsHandler = osgViewer.StatsHandler()
    viewer.addEventHandler(statsHandler)

    initUserStats(statsHandler)

    # add the help handler
    viewer.addEventHandler(osgViewer.HelpHandler(arguments.getApplicationUsage()))

    # load the data
    loadedModel = osgDB.readNodeFiles(arguments)
    if  not loadedModel :
        print arguments.getApplicationName(), ": No data loaded"
        return 1

    # any option left unread are converted into errors to write out later.
    arguments.reportRemainingOptionsAsUnrecognized()
def main(argv):

    
    arguments = osg.ArgumentParser(argv)
    arguments.getApplicationUsage().setApplicationName(arguments.getApplicationName())
    arguments.getApplicationUsage().setDescription(arguments.getApplicationName()+" is an example for viewing osgAnimation animations.")
    arguments.getApplicationUsage().addCommandLineOption("-h or --help","List command line options.")
    arguments.getApplicationUsage().addCommandLineOption("--drawbone","draw helps to display bones.")

    if arguments.read("-h")  or  arguments.read("--help") :
        arguments.getApplicationUsage().write(std.cout, osg.ApplicationUsage.COMMAND_LINE_OPTION)
        return 0

    if arguments.argc()<=1 :
        arguments.getApplicationUsage().write(std.cout, osg.ApplicationUsage.COMMAND_LINE_OPTION)
        return 1

    drawBone = False
    if arguments.read("--drawbone") :
        drawBone = True

    viewer = osgViewer.Viewer(arguments)
    group = osg.Group()

    node = dynamic_cast<osg.Group*>(osgDB.readNodeFiles(arguments)) #dynamic_cast<osgAnimation.AnimationManager*>(osgDB.readNodeFile(psr[1]))
    if  not node :
        print arguments.getApplicationName(), ": No data loaded"
        return 1

    # Set our Singleton's model.
    finder = AnimationManagerFinder()
    node.accept(finder)
    if finder._am.valid() : 
        node.setUpdateCallback(finder._am)
        AnimtkViewerModelController.setModel(finder._am)
     else:
        osg.notify(osg.WARN), "no osgAnimation.AnimationManagerBase found in the subgraph, no animations available"

    if drawBone : 
        osg.notify(osg.INFO), "Add Bones Helper"
        addHelper = AddHelperBone()
        node.accept(addHelper)
    node.addChild(createAxis())

    gui = AnimtkViewerGUI(viewer, WIDTH, HEIGHT, 0x1234)
    camera = gui.createParentOrthoCamera()

    node.setNodeMask(0x0001)

    group.addChild(node)
    group.addChild(camera)

    viewer.addEventHandler(AnimtkKeyEventHandler())
    viewer.addEventHandler(osgViewer.StatsHandler())
    viewer.addEventHandler(osgViewer.WindowSizeHandler())
    viewer.addEventHandler(osgGA.StateSetManipulator(viewer.getCamera().getOrCreateStateSet()))
    viewer.addEventHandler(osgWidget.MouseHandler(gui))
    viewer.addEventHandler(osgWidget.KeyboardHandler(gui))
    viewer.addEventHandler(osgWidget.ResizeHandler(gui, camera))
    viewer.setSceneData(group)

    viewer.setUpViewInWindow(40, 40, WIDTH, HEIGHT)

    return viewer.run()