Is there a way to set the size of a spatial after it has been created

I have a spatial (Quad or Box) that I have created lets say that it is (2,2,2).

Is there a method that will allow me to set the size to (5,5,5) instead of having to scale(2.5, 2.5, 2.5)?

Thank you for your time.

something like:

[java]
public static void scaleTo(Geometry geometry, Vector3f newSize) {
if (geometry.getModelBound() instanceof BoundingBox) {
BoundingBox boundingBox = (BoundingBox) geometry.getModelBound();
geometry.scale(newSize.getX() / boundingBox.getXExtent(), newSize.getY() / boundingBox.getYExtent(), newSize.getZ() / boundingBox.getZExtent());
geometry.updateModelBound();
}
}

[/java]

might do it… not tested however

1 Like

http://hub.jmonkeyengine.org/javadoc/com/jme3/scene/shape/AbstractBox.html#updateGeometry(com.jme3.math.Vector3f,%20float,%20float,%20float)
http://hub.jmonkeyengine.org/javadoc/com/jme3/scene/shape/Quad.html#updateGeometry(float,%20float)

Thank you for your input.

Ok, I have implemented this now.

It is working properly in all aspects until I rotate the model. When I rotate the model by 45 degrees the existing model bound extents come back different than expected.

Anyone know how I could set a specific size of the model and have it rotated into a 45 degree position without being distorted?

I highly suggest to place a test case which we just could copy paste and see, I personally have no clue what you mean, what you try or what exactly is not like you wished to be. And wow “one year later”…