How to eliminate squares in the main viewport?

I want to exclude these squares from the main viewport.

I set it up using something like the above。

        // Setup fourth view
        float nearPlane = 1.0f;
        float farPlane = 4096.0f;
        Camera cam4 = cam.clone();
        cam4.setViewPort(0, (cam.getWidth() / 5f) / cam.getWidth(), 0, (cam.getHeight() / 4f) / cam.getHeight());
        cam4.setLocation(new Vector3f(1024, 300f, 1024));
        camQuaternion = camQuaternion.fromAngleAxis(90 * FastMath.DEG_TO_RAD, Vector3f.UNIT_X);
        float frustumScale = 9;
        cam4.setFrustumLeft(cam4.getFrustumLeft() * frustumScale);
        cam4.setFrustumRight(cam4.getFrustumRight() * frustumScale);
        cam4.setFrustumTop(cam4.getFrustumTop() * frustumScale);
        cam4.setFrustumBottom(cam4.getFrustumBottom() * frustumScale);

        //vp = simpleApp.getRenderManager().createMainView("Top Right", cam4);
        vp = simpleApp.getRenderManager().createMainView("MiniMapCam", cam4);
        vp.setClearFlags(true, true, true);

But they still appear in the main viewport。Why is that?

Which squares are you talking about? The blue ones that look like they are around sprites? Are those blue squares supposed to be transparent (weird that they are blue if so)

Are you able to produce a small complete example that replicates the problem?

1 Like
package mygame;

import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.renderer.RenderManager;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.shape.Box;

 * This is the Main Class of your Game. You should only do initialization here.
 * Move your Logic into AppStates or Controls
 * @author normenhansen
public class TestMain extends SimpleApplication {
    Node iBox = new Node("iBox");
    public static void main(String[] args) {
        TestMain app = new TestMain();

    public void simpleInitApp() {
        Box b = new Box(1, 1, 1);
        Geometry geom = new Geometry("Box", b);

        Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat.setColor("Color", ColorRGBA.Blue);

    public void simpleUpdate(float tpf) {
        //TODO: add update code

    public void simpleRender(RenderManager rm) {
        //TODO: add render code

This setup does not remove the blue squares|
I guess it’s very likely that I’m using it incorrectly, do you know how to properly cull nodes in the default viewport?

    Box b = new Box(1, 1, 1);
    Geometry geom = new Geometry("Box", b);

    Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat.setColor("Color", ColorRGBA.Blue);

Here you are explicitly requesting that a blue box be rendered. What are you looking to achieve here?

I’m working on an RTS game where for the mini-map part I’m using a camera to look down on the map in an orthogonal way and then I need to put a square for each unit to show up on the mini-map, but the main viewport also shows the blue squares that are hanging on each unit, and I’d like to exclude these blue squares from the main view

Right! Id be inclined to have two (or more) root nodes with totally seperate scenes. Im out right now but ill post some examples of how to do that when i get back (if someone else doesnt first)

1 Like

Well thank you for your help.

I used this example: jmonkeyengine/jme3-examples/src/main/java/jme3test/renderer/ at master · jMonkeyEngine/jmonkeyengine · GitHub

I’d suggest something like this

public class DualSceneApplication extends SimpleApplication {

    private Node minimapRoot;

    public static void main(String[] args) {
        DualSceneApplication app = new DualSceneApplication();

    public void simpleInitApp() {
        minimapRoot = new Node("Minimap Root");


    public void simpleUpdate(float tpf){
        // as a separate root node we have to manage it ourselves

    private void initMainScene() {
        Box box = new Box(1, 1, 1);
        Geometry blueCube = new Geometry("Blue Cube", box);
        Material blueMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        blueMat.setColor("Color", ColorRGBA.Blue);
        blueCube.setLocalTranslation(0, 0, -10);

    private void initMinimapScene() {

        for(int i=-5;i<=5; i++){
            for(int j=-5;j<=5; j++){
                Box box = new Box(0.1f, 0.1f, 0.1f);
                Geometry greenCube = new Geometry("Green Cube", box);
                Material greenMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
                greenMat.setColor("Color", ColorRGBA.Green);
                greenCube.setLocalTranslation(i, 0, j);

        Camera minimapCamera = cam.clone();
        //use the bottom right for the minimap
        minimapCamera.setViewPort(0.75f, 1f, 0f, 0.25f);
        minimapCamera.setLocation(new Vector3f(0, 10, 0));
        minimapCamera.lookAt(Vector3f.ZERO, Vector3f.UNIT_X);

        //set the size of the minimap (in world units), note I've distorted the scene (because the minimap isn't square) but I've not worried about that as you already seem to have that right
        minimapCamera.setFrustum(1, 1000, -3f, 3f, 3f, -3f);

        ViewPort minimapViewPort = renderManager.createPostView("Minimap View", minimapCamera);
        minimapViewPort.setClearFlags(true, true, true);

Two totally different scenes, one creating the minimap and one the main view. Now in your application they are likely to be based off the same raw data (your game logic) but the scenes are separate interpretations of the game state, not the same scene looked at from two angles

1 Like

When we harp on keeping game objects separate from spatials… this is one of the examples of why we say that.


I understand what you mean thank you so much for your help! :slight_smile:

1 Like