How to calculate height of the loaded object?

Hi, all:

Question again.

After loading a Scene, I would like to know the loaded object’s absolute height at the very first loading without any further transform yet.
How to do that?


int flags = ObjectFile.TRIANGULATE | ObjectFile.STRIPIFY | ObjectFile.RESIZE;
ObjectFile f = new ObjectFile(flags, 0.0f);
m_S = null;
try {
	m_S = f.load(fname);
} catch (FileNotFoundException e) 
{
        ...
}
m_BGFace = m_S.getSceneGroup();
m_Object3d = (Shape3D)m_BGFace.getChild(0);
Bounds m_ObjBounds = m_Object3d.getBounds();
// Now, I would like to obtain the current size (better in 3 dimensions) of m_Obj3D !!

It seems “.obj” file is stored in a specific format that, the longest dimension is used to normalize the loaded object.
Say, in may case, my .obj is stored in the way that:
since from the top to bottom, the object is longest, longer than the size from left side to right side,
and longer than the size from the front to the back, so, the very top line of the object has the coordinate (y_top = 1.0)
and the very bottom line of the object has the coordinate (y_bottom = -1.0)

However, the size (1.0-(-1.0)=2.0) is corresponding to how many pixels on the screen?

This seems to have nothing to do with getLocalToVworld(), right?

Seriously urgent. Please do help.

Best Regards
JIA

I’m not sure what you’re using, but if you determine the distance between the farthest top point to the farthest bottom point, and then multiply that by your scaling value, you should have the correct size.

Hi, Thanks elias !!

You are absolutely correct.
If I’m able to know the distance between the farthest top point to the farthest bottom point,
I should be able to calculate out the correct size.

You point out what’s the key, but you didn’t show me the answer !!!
How can I obtain the coordinate of the farthest top point? and How can I obtain the coordinate of the farthest bottom point?

Can you give me a clue? I know that getLocalToVworld() might work, but it always gives out the value
1.0 for the farthest top point , and the value.
-1.0 for the farthest bottom point.
getLocalToVworld() doesn’t actually consider what is the current canvas size, say 640*480.
getLocalToVworld() always givems 1.0 and -1.0 for the farthest top and bottom points.

What I need, is not 1.0 or -1.0, I need something representing the row number of this point !!! For instance, 239 and -157.

Hope you can really help !!!

Best Regards
JIA

you could try getBounds(). If it is a Shape3D it will be a BoundingBox otherwise it is a BoundingSphere.

Hi, Thank you so much Tom.
You are always helpful.

I got the bounds of the loaded object.

Bounds m_bounds = m_Obj3d.getBounds();

And the current m_bounds is of value:


lower=Point3d
x=-0.88
y=-1.0
z=-0.67
upper=Point3d
x=0.88
y=1.0
z=0.67

However, as we can see, the bounds are normalized so that the object’s longest axis (Y) is normalized to “between -1.0 and 1.0”.
I’m still not able to find the value mapping to the screen.
what I mean is
y=-1.0 should be corresponding to around -100 pixels, while
y=1.0 should be corresponding to around +100 pixels.

Can you help please?

Best Regards
JIA