Update examples to use generated enums
This commit is contained in:
parent
828fb8b6da
commit
e7bae54662
6 changed files with 38 additions and 35 deletions
|
|
@ -4,7 +4,16 @@
|
|||
from geometry_script import *
|
||||
|
||||
@tree("City Builder")
|
||||
def city_builder(geometry: Geometry, building_size_min: Vector = (0.1, 0.1, 0.2), building_size_max: Vector = (0.3, 0.3, 1), size_x: Float = 5.0, size_y: Float = 5.0, road_width: Float = 0.25, seed: Int = 0, resolution: Int = 60):
|
||||
def city_builder(
|
||||
geometry: Geometry,
|
||||
building_size_min: Vector = (0.1, 0.1, 0.2),
|
||||
building_size_max: Vector = (0.3, 0.3, 1),
|
||||
size_x: Float = 5.0,
|
||||
size_y: Float = 5.0,
|
||||
road_width: Float = 0.25,
|
||||
seed: Int = 0,
|
||||
resolution: Int = 60
|
||||
):
|
||||
# Road geometry from input curves
|
||||
road_points = geometry.curve_to_points().points
|
||||
yield geometry.curve_to_mesh(
|
||||
|
|
@ -22,10 +31,10 @@ def city_builder(geometry: Geometry, building_size_min: Vector = (0.1, 0.1, 0.2)
|
|||
seed=seed
|
||||
# Delete invalid building points based on proximity to a road
|
||||
).points.delete_geometry(
|
||||
domain='POINT',
|
||||
selection=road_points.geometry_proximity(target_element='POINTS', source_position=position()).distance < road_width * 2
|
||||
domain=DeleteGeometry.Domain.POINT,
|
||||
selection=road_points.geometry_proximity(target_element=GeometryProximity.TargetElement.POINTS, source_position=position()).distance < road_width * 2
|
||||
)
|
||||
random_scale = random_value(data_type='FLOAT_VECTOR', min=building_size_min, max=building_size_max, seed=seed + id())
|
||||
random_scale = random_value(data_type=RandomValue.DataType.FLOAT_VECTOR, min=building_size_min, max=building_size_max, seed=seed + id())
|
||||
yield building_points.instance_on_points(
|
||||
instance=cube(size=(1, 1, 1)).transform(translation=(0, 0, 0.5)),
|
||||
scale=random_scale
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ from geometry_script import *
|
|||
@tree("LEGO")
|
||||
def lego(size: Vector, stud_radius: Float, stud_depth: Float, count_x: Int, count_y: Int):
|
||||
base = cube(size=size)
|
||||
stud_shape = cylinder(fill_type='NGON', radius=stud_radius, depth=stud_depth, vertices=8).mesh
|
||||
stud_shape = cylinder(fill_type=Cylinder.FillType.NGON, radius=stud_radius, depth=stud_depth, vertices=8).mesh
|
||||
stud = stud_shape.transform(translation=combine_xyz(z=(stud_depth / 2) + (size.z / 2)))
|
||||
hole = stud_shape.transform(translation=combine_xyz(z=(stud_depth / 2) - (size.z / 2)))
|
||||
segment = mesh_boolean(
|
||||
operation='DIFFERENCE',
|
||||
mesh_1=mesh_boolean(operation='UNION', mesh_2=[base, stud]).mesh,
|
||||
operation=MeshBoolean.Operation.DIFFERENCE,
|
||||
mesh_1=mesh_boolean(operation=MeshBoolean.Operation.UNION, mesh_2=[base, stud]).mesh,
|
||||
mesh_2=hole
|
||||
).mesh
|
||||
return mesh_line(count=count_x, offset=(1, 0, 0)).instance_on_points(
|
||||
|
|
@ -20,7 +20,7 @@ def lego(size: Vector, stud_radius: Float, stud_depth: Float, count_x: Int, coun
|
|||
@tree("Mesh to LEGO")
|
||||
def mesh_to_lego(geometry: Geometry, resolution: Float=0.2):
|
||||
return geometry.mesh_to_volume(interior_band_width=resolution, fill_volume=False).distribute_points_in_volume(
|
||||
mode='DENSITY_GRID',
|
||||
mode=DistributePointsInVolume.Mode.DENSITY_GRID,
|
||||
spacing=resolution
|
||||
).instance_on_points(
|
||||
instance=lego(size=resolution, stud_radius=resolution / 3, stud_depth=resolution / 8, count_x=1, count_y=1)
|
||||
|
|
|
|||
Reference in a new issue