Game Development Reference
In-Depth Information
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 15 steps:
1. Define a new class called MinimapUtil .
2. It will only have one static method, createMiniMap , with the following declar-
ation:
public static void createMiniMap(final
SimpleApplication app, final Spatial scene, int width,
int height)
3. The first thing we do is create a new camera called offScreenCamera with the
same width and height that were supplied to the method.
4. The camera should have the parallel projection set to true, and a frustrum that
spans between 1 and 1000 in depth, -width to width , and -height to
height , as shown in the following code:
offScreenCamera.setParallelProjection(true);
offScreenCamera.setFrustum(1, 1000, -width, width,
height, -height);
5. It should be located at some distance above the scene and rotated downwards, as
shown in the following code:
offScreenCamera.setLocation(new Vector3f(0, 100f, 0));
offScreenCamera.setRotation(new
Quaternion().fromAngles(new
float[]{FastMath.HALF_PI,FastMath.PI,0}));
6. Next, we create a new ViewPort by calling the application's RenderManager
and its createPreView method using offScreenCamera :
final ViewPort offScreenView =
app.getRenderManager().createPreView(scene.getName() +
"_View", offScreenCamera);
offScreenView.setClearFlags(true, true, true);
offScreenView.setBackgroundColor(ColorRGBA.DarkGray.mult(ColorRGBA.Blue).mult(0.3f));
Search WWH ::




Custom Search