Author Topic: Can't get the object dimensions correctly using the BoundingBox  (Read 748 times)

Offline jkndmiththinda

  • byte
  • *
  • Posts: 4
    • View Profile
Hi,
I am trying to determine how much space an object takes in 2D using the following method. But it doesn't seem to return the correct value.

float[] BoundingBox = 3DOBJECT.getMesh().getBoundingBox();
SimpleVector SV3D, SV2D;

SV3D.set(BoundingBox[1], BoundingBox[3], BoundingBox[5]);

SV3D.matMul(3DOBJECT.getWorldTransformation());

SV2D = Interact2D.project3D2D(WORLDOBJECT.getCamera(), FRAMEBUFFER, SV3D).normalize();

I expected SV2D.x to have the correct 2D width as displayed on screen, but it doesn't seem to give that.

Thanks for sharing this great engine!

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 11776
    • View Profile
    • http://www.jpct.net
Re: Can't get the object dimensions correctly using the BoundingBox
« Reply #1 on: March 18, 2012, 08:27:18 am »
No, that won't work, because you are not taking the min-values in to account. And actually, depending on the rotation of the object, what is min in object space could become max in world space, so you have to take that into account too. We had this topic a few month ago IIRC. There might be some code somewhere in the forum...