Break random things
This commit is contained in:
4
main.py
4
main.py
@@ -244,7 +244,7 @@ block_list = ["blue_concrete", "red_concrete", "green_concrete",
|
||||
|
||||
# ---
|
||||
|
||||
r = Road.Road(((-1572, 64, 518), (-1608, 65, 513),
|
||||
(-1627, 64, 534), (-1643, 71, 580)), "None")
|
||||
r = Road.Road(((-1829, 141, 553), (-1830, 110, 621), (-1711, 69, 625), (-1662,
|
||||
65, 627), (-1667, 65, 761), (-1683, 70, 800), (-1721, 70, 834)), "None")
|
||||
|
||||
r.place_roads()
|
||||
|
||||
@@ -17,8 +17,8 @@ class Strip:
|
||||
self.curvature = curve_tools.curvature(self.curve)
|
||||
|
||||
def compute_surface_perpendicular(self, width, normals):
|
||||
self.offset_left = curve_tools.offset(self.curve, width, normals)
|
||||
self.offset_right = curve_tools.offset(self.curve, -width, normals)
|
||||
self.offset_left = curve_tools.offset(self.curve, width/2, normals)
|
||||
self.offset_right = curve_tools.offset(self.curve, -width/2, normals)
|
||||
self.perpendicular_segment = []
|
||||
|
||||
for i in range(len(self.offset_left)):
|
||||
|
||||
@@ -18,7 +18,7 @@ class Road:
|
||||
editor = Editor(buffering=True)
|
||||
|
||||
self.resolution, self.distance = curve_tools.resolution_distance(
|
||||
self.coordinates, 6)
|
||||
self.coordinates, 12)
|
||||
|
||||
self.curve_points = curve_tools.curve(
|
||||
self.coordinates, self.resolution)
|
||||
@@ -36,13 +36,18 @@ class Road:
|
||||
# editor.placeBlock(coordinate, Block(block))
|
||||
|
||||
with open('networks/roads/lines/lines.json') as lines_materials:
|
||||
line_type = json.load(lines_materials).get('broken_white')
|
||||
line_type = json.load(lines_materials).get('solid_white')
|
||||
with open('networks/roads/lines/lines.json') as lines_materials:
|
||||
middle_line_type = json.load(lines_materials).get('broken_white')
|
||||
|
||||
print(line_type, lane_type)
|
||||
|
||||
# for coordinate, block in surface:
|
||||
# editor.placeBlock(coordinate, Block(block))
|
||||
|
||||
lines_coordinates = []
|
||||
middle_lines_coordinates = []
|
||||
|
||||
# Perpendicular
|
||||
self.curve_surface.compute_surface_perpendicular(10, self.curvature)
|
||||
for i in range(len(self.curve_surface.surface)):
|
||||
@@ -54,14 +59,29 @@ class Road:
|
||||
list(lane_type.keys()),
|
||||
weights=lane_type.values(),
|
||||
k=1,)[0]))
|
||||
if k == 0:
|
||||
block = random.choices(
|
||||
list(pattern_materials[pattern_iteration].keys()),
|
||||
weights=pattern_materials[pattern_iteration].values(
|
||||
),
|
||||
k=1)[0]
|
||||
if block != 'None':
|
||||
self.surface.append((coordinate, block))
|
||||
editor.placeBlock(
|
||||
(self.curve_surface.surface[i][j][k][l][0], self.curve_surface.surface[i][j][k][l][1]-1, self.curve_surface.surface[i][j][k][l][2]), Block(random.choices(
|
||||
list(lane_type.keys()),
|
||||
weights=lane_type.values(),
|
||||
k=1,)[0]))
|
||||
if k == 0 or k == len(self.curve_surface.surface[i][j])-1:
|
||||
lines_coordinates.extend(
|
||||
self.curve_surface.surface[i][j][k])
|
||||
if k == round((len(self.curve_surface.surface[i][j])-1)/2):
|
||||
middle_lines_coordinates.extend(
|
||||
self.curve_surface.surface[i][j][k])
|
||||
|
||||
line = Line.Line(lines_coordinates, line_type)
|
||||
line.get_blocks()
|
||||
middle_line = Line.Line(middle_lines_coordinates, middle_line_type)
|
||||
middle_line.get_blocks()
|
||||
for i in range(len(line.coordinates_with_blocks)):
|
||||
editor.placeBlock(
|
||||
line.coordinates_with_blocks[i][0], Block(line.coordinates_with_blocks[i][1]))
|
||||
for i in range(len(middle_line.coordinates_with_blocks)):
|
||||
editor.placeBlock(
|
||||
middle_line.coordinates_with_blocks[i][0], Block(middle_line.coordinates_with_blocks[i][1]))
|
||||
|
||||
# offset = curve.offset(curve_surface.curve, -9, curvature)
|
||||
# for i in range(len(offset)-1):
|
||||
# line = segment.discrete_segment(offset[i], offset[i+1])
|
||||
|
||||
@@ -28,8 +28,8 @@ class Line:
|
||||
if block != 'None':
|
||||
self.coordinates_with_blocks.append((coordinate, block))
|
||||
|
||||
pattern_iteration += 1
|
||||
if pattern_iteration >= pattern_length:
|
||||
pattern_iteration = 0
|
||||
pattern_iteration += 1
|
||||
if pattern_iteration >= pattern_length:
|
||||
pattern_iteration = 0
|
||||
|
||||
return self.coordinates_with_blocks
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
],
|
||||
|
||||
"broken_white": [
|
||||
[{"white_concrete": 3, "white_concrete_powder": 1}, 3],
|
||||
[{"None": 1}, 1]
|
||||
[{"red_concrete": 1}, 3],
|
||||
[{"green_concrete": 1}, 3],
|
||||
[{"blue_concrete": 1}, 3]
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user