model.getBounds().getRadius - not real radius?

I have two models, a plane and a ring. The ring is parented to the plane.

I have some code that looks like this:
a = plane.getBounds().getRadius()
b = ring.getBounds().getRadius()

print a
print b

ring.setScale(a / b)

print a
print b

In the first pair of print statements, it seems the radius of the plane is larger (~5.95) than the radius of the ring (~1.39). In the second pair of print statements, it shows that the radius of the bounding spheres for the two objects are identical (as I would expect, after that setScale statement).

However the ring is still much smaller than the plane. So I use the model.showBounds() method and this is what I see:

The model.getBounds().getRadius() returns identical values for my plane and ring models. But when the bounding spheres are drawn, you can see quite clearly that the radius of the two spheres are not the same!

Why is this happening?
model.showBounds() is showing the bounds that model.getBounds() is getting right? Why would two objects that clearly have different radius of bounding spheres, get the same result from model.getBounds().getRadius()?

(Edit: Also, why is it that when I have parented the ring to the plane, with no other movements, the center of the ring is not set to the center of the plane?)

The value returned by node.getBounds() is the bounding volume in the coordinate space of the node itself. This is not the same thing as the coordinate space of render, which is what you see in the frame.

To put it another way, your ring must be inheriting a scale from a parent node, which is different from the scale(s) that the plane is inheriting from its parent nodes. If your ring is parented to the plane, perhaps it is the plane itself that has a scale on it.

In the absence of any setPos() calls, parenting a node to another model places that model’s origin at the other model’s origin. The origin is the (0, 0, 0) point in the model. It is not necessarily the center.


Spot on, the plane has a scaling of 0.5

The plane is parented to something that is not scaled.

When I took the 0.5 into account, and adjusted the ring’s scaling to that, the ring now scales correctly.

That makes sense, but is there any way i can say - i want the center of the ring to be at the center of the plane?

I tried plane.getBounds().getCenter(), but it does not give me the center relative to where the plane is.

The best way is usually to load the plane in a modeling package, determine where the center is–say it is at (0, 5, 0)–and then setPos() your ring to (0, 5, 0).

If you really want to determine this totally automatically, you need to divide the center of its bounding volume by the plane’s scale. Or, perhaps even better, you can use the average of the two points returned by plane.getTightBounds().


Okay, thanks. I’ll go look into both of those methods.