[Maya][Python] Getting a list of occluded vertices in a camera view

Hello All,

I’m trying to simulate the output of a Kinect, by ouputting vertices of a model in point cloud pcd format. Getting the individual vertices into points in the point cloud is all fine, but I’d like to simulate occlusion as well.

Is there some way of getting a list of which vertices are visible from a specific camera view?

Thanks!

I’m going to guess that a custom vertex shader is your best bet. Viewport 2.0 does not support culling or vertex colors yet, so you are probably going to have to try something else.

I’m sure someone could come up with some crazy-ass solution involving tiny spheres at each vertex and rendering, but there’s got to be something easy… Does maya have any raycasting/intersection functions, like RayMeshGridIntersect in 3dsMax? Ie you could cast a ray from the camera to a point and see if it intersects with a mesh.

[QUOTE=Rob Galanakis;17764]I’m sure someone could come up with some crazy-ass solution involving tiny spheres at each vertex and rendering, but there’s got to be something easy… Does maya have any raycasting/intersection functions, like RayMeshGridIntersect in 3dsMax? Ie you could cast a ray from the camera to a point and see if it intersects with a mesh.[/QUOTE]

This is nothing I’ve ever seen I’m Afraid… Could you perhaps us the vertex normal and compare the camera vector to this? But this all depends on the density of vertices is. Or could you use the Clipping plane of the camera to manipulate it?

Thanks for all the suggestions. Based partly on the vertex shader idea, I’m trying the following-

Make a directional light, align it with the camera
Prelight shadows onto the mesh
Step through all of the vertices, get color values and if they’re above some threshold I haven’t worked out yet, then they’re not occluded.

It’s a bit ugly, and on big models is going to take forever, but I think it can maybe work.

have you considered using the zbuffer from the m3dview?

Use a distant light parented directly to the camera with no offset. The only problem you may face with vertex color baking (an awesome hack IMHO) is that Maya’s baking routines seem to fail a fair amount. This usually happens after you have baked a certain number of verts. You can usually restart Maya or reload the scene to fix it. Who knows, perhaps this has been resolved. I have a lot of experience with this, buy that was a few years back. You could also use a second light with a different color that is 180 degrees opposite if you needed to be able to tell occluded verts from shadowed ones…

> Does maya have any raycasting/intersection functions, like RayMeshGridIntersect in 3dsMax? Ie you could cast a ray from the camera to a point and see if it intersects with a mesh.

There’s a ray intersection plugin lying around called RayIntersect I believe, came in quite handy for a couple of plugins I made. Not sure if its still available/updated for later versions of maya.

Also, there’s fnMesh.closestIntersection method in the API, which is super useful. Its probably what you want.
This can be a bit of a bastard to setup your parameters and get results out of, so ping me if you get stuck.