I know exactly how to compute triangle normals, and how to ''average'' two normals to create smooth shading across edges etc etc - the problem is I don''t want to spend a lot of time coding ANOTHER editor/convertor. (See my D3D Utilities... thread).
Surely someone must have some tools they''re willing to share?
Failing that, how would you like to help me write an X-file editor? I only need to cover 3 criteria (again see the other thread) but maybe you''ll have other needs we can incorporate too.
Later
Matt
Check out my project at:www.btinternet.com/~Matthew.Bennett
Importing 3DSMAX asc files into usable geometry question
Hi!
Calculating normals actually isn't that complicated. I do it at the time when I load the objects. For each triangle (stored in a face structure, that has three vertices in it), I use this function.
Hope that helps, at least a little
Jarkko
Edited by - jalaine on June 27, 2000 4:25:20 AM
Calculating normals actually isn't that complicated. I do it at the time when I load the objects. For each triangle (stored in a face structure, that has three vertices in it), I use this function.
int findNormal(FACE *face){ VERTEX a, c, R; float length; // We sort of move the face in the origin (temporarily).. a.x=face->v1.x-face->v2.x; a.y=face->v1.y-face->v2.y; a.z=face->v1.z-face->v2.z; c.x=face->v3.x-face->v2.x; c.y=face->v3.y-face->v2.y; c.z=face->v3.z-face->v2.z; // Count the cross product R of the aquired vertices a and c R.x=(c.y*a.z) - (a.y*c.z); R.y=(c.z*a.x) - (a.z*c.x); R.z=(c.x*a.y) - (a.x*c.y); // Then scale R to length of 1 length=(float)sqrt((pow(R.x,2) + pow(R.y,2) + pow(R.z,2))); R.x=R.x/length; R.y=R.y/length; R.z=R.z/length; // And that's our normal // store it in the face struct face->normal=R; return 1;}
Hope that helps, at least a little
Jarkko
Edited by - jalaine on June 27, 2000 4:25:20 AM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement