How to make an Interactive texture (like computer screen)?

Hi there, this is my first post so please be gentle. :slight_smile:

I tried searching for console in the forums but it gave me a bunch of quake-style consoles which is not what I’m looking for.

As the title of this post states, I’m trying to do an interactive console/texture on a mesh.

The gist of it is to do a command-line prompt where the user can input commands which are then interpreted.

I’ve figure that I’ll need to do some kind of offscreen rendering to a texture. Then apply that texture to the mesh (which is correctly UV unwrapped already). The problem is that I don’t know where/how to start so if anyone can help then it will be much appreciated.

Thanks in advance.

Perhaps you should look into cleverly positioning another viewport? wow this is an interesting concept

Do you want the console to take prominence on the screen when jt is clicked?

Yes that is exactly what I’m trying to do. On mouse click the console becomes ‘active’ and all input is piped towards it.

A console is provided with Nifty… never used it… but it is what it is.

1 Like

@t0neg0d Hmm, I don’t think this is what I’m looking for as it is GUI control, but I’ll scratch in the code for a bit and see if I can bend it to my will :slight_smile: thanks for the reply.

Use a paintable texture. Probably not the most efficient way, but I’m using to redraw my minimap.

Redrawing the texture every x amount of time and setting the new texture.

1 Like

You can render a nifty gui on an geometry and then use the console as @t0neg0d hinted.

Is your console just text? Or graphics too?

@perfecticus Thanks for the hint! :slight_smile:

I found this after a quick google:

Think I’ll try to expand on it to do drawLn() and drawChar() etc… thanks for the reply.

@pspeed It will be both text and very simple graphics (like a rough .gif level of detail)

@pspeed hmm, after starting to code now I realized that adding gfx into the mix will complicate matters too much for my needs. It’s going to be text only.

@normen hi sorry, i missed your post above until now, ok cool, i’ll try that then. Thanks for the reply.

@raxar said:
@pspeed hmm, after starting to code now I realized that adding gfx into the mix will complicate matters too much for my needs. It's going to be text only.

If it's going to be text only then you can just use a BitmapText with a specified text box. Anything outside of this rectangle will be hidden... though it does operate at the character level. Usually that's ok in these situations since the "screen" would be setup to show a fixed number of lines, etc..
1 Like

I’m (hopefully, if all goes to plan) releasing ImagePainter as a plugin next week. That will most likely provide a lot of what you need.

The other approach would be to use nifty and map it to a texture. Either should work fine.


That’s great, the more options the better. :slight_smile: So far I like nifty’s render-to-texture since it gives me some animation out of the box. :slight_smile: There is a performance/memorty hit though, so I think some light weight alternatives is always good!

Yes, if you are only doing this in one place nifty would be fine. If you wanted screens everywhere though then you would need to either use the BitmapText or ImagePainter approach.

@pspeed @zarch Ok I’ve run into my first roadblock, I’ve managed to use the existing classes BitmapFont and BitmapText to load my font and setup the BitmapText object. I saw in the render-to-texture example for nifty that they used renderManager.createPreView() and a camara to setup the thingy.

I have no idea what next? How do I now render BitmapText to a texture?

I did see In the BitmapText object there is a render() method that takes RenderManager rm as the first parameter, I’m wildly guessing that it has something to do with that but I honsetly don’t know?

Any help would be appreciated, thanks

BitmapText is a completely different approach. You don’t render it to a texture at all.

Instead you create a bitmap text panel where you want the screen to be and put a black quad behind it for the actual screen surface.

I would expect that this will be the fastest approach as all you are doing is tweaking texture co-ordinates to cause the graphics card to render the right characters in the right places.

ImagePainter will offer more flexibility in that you can mix in Images, get more control over the writing and background, etc. It will most likely be slower though as most of the work is being done in the CPU and each time you change the image it needs sending to the graphics card again.

1 Like

The idea behind BitmapText would be to use it as is and just set a Rectangle to constrain it. That way you avoid the slow render-to-texture bit. Otherwise, if you want to render to text (and take the performance hit) then you could just as well use Nifty.

The BitmapText.render() method is just a hack-around to make nifty run faster in JME. It serves no other purpose so don’t call it.

1 Like