Model scale [SOLVED]

Hi all!

How can I scale a model so that its largest dimension is mapped between [0,1]?


Use this to get a model’s dimensions:

min, max = model.getTightBounds()
dimensions = max - min

You can then use that to set the model’s scale, with a little math.

Thanks for the answer!

The code I used is the following:

minLimit, maxLimit = self.model.getTightBounds()
dimensions = Point3(maxLimit - minLimit)
compList = [dimensions.getX(), dimensions.getY(), dimensions.getZ()]
self.model.setScale(1 / max(compList))


Thank’s, I had similar needs (normalizing objects’ sizes) and this worked quite well :slight_smile:

Also an interesting read, an iterative algorithm to find tight bounds but which can be stopped in the middle of the processing (may be interesting for a future implementation of getTightBounds() in Panda3D?): … &q&f=false