View Full Version : closestPointOnMesh problem
kletterget 06-18-2009, 10:09 AM I'm using the closestPointOnMesh node to detect, well... the closest point on a mesh from a locator.
So, I've connected the meshShape.worldMesh[0] to cpomNode.inMesh and locatorShape1.worldPosition[0] to cpomNode.inPosition.
It works exactly as I would expect, but only if the transform node of the mesh is at the origin. If I move the transform node of the mesh, the position returned doesn't change accordingly. Great for skinned objects, where the transform stays at the origin and the vertices are deformed separately, but how do I get it to work for objects whose transform node has moved?
I guess I could add the result to the worldSpace coordinates of the transform node, but this seems like an unwieldly and unnecessary step for an otherwise useful node.
Any help greatly appreciated!
/cameron
PS using maya 8.5 on Fedora
|
|
greatPumpkin
06-18-2009, 03:18 PM
if you are rigidly transforming your mesh, why do you need closest point on surface? Anyway another hack-y workaround could be to cluster the mesh and transform the cluster- slower computationally, but faster since you don't need to hook up any utility nodes- never noticed this was an issue before so not sure if there is a more standard workaround.
Keilun
06-18-2009, 05:20 PM
Reading up on the closestPointOnMesh node, it does all of its computations in local space. There is an attribute that you need to populate that represents the transform of the mesh. Have a look at the node documentation. Relevant attrs are:
inMesh(im)
Input mesh for the info
inputMatrx(ix)
Input transformation matrix of the mesh, which allows the closest point to be calculated in world space coords. This defaults to the identity matrix, so if it's not set to something else, the closest point will be calculated in the mesh's local space.
So:
1. Try connecting outMesh to the inMesh.
2. Connect the transform's worldMatrix to inputMatrix.
3. Connect the locatorShape1.worldPosition[0] to inPosition
kletterget
06-22-2009, 12:16 PM
strange, I don't see that in my documentation. All it says is:
This node returns the closest point of an (x,y,z) point (attribute
"inPosition") to a mesh (given by the attribute "inputMesh").
You can query the closest
(x,y,z) point (attribute "position") or you can query the closest
mesh (u,v) point (given by attributes "parameterU" and "parameterV").
...and there is no mention of any inputMatrix attribute in the documentation or in the connection editor. The only input attribute which exist are inMesh (im) and inPosition (ip). What version of Maya are you running?
benio33
06-22-2009, 01:35 PM
kletterget,
1. make connections like the ones in the picture:
http://img35.imageshack.us/i/closestpointonmeshtrans.gif/
2. "plusMinusAverage" node make it as add.
3. the sphere is your reference mesh
4. parent the controll locator (locator1) under the sphere.
simple yet powerful network.
Cheers,
Benio
kletterget
06-24-2009, 07:51 AM
yeah, like I said in my first post, I could always add the result of the cpomNode to the worldSpace coordinates of the transform node, but it seems all a bit beside the point.
Now I'm really curious about Keilun's reply: It sounds great and exactly what I'm looking for, but I just cannot find any evidence of it in the documentation or within Maya itself.
benio33
06-24-2009, 08:23 AM
Why is it beside the point? It computes the result based on the SHAPE NODE not final mesh. And final mesh output is addition of transform matrix over the each element vector, therefore if you add the shape node position to transform matrix it works fine. You can later on, after parenting the locator reference, constraint the locator to a new locator, so the locator controller doesn't move together with the mesh, and it's done. Maya cannot always give you the result "out of the box" because we'd end up using MAX which gives you millions of out of the box results but if your needs are not in the millions you're screwed, and Maya lets you build the structure yourself ... I think this is exactly this situation, probably it would be best if it worked the way you need i to at the moment, and maybe there is moer srtaight away solution I'm not aware of, but I think the one I provided is really simple and not so complicated one could complain about.
kletterget
06-24-2009, 08:45 AM
yes, you have a good point there actually.
It's just that in my specific problem there's a whole hierarchy of transform nodes to deal with, as well as shape-level deformations. Putting together a network like you suggested would be rather unwieldy, and doesn't allow for the rotations of the transform nodes. Any possiblilty of connecting the inputMatrix of the transform node in some way would be just fab!
In fact, now that think about it, I guess there's nothing stopping me from connecting the cpom-node to a pointMatrixMult node, and get the result from that once I connect the mesh's transform node to it aswell. That just might work actually (hopefully).
I'll give it a burl...
Keilun
06-24-2009, 05:34 PM
strange, I don't see that in my documentation. All it says is:
...and there is no mention of any inputMatrix attribute in the documentation or in the connection editor. The only input attribute which exist are inMesh (im) and inPosition (ip). What version of Maya are you running?
Sorry, I've been offline for a bit.
I was checking 2009 docs. You're looking at the DG node documentation, correct? Below that summary blurb, there should be a listing of all the attributes and a description of each attribute.
Beyond just relying on documentation, have you tried my suggestion? I'm somewhat concerned that the attributes aren't showing up in your documentation (perhaps you're on a really old version of Maya?). The node documentation is auto-generated from the source code itself. Not sure if there was any recent work done on that node (my guess would be no).
kletterget
06-25-2009, 06:55 AM
I was checking 2009 docs. You're looking at the DG node documentation, correct? Below that summary blurb, there should be a listing of all the attributes and a description of each attribute.
Ah that explains it. We're running maya 8.5. We like doing things old style here...
The documentation (http://download.autodesk.com/us/maya/docs/Maya85/Nodes/closestPointOnMesh.html) lists only the following attributes:
Attributes (18)
closestFaceIndex, closestVertexIndex, inMesh, inPosition, inPositionX, inPositionY, inPositionZ, normal, normalX, normalY, normalZ, parameterU, parameterV, position, positionX, positionY, positionZ, result
So any hope of connecting anything to any inputMatrix is quite non-existent.
Maya cannot always give you the result "out of the box" because we'd end up using MAX which gives you millions of out of the box results but if your needs are not in the millions you're screwed, and Maya lets you build the structure yourself ...
Just on that point, I checked the closestPointOnSurface node, and it does exactly what I want! Why have they constructed a node for nurbs surfaces which takes into account the parentMatrix of the object but left out that detail when they made one for polygons? I find that quite frustrating.
In fact, now that think about it, I guess there's nothing stopping me from connecting the cpom-node to a pointMatrixMult node, and get the result from that once I connect the mesh's transform node to it aswell. That just might work actually (hopefully).
I'm not having much luck here. It doesn't seem as simple as I had hoped. I still get an incorrect result. I'll keep battling on...
benio33
06-25-2009, 08:55 AM
Just on that point, I checked the closestPointOnSurface node, and it does exactly what I want! Why have they constructed a node for nurbs surfaces which takes into account the parentMatrix of the object but left out that detail when they made one for polygons? I find that quite frustrating.
That's a good point ... I don't know why :( maybe the polygon developers there are less skilled then the NURBS ones - just look at the poly modelling in Maya comparing to NURBS one :)
Keilun
06-25-2009, 03:59 PM
Ok so then for 8.5, could you try transforming the point into local space of the mesh before sending it into the cpom node? Let it run its computation in local space and then you can convert it back once it comes out.
That is:
1. Connect outMesh to inMesh
2. Create a pointMultMatrix connecting your input point and the inverseWorldMatrix of the mesh.
3. Connect that resulting point into the cpom node.
4. Create a pointMultMatrix for the output, connecting output point and worldMatrix.
kletterget
06-26-2009, 06:53 AM
...and we have a winner: It works a treat! I guess that having two pointMatrixMult nodes either side of the cpom node isn't much extra work in the grand scheme of things.
Thanks a lot for all your input, the both of you!
Happy friday to you :thumbsup:
CGTalk Moderation
06-26-2009, 06:53 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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.