# How to change object size?

I realize this sounds like a simple question, but say I have an object of type Box wrapped in a Geometry object. I know I can scale/translate/rotate that object. But what if I just want to resize it?

For instance, consider that I have an interface that allows the user to specify the height of a cube. If they specify the height to be “20”, I can’t use that value to scale the cube because the new height would just be: current_height * 20. Rather, it’s almost as if I want to reconstruct the object:

[java]

Box b = new Box(Vector3f.ZERO, 30, new_height, 30);

[/java]

Hope this is clear…

[java]geometry.setLocalScale(1, new_height, 1);[/java] for the height?

Hmm. I can’t see any diference between “resize” and “scale”… you could scale the geometry : geo.scale(0, newHeight, 0);

If is not it what do you are waiting, tell us.

[java]

b.getYExtent().y = (new_height / 2);

b.updateGeometry();

[/java]

i found getYExtent() inherited in Box from AbstractBox, there doesnt seem to be a setter method, but i think the field is public.

new height needs to be cut in half because it alters the “extents” which change size equally in both directions from the center.

meaning you can increment the size of your box without scaling it, but it will grow and shrink up and down equally.

you may have to move it up or down by half the new height to position it where it was previously set.

its a bit different, but you wont have to scale by a factor, you can change size in increments along independent axes.

i wasnt able to test this, i hope it works.

Use math.

30 / 20 = 1.5, so thats the scale you need to get the box from 30 units to 20 units

Momoko_Fan said:
Use math.
30 / 20 = 1.5, so thats the scale you need to get the box from 30 units to 20 units

From 20 to 30 units.
pspeed said:
From 20 to 30 units.

Yes, this seems to make the most sense. Although, perhaps the simplest thing to do is just to start with a y-value of "1", and then scaling it is trivial.

Decoy said:
[java]
b.getYExtent().y = (new_height / 2);
b.updateGeometry();
[/java]
i found getYExtent() inherited in Box from AbstractBox, there doesnt seem to be a setter method, but i think the field is public.
new height needs to be cut in half because it alters the "extents" which change size equally in both directions from the center.
meaning you can increment the size of your box without scaling it, but it will grow and shrink up and down equally.
you may have to move it up or down by half the new height to position it where it was previously set.
its a bit different, but you wont have to scale by a factor, you can change size in increments along independent axes.
i wasnt able to test this, i hope it works.

I haven't found that using localScale() causes the box to move, but just to extend in the y-direction. Example:

[java]mBuilding.setLocalScale(1, new_height, 1);[/java]

(where the previous height is simply "1").

But duh… obviously that only works in the single case. Sorry for missing that

I’ll use simple math as suggested above :S