Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from direct.showbase.ShowBase import ShowBase
- from panda3d.core import TextFont, TextNode
- class MyApp(ShowBase):
- def __init__(self):
- ShowBase.__init__(self)
- # Make the background solid black (red, green, blue, alpha parameters)
- self.setBackgroundColor(0, 0, 0, 1)
- # Define a solid (3D), high resolution font
- font = loader.loadFont("ClearSans-Bold.ttf")
- font.setRenderMode(TextFont.RMSolid)
- font.setPixelsPerUnit(100)
- # Create some 3D text using the solid font
- text = TextNode("")
- text.setText("Hello World!")
- text.setFont(font)
- text.setAlign(TextNode.ACenter)
- # Add the 3D text to the renderer
- textNP = render.attachNewNode(text)
- textNP.setColor(0.5, 0.5, 1, 1)
- textNP.setRenderModeWireframe()
- # Set Y position for the text, and allow the NodePath to be moved elsewhere
- self.textY = 50
- self.textNP = textNP
- # Move the text every frame
- self.taskMgr.add(self.moveTextTask, "moveTextTask")
- def moveTextTask(self, task):
- # Move the text NodePath towards us by 0.1 units each frame
- self.textNP.setPos(0, self.textY, -0.25)
- self.textY -= 0.1
- # Quit if the text is moving behind the camera
- if self.textY < -0.5:
- self.userExit()
- # Continue with the task on the next frame
- return task.cont
- app = MyApp()
- app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement