Allow camera only in part of the window?


i have a little problem with my application (after all the others are more or less solved :wink: thx to u again!).

the application window is divided into two parts as you can see in this picture

the red one is the GUI, created with fengGUI, the green one shows an application. Now if i want to move, scroll, strafe or whatever else the green part, it isn’t possible to border the moving of the nodes only to the green part and no the red one. this means, if i strafe for example, the image glides over the GUI.

How can i avoid this behaviour?


Sebastian23 said:


Please fix the image link, this will make answering your question a lot easier ;)

sry about that. here we go:

Oh. I'm afraid I don't see much clearer now.

Basically you are saying you want to "move the green part", but prevent it from "sliding over the red part".

What exactly are the "green part" and the "red part"? Are they both quads in ortho mode? Is only the gui in ortho mode, and the "green part" actually the current camera's view?

Do you understand what I mean with "quad in ortho mode"? If not, you might want to (re-)read the articles about HUDs and GUIs on the wiki before going any further.

im trying to answer your questions:

the red part is the GUI created by fengGUI. i dont know exactly in which rendermode it is rendered, because as far as i know you haven't to atach the gui to a node. the red part is just one window where i have attached some widgets.

the green party contains 2 or 3 nodes where i had add some boxes, lines and things like that.

know i want that i can rotate the nodes in the green party by moving the mouse while pressing the mouse button. somehow i managed to implement that the nodes are moving when i press a key. but the vanish behind the red part. i want that if i use the mouse or keys, that only the nodes in the green party rotate and only in the borders of the green part.

is it clearer know?

Have you tried implementing this yet? FengGUI is not effected at all by jME's transformations, so unless you try really hard, you can't make the red part move with the green part. There are some other posts on the wiki and forum on how to integrate FengGUI into your application, try searching.

i dont want to move the red part. i want that the red part is always in front.

That's exactly what I said. You can't move the red part with the green part…

I think I understand your problem now.

I am afraid there's no super simple answer to this question.

A quick solution could be to check the screen coordinates (DisplaySystem.getScreenCoordinates()) for every vertex (Geometry.getVertexBuffer()) if they are inside the green area's bounds.

hmm maybe im totally wrong but i think you still dont understand my problem :smiley: i will draw a new image to make it clear:

first the situation right after starting my application:

the red part is the menu created with feng gui

the green part is the rest of the window.

the black parts are quads, boxes and so on

after i used zooming in or out, the following happens:

now i want, that the order of drawing isn’t black - red - green, but instead - red - black - green

know my idea was either to

  • draw i some way the red part always headmost


  • somehow limit the camera view to the green part

    but both solution i don't know how to start with implementing

Make sure you render your scene first, clear the zbuffer, then render FengGUI.

thats part of my initGame Code

ZBufferState buf = display.getRenderer().createZBufferState();
myRoot.updateGeometricState(0.0f, true);
//create GUI

i think i have to clear the buffer just before initGUI() but wich method should i call? the API doesnt provide any methode clearBuffer or similar ;)

edit: i added these two lines in front of the initGUI() call but it still doesnt work


That only effects the first frame, you need to stick that code in renderGame, not initGame.

It should look something like this:

