From 1752901444e40d977083933a987a5540d798bba6 Mon Sep 17 00:00:00 2001 From: David Rose Date: Thu, 8 Mar 2001 23:34:31 +0000 Subject: [PATCH] *** empty log message *** --- direct/src/gui/OnscreenText.py | 7 ------- direct/src/showbase/ShowBase.py | 18 ++++++++++++++++++ direct/src/showbase/ShowBaseGlobal.py | 1 + 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/direct/src/gui/OnscreenText.py b/direct/src/gui/OnscreenText.py index 674ac55b44..ded74da4da 100644 --- a/direct/src/gui/OnscreenText.py +++ b/direct/src/gui/OnscreenText.py @@ -64,13 +64,6 @@ class OnscreenText(PandaObject, NodePath): Set the text of the onscreen text """ self.node().setText(string) - - def setScale(self, scale): - """setScale(self, float) - Override NodePath setScale to account for aspect ratio - """ - # assume 4:3 aspect ratio - NodePath.setScale(self, scale, 1.0, scale * (4.0/3.0)) def setPos(self, x, y): """setPos(self, float, float) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index a16e81e38c..7e86e946de 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -74,6 +74,24 @@ class ShowBase: # Set up a 2-d layer for drawing things behind Gui labels. self.render2d = NodePath(setupPanda2d(self.win, "render2d")) + # The normal 2-d layer has an aspect ratio that matches the + # window, but its coordinate system is square. This means + # anything we parent to render2d gets stretched. For things + # where that makes a difference, we set up aspect2d, which + # scales things back to the right aspect ratio. + + # For now, we assume that the window will have an aspect ratio + # matching that of a traditional PC screen. + self.aspectRatio = 4.0 / 3.0 + self.aspect2d = self.render2d.attachNewNode("aspect2d") + self.aspect2d.setScale(1.0 / self.aspectRatio, 1.0, 1.0) + + # It's important to know the bounds of the aspect2d screen. + self.a2dTop = 1.0 + self.a2dBottom = -1.0 + self.a2dLeft = -self.aspectRatio + self.a2dRight = self.aspectRatio + # Set up another 2-d layer for drawing the Gui labels themselves. self.renderGui = NodePath(setupPanda2d(self.win, "renderGui")) diff --git a/direct/src/showbase/ShowBaseGlobal.py b/direct/src/showbase/ShowBaseGlobal.py index 8642fd7419..6fca3cc35b 100644 --- a/direct/src/showbase/ShowBaseGlobal.py +++ b/direct/src/showbase/ShowBaseGlobal.py @@ -7,6 +7,7 @@ __builtin__.base = ShowBase() # Make some global aliases for convenience __builtin__.render2d = base.render2d +__builtin__.aspect2d = base.aspect2d __builtin__.render = base.render __builtin__.hidden = base.hidden __builtin__.camera = base.camera