Page 1 of 2 12 LastLast
Results 1 to 15 of 20

Thread: point and poly normals

  1. #1

    point and poly normals

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

  2. #2
    Registered User mattbolton's Avatar
    Join Date
    Apr 2003
    KS, USA
    From page 81 and 82 of the LScript Reference Manual.

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

    prototype:    status polynormal(polygon) (MD)

    status        boolean; if the operation succeeded.
    polygon       polygon id; the polygon to change.
    surface       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. #3
    well duh
    heheh thanks missed that one in the docs

  4. #4
    Newbie Member
    Join Date
    Dec 2003
    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 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. #5
    Newbie Member
    Join Date
    Dec 2003
    Ups! Sorry ...

    vtxPolygons is the array containing polygon IDs.

  6. #6
    Code Muppet evenflcw's Avatar
    Join Date
    Feb 2003
    Stockholm, Sweden
    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".
    Last edited by evenflcw; 12-28-2003 at 11:01 PM.

  7. #7
    Newbie Member
    Join Date
    Dec 2003
    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. #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. #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. #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
    Last edited by fortress; 01-12-2004 at 02:07 PM.

  11. #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. #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. #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. #14
    a better question would be how do you calculate a point normal while to include the smoothing angle as well?

  15. #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

Page 1 of 2 12 LastLast


Posting Permissions

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