Reposition NodePath to its Bounding volume center?

I used to know how to “re-center” a NodePath like this by getting its “tight bounds” but I have forgotten how to code that. Checking the API now, getBound() returns a BoundingSphere which is less useful here.
So how can it be done?

Возможно решение. Draw a 2D bounding box around a randomly placed 3D model

min, max = np.getTightBounds()
center = (min + max) * 0.5
np.setPos(np.getPos() - center)

The bounding sphere can also be used. It has a center point you can query. It will be faster than getting the tight bounds.

1 Like