Point Normal

On 26/08/2013 at 10:03, xxxxxxxx wrote:
Hi,
is there by any chance a function that will return the Point Normal, given a Point Object and a point id? Basically like the xpresso Point node...
Cheers
Michael

On 26/08/2013 at 10:31, xxxxxxxx wrote:
There is no builtin method. You can calculate the vertex normal by taking the average of the normal
of all adjacent polygons. A vertex without adjacent polygons does simply not have a normal.Cheers,
Niklas

On 26/08/2013 at 10:35, xxxxxxxx wrote:
There isn't even really a method to calculate polygon normals. There is PolygonObject.
CreatePhongNormals(), but it does require a (already cached / executed) phong tag.
Calculating the normals yourself might be the fastest way, simply calculate all polygon
normals for the mesh.> normallist[polyindex] = ((poly.VecB  poly.VecA) % (poly.VecC poly.VecA)).GetNormalized()
Then calculate the point normal for each point.
> pnormal = Vector()
>
> cnt = 0
>
> for each polygon attached to point:
>
> pnormal += normallist[polygon]
>
> cnt += 1
>
> pnormal *= (1.0/cnt)edit : nikklas was faster and FYI, the example is meant for triangles of course, for quads or
mixed meshes you have to extend the polygon normal calculation for nonplanar quads to the
fourth point.

On 26/08/2013 at 10:56, xxxxxxxx wrote:
Originally posted by xxxxxxxx
[...] FYI, the example is meant for triangles of course, for quads or
mixed meshes you have to extend the polygon normal calculation for nonplanar quads to the
fourth point.You actually only have to replace the C in your calculation with the D and don't take C into
account at all.points = op.GetAllPoints()
polygons = op.GetAllPolygons()
normals = []for p in polygons:
a = points[p.a]
b = points[p.b]
c = points[p.c]
d = points[p.d]n = (b  a).Cross(d  a).GetNormalized()
normals.append(n)The value of D == C for a triangle, therefore the calculation is valid for triangles and quads and
you do not have to distinguish them explicitly.Cheers,
Niklas

On 27/08/2013 at 01:13, xxxxxxxx wrote:
You actually only have to replace the C in your calculation with the D and don't take C into
account at all.points = op.GetAllPoints()
polygons = op.GetAllPolygons()
normals = []for p in polygons:
a = points[p.a]
b = points[p.b]
c = points[p.c]
d = points[p.d]n = (b  a).Cross(d  a).GetNormalized()
normals.append(n)The value of D == C for a triangle, therefore the calculation is valid for triangles and quads and
you do not have to distinguish them explicitly.Cheers,
NiklasThanks guys! I'll give it a go right away...