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

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

andquads and

you do not have to distinguish them explicitly.Cheers,

-Niklas

Thanks guys! I'll give it a go right away...

]]>

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

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.

There is no built-in 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