PDA

View Full Version : closestPointOnMesh problems


bombadillo
09-25-2004, 11:38 AM
I used the closestPointOnMesh node to check the closest point but when I try to check the closest point it gives me different coordinates than he should.

for example

I have a pSphere1 object translated of 4 units along the Y axis so i write this in the script editor:
///////////////////////////////////////////

createNode closestPointOnMesh;
connectAttr pSphere1.worldMesh closestPointOnMesh.inMesh;

setAttr closestPointOnMesh1.inPosition 0 0 0;

float $position[] = `getAttr ("closestPointOnMesh1.position")`;

print $position;
-------
Result
0
7.62
0

/////////////////////////////////////////

The closest point to the origin should be the lowest vertex of pSphere1
but if I check its position with:
/////////////////////////////////////////

pointPosition -w pSphere1.vtx[90]

the Result is
0
3
0

and i know this is the right result.

So, someone knows what is the result that closestPointOnMesh gives me. pleeease.
It's all day I'm kocking my head on the table but still can't find a solution.

James Jacobs
09-25-2004, 01:16 PM
If I remember correctly, this node makes the assumption that your units are set to centimeters.
To correct the problem, you'll either have to set your current unit to centimeters, or pipe the output from this node into an expression or utility node network that will convert the position in centimeters to your current unit of measure.

-hope this helps
-jj

bombadillo
09-26-2004, 01:13 PM
Thank you James.
I made some test and i figured out that there is a proportional constant of 2,54 so i simply divided the result :).
Now everything works fine

James Jacobs
09-26-2004, 01:50 PM
Thank you James.
I made some test and i figured out that there is a proportional constant of 2,54 so i simply divided the result :).
Now everything works fine

Sure thing. :)

As an aside, the closestPointOnMesh node seems to have another caveat.
If your mesh contains 3 or N-sided polys, the "closest point" may be slightly off
for those polys.

It looks as though the the node calculates a normalized U and V along the first two edges of each poly in the mesh.
Consequently, if the polys are N-Sided, not all of the poly surface will be mapped.
If they are triangles, only half of the mapping will be meaningful.

-jj

bombadillo
09-28-2004, 01:05 PM
Strangelly everything works fine except than when I works with polyTorus.

????

I really can't figure it out.
It gives me strange results.
Is there something different between the costruction of a polyTorus and the other polygons?

I checked the normals and they seem correct. So i really dunno.
Does anyone know something about this?

CGTalk Moderation
01-19-2006, 09:00 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.