Hi all, so far I've learned a lot going through the archives -- I'm trying to leave a paper trail so anyone who comes after me will have an easier time of it. Apparently about a year ago Jason Osipa came through with similar questions, his experience has been very valuable for me.
I'm still curious about easy and standardized ways of getting and setting values of OpenMaya variables, but my main goal is to get the allIntersections node working: it should be storing the hitPoints of the intersections in an MFloatPointArray(), but so far I can only get the array to store one (0,0,0) point per mesh, which is not what I was expecting. I'm in world space, I can get the proper faceId and faceNormal, everything else seems to be working but the array. ...or the array's storing good values, but I'm extracting them improperly. I can't tell the difference right now. I've probably just set it up incorrectly, does this sound familiar to anyone? Cheers P On Feb 21, 9:27 pm, pjrich <[email protected]> wrote: > Just found Jason Osipa's > half-startedhttp://docs.osipaentertainment.com/Maya_API_Python_Attribute_and_Type... > which suggests there isn't an easy way, but I also found his oeRay.py > which is a plugin-ified version of closestIntersection, which is very > similar to the function I'm interested in... so I think I have a good > idea of how to do it the hard way if no easy way exists, by which I > mainly mean PyMEL. > > But I'd still love to know if there's an easy way. > > Cheers, > P > > On Feb 21, 6:52 pm, pjrich <[email protected]> wrote: > > > > > So far I've been able to extract the data through a roundabout method, > > but I don't have confidence in the result. I'm trying to find the > > points in space where a ray intersects a mesh, but though it's in > > world space and the ray should be passing all the way through the > > object I'm apparently only getting 1 intersection at (0,0,0). I can > > set it to "direction = Both" but in that case hitRayParams, which > > should return the distance, shows two intersections at the same > > distance, which I believe means it's just hitting both sides of the > > same polygon. > > > hitPoints = om.MFloatPointArray() > > hit = fnMesh.allIntersections(raySource, rayDir, faceIds, triIds, > > idsSorted, worldSpace, maxParam, testBothDirections, accelParams, > > sortHits, hitPoints, hitRayParams, hitFaces, hitTris, hitBarys1, > > hitBarys2, tolerance) > > hitPointsList = [om.MFloatPoint() for i in range(hitPoints.length())] > > for x in hitPointsList: > > print "hitpoint:", x[0], x[1], x[2], x[3] > > > So how do I get all the intersections in world space? > > > Thanks, > > p > > > On Feb 21, 2:57 pm, pjrich <[email protected]> wrote: > > > > I'm using a python wrapper of fnMesh.allIntersections, which uses a > > > number of other wrappers including MFloatPointArray() -- when I try to > > > get the contents of the array I only get a pointer to the array's > > > wrapper (I think): > > > > <maya.OpenMaya.MFloatPointArray; proxy of <Swig Object of type > > > 'MFloatPointArray *' at 0x23fed220> > > > > > I don't know enough about the API to use MFloatPointArray.get(), I get > > > errors like: > > > > # NotImplementedError: Wrong number of arguments for overloaded > > > function 'MFloatPointArray_get'. > > > # Possible C/C++ prototypes are: > > > # get(float [][4]) > > > # get(double [][4]) > > > > Is there an easy way to get these kinds of values with pymel, or to > > > work with these wrappers in general, besides learning C++? The Maya > > > API docs all seem to assume I already know it. -- http://groups.google.com/group/python_inside_maya