private void render(Renderer r){

hmm my render mode is know like this, but it doesnt work :frowning:

protected void render(float interpolation) {

Renderer r = display.getRenderer();







here is my complet code for the init methods… i hope someone can help me now:

package src;

import java.util.logging.Logger;

import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.input.MouseInput;
import com.jme.light.PointLight;
import com.jme.math.Vector3f;
import com.jme.renderer.Camera;
import com.jme.renderer.ColorRGBA;
import com.jme.renderer.Renderer;
import com.jme.scene.Node;
import com.jme.scene.shape.Box;
import com.jme.scene.state.LightState;
import com.jme.scene.state.ZBufferState;
import com.jme.system.DisplaySystem;
import com.jme.system.JmeException;
import com.jme.util.Timer;
import com.jme.util.lwjgl.LWJGLTimer;

public class CPController extends BaseGame {
   private static final Logger logger = Logger.getLogger(BaseGame.class.getName());
   Timer timer;
   private Camera cam;
   private Node myRoot;
   private Node coordNode;
   private CPCoordinateSystem cs;
   private int height;
   private int width;
   private int depth;
   private int freq;
   private boolean fullscreen;
   private Node boxNode;
   private Node lineNode;
   private PointLight light;
   private CPController controller;
   private Boxes boxes;
   private LightState lightstate;
   private CPMenu cpm;
   org.fenggui.Display disp;
   FengJMEInputHandler input;
   public void init(CPController controller) {
      this.controller = controller;
      setDialogBehaviour(ALWAYS_SHOW_PROPS_DIALOG, CPController.class.getClassLoader().getResource("data/fractal.gif"));
    protected void initGame() {
       myRoot = new Node("overall Root");
       light = new PointLight();
       ZBufferState buf = display.getRenderer().createZBufferState();
       light.setDiffuse(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
       light.setAmbient(new ColorRGBA(0.5f, 0.5f, 0.5f, 1.0f));
       light.setLocation(new Vector3f(100,100,100));
       lightstate = display.getRenderer().createLightState();
       myRoot.updateGeometricState(0.0f, true);
      //create GUI

   protected void cleanup() { "Cleaning up resources." );

   protected void initSystem() {
      width = properties.getWidth();
      height = properties.getHeight();
      depth = properties.getDepth();
      freq = properties.getFreq();
      fullscreen = properties.getFullscreen();
      try {
      display = DisplaySystem.getDisplaySystem(properties.getRenderer());
      display.createWindow(width, height, depth, freq, fullscreen);
      cam = display.getRenderer().createCamera(width, height);
      } catch (JmeException e) {
      cam.setFrustumPerspective(45.0f, (float)width / (float)height, 1, 1000);
      Vector3f loc = new Vector3f(0.0f, 0.0f, 25.0f);
      Vector3f left = new Vector3f(-1.0f, 0.0f, 0.0f);
      Vector3f up = new Vector3f(0.0f, 1.0f, 0.0f);
      Vector3f dir = new Vector3f(0.0f, 0f, -1.0f);
      cam.setFrame(loc, left, up, dir);
      timer = new LWJGLTimer();

      MouseInput.get().addListener( new CPMouseInputListener(cam));
      KeyInput.get().addListener(new CPKeyInputListener(cam));
      KeyBindingManager.getKeyBindingManager().set("quit", KeyInput.KEY_ESCAPE);

   protected void reinit() {
      display.recreateWindow(width, height, depth, freq, fullscreen);

   protected void render(float interpolation) {
      Renderer r = display.getRenderer();

   protected void update(float interpolation) {
      float tpf = timer.getTimePerFrame();
      if(!input.wasKeyHandled()) {
         if (KeyBindingManager.getKeyBindingManager().isValidCommand("quit")) {

   protected void shutDown() {
    * @return the height
   public int getHeight() {
      return height;

    * @return the width
   public int getWidth() {
      return width;

    * @param height the height to set
   public void setHeight(int height) {
      this.height = height;

    * @param width the width to set
   public void setWidth(int width) {
      this.width = width;
   public void initGUI() {
      cpm = new CPMenu(controller, light, disp);
      input = cpm.getMenuHandler();
      disp = cpm.getFDisplay();
   public DisplaySystem getDisplay() {
      return display;
   protected void initBoxes() {
      boxes = new Boxes(controller);
      boxNode = boxes.getBoxNode();
   protected void initLine() {
      Box[] boxcollection = new Box[4];
      boxcollection = boxes.getBoxes();
      lineNode = boxes.getNode();
   protected void initCoordinateSystem() {
      cs = new CPCoordinateSystem(display);
      coordNode = cs.getCoordNode();
   protected void tearDownCoordinateSystem() {
      System.out.println("Tear Down Coordinate System");
   protected void tearDownBoxes() {
      System.out.println("Tear Down Boxes");
   protected void tearDownLine() {
      System.out.println("Tear Down Line");

All these "red parts" and "green parts" make my head hurt,