Add bio type light.
This commit is contained in:
parent
29f788385d
commit
b74feeb77c
11 changed files with 72 additions and 56 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -24,6 +24,7 @@ def generate_models(shape, height, radius):
|
|||
|
||||
|
||||
# Base
|
||||
if "bio" not in shape:
|
||||
radius1 = 0.3
|
||||
radius2 = 0.07
|
||||
depth = 0.5
|
||||
|
@ -42,6 +43,8 @@ def generate_models(shape, height, radius):
|
|||
models = {shade.name: shade,
|
||||
chord.name: chord,
|
||||
base.name: base}
|
||||
else:
|
||||
models = {shade.name: shade}
|
||||
return models
|
||||
|
||||
def optimize_for_render(models):
|
||||
|
|
|
@ -22,15 +22,17 @@ def generate(shape,
|
|||
product_gen.generate_lamp.optimize_for_render(models)
|
||||
|
||||
# Set up materials and textures
|
||||
if "bio" not in shape:
|
||||
colormap = {"shade": color,
|
||||
"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)}
|
||||
else:
|
||||
colormap = {"shade": color}
|
||||
|
||||
product_gen.generate_lamp.apply_textures(colormap, models)
|
||||
|
||||
rendering.setup_scene.setup_scene()
|
||||
|
||||
|
||||
|
||||
# Do rendering
|
||||
prefix = os.getcwd() + "/" + output_prefix + "/" + output_prefix
|
||||
if is_final:
|
||||
|
|
|
@ -131,36 +131,14 @@ def generate_mesh_shade(radius1, radius2, depth):
|
|||
ob.select = False
|
||||
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
|
||||
|
||||
def generate_bio_shade(radius1, radius2, depth):
|
||||
def make_square_ring(radius, depth, thickness):
|
||||
|
||||
bpy.ops.mesh.primitive_cone_add(radius1=radius1,
|
||||
radius2=radius2,
|
||||
bpy.ops.mesh.primitive_cylinder_add(radius=radius,
|
||||
depth=depth)
|
||||
cone = bpy.data.objects["Cone"]
|
||||
cone.name = "shade"
|
||||
cone = bpy.data.objects["Cylinder"]
|
||||
cone.name = "square_ring"
|
||||
bpy.ops.object.mode_set(mode='EDIT')
|
||||
bm = bmesh.from_edit_mesh(cone.data)
|
||||
for face in bm.faces:
|
||||
|
@ -178,8 +156,41 @@ def generate_bio_shade(radius1, radius2, depth):
|
|||
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})
|
||||
TRANSFORM_OT_shrink_fatten={"value":-thickness})
|
||||
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.
|
@ -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 |
|
@ -7,14 +7,14 @@ from argparse import ArgumentParser
|
|||
|
||||
if __name__ == "__main__":
|
||||
|
||||
shape = "mesh"
|
||||
shape = "bio"
|
||||
output = "test"
|
||||
|
||||
if not os.path.exists(os.getcwd() + "/" + output):
|
||||
os.makedirs(os.getcwd() + "/" + output)
|
||||
|
||||
height = 1.5
|
||||
radius = 0.8
|
||||
radius = 1.5
|
||||
color = [0.1, 0.1, 0.1]
|
||||
|
||||
product_gen.generate_product.generate(shape, height, radius, color, output)
|
||||
|
|
Loading…
Reference in a new issue