How can i scale a model to 100wu?


#1

is it possible to set the model size to exactly 100 world Unit? and how to do it?


#2

not sure if i understand you correctly, but i hope you mean something like:

   Vector3f bound = obj.getWorldBounding();
   float max = Math.max(Math.max(bound.xExtent*2, bound.yExtent*2), bound.zExtent*2);
   float resize = 100 / max;
   obj.scale(resize);

it will not be exactly, but will auto-scale to required bounding. not sure if there needed to be *2, but i think yes


#3

The Real question is what you want to do?
If you model was 1wu wide, you’d scale by 100.
Ox’ Solution will scale so that the largest extent is 100wu wide, others might be smaller.

Technically you could also use scale(x, y, z) to scale so everything is 100wu wide, but the question seems wierd in-it and paul always says that non-uniform scale most things (some code I’ve seen doesn’t even look at the scale). So you probably want to scale in your model editor first. especially since this approach would just distort the model by hugely changing the proportions.


#4

yes, thats correct, but i belive he wanted to do for example:

  1. “put model in gui with specific scale”
    or
  2. “make preview system, that scale models to match, instead of moving camera far away”

or even something else. i just answered exact question :slight_smile:

but yes, we should ask what is primary goal of this.