Beispiel #1
0
def main(argv):

    

    viewer = osgViewer.Viewer()

    wm = osgWidget.WindowManager(
        viewer,
        1280.0,
        1024.0,
        MASK_2D,
        osgWidget.WindowManager.WM_PICK_DEBUG
    )

    fontSize = 20
    font = "fonts/arial.ttf"
    buttonTheme = "osgWidget/theme-8-shadow.png"
    borderTheme = "osgWidget/theme-8.png"

    message = MessageBox()
    message.create(borderTheme, 
                   buttonTheme,
                   "Error - Critical",
                   LABEL1,
                   "Quit",
                   font,
                   fontSize)

    alpha = AlphaSetterVisitor(.8)
    message.getWindow().accept(alpha)

    wm.addChild(message.getWindow())

    # center
    w = wm.getWidth()
    h = wm.getHeight()
    ww = message.getWindow().getWidth()
    hw = message.getWindow().getHeight()
    ox = (w - ww) / 2
    oy = (h - hw) / 2
    message.getWindow().setPosition(osgWidget.Point(
        osg.round(ox), osg.round(oy), message.getWindow().getPosition()[2])
    )
#    frame.resizeAdd(30, 30)

#    alpha = AlphaSetterVisitor(.8)
#    frame.accept(alpha)
    return osgWidget.createExample(viewer, wm) #osgDB.readNodeFile("cow.osgt"))
Beispiel #2
0
        , _imageStream(is)
        , _fps(0)
        , _lastData(NULL)
        , _lastDataTimeStamp(0)

    def setImageStream(is):

         _imageStream = is 

    virtual void update(osg.NodeVisitor* nv, osg.Drawable*)
        if _text.valid()  and  _imageStream.valid() :
            if _imageStream.data()  not = _lastData :
                dt = nv.getFrameStamp().getReferenceTime() - _lastDataTimeStamp

                _fps = 0.9 * _fps + 0.1 * (1 / dt)
                _fps = osg.round(10 * _fps) / 10.0

                _lastDataTimeStamp = nv.getFrameStamp().getReferenceTime()
                _lastData = _imageStream.data()

            ss = std.ostringstream()
            ss, _imageStream.s(), "x", _imageStream.t(), " | ", _fps, "fps"
            ss, " | len: ", osg.round(_imageStream.getLength()*10) / 10.0
            ss, " | cur: ", osg.round(_imageStream.getCurrentTime()*10) / 10.0
            if _imageStream.getStatus() == osg.ImageStream.PLAYING :
                ss, " | playing"
            else:
                ss, " | paused"
                _fps = 0
            if _imageStream.getLoopingMode() == osg.ImageStream.LOOPING : 
                ss, " | looping"