Still trying to understand setLocalScale… this should be simple!

I’m really scratching my head on this one. The bottom line is that I instantiate a Box geometry, draw it, and then scale it and draw it again. Here is some code:



public void simpleInitApp()




cam.setLocation(new Vector3f(0, 15, 45));

cam.lookAt(Vector3f.ZERO, Vector3f.UNIT_Y);

mBuildingWidth = 16f;

mBuildingHeight = 1f;

mBuildingDepth = 16f;

// building shell

Box b2 = new Box(new Vector3f(0, mBuildingHeight/2f, 0), mBuildingWidth / 2f, mBuildingHeight / 2f, mBuildingDepth / 2f);

mBuilding = new Geometry(“building”, b2);

mat = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);

mat.setBoolean(“UseMaterialColors”, true);

mat.setColor(“Ambient”, ColorRGBA.Black);

mat.setColor(“Diffuse”, ColorRGBA.LightGray);

mat.setColor(“Specular”, ColorRGBA.White);

mat.setFloat(“Shininess”, 12);



Then I have a method that updates the height of the building:


public void updateBuildingHeight(final float height)


Future fut = this.enqueue(new Callable()


public Object call() throws Exception


mBuildingHeight = height;

mBuilding.setLocalScale(1, mBuildingHeight, 1);


return null;







} catch (InterruptedException ex)


Logger.getLogger(BuildingGenerator.class.getName()).log(Level.SEVERE, null, ex);

} catch (ExecutionException ex)


Logger.getLogger(BuildingGenerator.class.getName()).log(Level.SEVERE, null, ex);




I’ve traced the source-code for setLocalScale, and all it does is set the x,y,z of the localTransform to the values passed to setLocalScale.

So, when I run the above, I get a box as expected. Then when I change the height to “2”, the System.out.println dumps:

(1.0, 2.0, 1.0) and the box doubles in size. See this image:

First image (box at scale.y = 2)

which is as expected. But if I update the height to “2” again (i.e., no change) by calling the updateBuildingHeight() function, although I still get a scale vector of (1.0, 2.0, 1.0), the box doubles in height again (this would make sense if we are actually scaling the height by two. See the next image:

Second image (box still at scale.y = 2)

But here is the catch!

If I update the height AGAIN with the same “2” value (i.e., no change!), the box then goes back to it’s previous height!! See image:

Third image (box at scale.y = 2)

What am I missing?!?

its a fixed multiplier… When you set it to two its double size, setting two again obviously doesn’t change anything, its still double size…

Exactly! So why does it sometimes double the height again? That’s why in the second image you see that the box is taller again, but the multiplier never changed! Must be something with my code somewhere… but I’m scratching my head on this one.

Maybe you scale a parent the second time

If that were the case, then why does it go back down in the third image? Bottom line is that I can make that function call (updateBuildingHeight) and it has unexpected results.

I’m guessing that it’s a threading issue. Now I just have updateBuildingHeight updating the height variable, and then setLocalScale happens in the simpleUpdate method… and now I have consistent behaviour.