Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I want to display a spatial (or the rendering of a spatial/scene) in my HUD interface. I'm really not sure how to go with this. I have search the documentation, but all the queries I search yields no result, and all I could find about images is that one can specify one with the setBackgroundImage method in the builder and setImage from the ImageRenderer class. The latter takes a String or a NiftyImage, but I'm not sure how to create one without loading an image file.

Any help to understand this (if even possible) is appreciated. Thanks!

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

There is but one way I can imagin to get this working.

Creating a new NiftyImage as it is needed to get requires two arguments:

  1. the NiftyRenderEngine you can receive from the current Nifty-GUI instance using the getRenderEngine function
  2. A RenderImage that is part of the SPI.

The key is to implement the RenderImage yourself. To be more precise you have to overload RenderImageJme that is used by the JME-Renderer for Nifty to to define images. This class implements a getTexture() method you can overwrite to send in a alternative texture.

If you render the things you want to display to a texture and return this texture in your own implementation of the RenderImageJme, then you should be able to display what ever you want.

share|improve this answer
    
where is that implementation? de.lessvoid.nifty.spi.render.RenderImage is an interface and has only 3 methods : getWidth(), getHeight() and dispose(). Do you mean com.jme3.niftygui.RenderImageJme ? –  Yanick Rochon Apr 4 '12 at 14:44
    
Exactly. <code>com.jme3.niftygui.RenderImageJme</code> is the implementation of <code>de.lessvoid.nifty.spi.render.RenderImage</code> that is used by the render display JME uses. So you have to extend <code>RenderImageJme</code> in order to use it with the render device of JME. If you implement <code>RenderImage</code> and not <code>RenderImageJme</code> you wil receive a <code>ClassCastException</code> as the JME render device performs a unchecked cast. –  Nitram Apr 4 '12 at 14:59
    
then I suspect the magic happens here (NiftyImage) : this.imageMode = ImageModeFactory.getSharedInstance().createImageMode(null, null); where it returns a JME implementation of ImageMode? –  Yanick Rochon Apr 4 '12 at 15:06
    
I should. But as I just saw the RenderImageJme offers a constructor that should do what you want. Using RenderImageJme(Texture2D). You need to get the graphics you want to display into this Texture2D using render-to-texture. The instance if the RenderImageJme can we wrapped into a NiftyImage using new NiftyImage(nifty.getRenderEngine(), newRenderImageJme). That should do the job. –  Nitram Apr 4 '12 at 15:12
    
Forgot about this question! But this is what I ended up using and it works great! I made an utility class that received a root node and from which the camera could be controlled, and it allowed making UI views of the same scene from different angles (ex: rear view mirror in a race, bullet-time view on a missile, etc.) or display custom scenes (3D map, model, etc.) seemlessly. Got me good marks on my assignment. –  Yanick Rochon Dec 5 '12 at 19:20
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.