Mesh lights in reasonable condition now.

This commit is contained in:
jmsgrogan 2017-10-25 11:46:01 +01:00
parent 911ea182b2
commit 83d88728c5
10 changed files with 22 additions and 6 deletions

View file

@ -102,6 +102,9 @@ def generate_mesh_shade(shape_parameters):
bm = bmesh.from_edit_mesh(cube.data) bm = bmesh.from_edit_mesh(cube.data)
slat_thickness = 0.06 slat_thickness = 0.06
max_rad = 0.0 max_rad = 0.0
max_z = 0.0
min_z = 0.0
rad_min_z = 0.0
for i in range( len( bm.verts ) ): for i in range( len( bm.verts ) ):
bm.verts.ensure_lookup_table() bm.verts.ensure_lookup_table()
vert = bm.verts[i] vert = bm.verts[i]
@ -114,7 +117,7 @@ def generate_mesh_shade(shape_parameters):
if abs(vert.co.z)<shape_parameters["stem_length"]: if abs(vert.co.z)<shape_parameters["stem_length"]:
rad = shape_parameters["fixture_radius"] rad = shape_parameters["fixture_radius"]
else: else:
rad = morph_shape(abs(vert.co.z)-shape_parameters["stem_length"], rad = morph_shape(1.8*(abs(vert.co.z)-shape_parameters["stem_length"]),
depth-shape_parameters["stem_length"], depth-shape_parameters["stem_length"],
radius1-shape_parameters["fixture_radius"], radius1-shape_parameters["fixture_radius"],
morph_type=shape_parameters["division_pattern"]) morph_type=shape_parameters["division_pattern"])
@ -123,6 +126,11 @@ def generate_mesh_shade(shape_parameters):
vert.co.x += rad vert.co.x += rad
if vert.co.x>max_rad: if vert.co.x>max_rad:
max_rad = vert.co.x max_rad = vert.co.x
max_z = vert.co.z
if vert.co.z<min_z:
min_z = vert.co.z
rad_min_z = vert.co.x
bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.mode_set(mode='OBJECT')
@ -137,9 +145,14 @@ def generate_mesh_shade(shape_parameters):
scene.update() scene.update()
# Add torus # Add torus
bpy.ops.mesh.primitive_torus_add(location=(0.0, 0.0, -depth), bpy.ops.mesh.primitive_torus_add(location=(0.0, 0.0, max_z),
major_radius=max_rad, major_radius=max_rad,
minor_radius=0.02) minor_radius=0.02)
if (abs(min_z)-abs(max_z))>0.5:
bpy.ops.mesh.primitive_torus_add(location=(0.0, 0.0, min_z),
major_radius=rad_min_z,
minor_radius=0.02)
for ob in bpy.context.scene.objects: for ob in bpy.context.scene.objects:
if ob.type == 'MESH': if ob.type == 'MESH':

View file

@ -20,4 +20,5 @@ def setup_renderer(shape_parameters, engine="CYCLES"):
this_scene.render.resolution_y = 600.0 this_scene.render.resolution_y = 600.0
this_scene.render.tile_x = 32 this_scene.render.tile_x = 32
this_scene.render.tile_y = 32 this_scene.render.tile_y = 32
this_scene.render.resolution_percentage = 50.0 this_scene.render.resolution_percentage = 50.0
this_scene.render.image_settings.compression = 60.0

View file

@ -43,8 +43,10 @@ def get_random_shape_description(shape, bbox, feature_min):
shape_description = copy.deepcopy(_shape_description) shape_description = copy.deepcopy(_shape_description)
shape_description["shape"] = shape shape_description["shape"] = shape
feature_height = feature_min[1] + random.random()*(bbox[1]-feature_min[1])
feature_radius = feature_min[0] + random.random()*(bbox[0]-feature_min[0]) feature_radius = feature_min[0] + random.random()*(bbox[0]-feature_min[0])
#feature_height = 0.8*feature_radius
feature_height = feature_min[1] + random.random()*(bbox[1]-feature_min[1])
shape_description["height"] = feature_height shape_description["height"] = feature_height
shape_description["radius"] = feature_radius shape_description["radius"] = feature_radius
shape_description["division_pattern"] = random.choice(_division_types) shape_description["division_pattern"] = random.choice(_division_types)

Binary file not shown.

Binary file not shown.

View file

@ -1 +1 @@
{"shape": "mesh", "radius": 2.436703407562188, "division_param1": 1.0, "fixture_radius": 0.3, "output": "test789", "division_pattern": "sinusoid", "height": 1.9801308149425492, "style": "billard", "division_param2": 1.0, "fixture_length": 0.3, "stem_length": 0.5} {"division_param1": 1.0, "division_param2": 1.0, "stem_length": 0.5, "fixture_length": 0.3, "style": "billard", "radius": 3.687568125159161, "output": "test789", "shape": "mesh", "division_pattern": "circle", "fixture_radius": 0.3, "height": 3.6552215108138246}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 141 KiB