Exemple #1
0
 def initializeGL (self):
     """initializeGL the context and create the osgViewer, also set manipulator and event handler """       
     self.gw = self.createContext()
     self.viewer = self.createViewer()
     #init the default eventhandler
     self.viewer.setCameraManipulator(osgGA.TrackballManipulator())
     self.viewer.addEventHandler(osgViewer.StatsHandler())
     self.viewer.addEventHandler(osgViewer.HelpHandler())
     QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout ()"), self.updateGL)
     self.timer.start(0)
Exemple #2
0
 def createViewer(self):
     """create a osgViewer.Viewer and set the viewport, camera and previously created graphical context """
     global viewerFactory
     viewer = viewerFactory()
     #init the default eventhandler
     #        self.viewer.setCameraManipulator(osgGA.TrackballManipulator())
     viewer.addEventHandler(osgViewer.StatsHandler())
     viewer.addEventHandler(osgViewer.HelpHandler())
     viewer.getUpdateVisitor().setTraversalMask(UPDATE_MASK)
     self.resetCamera(viewer)
     return viewer
    def __init__(self, glconfig, viewer=None, window=None):
        gtk.DrawingArea.__init__(self)

        # Set OpenGL-capability to the drawing area
        self.set_gl_capability(glconfig)

        # Connect the relevant signals.
        self.connect_after('realize', self._on_realize)
        self.connect('configure_event', self._on_configure_event)
        self.connect('expose_event', self._on_expose_event)
        self.connect("key_press_event", self._on_key_press_event)

        self.add_events(gtk.gdk.BUTTON_PRESS_MASK
                        | gtk.gdk.BUTTON_RELEASE_MASK)

        self.__motion_events = 0
        self.__motion_events |= gtk.gdk.BUTTON_MOTION_MASK
        self.__motion_events |= gtk.gdk.POINTER_MOTION_MASK
        self.add_events(self.__motion_events)
        self.connect('motion_notify_event', self._on_mouse_event)
        self.connect("button_press_event", self._on_mouse_event)
        self.connect("button_release_event", self._on_mouse_event)

        #experimental: Stereo in a window
        #self.ds = osg.DisplaySettings_instance()
        #self.ds.setStereo(True)
        #self.ds.setStereoMode(osg.DisplaySettings.QUAD_BUFFER)

        if viewer is None:
            self.viewer = osgViewer.Viewer()
        else:
            self.viewer = viewer
        self.osgwindow = self.viewer.setUpViewerAsEmbeddedInWindow(
            0, 0, 200, 200)
        # one could try using a pythonic alternative:
        #  self.osgwindow = self.setup_osgwindow(0,0,200,200)
        self.viewer.setCameraManipulator(osgGA.TrackballManipulator())

        self.viewer.addEventHandler(osgViewer.StatsHandler())
        self.viewer.addEventHandler(osgViewer.HelpHandler())

        self.rootnode = osg.MatrixTransformRef(osg.MatrixTransform())
        self.viewer.setSceneData(self.rootnode.get())

        self._x, self._y = 0, 0
	return layer

# create a root node
root = osg.Group()

# only use Python path
#osgDB.Registry.instance().setLibraryFilePathList(sys.path)

# create a viewer
viewer = osgViewer.Viewer()

# add some convenience handlers
viewer.addEventHandler(osgViewer.WindowSizeHandler())
viewer.addEventHandler(osgViewer.StatsHandler())
viewer.addEventHandler(osgViewer.ThreadingHandler())
viewer.addEventHandler(osgViewer.HelpHandler())

# set the scene root
viewer.setSceneData(root)

# preload plugins
video_id = osgART.PluginManager.instance().load("osgart_video_artoolkit2")	
tracker_id = osgART.PluginManager.instance().load("osgart_tracker_artoolkit2")

# create a video source (move to settings)
video = osgART.Video.cast(osgART.PluginManager.instance().get(video_id))

# open the video
video.open()

# tracker