Random spaceship model generation script for Blender
Likely of some interest here:
https://github.com/a1studmuffin/SpaceshipGenerator/
https://www.youtube.com/watch?v=xJZyXqJ6nog
https://github.com/a1studmuffin/SpaceshipGenerator/
https://www.youtube.com/watch?v=xJZyXqJ6nog
Comments
Playing with it now.
Looks good for Capitol ships. Might need tweaked for smaller ship.
I'm guessing the path for the images is expecting Windows as I can't view the textures for the models on Linux. Trying to tweak the code to fix it.Never mind. Still trying to learn blender. Works when I render it.
The extra steps I took were to apply the Decimator modifier in Blender, export to OBJ without materials, then load the OBJ into MisfitModel3D and export back out into OBJ again. (Not sure why the last part was necessary, maybe Blender is throwing some weird vertices in that MM3D removes. If I didn't re-export the model, EE would crash on loading the mesh.)
I didn't use Decimator (haven't heard of it until now).
These are the export settings I use from blender.
I'm also using the new generator plugin, and the UI makes it easier to set the randomization seed and configure or toggle asymmetry and materials. If I use the UI with the epsilon seed, and disable the bevel modifier and asymmetric components, the resulting model size with smart UV map is around 150kb. With bevels and asymmetric components enabled, it's about 5Mb.
The models don't look terrible in game, but they do need some UV mapping and a decent texture to make up for the missing materials.
You can work around this by baking the materials. It's a little labor intensive, but considering the nature of these generated models it's probably scriptable, too.
1. Generate the model in Blender.
2. In 3D View, switch to Edit Mode.
3. Select everything (A key).
4. Unwrap the mesh (U key, select Smart UV Project).
5. Switch to the UV/Image Editor. You should see a square-ish image with a bunch of lines on it. That's the UV map.
6. Create a new image (Alt-N).
7. Check "Selected to Active" in the Bake panel. (The Bake panel is at the bottom of the Render toolkit. By default, it'll be at the bottom of the right sidebar.)
8. Click Bake. The other defaults should work (Bake: "Full Render", "Clear images before baking" checked, distance 0.000, Bias 0.001, margin 16px, split Automatic). You should see Blender fill in the UV map image.
9. Save the image (F3). That's your texture.
10. Export the model to OBJ.
Stick the texture and model in EE/Resources, add them to the model_data file, and congratulations:
You could break the Bake step into more granular parts to generate the illumination and specular textures.
Wonder if that could be automated in the script, or put in another one.
- The models face backwards when used in EE. This can be fixed by either rotating the model before exporting, or changing the Forward from -Z Forward to Z Forward while exporting.
- The models are small; the one in the shots above uses setScale(48) in the model_info to get about as large as a default Atlantis cruiser.
- The script knows when it's generating engine panels and turrets, so there might even be a way to script the ModelInfo block complete with engine emitter and beam locations.
Note that my Python is worse than my Lua, which is worse than my C++, which is worse than my JavaScript. ¯\_(ツ)_/¯
Recently forked and maintained for Blender 2.8, with new features: https://github.com/ldo/blender_spaceship_generator/releases