Hi,
I have two questions concerning Viewing Frustum inclusion of mesh faces and visibility of these faces.
What is the best way to determine if mesh faces are inside a Viewing frustum? I am considering to use the information from ViewportInfo.GetFar(Near)PlaneCorners method which gives 4 corners of this planes. Then I would constuct Truncated Pyramid and test, if the mesh faces are inside the frustum by Mitches’ function - Select objects inside solid … Is there any method that will do this in some easier way?
I also need to know, which faces contained in Viewing frustum are visible. Can I somehow use the ZBuffer? I don’t want to render the scene, I just want to return indices of faces, that are “in the front” in current view.
if ( fabs(q.x) <= 1.0 && fabs(q.y) <= 1.0 && (fabs(q.z) <= 1.0) )
…Then the point is inside the frustum
I should point out that there is a “IsVisible( p )” method on the pipeline that does exactly that… but acts on the pipe’s viewport and not some arbitrary one.
As for culling points because they’re occluded by other (or parts of other) faces… That’s a whole different story and I’ll need to think about it for a while… display tricks are currently the only thing I can think of at the moment, which aren’t really available in the SDK.
Thanks Steve and Jeff.
As fast as possible, of course No, it’s a part of the longer calculation, so speed isn’t the key element.
I’m not sure I get the transformation part…Basically you are creating new point (q) in the tranformed position and then checking the inclusion by fabs? What is it exactly doing?
Thanks Steve,
I’ve studied this topic a little and I’ve already implemented it to my solution and it seems it works just fine.
Regarding the occluded points. I’ve already used in another part of my code the Rhino.Geometry.Intersect.Intersection.MeshRay function, that could solve this problem. I would send the MeshRay to each center of face and compare the distance of intersection with the distance to this point.
Can you think of some smarter and probably faster solution? Although the speed isn’t the key parameter.