Selecting All Visible Faces
-
And another problem with raytest is what points to test? testing just vertices isn't enough, they could all be hidden from the camera, but a part of the surface might be visible.
-
I just wrote a test code that run pickhelper on every x,y of the screen and adds everything it hits to the selection.
It worked ok. Biggest problems are that it can miss tiny faces (though it was a LOT better than I thought it would be) and even worse - it was over-zealous. It added things that were definitely not visible.
But I'd say it was about 80% good. You can play with it here:
WARNING: This is EXTREMELY slow. Minimize your window to a large thumbnail size view if you just want to quickly test this. Full size window takes easily over an hour to process I think.
view = Sketchup.active_model.active_view Sketchup.active_model.selection.clear w = view.vpwidth h = view.vpheight w.times do |x| h.times do |y| ph = view.pick_helper ph.do_pick x,y t = ph.all_picked t.each do |ent| if (ent.is_a? Sketchup;;Face) or (ent.is_a? Sketchup;;Edge) Sketchup.active_model.selection.add ent end end end end
-
The pick_helper has an aperture, have you tried adjusting that and see if you get different results?
-
No, I did not play with it at all....might be intersting.
I think the reason it over actively picks things is at least 2 fold. 1 - I am adding all picked ents (as opposed to
best_picked
, which I think you hit an edge of a face that is not visible, it returns the face anyhow. 2 - it seems to pick right through close faces. So if a hidden face is clse to the front face, I think it wll pick right through the front face, much like z-fighting. -
Hi Chris, That's a neat snippet.
-
Thanks, it would be a lot cooler if it was fast and accurate I would like to play with the aperture size. Maybe that would help speed things up? What if the aperture could be sut to the height and width of the monitor, and then just run a single "pick" and choose all selected. I'll try to play with it when I get a chance, unless someone beats me to it.
Chris
-
I was thinking that the aperture was why you got entities not really visible,,,
-
Chris, I used your scanning engine in this plugin. It adjust the fov to decrease the scanning time, but it is still slow. However it will help me port, and correctly face my Cad models for visualization in Sketchup. Thanks.
The attached images are of a model that contains a total of 2,000 edges and 650 faces. It took about 45 seconds to check the view and reverse the back faces.
-
Chris's method along with 'deselect faces that have normals away from camera'
will do the task,
What if,
Just to filter the occluded faces.
but might be elementary
Is it feasible to project random points from planes in the camera.direction to test if the points do project on other planes?Would it be taking too much to calculate?
this filter might include the partially visible ones any ways. -
I couldnt understand the way they did it here
http://forums.cgsociety.org/archive/index.php/t-197347.html -
@gude said:
I couldnt understand the way they did it here
http://forums.cgsociety.org/archive/index.php/t-197347.htmlThat is the method I mentioned earlier - it selects the faces which normal is pointing towards the camera - but it doesn't take into account other faces blocking the view.
Advertisement