Bounding volume doens't move with its Geometry


Probably missing something very basic, but can't figure out what I'm doing wrong:

Quad q = new Quad("myQuad", 100, 100);

q.setLocalTranslation(50, 0, 0);
q.setModelBound(new BoundingBox());
//         q.updateWorldBound();

System.out.println("QUAD: " + q.getCenter());
System.out.println("BOUND-VOL: " + q.getModelBound());

This outputs:
QUAD: (50.0, 0.0, 0.0)
BOUND-VOL: center=(0.0, 0.0, 0.0) ...

And indeed when I strafe away from the quad going from left to right it disappears in one shot
because its bounding volume hasn't moved with it (!)

What am I doing wrong? Is this not how you move an object (q.setLocalTranslation), is this not how you make its bounding volume follow it (q.updateModelBound)?

Thanks for any help

The location of the bounding volume is relative to the spatials location so it doesnt change.

Thanks for answering, that's good to know.

I do not understand why jMe treats my quad as if it is out of the view frustum.

I am using parallel projection, I've written code to draw a Quad moved from (0,0,0) 200 units to the right,

and the user can position the mouse at edges of the screen in order to strafe above the plane that the quad is on.

When strafing to the right - the quad disappears at once - as if jMe thinks it's out of the view frustum…

package gui;

import com.jme.bounding.BoundingBox;
import com.jme.image.Texture;
import com.jme.input.AbsoluteMouse;
import com.jme.input.InputHandler;
import com.jme.input.action.InputAction;
import com.jme.input.action.InputActionEvent;
import com.jme.math.Vector2f;
import com.jme.math.Vector3f;
import com.jme.scene.Spatial.CullHint;
import com.jme.scene.Spatial.LightCombineMode;
import com.jme.scene.shape.Quad;
import com.jme.scene.state.BlendState;
import com.jme.scene.state.TextureState;
import com.jme.util.TextureManager;

public class CopyOfMain extends SimpleGame {

   private Vector2f pos;
   private float zoom;
   private boolean onTheMove;
   private AbsoluteMouse am;

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

   private void updateCamera() {      
      float left = pos.x - zoom*display.getWidth();
      float right = pos.x + zoom*display.getWidth();
      float top = pos.y - zoom*display.getHeight();
      float bottom = pos.y + zoom*display.getHeight();
      float near = -0.1f;
      float far = 2;      
      cam.setFrustum(near, far, left, right, top, bottom);
   protected void simpleInitGame() {
      zoom = 1;
      pos = new Vector2f(0,0);
      cam.setLocation(new Vector3f(0,0,1));
      onTheMove = false;

      int accumX = 0;
      URL url = CopyOfMain.class.getClassLoader().getResource("images/dr.jpg");
      Texture texture = TextureManager.loadTexture(url, Texture.MinificationFilter.Trilinear, Texture.MagnificationFilter.Bilinear);
      TextureState ts = display.getRenderer().createTextureState();

      Quad q = new Quad("myQuad", 400, 400);
      q.setLocalTranslation(200, 0, 0);
      q.setModelBound(new BoundingBox());

      // Controls init
      // Create a new mouse. Restrict its movements to the display screen.
      am = new AbsoluteMouse("The Mouse", display.getWidth(), display.getHeight());

      // Get a picture for my mouse.
      TextureState ts2 = display.getRenderer().createTextureState();
      URL cursorLoc = CopyOfMain.class.getClassLoader().getResource("resources/cursor1.png" );
      Texture t = TextureManager.loadTexture(cursorLoc, Texture.MinificationFilter.BilinearNearestMipMap,   Texture.MagnificationFilter.Bilinear);

      // Make the mouse's background blend with what's already there
      BlendState as = display.getRenderer().createBlendState();

      am.setLocalTranslation(new Vector3f(display.getWidth()/2, display.getHeight()/2, 0.5f));
//      am.setUsingDelta(false);
      am.registerWithInputHandler( input );

      //create an action to show axis activity
      InputAction axisAction = new InputAction() {
         public void performAction( InputActionEvent evt ) {
            Vector3f mPos = am.getHotSpotPosition();
            float x = mPos.x;
            float y = mPos.y;
            if (x<100 || x>display.getWidth()-100 || y<100 || y>display.getHeight()-100)
               onTheMove = true;
               onTheMove = false;

      //register it with all devices and all axes of these
      input.addAction(axisAction, InputHandler.DEVICE_MOUSE, InputHandler.BUTTON_NONE, 0, false );   // x axis
      input.addAction(axisAction, InputHandler.DEVICE_MOUSE, InputHandler.BUTTON_NONE, 1, false );   // y axis

   protected void simpleUpdate() {
      if (onTheMove) {         
         Vector2f mPos = new Vector2f(am.getHotSpotPosition().x, am.getHotSpotPosition().y);
         Vector2f scrCenter = new Vector2f(display.getWidth()/2, display.getHeight()/2);
         Vector2f dir = mPos.subtractLocal(scrCenter).normalizeLocal().multLocal(0.5f);



This may also be a place to ask about another difficulty I'm having - when the game starts, the mouse is positioned at the middle of the screen, but upon the tiniest movement it goes to (0,0) as if it was actually there to begin with.

Try an updateWorldBounds() on the spatial and see if that works, might be that it has none.