|
@@ -2210,9 +2210,7 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
|
|
|
|
|
# If oobeMode was never set, set it to false and create the
|
|
# If oobeMode was never set, set it to false and create the
|
|
|
# structures we need to implement OOBE.
|
|
# structures we need to implement OOBE.
|
|
|
- try:
|
|
|
|
|
- self.oobeMode
|
|
|
|
|
- except:
|
|
|
|
|
|
|
+ if not hasattr(self, 'oobeMode'):
|
|
|
self.oobeMode = 0
|
|
self.oobeMode = 0
|
|
|
|
|
|
|
|
self.oobeCamera = self.hidden.attachNewNode('oobeCamera')
|
|
self.oobeCamera = self.hidden.attachNewNode('oobeCamera')
|
|
@@ -2227,12 +2225,15 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
self.oobe2cam.node().setNode(self.oobeCameraTrackball.node())
|
|
self.oobe2cam.node().setNode(self.oobeCameraTrackball.node())
|
|
|
|
|
|
|
|
self.oobeVis = loader.loadModel('models/misc/camera', okMissing = True)
|
|
self.oobeVis = loader.loadModel('models/misc/camera', okMissing = True)
|
|
|
|
|
+ if not self.oobeVis:
|
|
|
|
|
+ # Sometimes we have default-model-extension set to
|
|
|
|
|
+ # egg, but the file might be a bam file.
|
|
|
|
|
+ self.oobeVis = loader.loadModel('models/misc/camera.bam', okMissing = True)
|
|
|
if not self.oobeVis:
|
|
if not self.oobeVis:
|
|
|
self.oobeVis = NodePath('oobeVis')
|
|
self.oobeVis = NodePath('oobeVis')
|
|
|
self.oobeVis.node().setFinal(1)
|
|
self.oobeVis.node().setFinal(1)
|
|
|
self.oobeVis.setLightOff(1)
|
|
self.oobeVis.setLightOff(1)
|
|
|
self.oobeCullFrustum = None
|
|
self.oobeCullFrustum = None
|
|
|
- self.oobeCullFrustumVis = None
|
|
|
|
|
|
|
|
|
|
self.accept('oobe-down', self.__oobeButton, extraArgs = [''])
|
|
self.accept('oobe-down', self.__oobeButton, extraArgs = [''])
|
|
|
self.accept('oobe-repeat', self.__oobeButton, extraArgs = ['-repeat'])
|
|
self.accept('oobe-repeat', self.__oobeButton, extraArgs = ['-repeat'])
|
|
@@ -2242,7 +2243,7 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
# Disable OOBE mode.
|
|
# Disable OOBE mode.
|
|
|
if self.oobeCullFrustum != None:
|
|
if self.oobeCullFrustum != None:
|
|
|
# First, disable OOBE cull mode.
|
|
# First, disable OOBE cull mode.
|
|
|
- self.oobeCull()
|
|
|
|
|
|
|
+ self.oobeCull(cam = cam)
|
|
|
|
|
|
|
|
if self.oobeVis:
|
|
if self.oobeVis:
|
|
|
self.oobeVis.reparentTo(self.hidden)
|
|
self.oobeVis.reparentTo(self.hidden)
|
|
@@ -2313,48 +2314,39 @@ class ShowBase(DirectObject.DirectObject):
|
|
|
# Transmit other buttons.
|
|
# Transmit other buttons.
|
|
|
messenger.send(button + suffix)
|
|
messenger.send(button + suffix)
|
|
|
|
|
|
|
|
- def oobeCull(self):
|
|
|
|
|
|
|
+ def oobeCull(self, cam = None):
|
|
|
"""
|
|
"""
|
|
|
While in OOBE mode (see above), cull the viewing frustum as if
|
|
While in OOBE mode (see above), cull the viewing frustum as if
|
|
|
it were still attached to our original camera. This allows us
|
|
it were still attached to our original camera. This allows us
|
|
|
to visualize the effectiveness of our bounding volumes.
|
|
to visualize the effectiveness of our bounding volumes.
|
|
|
"""
|
|
"""
|
|
|
# First, make sure OOBE mode is enabled.
|
|
# First, make sure OOBE mode is enabled.
|
|
|
- try:
|
|
|
|
|
- if not self.oobeMode:
|
|
|
|
|
- self.oobe()
|
|
|
|
|
- except:
|
|
|
|
|
- self.oobe()
|
|
|
|
|
|
|
+ if not getattr(self, 'oobeMode', False):
|
|
|
|
|
+ self.oobe(cam = cam)
|
|
|
|
|
|
|
|
if self.oobeCullFrustum == None:
|
|
if self.oobeCullFrustum == None:
|
|
|
# Enable OOBE culling.
|
|
# Enable OOBE culling.
|
|
|
pnode = LensNode('oobeCull')
|
|
pnode = LensNode('oobeCull')
|
|
|
pnode.setLens(self.camLens)
|
|
pnode.setLens(self.camLens)
|
|
|
|
|
+ pnode.showFrustum()
|
|
|
self.oobeCullFrustum = self.camera.attachNewNode(pnode)
|
|
self.oobeCullFrustum = self.camera.attachNewNode(pnode)
|
|
|
|
|
|
|
|
- # Create a visible representation of the frustum.
|
|
|
|
|
- geom = self.camLens.makeGeometry()
|
|
|
|
|
- if geom != None:
|
|
|
|
|
- gn = GeomNode('frustum')
|
|
|
|
|
- gn.addGeom(geom)
|
|
|
|
|
- self.oobeCullFrustumVis = self.oobeVis.attachNewNode(gn)
|
|
|
|
|
-
|
|
|
|
|
# Tell the camera to cull from here instead of its own
|
|
# Tell the camera to cull from here instead of its own
|
|
|
# origin.
|
|
# origin.
|
|
|
- for cam in base.camList:
|
|
|
|
|
- cam.node().setCullCenter(self.oobeCullFrustum)
|
|
|
|
|
|
|
+ for c in base.camList:
|
|
|
|
|
+ c.node().setCullCenter(self.oobeCullFrustum)
|
|
|
|
|
+ for c in cam.findAllMatches('**/+Camera'):
|
|
|
|
|
+ c.node().setCullCenter(self.oobeCullFrustum)
|
|
|
else:
|
|
else:
|
|
|
# Disable OOBE culling.
|
|
# Disable OOBE culling.
|
|
|
|
|
|
|
|
- for cam in base.camList:
|
|
|
|
|
- cam.node().setCullCenter(NodePath())
|
|
|
|
|
|
|
+ for c in base.camList:
|
|
|
|
|
+ c.node().setCullCenter(NodePath())
|
|
|
|
|
+ for c in cam.findAllMatches('**/+Camera'):
|
|
|
|
|
+ c.node().setCullCenter(NodePath())
|
|
|
self.oobeCullFrustum.removeNode()
|
|
self.oobeCullFrustum.removeNode()
|
|
|
self.oobeCullFrustum = None
|
|
self.oobeCullFrustum = None
|
|
|
|
|
|
|
|
- if self.oobeCullFrustumVis != None:
|
|
|
|
|
- self.oobeCullFrustumVis.removeNode()
|
|
|
|
|
- self.oobeCullFrustumVis = None
|
|
|
|
|
-
|
|
|
|
|
def showCameraFrustum(self):
|
|
def showCameraFrustum(self):
|
|
|
# Create a visible representation of the frustum.
|
|
# Create a visible representation of the frustum.
|
|
|
self.removeCameraFrustum()
|
|
self.removeCameraFrustum()
|