View Full Version : pntBaseNormal problem

04-30-2007, 05:42 AM
Hi there

I'm stuck with pntBaseNormal. It always returns completely smoothed point normals even if polygonID is defined and according to smoothing angle surrounding polygons have sharp edge.

according to SDK help:

hasnormal = pntBaseNormal( meshinfo, polygon, point, normal ) (LW9.0+)
Get the base normal of a vertex. If the polygon ID is defined, the normal will be calculated taking surface smoothness parameters and the surrounding polygons into account. If the polygon ID is not defined (0), an averaged normal of the surrounding polygons is computed. Returns 1 if the vertex has a valid normal, returns 2 if the normal is not smoothed, 0 for an invalid normal.

I've got:

static size_t WritePolyPointNor_Scan( LWMeshInfo *mesh, LWPolID id )

int i;
LWFVector nor;
for(i = 0; i < mesh->polSize(mesh, id); i++ ) {
mesh->pntBaseNormal( mesh, id, mesh->polVertex(mesh, id, i), nor );
fprintf( fp, "VN <%g, %g, %g>\n" nor[0], nor[1], nor[2] );
return 0;


What I missed? I always get smoothed normals as if surface smooth angle is 360 degrees (or as if polyID is set to 0) ;(

05-03-2007, 02:21 AM
Nobody ever need correct point normals? Pitty ;(

I understand (from what I saw in source files) that everybody calculate point normals from scrath, but this function (pntBaseNormal) is recomended in LW SDK so I suppose that it should be working...

Maybe somebody from NT could reply ...

Simply say "it's working for us" and I'll be happy and try to find my mistake... ;)

05-03-2007, 03:21 AM
I haven't had time to look at it yet. Is this in Layout or Modeler? In what sort of plugin is this code?


05-03-2007, 10:47 AM
Thanks a lot!

It's MeshDateEdit (modeler) and that function is passed to scanPolys (MeshInfo).
I'm trying to rewrite my LScript exporter into propper plugin because of the speed (I had to compute the vertex normals in LSCript by myself, so it's really slow) and I'm also plannig to use most of the code in Layout Generic to be able to export meshes from layout too.

Now, I'm just learning the structures and SDK and everything what it does is that it outputs my model in the text file (I'm just trying to understand how I can collect all information).
Problem is that that damned pntBaseNormal returns vertex normals as if the mesh is completely smoothed even if surfacesmooth is OFF.
According to SDK if you provide that function with polyID, surface smooth will be taken into account (it's needed to get propper vertex normals). But it seems that it behaves as if (0) is provided as polygonID (like its said in the sdk help).

I'm really desperade ;( I though that it takes some short and limited time to rewrite it from LS to plugin but it's not the only thing into which I run... The SDK itself is not well structured and most of the time you'll need something which belong to some group (structure) but it's not there and you'll have to read it elsewhere. But it's just matter of understanding the whole SDK and matter of time to find it - but it's not this case. This time (with the pntBaseNorm) I'm really don't know what's happening and I'm completely stuck ;(