distance from a point to an Object3D?

Started by Melssj5, July 13, 2007, 06:23:29 PM

Previous topic - Next topic

Melssj5

Can I get the distance from a point to an Object3D?, not just getting the difference from its centers, but calculating a perpendicular projection from a point to the body?. I will post images later

Nada por ahora

EgonOlsen

#1
You can iterate through all transformed vertices of the object by using the PolygonManager, calculate the euclidean distance from your point in world space by yourself and take the lowest value as the distance (which is not always the shortest distance because it ignores that a polygon's plane can have a shorter distance than it's points, but it may be good enough).

Edit: Or you can use the IVertexController to get the vertices in object space and do the check there, after transforming your point into object space using the object's inverse world transformation...should be more efficient.

Mizuki Takase

That sounds painfully slow but then again, I cannot imagine any other way to do that... X_X

EgonOlsen

For getting the smallest distance, it's not needed to really calculate it, so you can at least leave the square root out and calculate it once on the lowest found value. It should be fast enough. The collision detection methods are doing more work and a usually fast enough too.