mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 01:07:51 -04:00
fix aspect ratio logic some more, remove some legacy code
This commit is contained in:
parent
f16e172180
commit
372dc51408
@ -294,8 +294,6 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
self.graphicsEngine.removeAllWindows()
|
self.graphicsEngine.removeAllWindows()
|
||||||
|
|
||||||
if self.musicManager:
|
if self.musicManager:
|
||||||
# Temporary condition for old Pandas.
|
|
||||||
if hasattr(self.musicManager, 'shutdown'):
|
|
||||||
self.musicManager.shutdown()
|
self.musicManager.shutdown()
|
||||||
|
|
||||||
del self.win
|
del self.win
|
||||||
@ -610,12 +608,7 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
rendering 3-d geometry.
|
rendering 3-d geometry.
|
||||||
"""
|
"""
|
||||||
self.render = NodePath('render')
|
self.render = NodePath('render')
|
||||||
|
self.render.setAttrib(RescaleNormalAttrib.makeDefault())
|
||||||
# Temporary try..except for old pandas.
|
|
||||||
try:
|
|
||||||
self.render.node().setAttrib(RescaleNormalAttrib.makeDefault())
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
self.render.setTwoSided(0)
|
self.render.setTwoSided(0)
|
||||||
self.backfaceCullingEnabled = 1
|
self.backfaceCullingEnabled = 1
|
||||||
@ -687,10 +680,8 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
|
|
||||||
dt = DepthTestAttrib.make(DepthTestAttrib.MNone)
|
dt = DepthTestAttrib.make(DepthTestAttrib.MNone)
|
||||||
dw = DepthWriteAttrib.make(DepthWriteAttrib.MOff)
|
dw = DepthWriteAttrib.make(DepthWriteAttrib.MOff)
|
||||||
#lt = LightTransition.allOff()
|
self.render2dp.setDepthTest(0)
|
||||||
self.render2dp.node().setAttrib(dt)
|
self.render2dp.setDepthWrite(0)
|
||||||
self.render2dp.node().setAttrib(dw)
|
|
||||||
#self.render2dp.node().setAttrib(lt, 1)
|
|
||||||
|
|
||||||
self.render2dp.setMaterialOff(1)
|
self.render2dp.setMaterialOff(1)
|
||||||
self.render2dp.setTwoSided(1)
|
self.render2dp.setTwoSided(1)
|
||||||
@ -704,8 +695,6 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
|
|
||||||
aspectRatio = self.getAspectRatio()
|
aspectRatio = self.getAspectRatio()
|
||||||
self.aspect2dp = self.render2dp.attachNewNode(PGTop("aspect2dp"))
|
self.aspect2dp = self.render2dp.attachNewNode(PGTop("aspect2dp"))
|
||||||
# Temporary test for old panda.
|
|
||||||
if hasattr(PGTop, 'setStartSort'):
|
|
||||||
self.aspect2dp.node().setStartSort(16384)
|
self.aspect2dp.node().setStartSort(16384)
|
||||||
self.aspect2dp.setScale(1.0 / aspectRatio, 1.0, 1.0)
|
self.aspect2dp.setScale(1.0 / aspectRatio, 1.0, 1.0)
|
||||||
|
|
||||||
@ -732,16 +721,21 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
aspectRatio = float(win.getXSize()) / float(win.getYSize())
|
aspectRatio = float(win.getXSize()) / float(win.getYSize())
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
if win == None:
|
||||||
props = WindowProperties.getDefault()
|
props = WindowProperties.getDefault()
|
||||||
if not props.hasSize():
|
else:
|
||||||
props = win.getRequestedProperties()
|
props = win.getRequestedProperties()
|
||||||
|
if not props.hasSize():
|
||||||
|
props = WindowProperties.getDefault()
|
||||||
|
|
||||||
if props.hasSize():
|
if props.hasSize():
|
||||||
aspectRatio = float(props.getXSize()) / float(props.getYSize())
|
aspectRatio = float(props.getXSize()) / float(props.getYSize())
|
||||||
|
|
||||||
return aspectRatio
|
return aspectRatio
|
||||||
|
|
||||||
def makeCamera(self, win, sort = 0, scene = None,
|
def makeCamera(self, win, sort = 0, scene = None,
|
||||||
displayRegion = (0, 1, 0, 1), aspectRatio = None, camName = 'cam'):
|
displayRegion = (0, 1, 0, 1), aspectRatio = None,
|
||||||
|
lens = None, camName = 'cam'):
|
||||||
"""
|
"""
|
||||||
Makes a new 3-d camera associated with the indicated window,
|
Makes a new 3-d camera associated with the indicated window,
|
||||||
and creates a display region in the indicated subrectangle.
|
and creates a display region in the indicated subrectangle.
|
||||||
@ -755,12 +749,13 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
# By default, we do not clear 3-d display regions (the entire
|
# By default, we do not clear 3-d display regions (the entire
|
||||||
# window will be cleared, which is normally sufficient).
|
# window will be cleared, which is normally sufficient).
|
||||||
|
|
||||||
if aspectRatio == None:
|
|
||||||
aspectRatio = self.getAspectRatio(win)
|
|
||||||
|
|
||||||
# Now make a new Camera node.
|
# Now make a new Camera node.
|
||||||
camNode = Camera(camName)
|
camNode = Camera(camName)
|
||||||
|
if lens == None:
|
||||||
lens = PerspectiveLens()
|
lens = PerspectiveLens()
|
||||||
|
|
||||||
|
if aspectRatio == None:
|
||||||
|
aspectRatio = self.getAspectRatio(win)
|
||||||
lens.setAspectRatio(aspectRatio)
|
lens.setAspectRatio(aspectRatio)
|
||||||
|
|
||||||
camNode.setLens(lens)
|
camNode.setLens(lens)
|
||||||
@ -784,7 +779,8 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
return cam
|
return cam
|
||||||
|
|
||||||
def makeCamera2d(self, win, sort = 10,
|
def makeCamera2d(self, win, sort = 10,
|
||||||
displayRegion = (0, 1, 0, 1), coords = (-1, 1, -1, 1)):
|
displayRegion = (0, 1, 0, 1), coords = (-1, 1, -1, 1),
|
||||||
|
lens = None):
|
||||||
"""
|
"""
|
||||||
Makes a new camera2d associated with the indicated window, and
|
Makes a new camera2d associated with the indicated window, and
|
||||||
assigns it to render the indicated subrectangle of render2d.
|
assigns it to render the indicated subrectangle of render2d.
|
||||||
@ -800,6 +796,7 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
|
|
||||||
# Now make a new Camera node.
|
# Now make a new Camera node.
|
||||||
cam2dNode = Camera('cam2d')
|
cam2dNode = Camera('cam2d')
|
||||||
|
if lens == None:
|
||||||
lens = OrthographicLens()
|
lens = OrthographicLens()
|
||||||
lens.setFilmSize(right - left, top - bottom)
|
lens.setFilmSize(right - left, top - bottom)
|
||||||
lens.setFilmOffset((right + left) * 0.5, (top + bottom) * 0.5)
|
lens.setFilmOffset((right + left) * 0.5, (top + bottom) * 0.5)
|
||||||
@ -817,7 +814,8 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
return camera2d
|
return camera2d
|
||||||
|
|
||||||
def makeCamera2dp(self, win, sort = 20,
|
def makeCamera2dp(self, win, sort = 20,
|
||||||
displayRegion = (0, 1, 0, 1), coords = (-1, 1, -1, 1)):
|
displayRegion = (0, 1, 0, 1), coords = (-1, 1, -1, 1),
|
||||||
|
lens = None):
|
||||||
"""
|
"""
|
||||||
Makes a new camera2dp associated with the indicated window, and
|
Makes a new camera2dp associated with the indicated window, and
|
||||||
assigns it to render the indicated subrectangle of render2dp.
|
assigns it to render the indicated subrectangle of render2dp.
|
||||||
@ -833,6 +831,7 @@ class ShowBase(DirectObject.DirectObject):
|
|||||||
|
|
||||||
# Now make a new Camera node.
|
# Now make a new Camera node.
|
||||||
cam2dNode = Camera('cam2d')
|
cam2dNode = Camera('cam2d')
|
||||||
|
if lens == None:
|
||||||
lens = OrthographicLens()
|
lens = OrthographicLens()
|
||||||
lens.setFilmSize(right - left, top - bottom)
|
lens.setFilmSize(right - left, top - bottom)
|
||||||
lens.setFilmOffset((right + left) * 0.5, (top + bottom) * 0.5)
|
lens.setFilmOffset((right + left) * 0.5, (top + bottom) * 0.5)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user