PDA

View Full Version : Problem: Deleting non-viewable faces (Volume select modifier)


magost
10-12-2008, 09:04 PM
Hi all

I have a little problem with the Volume select modifier as i said on the title. First of all i will explain you what i'm trying to do in order to know if there's a better solution.
I want to remove all the faces of an object that do not appears on camera.
First of all i simulate the camera view with a pyramid aligned to the camera object. I don't know the exact size so i have to guess (there's any way to know the exact size of the camera view for doing a pyramid with those values?)
After that i add a volume select modifier for knowing the faces that lay inside that pyramid in order to remove the others.
The problem i have is that the faces that lay inside of the pyramid i use as mesh object are not selected. If i do it by hand it works fine but it does not happend the same if i use scripting. Someone does know the reason?

Thanks in advance for your help!

The code i'm using is this:

obj = box lengthsegs:10 widthsegs:10 heightsegs:10
camPyr=Pyramid width:120 depth:80 height:165
camPyr.pivot = [camPyr.pos.x, camPyr.pos.y, camPyr.pos.z+camPyr.height]
cam = Freecamera fov:45 targetDistance:160 nearclip:1 farclip:1000 nearrange:0 farrange:1000 mpassEnabled:off mpassRenderPerPass:off transform:(matrix3 [0,-1,0] [0,0,1] [-1,0,0] [-165.639,-2.75248,0])
ResetXForm camPyr
camPyr.transform = cam.transform
addModifier obj (volumeselect level:2 type:1 volume:3 node:camPyr)
addModifier obj (edit_Mesh())

ypuech
10-12-2008, 09:15 PM
Have you tried to output the results of the actions by hand in the MAXScript listener ?

magost
10-12-2008, 10:33 PM
Hi!

Yes, i've seen the output and is the same i'm using, that's why i don't know what's happening.

ZeBoxx2
10-13-2008, 12:41 AM
heh.. this worked just dandy in 3ds Max 5

Anyway, popped up 3ds Max 2009 and, lo and behold, it does indeed fail to select. If you move the box around a bit, you can see that it actually does get selected near the apex of the pyramid, then just magically stops getting selected further down. Increasing the segments of the Pyramid helps a bit, giving it a lot of segments seems to make it work everywhere in the volume, but I'd stress 'seems to'.

Edit: Hum.. in fact, what it -is- selected when it's selecting something (with the Segments of the Pyramid at 1), isn't even what's inside the volume. See attached image. Yikes.

mcernusca
10-13-2008, 12:51 AM
I was getting weird results with this method too. I went with a different solution that involves creating a light to match the camera and baking the lighting information into the geometry (vertex color). You can then delete all the purely black faces as there is no way the camera can see them.

Just a thought. I can post some sample code if you are interested.

ZeBoxx2
10-13-2008, 01:06 AM
looks like it just really, really hates the Pyramid object for some reason. Even when collapsed to a mesh, even if the Apex is removed and made into a nice quadrilateral, even when the -base- is turned into a 2-face quadrilateral (instead of the 4), even if I snapshot it as a mesh, even if I export it and then import it back in... that volume select keeps messing up.

If I use a Box and Taper that box, however... it has no complaints whatsoever.

*puzzled*

Anyway...

For the camera's view dimensions - remember your trigonometry. The length of the opposing side of a triangle is equal to the length of the adjacent side of the triangle multiplied by the tan(gent value) of the angle between the adjacent side and the hypotenuse. Lots of fancy words, but what it comes down to is that you can take the camera's FOV, divide it by two, get its tan(gent value), then multiply that by the distance from the camera, and you get half the width of the camera's FOV at that distance. Multiply by two to get the full width. Multiply by the aspect ratio of the image output (don't forget the pixel aspect as well) to get the height.

magost
10-13-2008, 07:50 AM
Thanks to all for your replys. I'm gonna try all you said. I thought it was going to be easier when i thought about it but it doesn't :sad:

mcernusca i will think about your idea but right now i don't really see how to do it.
ZeBoxx2 thanks for all your attempts, it seems that max doesn't likes the egyptians.

CGTalk Moderation
10-13-2008, 07:50 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.