Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. for(unsigned int z = 1; z < N; z++)
  2. {
  3. for(unsigned int x = 1; x < M; x++)
  4. {
  5. index = z * M + x;
  6. indices[indices_index++] = index;
  7. indices[indices_index++] = index - 1;
  8. indices[indices_index++] = index - M - 1;
  9.  
  10. vec3 a = vertices[index].pos;
  11. vec3 b = vertices[index - 1].pos;
  12. vec3 c = vertices[index - M - 1].pos;
  13. vec3 ab = b - a;
  14. vec3 ac = c - a;
  15. vec3 n = cross(ab, ac);
  16.  
  17. vertices_ex[index ].normals.push_back(n);
  18. vertices_ex[index - 1 ].normals.push_back(n);
  19. vertices_ex[index - M - 1].normals.push_back(n);
  20.  
  21. indices[indices_index++] = index;
  22. indices[indices_index++] = index - M - 1;
  23. indices[indices_index++] = index - M;
  24.  
  25. a = vertices[index].pos;
  26. b = vertices[index - M].pos;
  27. c = vertices[index - M - 1].pos;
  28. ab = b - a;
  29. ac = c - a;
  30. n = cross(ab, ac);
  31.  
  32. vertices_ex[index ].normals.push_back(n);
  33. vertices_ex[index - M ].normals.push_back(n);
  34. vertices_ex[index - M - 1].normals.push_back(n);
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement