Adding Nifty to Spatials or 3D Models

Hi all. Can any one tell me how to add nifty to spatial or 3D models? I did some search but could not find one. Much appreciated.

K Out!

Could use a SceneProcessor to pre-render the GUI node (or sub-node) and then take the outputted texture and pass it into the material for the object you want to render.

@t0neg0d is there an example code showing how that is done?

I was just about to post something… I realized the answer was REALLY vague.

In the postQueue method of the SceneProcessor you would do something like this:


Renderer r = renderManager.getRenderer();

// You’ll need to set up a frame buffer to store the rendered image


// Since it’s a color buffer… you’ll only need to clear that

r.clearBuffers(true, false, false);

// Render the GUI Bucket

viewPort.getQueue().renderQueue(Bucket.GUI, renderManager, viewPort);

// Reset the frame buffer to the viewport’s default buffer



If you open any class in JME that extends the SceneProcessor, you’ll see how the rest of it works. Maybe the basic shadow renderer is a decent place to go to see a simple example of a SceneProcessor.

EDIT: Also, because this renders the entire GUI Bucket, you’ll need to swap Nifty components in and out of the GUI Bucket to only render what you like… or maybe someone else has a fancier way of limiting what you render in the GUI Bucket.

in the nifty jMETests it has it rendering to a cube

@wezrule said:
in the nifty jMETests it has it rendering to a cube

Do what he said... someone already put together what I explained above for you!

EDIT: Still will have the issue of swapping Nifty components though.

One last thought. You may want to go through the exercise of creating this yourself just to see how it works. You’ll learn a lot about how to accomplish these sort of tasks so the next time you stumble across an issue and there isn’t an existing solution… you’ll know how to create the solution yourself. It’s not a must… but certainly is helpful in a pinch.

Thanks for the tips. I will look into it now and will also check out the nifty jMETests( Dont know how I missed that -.-). Any way thanks.

K Out!

What are you actually trying to do? Render a nifty GUI as the texture of a 3d object?

If so then use the nifty jme tests show you exactly how to do it. I should warn you it’s not super-fast though and if you also use nifty as a gui (or for multiple objects) you will get some warnings (that seem to be safe to ignore but I can’t promise it).

Performance wise doing it for one or two objects is fine but don’t try and do a lot.