def boundingVolume( self, mode ): """Calculate the bounding volume for this node The bounding volume for a grouping node is the union of it's children's nodes, and is dependent on the children of the node's bounding nodes, as well as the children field of the node. """ current = boundingvolume.getCachedVolume( self ) if current is not None: return current # need to create a new volume and make it depend # on the appropriate fields... volumes = [] dependencies = [(self,'children')] unbounded = 0 for child in self.children: try: if hasattr(child, 'boundingVolume'): volume = child.boundingVolume(mode) volumes.append( volume ) dependencies.append( (volume, None) ) else: unbounded = 1 break except boundingvolume.UnboundedObject: unbounded = 1 try: volume = boundingvolume.BoundingBox.union( volumes, None ) except boundingvolume.UnboundedObject: unbounded = 1 if unbounded: volume = boundingvolume.UnboundedVolume() return boundingvolume.cacheVolume( self, volume, dependencies )
def boundingVolume(self, mode): """Calculate the bounding volume for this node The bounding volume for a grouping node is the union of it's children's nodes, and is dependent on the children of the node's bounding nodes, as well as the children field of the node. """ current = boundingvolume.getCachedVolume(self) if current is not None: return current # need to create a new volume and make it depend # on the appropriate fields... volumes = [] dependencies = [(self, 'choice'), (self, 'whichChoice')] unbounded = 0 for child in self.renderedChildren(): try: if hasattr(child, 'boundingVolume'): volume = child.boundingVolume(mode) volumes.append(volume) dependencies.append((volume, None)) else: unbounded = 1 break except boundingvolume.UnboundedObject: unbounded = 1 try: volume = boundingvolume.BoundingBox.union(volumes, None) except boundingvolume.UnboundedObject: unbounded = 1 if unbounded: volume = boundingvolume.UnboundedVolume() return boundingvolume.cacheVolume(self, volume, dependencies)
def boundingVolume(self, mode): """Create a bounding-volume object for this node""" from OpenGLContext.scenegraph import boundingvolume current = boundingvolume.getCachedVolume(self) if current: return current return boundingvolume.cacheVolume( self, boundingvolume.AABoundingBox(size=self.size, ), ((self, 'size'), ), )
def boundingVolume(self, mode): """Create a bounding-volume object for this node""" from OpenGLContext.scenegraph import boundingvolume current = boundingvolume.getCachedVolume(self) if current: return current return boundingvolume.cacheVolume( self, boundingvolume.AABoundingBox( # This vastly overestimates the size! size=[self.size * 2, self.size * 2, self.size * 2], ), ((self, 'size'), ), )
def boundingVolume( self, mode ): """Create a bounding-volume object for this node""" from OpenGLContext.scenegraph import boundingvolume current = boundingvolume.getCachedVolume( self ) if current: return current return boundingvolume.cacheVolume( self, boundingvolume.AABoundingBox( size = self.size, ), ( (self, 'size'), ), )
def boundingVolume( self, mode ): """Create a bounding-volume object for this node""" from OpenGLContext.scenegraph import boundingvolume current = boundingvolume.getCachedVolume( self ) if current: return current return boundingvolume.cacheVolume( self, boundingvolume.AABoundingBox( # This vastly overestimates the size! size = [self.size*2,self.size*2,self.size*2], ), ( (self, 'size'), ), )
def boundingVolume(self, mode=None): """Create a bounding-volume object for this node In this case we use the AABoundingBox, despite the presence of the bounding sphere implementation. This is just a preference issue, I'm using AABoundingBox everywhere else, and want the sphere to interoperate properly. """ current = boundingvolume.getCachedVolume(self) if current: return current radius = self.radius return boundingvolume.cacheVolume( self, boundingvolume.AABoundingBox(size=(radius * 2, self.height, radius * 2), ), ((self, 'radius'), (self, 'height')), )
def boundingVolume( self, mode=None ): """Create a bounding-volume object for this node In this case we use the AABoundingBox, despite the presence of the bounding sphere implementation. This is just a preference issue, I'm using AABoundingBox everywhere else, and want the sphere to interoperate properly. """ current = boundingvolume.getCachedVolume( self ) if current: return current return boundingvolume.cacheVolume( self, boundingvolume.AABoundingBox( size = (self.radius*2,self.radius*2,self.radius*2), ), ( (self, 'radius'), ), )
def boundingVolume(self, mode): """Calculate bounding volume of this attribute's current values""" current = boundingvolume.getCachedVolume(self) if current: return current try: buffer = self.bufferView() except AttributeError as err: bv = boundingvolume.BoundingVolume() else: bv = boundingvolume.AABoundingBox.fromPoints(buffer) return boundingvolume.cacheVolume( self, bv, ( (self, None), (self, 'buffer'), (self, 'offset'), (self, 'stride'), (self.buffer, 'buffer'), ), )
def boundingVolume( self, mode ): """Create a bounding-volume object for this node This is our geometry's boundingVolume, with the addition that any dependent volume must be dependent on our geometry field. """ current = boundingvolume.getCachedVolume( self ) if current: return current if self.geometry: if hasattr( self.geometry, 'boundingVolume'): volume = self.geometry.boundingVolume(mode) else: # is considered always visible volume = boundingvolume.UnboundedVolume() else: # is never visible volume = boundingvolume.BoundingVolume() return boundingvolume.cacheVolume( self, volume, ((self, 'geometry'),(volume,None)), )
def boundingVolume( self, mode ): """Create a bounding-volume object for this node This is our geometry's boundingVolume, with the addition that any dependent volume must be dependent on our geometry field. """ current = boundingvolume.getCachedVolume( self ) if current: return current if self.geometry: if hasattr( self.geometry, 'boundingVolume'): volume = self.geometry.boundingVolume(mode) else: # is considered always visible volume = boundingvolume.UnboundedVolume() else: # is never visible volume = boundingvolume.BoundingVolume() return boundingvolume.cacheVolume( self, volume, ((self, 'geometry'),(volume,None)), )
def OnInit( self ): """Load the image on initial load of the application""" print """Each dot is a request (y shows data transferred)""" self.log_queue = Queue.Queue( maxsize=self.dataPoints ) self.coordinate = Coordinate( point = [(0,0,0)]*self.dataPoints, ) # should *not* be necessary, but is, to prevent a cached # bounding volume from dropping the graph boundingvolume.cacheVolume( self.coordinate, boundingvolume.UnboundedVolume(), ) # just an arbitrary format/style for the text self.fontstyle = FontStyle( family='SANS', format = 'bitmap', justify = 'BEGIN', ) # self.color = Color( color = [1.0,0.0,0.0], ) self.data_slider = Transform( translation=(0,0,0), scale = (1/600.,1,1,), children = [ Shape( appearance = Appearance( texture = ImageTexture( url='_particle.png' ), material = Material( diffuseColor = [1,0,0], ) ), geometry = PointSet( coord = self.coordinate, minSize = 5.0, maxSize = 5.0, ), ), ], ) self.axes = Transform( children = [ Transform( translation = (.25,coord,0), children = [ Shape( geometry = Text( string = [label], fontStyle = self.fontstyle, )) ], ) for (coord,label) in [ (0,'0B'), (3,'1KB'), (6,'1MB'), (9,'1GB'), ] ] + [ Transform( translation = (coord,-.75,0), children = [ Shape( geometry = Text( string = [label], fontStyle = self.fontstyle, )) ], ) for (coord,label)in [ (0,'now'), (-1200*self.data_slider.scale[0],'-20m'), (-2400*self.data_slider.scale[0],'-40m'), (-3600*self.data_slider.scale[0],'-60m'), ] ] ) self.transform = Transform( translation = (3,-2,0), children = [ self.data_slider, self.axes, ] ) self.sg = sceneGraph( children = [ self.transform, ], ) self.time = Timer( duration = 1, repeating = 1 ) self.time.addEventHandler( "fraction", self.OnTimerFraction ) self.time.register (self) self.time.start () thread = threading.Thread( target = log_reader, args=('epa-http.txt',self.log_queue)) thread.setDaemon(True) thread.start()
def boundingVolume( self, mode ): """Calculate bounding volume of this attribute's current values""" current = boundingvolume.getCachedVolume( self ) if current: return current try: buffer = self.bufferView() except AttributeError, err: bv = boundingvolume.BoundingVolume() else: bv = boundingvolume.AABoundingBox.fromPoints( buffer ) return boundingvolume.cacheVolume( self, bv, ( (self,None), (self,'buffer'), (self,'offset'), (self,'stride'), (self.buffer,'buffer'), ), ) class _Uniform( object ): """Uniform common operations""" warned = False def location( self, shader, mode ): """Get our location (-1 if not defined/used)""" return shader.getLocation( mode, self.name, uniform=True ) def currentValue( self, shader, mode ): """Retrieve the current value for this item
"""Calculate bounding volume of this attribute's current values""" current = boundingvolume.getCachedVolume(self) if current: return current try: buffer = self.bufferView() except AttributeError, err: bv = boundingvolume.BoundingVolume() else: bv = boundingvolume.AABoundingBox.fromPoints(buffer) return boundingvolume.cacheVolume( self, bv, ( (self, None), (self, 'buffer'), (self, 'offset'), (self, 'stride'), (self.buffer, 'buffer'), ), ) class _Uniform(object): """Uniform common operations""" warned = False def location(self, shader, mode): """Get our location (-1 if not defined/used)""" return shader.getLocation(mode, self.name, uniform=True)
def OnInit(self): """Load the image on initial load of the application""" print """Each dot is a request (y shows data transferred)""" self.log_queue = Queue.Queue(maxsize=self.dataPoints) self.coordinate = Coordinate(point=[(0, 0, 0)] * self.dataPoints, ) # should *not* be necessary, but is, to prevent a cached # bounding volume from dropping the graph boundingvolume.cacheVolume( self.coordinate, boundingvolume.UnboundedVolume(), ) # just an arbitrary format/style for the text self.fontstyle = FontStyle( family='SANS', format='bitmap', justify='BEGIN', ) # self.color = Color(color=[1.0, 0.0, 0.0], ) self.data_slider = Transform( translation=(0, 0, 0), scale=( 1 / 600., 1, 1, ), children=[ Shape( appearance=Appearance( texture=ImageTexture(url='_particle.png'), material=Material(diffuseColor=[1, 0, 0], )), geometry=PointSet( coord=self.coordinate, minSize=5.0, maxSize=5.0, ), ), ], ) self.axes = Transform(children=[ Transform( translation=(.25, coord, 0), children=[ Shape(geometry=Text( string=[label], fontStyle=self.fontstyle, )) ], ) for (coord, label) in [ (0, '0B'), (3, '1KB'), (6, '1MB'), (9, '1GB'), ] ] + [ Transform( translation=(coord, -.75, 0), children=[ Shape(geometry=Text( string=[label], fontStyle=self.fontstyle, )) ], ) for (coord, label) in [ (0, 'now'), (-1200 * self.data_slider.scale[0], '-20m'), (-2400 * self.data_slider.scale[0], '-40m'), (-3600 * self.data_slider.scale[0], '-60m'), ] ]) self.transform = Transform(translation=(3, -2, 0), children=[ self.data_slider, self.axes, ]) self.sg = sceneGraph(children=[ self.transform, ], ) self.time = Timer(duration=1, repeating=1) self.time.addEventHandler("fraction", self.OnTimerFraction) self.time.register(self) self.time.start() thread = threading.Thread(target=log_reader, args=('epa-http.txt', self.log_queue)) thread.setDaemon(True) thread.start()