Public Group

# Computing .XFile Mesh Normals

This topic is 4931 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Does anybody know how to compute mesh normals? I'm trying to make an automated procedure to take in mesh files and computes the mesh normal. The automated normal creator doesn't work like I need it to. I've included a basic box and need normals to be perpendicular to the main sides. If you have any idea could you please include the calculations. Thank you very much, TestBox.x ------------------------------------ xof 0303txt 0032 # Created By Joshua Mesh v0{ 8; 268.00; 365.00; 0.00;, 852.00; 363.00; 0.00;, 267.00; 354.00; 0.00;, 851.00; 352.00; 0.00;, 268.00; 365.00; 200.00;, 852.00; 363.00; 200.00;, 267.00; 354.00; 200.00;, 851.00; 352.00; 200.00;; 12; 3; 0,1,3;, 3; 0,3,2;, 3; 0,5,1;, 3; 0,4,5;, 3; 0,2,6;, 3; 0,6,4;, 3; 4,7,5;, 3; 4,6,7;, 3; 1,7,3;, 3; 1,5,7;, 3; 2,3,7;, 3; 2,7,6;; MeshTextureCoords { 8; 0.0;2.22;, 1.11;2.22;, 1.11;2.22;, 0.0;2.22;, 0.0;0.0;, 1.11;0.0;, 1.11;0.0;, 0.0;0.0;; } MeshMaterialList { 3; 12; 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 2, 2;; Material { 0.753;0.565;0.341;0.000;; 0.00; 0.00;0.00;0.00;; 0.00;0.00;0.00;; } Material { 0.000;0.004;0.000;0.000;; 0.00; 0.00;0.00;0.00;; 0.00;0.00;0.00;; } Material { 0.753;0.565;0.341;0.000;; 0.00; 0.00;0.00;0.00;; 0.00;0.00;0.00;; } } }

##### Share on other sites
Say you have a flat polygon with vertices A, B, and C (it doesn't matter which you pick, as long as the poly is flat). You can construct two vectors v1 = A - B and v2 = B - C that are parallel to the polygon's plane but not parallel to each other. If you take their cross product, you'll get the normal of that polygon. If it comes out inside out then swap the order you do the cross product in.

For something like a box you can just use the same normal for every vertex on a face. If you wanted to make, say, a sphere, you'd blend the normals of the faces touching each vertex together, and use a different normal for each point on the sphere.

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633661
• Total Posts
3013220
×