mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 10:54:24 -04:00
*** empty log message ***
This commit is contained in:
parent
2339f5ef8a
commit
75dd4f1771
@ -19,6 +19,7 @@ class OnscreenText(PandaObject, NodePath):
|
|||||||
def __init__(self, text = '',
|
def __init__(self, text = '',
|
||||||
style = Plain,
|
style = Plain,
|
||||||
pos = (0, 0),
|
pos = (0, 0),
|
||||||
|
roll = 0,
|
||||||
scale = None,
|
scale = None,
|
||||||
fg = None,
|
fg = None,
|
||||||
bg = None,
|
bg = None,
|
||||||
@ -151,6 +152,7 @@ class OnscreenText(PandaObject, NodePath):
|
|||||||
# Save some of the parameters for posterity.
|
# Save some of the parameters for posterity.
|
||||||
self.scale = scale
|
self.scale = scale
|
||||||
self.pos = pos
|
self.pos = pos
|
||||||
|
self.roll = roll
|
||||||
|
|
||||||
if font == None:
|
if font == None:
|
||||||
font = DirectGuiGlobals.getDefaultFont()
|
font = DirectGuiGlobals.getDefaultFont()
|
||||||
@ -185,9 +187,7 @@ class OnscreenText(PandaObject, NodePath):
|
|||||||
# We'd rather do it here, on the text itself, rather than on
|
# We'd rather do it here, on the text itself, rather than on
|
||||||
# our NodePath, so we have one fewer transforms in the scene
|
# our NodePath, so we have one fewer transforms in the scene
|
||||||
# graph.
|
# graph.
|
||||||
mat = Mat4.scaleMat(
|
self.updateTransformMat()
|
||||||
scale[0], 1, scale[1]) * Mat4.translateMat(pos[0], 0, pos[1])
|
|
||||||
textNode.setTransform(mat)
|
|
||||||
|
|
||||||
if drawOrder != None:
|
if drawOrder != None:
|
||||||
textNode.setBin('fixed')
|
textNode.setBin('fixed')
|
||||||
@ -270,15 +270,21 @@ class OnscreenText(PandaObject, NodePath):
|
|||||||
Position the onscreen text in 2d screen space
|
Position the onscreen text in 2d screen space
|
||||||
"""
|
"""
|
||||||
self.pos = (x, y)
|
self.pos = (x, y)
|
||||||
mat = Mat4.scaleMat(
|
self.updateTransformMat()
|
||||||
self.scale[0],
|
|
||||||
1,
|
|
||||||
self.scale[1]) * Mat4.translateMat(self.pos[0], 0, self.pos[1])
|
|
||||||
self.textNode.setTransform(mat)
|
|
||||||
|
|
||||||
def getPos(self):
|
def getPos(self):
|
||||||
return self.pos
|
return self.pos
|
||||||
|
|
||||||
|
def setRoll(self, roll):
|
||||||
|
"""setRoll(self, float)
|
||||||
|
Rotate the onscreen text around the screen's normal
|
||||||
|
"""
|
||||||
|
self.roll = roll
|
||||||
|
self.updateTransformMat()
|
||||||
|
|
||||||
|
def getRoll(self):
|
||||||
|
return self.roll
|
||||||
|
|
||||||
def setScale(self, sx, sy = None):
|
def setScale(self, sx, sy = None):
|
||||||
"""setScale(self, float, float)
|
"""setScale(self, float, float)
|
||||||
Scale the text in 2d space. You may specify either a single
|
Scale the text in 2d space. You may specify either a single
|
||||||
@ -292,10 +298,14 @@ class OnscreenText(PandaObject, NodePath):
|
|||||||
self.scale = (sx, sx)
|
self.scale = (sx, sx)
|
||||||
else:
|
else:
|
||||||
self.scale = (sx, sy)
|
self.scale = (sx, sy)
|
||||||
mat = Mat4.scaleMat(
|
self.updateTransformMat()
|
||||||
self.scale[0],
|
|
||||||
1,
|
def updateTransformMat(self):
|
||||||
self.scale[1]) * Mat4.translateMat(self.pos[0], 0, self.pos[1])
|
mat = (
|
||||||
|
Mat4.scaleMat(self.scale[0],1,self.scale[1]) *
|
||||||
|
Mat4.rotateMat(self.roll, Vec3(0,-1,0)) *
|
||||||
|
Mat4.translateMat(self.pos[0], 0, self.pos[1])
|
||||||
|
)
|
||||||
self.textNode.setTransform(mat)
|
self.textNode.setTransform(mat)
|
||||||
|
|
||||||
def getScale(self):
|
def getScale(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user