Pyrr
Pyrr copied to clipboard
generate_vertex_normals_ts
- [x] Generate normals for indexed triangle strips
- [x] Support primitive restart index
- [ ] Tests for generating normals for triangle strips
- [ ] Docs
Unfortunately the winding changes for the triangles generated. Removing the invalid triangles will mess up the winding order.
Example:
index: 1 2 3 4 5 6 -1 7 8 9
triangles:
1 2 3 CCW
2 3 4 CW
4 5 6 CCW
----- primitive restart
7 8 9 CCW
Visual example:
index: 0 1 2 3 4 5 6 7 8
triangles:
(see the image above)
You'd have to split the array into subarrays first, then call the index restructuring procedure for each of the subarrays, and then concatenate them.
something like this: https://stackoverflow.com/a/38278327/552379
I had no time to push it, but I have some code that can build the indices. I stopped work on this because I noticed the normals are not correct. I will have time around the weekend.
The normals depend on the number of triangles and the "area" of the triangles.
I understand the problem and I want to fix it (maybe it is not a fix but a tweak or a different solution)
I expect to have normals like this:
You can ignore the area of the triangles to get that result. Maybe add a kwarg weighted=True
to the generate_vertex_normals
function?
This is another example where the normals are not okey. I have an idea but I have not time right now.
Yes I will add a kwarg for that.