A Blender script to procedurally generate 3D spaceships

Overview

Spaceship Generator

A Blender script to procedurally generate 3D spaceships from a random seed.

Spaceship screenshots

Usage

  • Install Blender 2.80 or greater: http://blender.org/download/
  • Download newest add_mesh_SpaceshipGenerator.zip from the Releases section
  • Under Edit > Preferences... > Add-ons > Install... open the downloaded ZIP file
  • Under Edit > Preferences... > Add-ons enable the "Add Mesh: Spaceship Generator" script (search for "spaceship")
  • Add a spaceship in the 3D View under Add > Mesh > Spaceship
  • Expand the Spaceship tab that appears in the bottom left of the viewport to adjust procedural generation settings

How it works

Step-by-step animation

Watch on YouTube: https://www.youtube.com/watch?v=xJZyXqJ6nog

  • Start with a box.
  • Build the hull: Extrude the front/rear faces several times, adding random translation/scaling/rotation along the way.
  • Add asymmetry to the hull: Pick random faces and extrude them out in a similar manner, reducing in scale each time.
  • Add detail to the hull: Categorize each face by its orientation and generate details on it such as engines, antenna, weapon turrets, lights etc.
  • Sometimes apply horizontal symmetry.
  • Add a Bevel modifier to angularize the shape a bit.
  • Apply materials to the final result.
  • Take over the universe with your new infinite fleet of spaceships.

Extreme examples

The following screenshots were created using extreme values for the number of hull segments and asymmetry segments to show how the algorithm works.

Extreme spaceship screenshots

Tips and Tricks

  • By default the script will delete all objects starting with Spaceship before generating a new spaceship. To disable this feature, remove or comment out the call to reset_scene() around line 735 in the main function.
  • You can provide a seed to the generate_spaceship() function to always generate the same spaceship. For example, generate_spaceship('michael').
  • The generate_spaceship() function takes many more parameters that affect the generation process. Try playing with them!
  • You can replace the textures with your own ones. All textures are applied using global-space cube UVs. hull_normal.png is a normal map that adds extra surface "greebles". hull_lights_diffuse.png is an additive diffuse texture to set the color of the window lights. hull_lights_emit.png is an emissive texture to make the windows glow in darkness.

Credits

Written for fun as part of the /r/proceduralgeneration June 2016 monthly challenge.

Released under the MIT License.

Authored and maintained by Michael Davies.

GitHub @a1studmuffin Twitter @butterparty

Special thanks to @panzi for bugfixes, a proper GUI and build script. Also to @mjrthemes for bugfixing, and @LendoK for the 2.80 port.

Issues
  • License makes no sense

    License makes no sense

    If in doubt, please get in touch. As a rule of thumb I'm fine with anyone using these spaceships in commercial works, but I am less okay with people selling the spaceship models directly for commercial gain. Use common sense.

    Creative Commons Attribution By 3.0 does allow selling the model itself

    opened by Aspie96 7
  • Install instructions out of date?

    Install instructions out of date?

    I can't seem to get this to work using blender v2.83.0. I am installing and it isn't showing any errors, but then I can't see Spaceship from the Add Mesh menu. Not sure if I should downgrade blender to get this to work?

    opened by g-klein 5
  • import fails when activating addon using Blender 2.77

    import fails when activating addon using Blender 2.77

    There is an error on line #18 of init.py. from add_mesh_SpaceshipGenerator import spaceship_generator This needs to be changed to from . import spaceship_generator

    opened by AtomicPerception 5
  • Can't enable installed addon

    Can't enable installed addon

    Windows 7x64 Blender 2.77

    How to reproduce:

    1. Download https://github.com/a1studmuffin/SpaceshipGenerator/archive/master.zip
    2. «Install from File...»
    3. Enable addon

    277

    opened by mishantrop 5
  • Stupidy McStupidQuestion: How do I render ships?

    Stupidy McStupidQuestion: How do I render ships?

    Am I an idiot, or how do I get a generated ship to render like the pictures in the Readme? I run the default render settings, and the ships just look kind of flat, and the hull panels texture is almost invisible.

    opened by CaptainMegavolt 4
  • I found a seed and set of parameters that causes a reproducible crash

    I found a seed and set of parameters that causes a reproducible crash

    Seed: walnut! Min. Hull Segments: 3 Max. Hull Segments: 6 Create Asymmetry: OFF Min. Asymmetry Segments: 1 Max. Asymmetry Segments: 5 Create Face Detail: ON Allow Horizontal Symmetry: ON Allow Vertical Symmetry: OFF Apply Bevel Modifier: ON Assign Materials: ON

    Now render it or display it in Material mode. Blender will hang.

    opened by flarn2006 4
  • Spaceship generator not working in Blender 3.1

    Spaceship generator not working in Blender 3.1

    The error I am getting is this:

    Python: Traceback (most recent call last):
      File "/home/wulfalpha/.config/blender/3.1/scripts/addons/add_mesh_SpaceshipGenerator/__init__.py", line 43, in execute
        spaceship_generator.generate_spaceship(
      File "/home/wulfalpha/.config/blender/3.1/scripts/addons/add_mesh_SpaceshipGenerator/spaceship_generator.py", line 669, in generate_spaceship
        add_surface_antenna_to_face(bm, face)
      File "/home/wulfalpha/.config/blender/3.1/scripts/addons/add_mesh_SpaceshipGenerator/spaceship_generator.py", line 341, in add_surface_antenna_to_face
        result = bmesh.ops.create_cone(bm,
    TypeError: create_cone: keyword "segments" expected an int, not float
    
    location: <unknown location>:-1
    

    I have tried a couple of the fixes i have seen here and sadly none of them seems to work. It looks like a type casting issue to me but I can't see where the problem actually is because I'm not familiar enough with python or the code itself. Any help would be great

    opened by wulfalpha 2
  • Run in Blender 2.8

    Run in Blender 2.8

    Hi, thank you for the script !

    Blender 2.8 changed some core functions. It is certainly too soon to adapt the script now, as some changes are not completely settled, nor documented, yet (stable release in forseen in 2019 Q3 I think)

    Anyway, I did some minor changes to run it in Blender 2.8, without materials. https://github.com/vincent/SpaceshipGenerator

    The code is absolutely not polished - hence no pr yet - but can be useful if you just want to try it in 2.8.

    Cheers

    opened by vincent 2
  • Asking about the license

    Asking about the license

    Hi a1studmuffin,

    Sorry to contact you like this by creating an issue (do not know how to do so otherwise).

    I have purchased many tools to help me in my Sci Fi assets to sell. I am very interested in this plugin to create the basis for my spaceships assets. Meaning, I do not want to sell the results of this plugins directly. Rather, I would like to build upon the generated spaceships using my different tools to create polished and customized ones to sell.

    Is this OK?

    Regards

    opened by Mohammad-Aliraqi 2
  • Examples of parameters for generate_spaceship function

    Examples of parameters for generate_spaceship function

    Not and issue as such but could you provide a few examples of the different parameters you can pass to the generate_spaceship function?

    What, for example, did you pass through to make the extreme ships?

    opened by mixedbredie 2
  • Typos when calling 'generate_spaceship'

    Typos when calling 'generate_spaceship'

    Hi @a1studmuffin, nice plugin, but i have found some typos in your code. In init.py file the function call should be:

    spaceship_generator.generate_spaceship(
      self.random_seed,
      self.num_hull_segments_min,
      self.num_hull_segments_max,
      self.create_asymmetry_segments,
      self.num_asymmetry_segments_min,
      self.num_asymmetry_segments_max,
      self.create_face_detail,
      self.allow_horizontal_symmetry,
      self.allow_vertical_symmetry,
      self.apply_bevel_modifier,
      self.assign_materials
    )
    

    Now arguments num_hull_segments_min and num_hull_segments_max are not passed, and assign_materials also.

    opened by codeagent 2
  • GUI + batch-autogeneration of different spaceships?

    GUI + batch-autogeneration of different spaceships?

    Would it be possible to add a trivial GUI such as via pygobject, as well as means to generate different spaceships via blender from the commandline, to then display these as-is?

    That way the user could select the model that may be most appropriate such as for a game that makes use of spaceships, a bit like context free grammar works (example for what I mean can be seen at the cfdg gallery: https://www.contextfreeart.org/gallery/search.php?t=new&num=25)

    Obviously this suggestion "works" only if the required work is not too enormous, so perhaps the first step would be to have a way for the SpaceshipGenerator to batch-generate different models via the commandline, and then when that works plug in a minimal GUI that shows these different results as-is via that app).

    opened by rubyFeedback 1
  • reports an error when i try to add spaceship

    reports an error when i try to add spaceship

    Screen Shot 2022-04-13 at 6 45 32 PM

    Report: Error Python: Traceback (most recent call last): File "/Users/enda/Library/Application Support/Blender/3.1/scripts/addons/add mesh SpaceshipGenerator/init.py",line 43, in execute spaceship generator.generate spaceship( File "/Users/enda/Library/Application Support/Blender/3.1/scripts/addons/add mesh SpaceshipGenerator/spaceship generator.py", line 669, in generate spaceship add surface antenna to face(bm, face) File "/Users/enda/Library/Application Support/Blender/3.1/scripts/addons/add mesh SpaceshipGenerator/spaceship generator.py", line 341, in add surface antenna to face result = bmesh.ops.create cone(bm, TypeError: create cone: keyword "segments" expected an int, not float location: :-1

    opened by Enda111 8
  • Additional Fixes for Blender 3.1

    Additional Fixes for Blender 3.1

    I had also to change following lines/commands in spaceship_generator.py to work again in Blender 3.1: bmesh.ops.create_icosphere - now needs parameter radius instead of diameter - line 310 bmesh.ops.create.cone - radius1, radius2 instead of diameter1, diameter2 - lines 200,232,245,,258,272,282,291,341,354,372,380 tip: use find&replace (worked for me)

    Hope this helps Thomas

    opened by thomasenzi 0
  • TypeError: bpy_struct: item.attr = val: enum

    TypeError: bpy_struct: item.attr = val: enum "Raw" not found in ('Linear', 'sRGB')

    bpy.ops.object.origin_set(type='ORIGIN_CENTER_OF_MASS', center='MEDIAN')
    bpy.ops.mesh.generate_spaceship()
    Python: Traceback (most recent call last):
      File "/home/kenorb/.config/blender/2.93/scripts/addons/add_mesh_SpaceshipGenerator/__init__.py", line 43, in execute
        spaceship_generator.generate_spaceship(
      File "/home/kenorb/.config/blender/2.93/scripts/addons/add_mesh_SpaceshipGenerator/spaceship_generator.py", line 724, in generate_spaceship
        materials = create_materials()
      File "/home/kenorb/.config/blender/2.93/scripts/addons/add_mesh_SpaceshipGenerator/spaceship_generator.py", line 458, in create_materials
        set_hull_mat_basics(mat, hull_base_color, hull_normal_map)
      File "/home/kenorb/.config/blender/2.93/scripts/addons/add_mesh_SpaceshipGenerator/spaceship_generator.py", line 436, in set_hull_mat_basics
        return add_hull_normal_map(mat, hull_normal_map)
      File "/home/kenorb/.config/blender/2.93/scripts/addons/add_mesh_SpaceshipGenerator/spaceship_generator.py", line 419, in add_hull_normal_map
        teximage_node.image.colorspace_settings.name = 'Raw'
    TypeError: bpy_struct: item.attr = val: enum "Raw" not found in ('Linear', 'sRGB')
    
    location: <unknown location>:-1
    
    • Blender v2.93.3 on Ubuntu.
    opened by kenorb 1
  • No more working in 3.1 - quick fix

    No more working in 3.1 - quick fix

    Hello, spaceship generator - which I find AMUSING! - did not work anymore on my Blender 3.1: being a programmer I was able to reaad the log (it's an int - float conversion error) and managed to fix it in this way:

    • in spaceship_generator.py on line 340 simply substituted num_segments = uniform(3, 6) with num_segments = int( uniform(3, 6) ) Now it works again! Hope this is useful to other people. Thanks again for this beautiful piece of software! Sincerely, Giorgio
    opened by giouti 0
Releases(v1.1.3)
Owner
Michael Davies
Video games/VR software engineer. Games: Earthlight, Obliteracers, Battlefield 4, Need For Speed Rivals, Dead Space 1-3. Weapons of choice: C, C++, C#, Python.
Michael Davies
Small stack-based DSL for procedurally generated 1-bit graphics

Bitlang Bitlang is a tiny stack-based DSL, designed for the sole purpose of producing procedurally generated 1-bit art. It is implemented in ANSI-C, a

Paul Batchelor 7 Jan 20, 2022
Blender addon for AutoRemesher by huxingyi

AutoRemesher Blender 2.8 Blender addon implementation of AutoRemesher by huxingyi. This implementation works on Windows 10 and Ubuntu. Install the add

null 69 Jul 26, 2022
Integrate the ZENO node system into Blender for creating robust physics animations!

ZenoBlend Integrate the ZENO node system into Blender for creating robust physics animations! End-user Installation Goto Release page, and click Asset

Zenus Technology 31 Jun 10, 2022
A Blender 2.7+ plugin that exports sausage link characters with animations

Sausage64 Sausage64 is a plugin for Blender 2.7 onwards, which allows you to export "sausage link" style character models with animations. The plugin

Buu342 25 Jul 7, 2022
Windows 7 support for Blender 3.0

BlenderCompat Windows 7 support for Blender 3.0 Description This repository contains a compatibility DLL for running Blender 3.0 on Windows 7 and a pa

Alexandru Naiman 120 Aug 1, 2022
A blender import/export system for Defold

defold-blender-export A blender import/export system for Defold Setup Notes There are no exhaustive documents for this tool yet. Its just not complete

David Lannan 21 Jun 3, 2022
Blender is the free and open source 3D creation suite

Blender is the free and open source 3D creation suite. It supports the entirety of the 3D pipeline-modeling, rigging, animation, simulation, rendering, compositing, motion tracking and video editing.

Blender 6.2k Aug 1, 2022
The FLIP Fluids addon is a tool that helps you set up, run, and render high quality liquid fluid effects all within Blender, the free and open source 3D creation suite.

FLIP Fluids The FLIP Fluids addon is a tool that helps you set up, run, and render liquid simulation effects. Our custom built fluid engine is based a

Ryan Guy 1.3k Aug 4, 2022
A python script loader for Grand Theft Auto San Andreas

PyLoader Introduction This is a .asi plugin that allows writing custom Python scripts for GTA SanAndreas. This plugin is still in the early stages of

Grinch_ 23 May 22, 2022
Simple and easy script language for your dead brain, or break time of you.

What is this trush? Shut up, this isnt a trush. Lol This is a easy and simple script language. Change the world. Rotation the world. BIG REVOLUTION OF

zkr 6 May 28, 2021
A new JS script plugin for flutter

js_script Run JS script. Usage // Create a JS context. JsScript script = JsScript(); // Define a class. var classInfo = ClassInfo<TestClass>( newI

null 5 Mar 8, 2022
This is Script tools from all attack Denial of service by C programming

RemaxDos Paltfrom Attack RemaxDos This is Script tools from all attack Denial of service Remax Box Team !. Features ! Cam overflow Syn Flooding. Smurf

null 6 Jul 19, 2022
A Roblox Script Executor made by me

Roblox Executor A self made Roblox Executor. Works with most scripts and rarely crashes How to use the Roblox Executor [+] - Download it, then compile

xEnething 6 Jun 5, 2022
A Script to thin Universal Apps on macOS quickly

UBThinner A Script to thin Universal Apps on macOS quickly. It traverses through the given folder recursively, identifies any universal binaries and t

Arm 2 Dec 26, 2021
An extremely basic Python script to split word-based data into high and low byte files.

An extremely basic Python script to split word-based data into high and low byte files. This is for use in programming 16 bit computer ROMs.

null 1 Dec 26, 2021
Golang bindings of Sciter: the Embeddable HTML/CSS/script engine for modern UI development

Go bindings for Sciter Check this page for other language bindings (Delphi / D / Go / .NET / Python / Rust). Attention The ownership of project is tra

Terra Informatica Software, Inc 2.4k Aug 4, 2022
Patches & Script for AOSP to run on Xuantie RISC-V CPU

Overview Graph 1. AOSP on RISC-V 64(XuanTie 910) Video for Android on XuanTie910 News and related resources Chip ICE is a XuanTie C910 based high perf

T-Head Semiconductor Co., Ltd. 419 Aug 1, 2022
A cross-platform,lightweight,scalable game server framework written in C++, and support Lua Script

Current building status Moon Moon is a lightweight online game server framework implement with multithread and multi-luaVM. One thread may have 1-N lu

Bruce 431 Aug 2, 2022
RIAT is a free script compiler for Halo: Combat Evolved scripts

Rat In a Tube RIAT is a free script compiler for Halo: Combat Evolved scripts. To compile, you will need: CMake 3.14 or newer Python 3 or newer C11 co

Snowy 3 May 12, 2022