Mesh faces inside frustum + visibility of mesh faces


#1

Hi,
I have two questions concerning Viewing Frustum inclusion of mesh faces and visibility of these faces.

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

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

Thanks,
Tomas


(Rajaa Issa) #2

@jeff , can you help?


#3

@jeff or anyone else can help with this?

Tomas


(Steve Baer) #4

I would get the transformation from world to clip for the viewport and then transform faces to see if they lie inside of or cross the clipping volume.


(Jeff Lasor) #5

How fast does this need to be? Here’s something based on what Steve just mentioned…

vp = your viewport to test…
p = a vertex point

ON_3dPoint q;
ON_Xform w2c;

vp.GetXform( ON::world_cs, ON::clip_cs, w2c );
q = w2c * p;

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.

-J


#6

Thanks Steve and Jeff.
As fast as possible, of course :smile: 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,
Tomas


(Steve Baer) #7

Probably best to search for ‘clip coordinates’ on google there are going to be a lot of sites that can explain this.


#8

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.

Tomas


#9

Hi all,
the solution I’ve described works just fine and it can be even speeded up by parallelization, so the final speed is sufficient.

Tomas