Add bio type light.

This commit is contained in:
jmsgrogan 2017-10-24 12:58:25 +01:00
parent 29f788385d
commit b74feeb77c
11 changed files with 72 additions and 56 deletions

View file

@ -24,6 +24,7 @@ def generate_models(shape, height, radius):
# Base # Base
if "bio" not in shape:
radius1 = 0.3 radius1 = 0.3
radius2 = 0.07 radius2 = 0.07
depth = 0.5 depth = 0.5
@ -42,6 +43,8 @@ def generate_models(shape, height, radius):
models = {shade.name: shade, models = {shade.name: shade,
chord.name: chord, chord.name: chord,
base.name: base} base.name: base}
else:
models = {shade.name: shade}
return models return models
def optimize_for_render(models): def optimize_for_render(models):

View file

@ -22,15 +22,17 @@ def generate(shape,
product_gen.generate_lamp.optimize_for_render(models) product_gen.generate_lamp.optimize_for_render(models)
# Set up materials and textures # Set up materials and textures
if "bio" not in shape:
colormap = {"shade": color, colormap = {"shade": color,
"base": (132.0/255.0, 64.0/255.0, 11.0/255.0), "base": (132.0/255.0, 64.0/255.0, 11.0/255.0),
"chord": (5.0/255.0, 5.0/255.0, 5.0/255.0)} "chord": (5.0/255.0, 5.0/255.0, 5.0/255.0)}
else:
colormap = {"shade": color}
product_gen.generate_lamp.apply_textures(colormap, models) product_gen.generate_lamp.apply_textures(colormap, models)
rendering.setup_scene.setup_scene() rendering.setup_scene.setup_scene()
# Do rendering # Do rendering
prefix = os.getcwd() + "/" + output_prefix + "/" + output_prefix prefix = os.getcwd() + "/" + output_prefix + "/" + output_prefix
if is_final: if is_final:

View file

@ -131,36 +131,14 @@ def generate_mesh_shade(radius1, radius2, depth):
ob.select = False ob.select = False
bpy.ops.object.join() bpy.ops.object.join()
# mapped_rad = radius2 + delta**2
# vert.co.x = mapped_rad*math.sin(theta)
# vert.co.y = mapped_rad*math.cos(theta)
#
# for face in bm.faces:
# if UpOrDown(face.normal):
# face.select = True
# else:
# face.select = False
# faces_select = [f for f in bm.faces if f.select]
# bmesh.ops.delete(bm, geom=faces_select, context=3)
# bmesh.update_edit_mesh(cone.data, True)
#
# # Extrude faces
# bpy.ops.mesh.select_mode( type = 'FACE' )
# bpy.ops.mesh.select_all( action = 'SELECT' )
# bpy.ops.mesh.extrude_region_move(
# TRANSFORM_OT_translate={"value":(0, 0, 0.01)} )
# bpy.ops.mesh.extrude_region_shrink_fatten(
# TRANSFORM_OT_shrink_fatten={"value":-0.05})
return cube return cube
def generate_bio_shade(radius1, radius2, depth): def make_square_ring(radius, depth, thickness):
bpy.ops.mesh.primitive_cone_add(radius1=radius1, bpy.ops.mesh.primitive_cylinder_add(radius=radius,
radius2=radius2,
depth=depth) depth=depth)
cone = bpy.data.objects["Cone"] cone = bpy.data.objects["Cylinder"]
cone.name = "shade" cone.name = "square_ring"
bpy.ops.object.mode_set(mode='EDIT') bpy.ops.object.mode_set(mode='EDIT')
bm = bmesh.from_edit_mesh(cone.data) bm = bmesh.from_edit_mesh(cone.data)
for face in bm.faces: for face in bm.faces:
@ -178,8 +156,41 @@ def generate_bio_shade(radius1, radius2, depth):
bpy.ops.mesh.extrude_region_move( bpy.ops.mesh.extrude_region_move(
TRANSFORM_OT_translate={"value":(0, 0, 0.01)} ) TRANSFORM_OT_translate={"value":(0, 0, 0.01)} )
bpy.ops.mesh.extrude_region_shrink_fatten( bpy.ops.mesh.extrude_region_shrink_fatten(
TRANSFORM_OT_shrink_fatten={"value":-0.05}) TRANSFORM_OT_shrink_fatten={"value":-thickness})
bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.mode_set(mode='OBJECT')
return cone return bpy.data.objects["square_ring"]
def generate_bio_shade(radius1, radius2, depth):
ring1 = make_square_ring(3.0*radius1, depth/10.0, 0.2)
bpy.ops.transform.rotate(value=-math.pi/12.0, axis=(1.0,0.0,0.0))
ring2 = make_square_ring(1.5*radius1, depth/10.0, 0.2)
bpy.ops.transform.rotate(value=math.pi/12.0, axis=(1.0,0.0,0.0))
ring3 = make_square_ring(1.0*radius1, depth/10.0, 0.2)
bpy.ops.transform.rotate(value=-math.pi/8.0, axis=(1.0,0.0,0.0))
for ob in bpy.context.scene.objects:
if ob.type == 'MESH':
ob.select = True
bpy.context.scene.objects.active = ob
else:
ob.select = False
bpy.ops.object.join()
bpy.context.scene.objects.active = bpy.data.objects["square_ring"]
bpy.data.objects["square_ring"].name = "shade"
ring1 = make_square_ring(3.0*radius1+0.01, depth/16.0, 0.2)
bpy.ops.transform.rotate(value=-math.pi/12.0, axis=(1.0,0.0,0.0))
ring2 = make_square_ring(1.5*radius1+0.01, depth/16.0, 0.2)
bpy.ops.transform.rotate(value=math.pi/12.0, axis=(1.0,0.0,0.0))
ring3 = make_square_ring(1.1*radius1+0.01, depth/16.0, 0.2)
bpy.ops.transform.rotate(value=-math.pi/8.0, axis=(1.0,0.0,0.0))
return bpy.data.objects["shade"]

Binary file not shown.

Binary file not shown.

View file

@ -1 +1 @@
{"color": [0.1, 0.1, 0.1], "shape": "mesh", "radius": 0.8, "height": 1.5} {"height": 1.5, "radius": 1.5, "color": [0.1, 0.1, 0.1], "shape": "bio"}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 312 KiB

After

Width:  |  Height:  |  Size: 304 KiB

View file

@ -7,14 +7,14 @@ from argparse import ArgumentParser
if __name__ == "__main__": if __name__ == "__main__":
shape = "mesh" shape = "bio"
output = "test" output = "test"
if not os.path.exists(os.getcwd() + "/" + output): if not os.path.exists(os.getcwd() + "/" + output):
os.makedirs(os.getcwd() + "/" + output) os.makedirs(os.getcwd() + "/" + output)
height = 1.5 height = 1.5
radius = 0.8 radius = 1.5
color = [0.1, 0.1, 0.1] color = [0.1, 0.1, 0.1]
product_gen.generate_product.generate(shape, height, radius, color, output) product_gen.generate_product.generate(shape, height, radius, color, output)