mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
don't crash if no mouse
This commit is contained in:
parent
33ae898b0c
commit
a2c74532b6
@ -122,6 +122,7 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
self.pipe = None
|
self.pipe = None
|
||||||
self.pipeList = []
|
self.pipeList = []
|
||||||
self.mak = None
|
self.mak = None
|
||||||
|
self.mouse2cam = None
|
||||||
self.cam = None
|
self.cam = None
|
||||||
self.camList = []
|
self.camList = []
|
||||||
self.camNode = None
|
self.camNode = None
|
||||||
@ -620,6 +621,7 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
return aspectRatio
|
return aspectRatio
|
||||||
|
|
||||||
def makeCamera(self, win, chan = None, layer = None, layerSort = 0,
|
def makeCamera(self, win, chan = None, layer = None, layerSort = 0,
|
||||||
|
scene = None,
|
||||||
displayRegion = (0, 1, 0, 1), aspectRatio = None):
|
displayRegion = (0, 1, 0, 1), aspectRatio = None):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -634,6 +636,9 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
# Make a new layer on the window.
|
# Make a new layer on the window.
|
||||||
layer = chan.makeLayer(layerSort)
|
layer = chan.makeLayer(layerSort)
|
||||||
|
|
||||||
|
if scene == None:
|
||||||
|
scene = self.render
|
||||||
|
|
||||||
# And make a display region on this layer of the requested
|
# And make a display region on this layer of the requested
|
||||||
# area.
|
# area.
|
||||||
dr = layer.makeDisplayRegion(*displayRegion)
|
dr = layer.makeDisplayRegion(*displayRegion)
|
||||||
@ -664,7 +669,7 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
lens.setFilmSize(props.getXSize(), props.getYSize())
|
lens.setFilmSize(props.getXSize(), props.getYSize())
|
||||||
|
|
||||||
camNode.setLens(lens)
|
camNode.setLens(lens)
|
||||||
camNode.setScene(self.render)
|
camNode.setScene(scene)
|
||||||
|
|
||||||
# self.camera is the parent node of all cameras: a node that
|
# self.camera is the parent node of all cameras: a node that
|
||||||
# we can move around to move all cameras as a group.
|
# we can move around to move all cameras as a group.
|
||||||
@ -1107,15 +1112,18 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
self.taskMgr.remove('ivalloop')
|
self.taskMgr.remove('ivalloop')
|
||||||
self.eventMgr.shutdown()
|
self.eventMgr.shutdown()
|
||||||
|
|
||||||
def getBackgroundColor(self):
|
def getBackgroundColor(self, win = None):
|
||||||
"""
|
"""
|
||||||
Returns the current window background color. This assumes
|
Returns the current window background color. This assumes
|
||||||
the window is set up to clear the color each frame (this is
|
the window is set up to clear the color each frame (this is
|
||||||
the normal setting).
|
the normal setting).
|
||||||
"""
|
"""
|
||||||
return VBase4(self.win.getClearColor())
|
if win == None:
|
||||||
|
win = self.win
|
||||||
|
|
||||||
def setBackgroundColor(self, *args):
|
return VBase4(win.getClearColor())
|
||||||
|
|
||||||
|
def setBackgroundColor(self, r = None, g = None, b = None, win = None):
|
||||||
"""
|
"""
|
||||||
Sets the window background color to the indicated value.
|
Sets the window background color to the indicated value.
|
||||||
This assumes the window is set up to clear the color each
|
This assumes the window is set up to clear the color each
|
||||||
@ -1125,17 +1133,17 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
tuple, or the individual r, g, b parameters.
|
tuple, or the individual r, g, b parameters.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
numArgs = len(args)
|
if g != None:
|
||||||
if numArgs == 3 or numArgs == 4:
|
color = VBase4(r, g, b, 1.0)
|
||||||
color = VBase4(args[0], args[1], args[2], 1.0)
|
else:
|
||||||
elif numArgs == 1:
|
|
||||||
arg = args[0]
|
arg = args[0]
|
||||||
color = VBase4(arg[0], arg[1], arg[2], 1.0)
|
color = VBase4(arg[0], arg[1], arg[2], 1.0)
|
||||||
else:
|
|
||||||
raise TypeError, ('Invalid number of arguments: %d, expected 1, 3, or 4.' % numArgs)
|
|
||||||
|
|
||||||
if self.win:
|
if win == None:
|
||||||
self.win.setClearColor(color)
|
win = self.win
|
||||||
|
|
||||||
|
if win:
|
||||||
|
win.setClearColor(color)
|
||||||
|
|
||||||
def toggleBackface(self):
|
def toggleBackface(self):
|
||||||
if self.backfaceCullingEnabled:
|
if self.backfaceCullingEnabled:
|
||||||
@ -1195,6 +1203,7 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
# the mouse is disabled. However, we do move the mouse2cam
|
# the mouse is disabled. However, we do move the mouse2cam
|
||||||
# object out of there, so we won't be updating the camera any
|
# object out of there, so we won't be updating the camera any
|
||||||
# more.
|
# more.
|
||||||
|
if self.mouse2cam:
|
||||||
self.mouse2cam.reparentTo(self.dataUnused)
|
self.mouse2cam.reparentTo(self.dataUnused)
|
||||||
|
|
||||||
def enableMouse(self):
|
def enableMouse(self):
|
||||||
@ -1202,9 +1211,11 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
Reverse the effect of a previous call to disableMouse().
|
Reverse the effect of a previous call to disableMouse().
|
||||||
useDrive() also implicitly enables the mouse.
|
useDrive() also implicitly enables the mouse.
|
||||||
"""
|
"""
|
||||||
|
if self.mouse2cam:
|
||||||
self.mouse2cam.reparentTo(self.mouseInterface)
|
self.mouse2cam.reparentTo(self.mouseInterface)
|
||||||
|
|
||||||
def setMouseOnNode(self, newNode):
|
def setMouseOnNode(self, newNode):
|
||||||
|
if self.mouse2cam:
|
||||||
self.mouse2cam.node().setNode(newNode)
|
self.mouse2cam.node().setNode(newNode)
|
||||||
|
|
||||||
def changeMouseInterface(self, changeTo):
|
def changeMouseInterface(self, changeTo):
|
||||||
@ -1218,6 +1229,7 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
self.mouseInterfaceNode = self.mouseInterface.node()
|
self.mouseInterfaceNode = self.mouseInterface.node()
|
||||||
# Hookup the drive to the camera.
|
# Hookup the drive to the camera.
|
||||||
self.mouseInterface.reparentTo(self.mouseWatcher)
|
self.mouseInterface.reparentTo(self.mouseWatcher)
|
||||||
|
if self.mouse2cam:
|
||||||
self.mouse2cam.reparentTo(self.mouseInterface)
|
self.mouse2cam.reparentTo(self.mouseInterface)
|
||||||
|
|
||||||
def useDrive(self):
|
def useDrive(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user