def pipeline_start(pipeline, root): """ Draws several catenary cables. """ ddd.mats.traffic_signs = ddd.material(name="TrafficSigns", color="#ffffff", #color="#e01010", texture_path=ddd.DATA_DIR + "/materials/traffic-signs-es/traffic_signs_es_0.png", atlas_path=ddd.DATA_DIR + "/materials/traffic-signs-es/traffic_signs_es_0.plist", extra={'ddd:texture:resize': 2048}) items = ddd.group3() # Cube with logo fig = ddd.box() fig = fig.material(ddd.mats.logo) fig = ddd.uv.map_cubic(fig) items.append(fig) # Sphere with logo fig = ddd.sphere() fig = fig.material(ddd.mats.logo) #fig = fig.merge_vertices() #fig = fig.smooth(math.pi*2) fig = ddd.uv.map_spherical(fig) fig = fig.translate([0, 0, 2]) items.append(fig) # Cube fig = ddd.box() fig = fig.material(ddd.mats.traffic_signs) fig = ddd.uv.map_cubic(fig) #fig.show() #items.append(fig) fig = TextureAtlasUtils().create_sprite_rect(ddd.mats.traffic_signs) #fig.show() #items.append(fig) fig = TextureAtlasUtils().create_sprite_from_atlas(ddd.mats.traffic_signs, "ES_P6.png") #fig.show() #items.append(fig) ''' ddd.mats.roadmarks = ddd.material(name="Roadmarks", color='#e8e8e8', texture_path=ddd.DATA_DIR + "/materials/road-marks-es/TexturesCom_Atlas_RoadMarkings2_White_1K_albedo_with_alpha.png", atlas_path=ddd.DATA_DIR + "/materials/road-marks-es/RoadMarkings2.plist") fig = TextureAtlasUtils().create_sprite_from_atlas(ddd.mats.roadmarks, "give_way") fig.show() ''' items = ddd.align.grid(items, width=4) items.append(ddd.helper.all(size=40.0, center=[5, 5, 0]).twosided()) root.append(items)
def grid_xz(self, size=10.0, grid_space=1.0): gw = 0.05 grid = ddd.group3(name="Helper grid XZ") for i in range(int(size / grid_space) + 1): line1 = ddd.box([i * grid_space, 0, 0, i * grid_space + gw, 0 + gw, size]) grid.append(line1) for j in range(int(size / grid_space) + 1): line2 = ddd.box([0, 0, j * grid_space, size, 0 + gw, j * grid_space + gw]) grid.append(line2) grid = grid.combine() return grid
def reduce_bounds(self, obj): result = obj.copy() if not result.children: try: bounds = result.bounds() bounds = list(bounds[0]) + list(bounds[1]) result.mesh = ddd.box(bounds).mesh except Exception as e: logger.error("Could not calculate bounding box for: %s", result) result.mesh = None result.children = [self.reduce_bounds(c) for c in result.children] return result
def childrens_playground_slide(length=4.5, height=None, width=0.60): slide_thick = 0.03 side_thick = 0.06 if height is None: height = length * 0.45 side_mat = random.choice([ddd.mats.metal_paint_red, ddd.mats.metal_paint_green, ddd.mats.metal_paint_yellow]) slideline = ddd.point([0, 0], name="Slide").line_to([0.5, 0]).line_to([3, 1.5]).line_to([3.5, 1.5]) # TODO: slideline.interpolate_cubic(), or slideline.smooth() or similar slideprofile = slideline.buffer(slide_thick / 2, cap_style=ddd.CAP_FLAT) slide = slideprofile.scale([1 / 4.5 * length, 1 / 2.0 * height]) slide = slide.extrude(width - side_thick, center=True).rotate(ddd.ROT_FLOOR_TO_FRONT) slide = slide.material(ddd.mats.steel) slide = ddd.uv.map_cubic(slide) slidesideprofile = slideline.line_to([3.5, 1.7]).line_to([3, 1.7]).line_to([0.5, 0.2]).line_to([0, 0.2]) slidesideprofile = ddd.polygon(list(slidesideprofile.geom.coords), name="Slide profile") stairssideprofile = ddd.polygon([[3.5, 1.5], [3.5, 2], [4, 2], [4, 1.5], [4.5, 0], [4.0, 0], [3.5, 1.5]]) stairssideprofile = stairssideprofile.union(ddd.point([3.75, 2]).buffer(0.25, cap_style=ddd.CAP_ROUND)) stairssideprofile = stairssideprofile.subtract(ddd.point([3.75, 2]).buffer(0.15, cap_style=ddd.CAP_ROUND, resolution=2)) # Hole stairssideprofile = stairssideprofile.translate([-0.25, 0]) slidesideprofile = slidesideprofile.union(stairssideprofile) slidesideprofile = slidesideprofile.scale([1 / 4.5 * length, 1 / 2.0 * height]) slidesideprofile = slidesideprofile.extrude(side_thick, center=True).rotate(ddd.ROT_FLOOR_TO_FRONT) slidesideprofile = slidesideprofile.material(side_mat) slidesideprofile = ddd.uv.map_cubic(slidesideprofile) slidesideprofile1 = slidesideprofile.translate([0, width / 2, 0]) slidesideprofile2 = slidesideprofile.translate([0, -width / 2, 0]) item = ddd.group([slide, slidesideprofile1, slidesideprofile2]) numsteps = int((height - 1) / 0.3) + 1 for i in range(numsteps): step = ddd.box([-0.1, -((width - side_thick) / 2), 0, 0.1, ((width - side_thick) / 2), 0.05], name="Slide Step") step = step.translate([4 - (i + 1) * (0.5 / (numsteps + 1)), 0, (i + 1) * 0.3]).material(ddd.mats.steel) step = ddd.uv.map_cubic(step) item.append(step) item = item.translate([-4.5/2, 0, 0]).rotate(ddd.ROT_TOP_CCW) item = ddd.meshops.batch_by_material(item).clean(remove_degenerate=False) return item
def rock(bounds=(1, 1, 1)): """ Final size will be bounds * 2. """ obj = ddd.sphere(subdivisions=1) raise_factor = random.uniform(-0.15, 0.35) obj = obj.translate([0, 0, raise_factor]) obj = obj.subtract(ddd.box([-2, -2, 0, 2, 2, -2])) obj = obj.scale(bounds) noise_scale = min(bounds) * 0.25 obj = filters.noise_random(obj, scale=noise_scale) obj = obj.translate([0, 0, -0.2]) obj = obj.material(ddd.mats.rock) #obj.mesh = obj.mesh.smoothed(angle=0) obj = ddd.uv.map_cubic(obj) return obj
# Jose Juan Montes 2019-2020 from ddd.pack.sketchy import urban, landscape from ddd.ddd import ddd import math import random ddd.mats.traffic_signs = ddd.material( name="TrafficSigns", color="#ffffff", #color="#e01010", texture_path=ddd.DATA_DIR + "/materials/traffic_signs/traffic_signs_es_0.png", atlas_path=ddd.DATA_DIR + "/materials/traffic_signs/traffic_signs_es_0.plist") # Cube fig = ddd.box() fig = fig.material(ddd.mats.traffic_signs) fig = ddd.uv.map_cubic(fig) fig.show()