PDA

View Full Version : computing vertex normals while maintaining sharp edges



Pat
10-21-2002, 01:32 PM
I'm working on a viewer of stereolithography (stl) files. These files are simply a list of triangle with face normals. I'd like to find an example algorithm that can compute the vertex normals while maintaining any sharp edges in the model. Thanks.

WhatEver
10-21-2002, 02:18 PM
You'll have to check sharing vertices. Once you find one vertex sharing another vertex you do a DOT with the accompanying normals. Only average the normals if the DOT result is above your specified radian.

Be sure that your normals are normalized when you DOT them, this way you know that 1 = 0 radians, and -1 = 3.14 radians. LightWave calls this the Smoothing Angle.

if(DOT > RadToDot(SmoothAngle))
{
Average normal with shared vertex normal;
}

This isn't a super good explanation, but it should get your creative juices flowing.