Book Image

JMonkeyEngine 3.0 Cookbook

By : Rickard Eden
Book Image

JMonkeyEngine 3.0 Cookbook

By: Rickard Eden

Overview of this book

Table of Contents (17 chapters)
jMonkeyEngine 3.0 Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using offscreen rendering for a minimap


There are generally two ways of creating minimaps. One way is to let an artist draw a representation of the map, as shown in the following screenshot. This usually ends up beautifully as it gives considerable freedom to the artist when it comes to style. The method is not that viable during development when scenes might be changing a lot, or for games with procedural content where the end result is not known beforehand.

Minimap with unit marker

In those cases, taking a snapshot of the actual scene can be very helpful. The resulting image can then be run through various filters (or shaders during rendering) to get a less raw look.

In this recipe, we'll achieve this by creating a new ViewPort port, and FrameBuffer to store a snapshot of a camera. Finally, we'll create NiftyImage out of it and display it as a GUI element.

How to do it...

We're going to start by creating a Util class to handle the rendering of our minimap. This will consist of the following...