[Plib-devel] fast smooth normals in 3DS loader
Brought to you by:
sjbaker
From: Paolo L. <p.l...@ci...> - 2000-12-21 14:56:27
|
I'd be ready to contribute the subject functionality, but I need to know how. I wrote a new class, presently named ssgaSmooth, stored in a .h and .cxx files, whose methods are called in the new smooth_normals(). But implementing it as an SSGAux class implies SSG to depend on SSGA. Alternatively it could also be one more SSG class, or, forgetting someone else access, an utility only accessed by the 3DS loader - either within the loader's source file or in separate ones (better). Public methods are: /********* public procs ************/ void addTriangles( int start, int end, sgVec3 *vertex_list, unsigned short *vertex_index, sgVec3 *face_normals ); void includePolygon(int numVerts, Point3 *verts, float face_normal[], void *user); void makeVertexNormals( void ); void getVertexNormals( int num_faces, sgVec3 vertex_normals[] ); /********* public option control procs ************/ void setFuzzFraction(float fuzzFraction); void enableEdgePreservation(float minDot); void disableEdgePreservation( void ); The original C code I adapted in a class is: * ANSI C code from the article * "Building Vertex Normals from an Unstructured Polygon List" * by Andrew Glassner, gla...@pa... * in "Graphics Gems IV", Academic Press, 1994 This is a fairly general tool for n-sided polygon, yet very fast, keeping into account a "crease angle" for sharp EdgePreservation, that doesn't need connectivity info. It hasn't presently the elegant interface of other SSG classes, but it does the work very well. What I did additionally in the 3DS loader is the management of an hash table for the smoothing groups. Waiting for master opinion ... greetings - ---------------------------------------------------------------------------- - Paolo Leoncini phone: +39 (0823) 623134 Scientific Visualization & Virtual Reality fax: +39 (0823) 623126 CIRA - Italian Center for Aerospace Researches mailto:p.l...@ci... Via Maiorise - 81043 Capua (CE) Italy http://www.cira.it/research/vis |