Bounding box for an egg object

I try to get the bounding box from a NodePath (where I load an egg file) without success.
I tried with calcTightBounds and getTightBounds but the points values are wrong, they not corresponding to the showTightBounds result.
The methods return minPoint=(-1,-1,-1) and maxPoint=(1,1,1) but my object is not a cube.
How to get the showTightBounds values?

I’m not sure what you mean. The “tight bounds” of a model is always a box, and calcTightBounds gives you two coordinates that define that box. (getTightBounds is a wrapper method that simply calls calcTightBounds internally.) If you think this is incorrect, can you show a screenshot of the showTightBounds result for comparison?

This is an example of showTightBounds result.

I’m having trouble accessing that. But is it a box ranging between (-1, -1, -1) and (1, 1, 1)? Because that’s what it’s supposed to look like.

The direct link of the screenshot:
The value of getTightBounds is (-1,-1,-1) and (1,1,1), or (-5.68649, -98.063, 0.899927) and (94.36, 2.21888, 100.9) after apply transforms, … (like a cube with 100x100x100 edges)
On the picture, the showTightBounds of the object is right adjusted.

showTightBounds() works by internally calling calcTightBounds() and displaying the result. The only difference between that and the result you get directly might be due to the coordinate space you’re looking at the answer in. Make sure you apply all of the relevant transforms to convert your answer to the coordinate space you expect.


I checked the transforms and changed some mistakes but I have a strange behaviour with calcTightBounds, I compute the bounds at two places without obtain the same result:

class Item():
  def __init__(self):
    self.node = NodePath("ItemNodePath")

  def draw(self):
    lItem = loader.loadModel(lFilename)
    lMinPt, lMaxPt = Point3(), Point3()
    lItem.calcTightBounds(lMinPt, lMaxPt)
    print format(lMinPt)  #<-- Point3(-2.81876, -0.464872, -0.000734872)
    print format(lMaxPt)  #<-- Point3(2.81877, 0.464872, 20.0392)
lItem = DrawableItem()
lMinPt, lMaxPt = Point3(), Point3()
lItem.node.calcTightBounds(lMinPt, lMaxPt)
print format(lMinPt)  #<-- Point3(-2.81876, -0.464872, -0.000734872)
print format(lMaxPt)  #<-- Point3(100, 100, 100)

As you can see, the result is not the same when I’m call calcTightBounds in or out the class Item.
The difference is made on the max value returned, I find Point3(100, 100, 100) again. Like an initialized value.

What happens if you use self.node instead of lItem inside your class, to match the lItem.node you use outside the class?


Ok, I find my mistake!
I haven’t see this reparentTo on the Item class:

class Item():

I had these lines to draw the axes of the object.
The prints which succeed the reparentTo in the class doesn’t show the issue.
The axes are take into account after to go out the class.

Thanks for your help.
Best regards,