Skip to content

Commit

Permalink
Use separate random sequences for geometry versus materials,
Browse files Browse the repository at this point in the history
and keep seed values on redo (letting user edit them if desired)
so spaceship design only has to change on each new invocation.
  • Loading branch information
Lawrence D'Oliveiro committed Apr 23, 2020
1 parent bb14c31 commit 4b8eb21
Show file tree
Hide file tree
Showing 2 changed files with 481 additions and 455 deletions.
25 changes: 21 additions & 4 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"name" : "Spaceship Generator",
"author" : "Michael Davies, Lawrence D'Oliveiro",
"version" : (1, 2, 2),
"version" : (1, 3, 0),
"blender" : (2, 82, 0),
"location" : "View3D > Add > Mesh",
"description" : "Procedurally generate 3D spaceships from a random seed.",
Expand All @@ -19,6 +19,7 @@
from . import spaceship_generator
#end if

import random
import bpy
from bpy.props import \
BoolProperty, \
Expand All @@ -32,10 +33,15 @@ class GenerateSpaceship(bpy.types.Operator) :
bl_options = {"REGISTER", "UNDO"}

df = spaceship_generator.parms_defaults # temp short name
random_seed : StringProperty \
geom_ranseed : StringProperty \
(
default = df.random_seed,
name = "Seed"
default = df.geom_ranseed,
name = "Geometry Seed"
)
mat_ranseed : StringProperty \
(
default = df.mat_ranseed,
name = "Material Seed"
)
num_hull_segments_min : IntProperty \
(
Expand Down Expand Up @@ -97,6 +103,17 @@ class GenerateSpaceship(bpy.types.Operator) :
)
del df

def invoke(self, context, event) :
maxseed = 1e6
# [0 .. 999999] is enough to be interesting by
# default. Users can always replace seeds with
# anything they like.
self.geom_ranseed = str(random.randrange(maxseed))
self.mat_ranseed = str(random.randrange(maxseed))
spaceship_generator.generate_spaceship(self)
return {"FINISHED"}
#end invoke

def execute(self, context) :
spaceship_generator.generate_spaceship(self)
return {"FINISHED"}
Expand Down
Loading

0 comments on commit 4b8eb21

Please sign in to comment.