Example #1
0
 def getBoundingBox(self):
     """Get the last-known scenegraph bounding-box"""
     from OpenGLContext.scenegraph import boundingvolume
     return boundingvolume.AABoundingBox(
         center=(0, 0, 0),
         size=(20, 20, 20),
     )
Example #2
0
 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'), ),
     )
Example #3
0
def testExclusion():
    """Test that bounding volumes are properly excluded"""
    f = frustum.Frustum( planes = [
        utilities.pointNormal2Plane( (0,0,0), (-1,0,0) ), # through origin, facing left
    ])
    v = boundingvolume.AABoundingBox(
        center = (-3,0,0),
        size = (1,1,1),
    )
    assert v.visible( f, identity(4,'f'))
    v = boundingvolume.AABoundingBox(
        center = (3,0,0),
        size = (1,1,1),
    )
    assert not v.visible( f, identity(4,'f'))
    # test right at the border of the box...
    v = boundingvolume.AABoundingBox(
        center = (.5,0,0),
        size = (1,1,1),
    )
    assert v.visible( f, identity(4,'f'))
Example #4
0
 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'), ),
     )
Example #5
0
    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')),
        )