Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for(unsigned int z = 1; z < N; z++)
- {
- for(unsigned int x = 1; x < M; x++)
- {
- index = z * M + x;
- indices[indices_index++] = index;
- indices[indices_index++] = index - 1;
- indices[indices_index++] = index - M - 1;
- vec3 a = vertices[index].pos;
- vec3 b = vertices[index - 1].pos;
- vec3 c = vertices[index - M - 1].pos;
- vec3 ab = b - a;
- vec3 ac = c - a;
- vec3 n = cross(ab, ac);
- vertices_ex[index ].normals.push_back(n);
- vertices_ex[index - 1 ].normals.push_back(n);
- vertices_ex[index - M - 1].normals.push_back(n);
- indices[indices_index++] = index;
- indices[indices_index++] = index - M - 1;
- indices[indices_index++] = index - M;
- a = vertices[index].pos;
- b = vertices[index - M].pos;
- c = vertices[index - M - 1].pos;
- ab = b - a;
- ac = c - a;
- n = cross(ab, ac);
- vertices_ex[index ].normals.push_back(n);
- vertices_ex[index - M ].normals.push_back(n);
- vertices_ex[index - M - 1].normals.push_back(n);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement