Wollivan / SquadronLeader

Open Source 3D printable aerial combat that fits in an old tobacco tin
https://squadronleader.wollivan.dev/
Creative Commons Attribution Share Alike 4.0 International
31 stars 10 forks source link

Automate the creation of 2D-printable pieces from the 3D models #58

Open penyuan opened 2 years ago

penyuan commented 2 years ago

We started a discussion in pull request #51 about the possibility of deriving 2D-printable files from the 3D models in this repository. This way, someone without access to a 3D printer can print the pieces onto paper (and maybe cardboard) and play the game that way.

A few starting points from that thread for further discussion:

  1. This thread/post about projecting a 3D CAD file onto a 2D plane then export as SVG.
  2. @lifelike said: The script that I used in Inkscape to create the countersheet can run from the command-line as well. It still requires Inkscape to be installed, but at least it can be fully automated. If someone can figure out how to create a SVG (or PNG) from the CAD files it should be possible to set up export of the complete sheets: https://github.com/lifelike/countersheetsextension/wiki/Running-from-Command-Line
  3. OpenSCAD allows scripting (i.e. automating) the projection of 3D models onto 2D images, and making 2D slices of 3D models. See this documentation page.
  4. Once there is a 2D SVG, I know Inkscape can be scripted to do further post-processing as needed.

Does any of the above sound promising? It'll be cool if we can integrate this into a continuous integration pipeline!

lifelike commented 2 years ago

I think it can work. See the CSV and SVG file already checked in, that would be the input to the script. They can certainly be improved and possibly expanded to include more types of things, but should be enough for testing out the automation already.

Currently the plane used on the 2D counters is part of that template SVG. To make it use a SVG generated from OpenSCAD it should refer to an external file instead. The same thing for every other generated image to include on a counter.

lifelike commented 2 years ago

I added a quick-and-dirty script in PR #59. For creating a countersheet PDF only, not the other things.

For some reason when including SVG-images inside of the countersheet SVG the lines became a bit wavy and blurry. I exported the plane silhouettes to PNG instead and used those images. I think exporting the OpenSCAD models to PNG will work better, unless someone can figure out what was wrong with importing SVG. With high enough resolution the results should look good anyway.

Wollivan commented 1 year ago

I have finally found the feature in OpenSCAD that I was looking for, and can now export SVGs of a projection of the model using projection() funnily enough!

Here is the manoeuvre template for example: maneuver_template

The only issue is it doesn't notice lines in the image if they don't go all the way through. For example, here is the plane token: plane

Really not much use!

All this means is I need to go through and modify the models to have all the lines be from top to bottom and export the SVG, which is time consuming. So this will soon be done soon, and there will be an SVG version of every game asset!