# Thread: point and poly normals

1. ## point and poly normals

ok heres a question how to get the point and/or poly normal

2. From page 81 and 82 of the LScript Reference Manual.

polynormal
polynormal() returns a vector that represents the surface normal of the specified polygon.

prototype: &nbsp;&nbsp; status polynormal(polygon) (MD)

status &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; boolean; if the operation succeeded.
polygon &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; polygon id; the polygon to change.
surface &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; string; surface name to which polygon is now assigned.
I wish I could help more, but I've never used it myself. Knowing where to find the answer is half the battle.

3. well duh
heheh thanks missed that one in the docs

4. Here it is about point normals ... You get'em by adding all normals of polys that have 'guilty' point in it and divide it by polycount (numbers of polygons that have point You are interested).

Here is a bit of code I used for this. Originally You can find it in a NormalBaker.ls that come with a LW if I can recollect for certain :

// Get the point normal
numPolys = size(vtxPolygons);

for(k = 1;k <= numPolys;k++)
{
workVal = polynormal(vtxPolygons[k]);
pointNorm += workVal;
}

pointNorm.x /= numPolys;
pointNorm.y /= numPolys;
pointNorm.z /= numPolys;

numPolys is the array with poly IDs that have the point in it.
You can get those by :

pnt = points[i];
vtxPolygons = pnt.polygon();

Hope this helps.

See ya! D

5. Ups! Sorry ...

vtxPolygons is the array containing polygon IDs.

6. I think you might have been in a bit of a hurry, CroDude. Although someome lines are fine, some doesn't work and an important one was omitted.

When working with normals it is of great importance that you normalize created values:
PntNormal = normalize(AvgeragedSumOfPolyNormals);

If you don't, operations such as pointmove(pnt, PntLoc + PntNormal*Distance), while still moving points along the normals, will not move them the correct distance! Normalizing ensures the values get the correct "scale".

7. Ups again! I forgot to cut it out !

Here it is :

// Normalize point normal vector
pointNormN = normalize(pointNorm);

That one goes to the end...

Hope this helps.

8. thanks for all the replys guys
i just got back from a short vacation so ill get a chance to start on this asap
thanks again and happy holidays

9. well i looked at that normal baker plugin and that is really going to help alot and save me a lot of time

one question i had is would i still need to normalize the point normal if i am just exporting the data to be used in a game

10. well hit a big road block i guess i should have said from a layout lscript

i have tried useing the code form this thread and from normalbaker

but it seems like the polynormal function cant be accesed from layout

any other ideas

11. well so far the only thing i can think of for a work around is to have ascript that runs in modeler to find the normals of the points

so the next question i hae is it possable to invoke a script from a script (im sure it is but never have done it)

and is it possable to pass data between a modeler and layoput script

12. well a easy out is to run normalbaker on the model first then save the model and search for the custom vmap type the normal baker looks for

so that works for me until i found a better way or automate that part

thanks again guys for the help

13. i had a question as far as normalizing the normals
and getting the normals for points does that take smoothing groups into account

14. a better question would be how do you calculate a point normal while to include the smoothing angle as well?

15. ok i found where and how to get the smoothing angle of a surface

so the next question is how do you include the smoothing angle in the point normal calculation?

or do you even have to

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•