Advertisement
Guest User

Untitled

a guest
Jun 26th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. for (int i = 0; i < indices.Length / 3; i++)
  2. {
  3. int index1 = indices[i * 3];
  4. int index2 = indices[i * 3 + 1];
  5. int index3 = indices[i * 3 + 2];
  6.  
  7. Vector3 side1 = vertices[index1].Position - vertices[index3].Position;
  8. Vector3 side2 = vertices[index1].Position - vertices[index2].Position;
  9. Vector3 normal = Vector3.Cross(side1, side2);
  10.  
  11. vertices[index1].Normal += normal;
  12. vertices[index2].Normal += normal;
  13. vertices[index3].Normal += normal;
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement