[SOLVED]Poor Performance for RPG-style Text Scrolls

Hello, everyone. I’m experimenting with Panda3D, and right now I’m trying to replicate the letter-by-letter appearance of text that is so popular in video games such as the Final Fantasy series, Harvest Moon series, Zelda, and many others. I’ve put together a short snippet that does this via a task below:

from direct.showbase.ShowBase import ShowBase
from panda3d.core import TextNode
from direct.task import Task

class GuiTest(ShowBase):

	accessTest = 0
	textLength = 0
	
	def __init__(self):
		global accessTest
		global textLength
		ShowBase.__init__(self)
		base.disableMouse()
		base.setFrameRateMeter(True)
		textPrint = "The quick brown fox jumped over the lazy dogs."
		accessTest = 0
		textLength = len (textPrint)
		self.taskMgr.add(self.printText, "testing Task", extraArgs=[textPrint], appendTask=True)

	def printText(self, text, task):
		global accessTest
		global textLength
		if accessTest == 0:
			self.text = TextNode('TestScroll')
			textNodePath = aspect2d.attachNewNode(self.text)
			textNodePath.setScale(0.07)
			textNodePath.setX(-.9)
			textNodePath.setZ(-.8)
		if accessTest < textLength:
			self.text.setText(text[:accessTest])
			accessTest += 1
			return Task.cont
		else:
			return Task.done

app = GuiTest()
app.run()

Please excuse the extreme crudity of this example. It does work, but the performance is very poor (note the framerate while the example program runs!)—though there is no intentional delay coding and even though I have a fairly capable system, the text rendering is occurring much slower than even 30 frames per second.

I noted in the manual that Panda3D does have performance issues with text updating but this is an extremely common effect—I cannot think of many adventure/RPG/action games that do not use the scroll text effect. Am I missing something (very likely!), or is there a better, more performant way of doing this (even more likely!)?

Sure, try:

self.text.setFlattenFlags(TextNode.FFNone)

or maybe:

self.text.setFlattenFlags(TextNode.FFNone | TextNode.FFDynamicMerge)

based on how much text you have and how long it will remain onscreen before it is changed.

David

Thank you for your reply! That did the trick.