Can't get the object dimensions correctly using the BoundingBox

Started by jkndmiththinda, March 18, 2012, 07:15:49 AM

Previous topic - Next topic

jkndmiththinda

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!

EgonOlsen

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...