Fix texture and final render stages.

This commit is contained in:
jmsgrogan 2017-10-25 09:48:13 +01:00
parent 1c015a450d
commit 7c154c2ef6
18 changed files with 58 additions and 19 deletions

View file

@ -19,6 +19,12 @@ def generate(shape_parameters, output_prefix, is_final=False):
# Set up materials and textures # Set up materials and textures
color = (0.1, 0.1, 0.1) color = (0.1, 0.1, 0.1)
colors = [(0.1, 0.1, 0.1),
(0.68, 0.68, 0.68),
(0.033, 0.065, 0.376),
(0.019, 0.202, 0.032)]
color = random.choice(colors)
if "bio" not in shape_parameters["shape"]: if "bio" not in shape_parameters["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),

View file

@ -1,5 +1,6 @@
import os import os
import sys import sys
import ast
import random import random
import json import json
import product_gen.generate_product import product_gen.generate_product
@ -17,17 +18,18 @@ if __name__ == "__main__":
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 = float(shape_params["height"]) shape_parameters = {}
radius = float(shape_params["radius"]) shape_parameters["shape"] = shape
shape_parameters["output"] = output
shape_parameters["height"] = float(shape_params["height"])
shape_parameters["radius"] = float(shape_params["radius"])
shape_parameters["fixture_radius"] = float(shape_params["fixture_radius"])
shape_parameters["division_offsets"] = [float(x) for x in shape_params["division_offsets"]]
shape_parameters["style"] = shape_params["style"]
shape_parameters["division_patterns"] = shape_params["division_patterns"]
shape_parameters["division_radii"] = [float(x) for x in shape_params["division_radii"]]
colors = [(0.1, 0.1, 0.1), product_gen.generate_product.generate(shape_parameters, output)
(0.68, 0.68, 0.68),
(0.033, 0.065, 0.376),
(0.019, 0.202, 0.032)]
color = random.choice(colors)
product_gen.generate_product.generate(shape, height, radius, color, output)
shape_parameters = shape_params
shape_parameters["color"] = color
with open(os.getcwd() + "/" + output + "/"+ output + '.json', 'w') as outfile: with open(os.getcwd() + "/" + output + "/"+ output + '.json', 'w') as outfile:
json.dump(shape_parameters, outfile) json.dump(shape_parameters, outfile)

View file

@ -18,9 +18,15 @@ if __name__ == "__main__":
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 = float(shape_params["height"]) shape_parameters = {}
radius = float(shape_params["radius"]) shape_parameters["shape"] = shape
color = ast.literal_eval(shape_params["color"]) shape_parameters["output"] = output
print(color[0]) shape_parameters["height"] = float(shape_params["height"])
product_gen.generate_product.generate(shape, height, radius, shape_parameters["radius"] = float(shape_params["radius"])
color, output, is_final=True) shape_parameters["fixture_radius"] = float(shape_params["fixture_radius"])
shape_parameters["division_offsets"] = [float(x) for x in shape_params["division_offsets"]]
shape_parameters["style"] = shape_params["style"]
shape_parameters["division_patterns"] = shape_params["division_patterns"]
shape_parameters["division_radii"] = [float(x) for x in shape_params["division_radii"]]
product_gen.generate_product.generate(shape_parameters, output, is_final=True)

View file

@ -34,5 +34,7 @@ if __name__ == "__main__":
[feature_xmin, feature_ymin]) [feature_xmin, feature_ymin])
shape_parameters = product_gen.generate_product.generate(shape_parameters, output) shape_parameters = product_gen.generate_product.generate(shape_parameters, output)
shape_parameters["output"] = output
with open(os.getcwd() + "/" + output + "/"+ output + '.json', 'w') as outfile: with open(os.getcwd() + "/" + output + "/"+ output + '.json', 'w') as outfile:
json.dump(shape_parameters, outfile) json.dump(shape_parameters, outfile)

Binary file not shown.

Binary file not shown.

View file

@ -1 +1 @@
{"fixture_radius": 0.3, "division_radii": [0.7366486532785445, 0.8362702452541098, 0.9661599163089211, 0.9867733391465805], "radius": 0.611924774203075, "division_patterns": ["inv_square", "inv_ramp", "sine", "inv_square"], "shape": "cone", "height": 3.7486713335143, "style": "light", "division_offsets": [0.25, 0.25, 0.25, 0.25]} {"style": "light", "division_radii": [0.16451120949404027, 0.23096033701138935, 0.305533414672969, 0.7390854533319504], "height": 3.3522235508986156, "output": "test456", "division_offsets": [0.25, 0.25, 0.25, 0.25], "radius": 2.917962292483968, "shape": "cone", "division_patterns": ["square", "inv_ramp", "inv_square", "ramp"], "fixture_radius": 0.3}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

View file

@ -0,0 +1,23 @@
import numpy as np
import matplotlib.pyplot as plt
height = 10
radius = 2
base_radius = 0.5
base_length = 1.0
x_base = np.linspace(0, base_length, 10)
y_base = base_radius*np.ones(x_base.shape[0])
x_lamp = np.linspace(base_length, height, 100)
y_lamp = base_radius + ((x_lamp)/height)*(radius-base_radius)
x = np.append(x_base, x_lamp)
y = np.append(y_base, y_lamp)
plt.plot(x, y)
axes = plt.gca()
axes.set_xlim([0, 1.1*base_length+height])
axes.set_ylim([0,1.1*radius])
plt.show()

Binary file not shown.

Binary file not shown.

View file

@ -1 +1 @@
{"shape": "pendant", "division_offsets": [0.25, 0.25, 0.25, 0.25], "height": 3.6812407081509724, "fixture_radius": 0.3, "division_radii": [0.294556044831744, 0.587752251293952, 0.8598310084103927, 0.9056905517274985], "division_patterns": ["ramp", "ramp", "ramp", "sine"], "radius": 2.2969131039025945, "style": "billard"} {"shape": "pendant", "style": "billard", "division_offsets": [0.25, 0.25, 0.25, 0.25], "division_patterns": ["sine", "inv_square", "sine", "sine"], "fixture_radius": 0.3, "radius": 1.108292895591573, "height": 2.3656568205530943, "division_radii": [0.5013193491935374, 0.5714972928268524, 0.7183081060448532, 0.7995437239322076]}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 120 KiB