reForm01 January 2009, 07:47 PMSay you have a low poly cylinder with all the faces in the same smoothing group, is it possible to work out the normal of a point on a face based on the curvature defined by the smoothing between faces?
ZeBoxx2
01 January 2009, 08:18 PM
I may be mistaken - autogrid and such handily respect derived and explicit normals, so I hope I'm just missing something - but I think you'd have to do it manually - getting the face normals, checking the smoothing groups and calculating (via interpolation) the appropriate normals from those. Slightly easier may be through the edit normals modifier interface (get the normals from each of the face corners directly), which would also let you handle explicit normals.
Near's I know there's no 'getSurfaceNormal <node> <face> <bary coords>', at least.

Edit: just to note - you mentioned that they all have the same smoothing group - in that case, you can just interpolate between the vertex normals of each vertex for a given face using the mesh/poly methods of getting the vertex normal.

reForm
01 January 2009, 09:50 PM
Edit: just to note - you mentioned that they all have the same smoothing group - in that case, you can just interpolate between the vertex normals of each vertex for a given face using the mesh/poly methods of getting the vertex normal.

I guess that leads on to the next question of how one would work out the correct interpolation for the surface-point-normal.

Given the face could be attached to n-faces I would need to loop through all the adjacent faces to get their normals, and then measure the distances between the face centers and edges to work out the correct weighting to give each normal. Am I right in thinking an edge between two faces is always at the midpoint between the two face centers?

It quickly becomes quite a complicated process to my mind! hmmm

ZeBoxx2
01 January 2009, 10:17 PM
I think that the normal at the barycentric center of the face is the same as what getFaceNormal() returns - so if you just need it at the center, you could just use that. If you need it for an arbitrary barycentric coordinate on the face, then all you need to do is interpolate between the 3 vertex normals of that face (no need to check the other faces*), based on the barycoord - near's I know, it's a linear interpolation. I think there's some interpolation stuff in the math functions sticky in this forum.

* that 'no need to check other faces' hinges entirely on the assertion that the entire object only has a single smoothing group. If it does not, then you'll have to get really down and dirth with getting face normals, checking whether an adjacent face is in the same smoothing group - determine the vertex normal for just that face from that (again, edit normals interface gives more direct access to this), and then proceed as you would before.

Dare I ask what you're trying to do? :)

reForm
01 January 2009, 10:42 PM
Thanks, I forgot that the vertex normals would be an easier approach.

Haha, well if I told you I'd have to kill you.... well not quite. I'm trying to write a script or plugin that distributes objects on another object. But, to go beyond the normal scatter object, I intend this plugin to deform the child mesh's to conform to the shape and curvature of the object they are being applied to.

I have the basics working, I'm just looking at adding further functionality (ie being able to infer the curvature of a low poly parent object to smoothly deform the child object across its surface).

Hope that makes some sense!

ZeBoxx2
01 January 2009, 11:57 PM
yep, makes perfect sense :) good luck - sounds like a nice project

SyncViewS
01 January 2009, 11:32 PM
Hi Patrick,
maybe it can help you to know that tools like intersectRay, mouseTrack, thePainterInterface, take into account the face normal corrected by the smoothing groups.

You can get for example the actual face normal of a specific point on a surface, by casting a ray passing through the point and using the intersectRay to get a new ray composed by the intersection position between face and first ray (your point) and a vector representing the corrected normal.

- Enrico

CGTalk Moderation
01 January 2009, 11:32 PM
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.

1