예제 #1
0
    def OnInit(self):
        """Load the image on initial load of the application"""
        print """This demo loads a VRML97 scenegraph and modifies
the rotation of the transform which contains one of the two boxes.
The ROUTE in the scene transmits this rotational change to the
transform which contains the other box."""
        self.sg = Loader.load(os.path.join("wrls", "box.wrl"))
        self.trans = self.sg.getDEF("Box01")
        self.time = Timer(duration=8.0, repeating=1)
        self.time.addEventHandler("fraction", self.OnTimerFraction)
        self.time.register(self)
        self.time.start()
예제 #2
0
    def OnInit( self ):
        """Load the image on initial load of the application"""
        print """This demo loads a VRML97 scenegraph and modifies
the rotation of the transform which contains one of the two boxes.
The ROUTE in the scene transmits this rotational change to the
transform which contains the other box."""
        self.sg = Loader.load( os.path.join("wrls","box.wrl") )
        self.trans = self.sg.getDEF( "Box01" )
        self.time = Timer( duration = 8.0, repeating = 1 )
        self.time.addEventHandler( "fraction", self.OnTimerFraction )
        self.time.register (self)
        self.time.start ()
예제 #3
0
def saveSurfacePickle(fileName):
    """Extracts triangular faces from WRL file and saves them as a pickle."""
    in_sg = Loader.load(fileName + ".wrl")
    shapes, transforms = findShapes(in_sg)
    V, F = extractPolys(shapes, transforms)
    print(
        "Done vertices and faces extraction from WRL file (Connolly surface).")
    surfaceTrianglesWRL = []
    for i in range(0, len(F)):
        temp = []
        for j in F[i]:
            temp.append(tuple(V[j]))
        surfaceTrianglesWRL.append(temp)

    # Save pickle with data
    with open(fileName + ".pkl", "w") as f:
        pickle.dump(surfaceTrianglesWRL, f)
    print("Saved Connolly surface WRL triangular faces pickle.")
예제 #4
0
    def loadBackground(self, url, contexts=()):
        """Load an image from the given url in the background

        url -- SF or MFString URL to load relative to the
            node's root's baseURL

        On success:
            Sets the resulting PIL image to the
            client's image property (triggering an un-caching
            and re-compile if there was a previous image).

            if contexts, iterate through the list calling
            context.triggerRedraw(1)
        """
        try:
            from OpenGLContext.loaders.loader import Loader
        except ImportError:
            pass
        else:
            for u in url:
                try:
                    baseNode = protofunctions.root(self)
                    if baseNode:
                        baseURI = baseNode.baseURI
                    else:
                        baseURI = None

                    result = Loader.load(u, baseURL=baseURI)
                except IOError:
                    pass
                else:
                    print 'loaded', u
                    self.scenegraph = result
                    for context in contexts:
                        c = context()
                        if c:
                            c.triggerRedraw(1)
                    return
        warnings.warn(
            """Unable to load any scene from the url %s for the node %s""" %
            (url, str(self)))
예제 #5
0
    def loadBackground( self, url, contexts=() ):
        """Load an image from the given url in the background

        url -- SF or MFString URL to load relative to the
            node's root's baseURL

        On success:
            Sets the resulting PIL image to the
            client's image property (triggering an un-caching
            and re-compile if there was a previous image).

            if contexts, iterate through the list calling
            context.triggerRedraw(1)
        """
        try:
            from OpenGLContext.loaders.loader import Loader
        except ImportError:
            pass
        else:
            for u in url:
                try:
                    baseNode = protofunctions.root(self)
                    if baseNode:
                        baseURI = baseNode.baseURI
                    else:
                        baseURI = None
                    
                    result = Loader.load( u, baseURL = baseURI )
                except IOError:
                    pass
                else:
                    print 'loaded', u
                    self.scenegraph = result
                    for context in contexts:
                        c = context()
                        if c:
                            c.triggerRedraw(1)
                    return
        warnings.warn( """Unable to load any scene from the url %s for the node %s"""%( url, str(self)))
        
예제 #6
0
 def load(self, filename):
     """Load given url, replacing current scenegraph"""
     self.sg = Loader.load(filename)
예제 #7
0
 def OnInit( self ):
     """Load the image on initial load of the application"""
     self.sg = Loader.load( os.path.join("wrls","timesensor.wrl") )
예제 #8
0
 def OnInit(self):
     """Load the image on initial load of the application"""
     self.sg = Loader.load(os.path.join("wrls", "timesensor.wrl"))
예제 #9
0
 def load( self, filename ):
     """Load given url, replacing current scenegraph"""
     self.sg = Loader.load( filename )