Can this kind of an effect be coded using Panda's 1.7 APIs?

In my current master piece, I will have comic book style bubble text popping up on screen when engine based cut scenes play out (or when NPCs talk and you talk back).

This is no problem if you have pre-made bubbles with text.

What I really want to do is use a billboard bubble text object, open a text file to read the content that will go into the bubble text object and somehow map that text to the bubble text object (which should be plain white by default).

Is that even possible with Panda 1.7’s API package :question: Is so, example code please.

I guess you would get the text from a text file on disc via Pythons default file reading methods. ynjh_jo has demonstrated text2texture projection in the past, which you could propably use in the next step:
[Text as Texture?)

Alternatively, you could put either a TextNode or a DirectLabel in the 3D scene. I’ve done that in the past, though I forget which one I was using at the time.

Basically you’d make the TextNode or DirectLabel, turn off lighting for it, and then parent it to the bubble billboard. If you don’t turn off lighting it might display strangely, but you probably know that already if you’re making billboards. I’ve always had to setLightOff() on my billboards to make them not show up as flat black.

As for reading a text file, that’s supremely easy with python’s built in system. It would be something like this:

file = open("PathTo\MyFile.txt", "r")
data = file.readlines()

I don’t believe you even need to import anything. The “r” argument in the open call tells python what mode you want to open the file with. “r” is for read, “w” is for write (“w” will delete the file contents completely), and there’s one for re-writing that I don’t remember off the top of my head. Probably “rw” or some such.

The readlines call takes all of the lines of text in the file and puts them in a list. Each entry in the list is one line of text. The lines will include special characters, like line break characters, that you may need to remove.

When you pack the game into a p3d, your text files will end up having both line break characters used by various OSes, so keep that in mind if you’re removing such characters. You need to get rid of \n\r, not just \n, for example.

Does any part of a hidden buffer need to be in a task? or is the code suppose to be written and executed once for a texture?

I can’t seem to get anything to buffer. Below is my “BS” test code.

self.mybuffer ="My Buffer", 256, 256)
        self.mycamera = base.makeCamera(self.mybuffer)
        self.text=OnscreenText('What the Fuck!!', parent=self.textSG, scale = 0.05, fg=(1, 0, 0, 1), bg=(0, 0, 0, 1), align=TextNode.ALeft, shadow=(0,0.6,1,0.5), mayChange=True)

        self.mytexture = self.mybuffer.getTexture()
        self.tsWoodly = TextureStage('BengleTxt')
        self.Phe.setTexture(self.tsWoodly, self.mytexture)
        self.Phe.setTexScale(self.tsWoodly, 10, 10)


I kind of figured a lot of the explanations are somewhat vague. After pondering over it, I was able to clear it up a little in my mind. :slight_smile:

I realize the Texture Buffer Window created is like having a empty Texture or Texture with no appearance. Well…the texture still needs a look or appearance or it won’t show up.

I also realized that the 2D cam created for the Texture Buffer Window will render what it looks at into the Texture Buffer, giving the rendered texture an appearance.

So what I did was load up a Model and re-parented that Model to the NodePath my 2D Texture Buffer Cam was viewing.

I was able to see some of the results on another Model I had receiving the rendered texture. That’s when I noticed, things are not setup right by default in the Texture Buffer. I mean the camera had to be moved back and up some in order to view the Model I was rendering into the Rendered Texture. I was then able to see the Model rendered to texture on the second Model I had receiving the rendered texture.


Made it that far.

So I’m guessing when I tried to place Text into the Texture Buffer Window, that text was somehow off screen and that’s why I was not able to see results.

So how do you center texture in the Texture Buffer Window, based on the size (width x height) of the Texture Buffer :question:


Instead of using an Actor’s file, I tried a card object that was pre-textured with a desired texture. That worked well.

My main goal is to be able to update any in-game text externally and not have to dig through source code.

So I could really just make texture with the text already on it and if I need to change text later, just overwrite the old texture with a new one and “pop goes the weasel.” :laughing:

Can someone answer this…?

I tried to use egg-opt to isolate a part of an actor so I could change that parts texture, but it seems egg-opt only works for models. My Actor got all F’ked up.

Is there a way to just simple isolate a particular texture on a multi-textured
Actor and swap out that texture for another one, alone?

If someone can show me how to do this, if it can be done, I would be tickled pink. I don’t know every Panda API call, so you can see my limitations


I was able to get Text Render to Texture working. Turns out it was a Text BG Alpha issue.

How I was able to form up my own logic in order to understand this whole Render To Texture thing and get it working for both text and texture was “Kewl!”