prideout / svg3d

generate 3D wireframes as vector art
https://prideout.net/blog/svg_wireframes/
MIT License
349 stars 28 forks source link

Code breaks on irregular faces #2

Open smeaden opened 4 years ago

smeaden commented 4 years ago

Great code, I have written a conversion of the resultant SVG file to Excel shapes on a worksheet, https://exceldevelopmentplatform.blogspot.com/2020/06/python-wireframe-graphics-on-worksheet.html

However, I would like to get a childhood favorite spaceship of mine to be rendered as well, this is it https://programming-enchiladas.destructuring-bind.org/rm-hull/7098992?shape=cobra&style=translucent&scale=0.03 It is called a Cobra-MK3 and it is from a groundbreaking 1984 game called Elite , https://en.wikipedia.org/wiki/Elite_(video_game)#Gameplay

When I created a similar array of points for the cobra it failed at the numpy’s “fancy indexing” feature. So I wrote some simple code to do the equivalent manually and then convert to a numpy array but this failed also. It seems the code is expecting either all triangles or all squares. The cobra has some faces which have more than 4 sides.

I suppose one way out of this is to break polygons of more than 4 sides into triangles and switch off the drawing of internal edges. I don't know if that is better.

gever commented 2 years ago

Same issue here; at the tail-end of a series of CSG operations, I end up with a list of planar polygons that include 3, 4, 5, and more points. The reliance on numpy's "fancy indexing" requires that all polygons be the same number of points (I've gotten it to accept quads or triangles, but not both). Seems like we could just pass the list of faces and verts into the Mesh - at least for objects with less than 10k faces - pretty easily... Before I jump into it, let me know if you've already thought about it.

Hmm, now I'm thinking that since I can pass in multiple Mesh objects to the scene, maybe I can do the triangles in one mesh, the quads in another, and so on, for every class of polygon I have generated...

(Also, thanks for the awesome code base, it's really solved a problem for me in creating a way to render complex 3d objects in Google Collaboratory with my students)