Browse Source

*** empty log message ***

David Rose 25 years ago
parent
commit
1752901444

+ 0 - 7
direct/src/gui/OnscreenText.py

@@ -64,13 +64,6 @@ class OnscreenText(PandaObject, NodePath):
         Set the text of the onscreen text
         Set the text of the onscreen text
         """
         """
         self.node().setText(string)
         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):
     def setPos(self, x, y):
         """setPos(self, float, float)
         """setPos(self, float, float)

+ 18 - 0
direct/src/showbase/ShowBase.py

@@ -74,6 +74,24 @@ class ShowBase:
         # Set up a 2-d layer for drawing things behind Gui labels.
         # Set up a 2-d layer for drawing things behind Gui labels.
         self.render2d = NodePath(setupPanda2d(self.win, "render2d"))
         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.
         # Set up another 2-d layer for drawing the Gui labels themselves.
         self.renderGui = NodePath(setupPanda2d(self.win, "renderGui"))
         self.renderGui = NodePath(setupPanda2d(self.win, "renderGui"))
 
 

+ 1 - 0
direct/src/showbase/ShowBaseGlobal.py

@@ -7,6 +7,7 @@ __builtin__.base = ShowBase()
 
 
 # Make some global aliases for convenience
 # Make some global aliases for convenience
 __builtin__.render2d = base.render2d
 __builtin__.render2d = base.render2d
+__builtin__.aspect2d = base.aspect2d
 __builtin__.render = base.render
 __builtin__.render = base.render
 __builtin__.hidden = base.hidden
 __builtin__.hidden = base.hidden
 __builtin__.camera = base.camera
 __builtin__.camera = base.camera