Scale a geometry to a specific point?

I’m making a Tron-like game, so need to make a box and then have that box scale as the player moves down a line. I was creating a new box every time with the original position as the min Vector3f and the current position as the max Vector3f, and then setting that as my geometry’s mesh. But that seems really costly, so now I’m trying to instead scale the geometry to the necessary size as the player moves.

How exactly should I do this? I tried just making my geometry, then doing geometry.scale (0, 0, 20) but that just made my geometry disappear. Could someone post an example of how they scale a geometry?

Thanks very much!

e: New question in my last post!

try geometry.scale(20, 20, 20);

you scaled your node to zero in z and y directions, thats why it disappears

Ah oops that makes sense. When I try geometry.scale (20, 20, 20) it disappears still though. When I do geometry.scale (1, 1, 20) it stays the same size - shouldn’t that make it 20x larger though in the z direction?

e: Got it! It wasn’t working because the original box had a width of 0 in the z direction - so I guess when it tried scaling it in the z direction it disappeared. All good now, thanks very much!

Yes, just use the scale(float value) method, isnt there one? Otherwise try supplying a vector instead of single values:

geometry.scale(new Vector3f(20, 20, 20)); What is your geometry? A quad would not change size from 1,1,20 because it has no z dimension…

Yeah, that was exactly my problem - there was no z direction to start so it didn’t scale. Thanks!

e: Is there any way to make the geometry scale to a specific point, instead of by a multiple?

Lunnies said:
e: Is there any way to make the geometry scale to a specific point, instead of by a multiple?

Yep, math :P

Yeah I figured that’d be the case ><

I notice that when you scale a geometry, the mesh doesn’t get scaled as well - if you make a Geometry with a Box as the mesh, scale the geometry, and then print out an extent for the box - like ((Box)geometry.getMesh()).zExtent - the extents are the same as before the geometry was scaled. Is there anyway to make the mesh scaled up as well?

If there is a way to scale the mesh, each frame I would be doing the math to figure what factor to scale by, scaling the geometry, and scaling the mesh. Would that be just as costly as reinitializing a box with new min/max Vector3f’s, or would scaling still be more efficient?

Thanks very much for all the help :slight_smile:

Use the BoundingVolume to determine the “actual” size.