def osm_model_texts_fonts(pipeline, root, logger): """ Test 2D text generation. """ #pipeline.data['font'] = Font() pipeline.data['font:atlas:opensansemoji_64'] = ddd.material( name="FontOpenSansEmoji-64", color='#f88888', texture_path=ddd.DATA_DIR + "/fontatlas/opensansemoji64.greyscale.png", alpha_cutoff=0.5, metallic_factor=0.0, roughness_factor=1.0, extra={ 'ddd:material:type': 'font', 'ddd:collider': False, 'ddd:shadows': False, 'uv:scale': 1.00, 'zoffset': -5.0, 'ddd:texture:resize': 4096 }) pipeline.data['font:atlas:dddfonts_01_64'] = ddd.material( name="DDDFonts-01-64", color='#f88888', texture_path=ddd.DATA_DIR + "/fontatlas/dddfonts_01_64.greyscale.png", #texture_normal_path=ddd.DATA_DIR + "/materials/road-marks-es/TexturesCom_Atlas_RoadMarkings2_1K_normal.png", #atlas_path="/materials/road-marks-es/RoadMarkings2.plist", alpha_cutoff=0.5, metallic_factor=0.0, roughness_factor=1.0, extra={ 'ddd:material:type': 'font', 'ddd:collider': False, 'ddd:shadows': False, 'uv:scale': 1.00, 'zoffset': -5.0, 'ddd:texture:resize': 4096 }) atlas = DDDFontAtlas.load_atlas(ddd.DATA_DIR + "/fontatlas/dddfonts_01_64.dddfont.json") pipeline.data['font:opensansemoji'] = Text2D( atlas, "OpenSansEmoji-default-64", pipeline.data['font:atlas:dddfonts_01_64']) pipeline.data['font:oliciy'] = Text2D( atlas, "Oliciy-default-64", pipeline.data['font:atlas:dddfonts_01_64']) pipeline.data['font:technasans'] = Text2D( atlas, "TechnaSans-default-64", pipeline.data['font:atlas:dddfonts_01_64']) pipeline.data['font:adolphus'] = Text2D( atlas, "Adolphus-default-64", pipeline.data['font:atlas:dddfonts_01_64']) pipeline.data['ddd:osm:fonts'] = [ 'font:opensansemoji', 'font:oliciy', 'font:technasans', 'font:adolphus' ]
def parse_material(name, color): material = None if hasattr(ddd.mats, name): material = getattr(ddd.mats, name) else: material = ddd.material(name, color) return material
def osm_structured_export_2d_tile(root, osm, pipeline): """Save a cropped tileable 2D image of the scene.""" tile = ddd.group2([ ddd.shape(osm.area_crop).material(ddd.material(color='#ffffff')), # White background (?) #self.ground_2d, root.select(path="/Water", recurse=False), root.select(path="/Areas", recurse=False), root.select(path="/Ways", recurse=False), #, select="") self.ways_2d['-1a'], self.ways_2d['0'], self.ways_2d['0a'], self.ways_2d['1'], root.select(path="/Roadlines2", recurse=False), root.select(path="/Buildings", recurse=False), #self.areas_2d_objects, self.buildings_2d.material(ddd.material(color='#8a857f')), root.select(path="/ItemsAreas", recurse=False), #self.items_2d, root.select(path="/ItemsWays", recurse=False), #self.items_2d, root.select(path="/ItemsNodes", recurse=False).buffer(0.5).material(ddd.mats.red), ]).flatten().select(func=lambda o: o.extra.get('ddd:area:type') != 'underwater') tile = tile.intersection(ddd.shape(osm.area_crop)) tile = tile.clean() tile.prop_set('svg:stroke-width', 0.01, children=True) path = pipeline.data['filenamebase'] + ".png" tile.save(path) tile.save("/tmp/osm-structured.png")
def generate_building_3d_amenities(self, building_3d): for item_1d in building_3d.extra['ddd:building:items']: if item_1d.extra.get('osm:amenity', None) == 'pharmacy': coords = item_1d.geom.centroid.coords[0] # Side sign item = urban.sign_pharmacy_side(size=1.0) ''' # Plain sign (front view on facade) item = urban.sign_pharmacy(size=1.2) item = item.translate([0, -0.25, 2.0]) # no post ''' item.extra['ddd:item'] = item_1d item = self.snap_to_building(item, building_3d) item = item.translate([0, 0, 3.0]) # no post #item = terrain.terrain_geotiff_min_elevation_apply(item, self.osm.ddd_proj) building_3d.children.append(item) elif item_1d.extra.get('osm:amenity', None) and item_1d.extra.get('osm:amenity', None) not in ('fountain', 'taxi', 'post_box', 'bench', 'toilets', 'parking_entrance'): # Except parking? #coords = amenity.geom.centroid.coords[0] #panel_text = amenity.extra['amenity'] if amenity.extra['amenity'] else None panel_text = item_1d.extra['osm:name'] if item_1d.extra.get('osm:name', None) else (item_1d.extra['osm:amenity'].upper() if item_1d.extra['osm:amenity'] else None) item = urban.panel(width=3.2, height=0.9, text=panel_text) item.extra['ddd:item'] = item_1d item.name = "Panel: %s %s" % (item_1d.extra['osm:amenity'], item_1d.extra.get('osm:name', None)) item = self.snap_to_building(item, building_3d) if item: item = item.translate([0, 0, 3.2]) # no post color = random.choice(["#d41b8d", "#a7d42a", "#e2de9f", "#9f80e2"]) #item = terrain.terrain_geotiff_min_elevation_apply(item, self.osm.ddd_proj) building_3d.children.append(item) else: logger.info("Could not snap item to building (skipping item): %s", item) #building_3d.show() elif item_1d.extra.get('osm:shop', None): #coords = item_1d.geom.centroid.coords[0] panel_text = (item_1d.extra['osm:name'] if item_1d.extra.get('osm:name', None) else item_1d.extra['osm:shop']) item = urban.panel(width=2.5, height=0.8, text=panel_text) item.extra['ddd:item'] = item_1d item.name = "Panel: %s %s" % (item_1d.extra['osm:shop'], item_1d.extra.get('osm:name', None)) item = self.snap_to_building(item, building_3d) if item: item = item.translate([0, 0, 2.8]) # no post color = random.choice(["#c41a7d", "#97c41a", "#f2ee0f", "#0f90f2"]) item = item.material(ddd.material(color=color)) #item = terrain.terrain_geotiff_min_elevation_apply(item, self.osm.ddd_proj) building_3d.children.append(item) else: logger.info("Could not snap item to building (skipping item): %s", item) else: logger.debug("Unknown building-related item: %s", item_1d)
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 image_textured(self, feature): key = feature['properties']['key'] filename = "_cache/images/mapillary/%s-%s.jpg" % (key, 1024) material = ddd.material(texture_path=filename) plane = ddd.rect( name="Mapillary Image").triangulate().material(material) plane = ddd.uv.map_cubic(plane) plane = plane.recenter() plane = plane.rotate(ddd.ROT_FLOOR_TO_FRONT) return plane
def image_textured(filename): material = ddd.material( texture_path=filename) # name="Image: %s" % filename plane = ddd.rect(name="Image Rect").triangulate().material(material) plane = ddd.uv.map_cubic(plane) plane = plane.rotate(ddd.ROT_FLOOR_TO_FRONT) plane = plane.scale([5, 1, 5]) plane = plane.translate([0, 1, 0]) return plane
def fonts(pipeline, root, logger): """ Test 2D text generation. """ #pipeline.data['font'] = Font() pipeline.data['font:atlas:dddfonts_01_64'] = ddd.material(name="DDDFonts-01-64", color='#f88888', texture_path=ddd.DATA_DIR + "/fontatlas/dddfonts_01_64.greyscale.png", #texture_normal_path=ddd.DATA_DIR + "/materials/road-marks-es/TexturesCom_Atlas_RoadMarkings2_1K_normal.png", #atlas_path="/materials/road-marks-es/RoadMarkings2.plist", alpha_cutoff=0.5, metallic_factor=0.0, roughness_factor=1.0, extra={'ddd:material:type': 'font', 'ddd:collider': False, 'ddd:shadows': False, 'uv:scale': 1.00, 'zoffset': -5.0, 'ddd:texture:resize': 4096})
def sign_pharmacy(size=1.0, depth=0.3): ''' A pharmacy sign (cross). Sits centered on its back (vertical plane). ''' l1 = ddd.line([[-size / 2, 0], [size / 2, 0]]).buffer(size / 3.0, cap_style=3) l2 = ddd.line([[0, -size / 2], [0, size / 2]]).buffer(size / 3.0, cap_style=3) sign = l1.union(l2) sign = sign.extrude(depth) sign = sign.rotate([math.pi / 2.0, 0, 0]) sign = sign.material(ddd.material(color='#00ff00')) sign = ddd.uv.map_cubic(sign) sign.name = "Pharmacy Sign" return sign
def sign_pharmacy_side(size=1.0, depth=0.3, arm_length=1.0): ''' A pharmacy sign, attached sideways to a post arm. The post attaches centered (on the vertical plane). ''' arm_thick = depth / 2 sign = sign_pharmacy(size, depth) arm = ddd.rect([-arm_thick / 2, -arm_thick / 2, arm_thick / 2, arm_thick / 2]).extrude(arm_length) arm = arm.rotate([math.pi / 2.0, 0, 0]) arm = arm.material(ddd.material(color='#888888')) arm = ddd.uv.map_cubic(arm) sign = sign.rotate([0, 0, -math.pi / 2.0]).translate([depth / 2, 0, 0]) sign = sign.translate([0, -(arm_length + size * 0.66), 0]) return ddd.group([sign, arm], name="Pharmacy Side Sign with Arm")
def parse_material(name, color): """ Note: materials mapping shall rather be done by pipeline rules. Alternatively or in addition, a customizable materials mapping table shall be used by this method, instead of hard coding materials and names. TODO: Also search materials by name and ignoring dash/spaces/case. """ material = None if hasattr(ddd.mats, name): material = getattr(ddd.mats, name) else: material = ddd.material(name, color) return material
def image_textured(self, bbox): # TODO: Reuse most of this (material, plane, etc) bbox = ",".join(["%f" % c for c in bbox]) filename = "_cache/images/wms/%s-%s.jpg" % (self.name, bbox) material = ddd.material(texture_path=filename, color="#ffffff") plane = ddd.rect(name="WMS Image (%s)" % self.name).triangulate().material(material) plane = ddd.uv.map_cubic(plane) #plane = plane.recenter() #plane = plane.rotate(ddd.ROT_FLOOR_TO_FRONT) return plane
def panel(height=1.0, width=2.0, depth=0.2, text=None, text_back=None, texture=None, center=False): ''' A panel, like what commerces have either sideways or sitting on the facade. Also road panels. TODO: Provide anchor points w/size to allow for "document" objects (to allow for styling, rotation...). ''' panel = ddd.rect([-width / 2.0, -height / 2.0, width / 2.0, height / 2.0]).extrude(depth, center=True) panel = panel.rotate(ddd.ROT_FLOOR_TO_FRONT) panel = panel.material(ddd.material(color='#f0f0ff')) panel = ddd.uv.map_cubic(panel) panel.name = "Panel" if text: #textobj = ddd.marker(name="Panel Text Marker").translate([0, -depth * 0.5 - 0.02, 0]) textobj = ddd.instance(None, name="Panel Text Marker").translate([0, -depth * 0.5 - 0.02, 0]) textobj.extra['ddd:text'] = text textobj.extra['ddd:text:width'] = width * 0.9 textobj.extra['ddd:text:height'] = height * 0.9 textobj.extra['ddd:collider'] = False textobj.extra['ddd:shadows'] = False textobj.extra['ddd:occluder'] = False #textobj.extra['ddd:layer'] = "Texts" if text_back: #textbackobj = ddd.marker(name="Panel Text Marker").rotate([0, 0, math.pi]).translate([0, +depth * 0.5 + 0.02, 0]) textbackobj = ddd.instance(None, name="Panel Text Marker").rotate([0, 0, math.pi]).translate([0, +depth * 0.5 + 0.02, 0]) textbackobj.extra['ddd:text'] = text textbackobj.extra['ddd:text:width'] = width * 0.9 textbackobj.extra['ddd:text:height'] = height * 0.9 textbackobj.extra['ddd:collider'] = False textbackobj.extra['ddd:shadows'] = False textbackobj.extra['ddd:occluder'] = False panel = ddd.group3([panel]) if text: panel.append(textobj) if text_back: panel.append(textbackobj) if not center: panel = panel.translate([0, - depth * 0.5, 0]) return panel
def godot_materials(pipeline, root): ddd.mats.spritesheet = ddd.material(name="SpriteSheet", color="#ffffff", #color="#e01010", texture_path="assets/spritesheets/ropecow/spritesheet_0.png", texture_normal_path="assets/spritesheets/ropecow/spritesheet_0_n.png", atlas_path="/home/jjmontes/git/NinjaCow/assets/spritesheets/ropecow/spritesheet_0.plist") ddd.mats.grass = ddd.material(name="Grass", color='#2dd355', texture_path="assets/scene/props/grass-texture-tiled.png", #alpha_cutoff=0.05, #extra={'ddd:collider': False, 'ddd:shadows': False, 'uv:scale': 0.05} ) ddd.mats.grass_fore = ddd.material(name="GrassFore", color='#7f8d83', texture_path="assets/scene/props/grass-texture-tiled.png", #alpha_cutoff=0.05, extra={'godot:light_mask': 1 << 15} ) ddd.mats.bricks = ddd.material(name="Bricks", color='#89796a', # #d49156', texture_path="assets/textures/Bricks37_col.jpg", extra={'godot:texture_scale': [8.0, 8.0], 'godot:texture_rotation': math.pi / 2.0, 'godot:material:resource': 'res://assets/materials/textures/material-brick-normal.tres' }) ddd.mats.paintedplaster = ddd.material(name="Bricks", color='#89796a', # #d49156', texture_path="assets/textures/PaintedPlaster006_2K_Color.jpg", texture_normal_path="assets/textures/PaintedPlaster006_2K_Normal.jpg", extra={'godot:texture_scale': [8.0, 8.0], 'godot:texture_rotation': math.pi / 2.0, 'godot:material:resource': 'res://assets/materials/textures/material-brick-normal.tres' }) ddd.mats.rock = ddd.material(name="Rock", color='#5f5f4d', texture_path="assets/textures/Rock22_col.jpg", #extra={'ddd:collider': False, 'ddd:shadows': False, 'uv:scale': 0.05} extra={#'godot:texture_scale': [8.0, 8.0], 'godot:texture_rotation': math.pi / 2.0, 'godot:material:resource': 'res://assets/materials/textures/material-rock-normal.tres' }) ddd.mats.rock2 = ddd.material(name="Rock2(Background)(flat,grey,rock,smooth,wet)", color='#a0a0a0', texture_path="assets/textures/Rock020_2K_Color.jpg", texture_normal_path="assets/textures/Rock020_2K_Normal.jpg", #extra={'ddd:collider': False, 'ddd:shadows': False, 'uv:scale': 0.05} extra={'godot:texture_scale': [4.0, 4.0], 'godot:texture_rotation': math.pi / 2.0, #'godot:material:resource': 'res://assets/materials/textures/material-rock-normal.tres' }) ddd.mats.wood = ddd.material(name="Wood", color='#5f5f4d', texture_path="assets/textures/Planks16_col.jpg", #extra={'ddd:collider': False, 'ddd:shadows': False, 'uv:scale': 0.05} extra={'godot:texture_scale': [8.0, 8.0], 'godot:texture_rotation': math.pi / 2.0, 'godot:material:resource': 'res://assets/materials/textures/material-wood-normal.tres' }) # Concrete with Moss ddd.mats.concrete_moss = ddd.material(name="ConcreteMoss", color='#b0b0b0', texture_path="assets/textures/Concrete026_2K_Color.jpg", texture_normal_path="assets/textures/Concrete026_2K_Normal.jpg", extra={'godot:texture_scale': [6.0, 6.0], 'godot:texture_rotation': math.pi / 2.0, 'godot:material:resource': 'res://assets/materials/textures/material-concrete_moss-normal.tres' }) ddd.mats.tiles_checker = ddd.material(name="ConcreteMoss", color='#474747', texture_path="assets/textures/Tiles012_2K_Color.jpg", texture_normal_path="assets/textures/Tiles012_2K_Normal.jpg", extra={'godot:texture_scale': [12.0, 12.0], 'godot:texture_rotation': math.pi / 2.0, #'godot:material:resource': 'res://assets/materials/textures/material-concrete_moss-normal.tres' }) ddd.mats.obj_bush_def = ddd.material(name="Bush Def", texture_path="assets/scene/props/bush-def.png", texture_normal_path="assets/scene/props/bush-def_n.png" ) ddd.mats.obj_bush_wide= ddd.material(name="Bush Wide", texture_path="assets/scene/props/bush-wide.png", texture_normal_path="assets/scene/props/bush-wide_n.png" ) ddd.mats.obj_tree1 = ddd.material(name="Tree1", texture_path="assets/scene/props/tree1.png", texture_normal_path="assets/scene/props/tree1_n.png" ) ddd.mats.obj_tree2 = ddd.material(name="Tree2", texture_path="assets/scene/props/tree2.png", texture_normal_path="assets/scene/props/tree2_n.png" ) ddd.mats.obj_tree3 = ddd.material(name="Tree3", texture_path="assets/scene/props/tree3.png", texture_normal_path="assets/scene/props/tree3_n.png" ) ddd.mats.obj_tree4 = ddd.material(name="Tree4", texture_path="assets/scene/props/tree4.png", texture_normal_path="assets/scene/props/tree4_n.png" ) #ddd.mats.obj_tree_intro = ddd.material(name="TreeIntro", texture_path="assets/scene/truck/intro-hill-tree.png" ) ddd.mats.obj_barsx4 = ddd.material(name="BarsX4", texture_path="assets/scene/props/bars-4-vert.png") ddd.mats.obj_pipes = ddd.material(name="Pipes", texture_path="assets/scene/props/pipes.png", texture_normal_path="assets/scene/props/pipes_n.png", extra={'godot:obj:scale': 0.25}) ddd.mats.obj_plant = ddd.material(name="Plant", texture_path="assets/scene/props/plant.png" ) ddd.mats.obj_plantsx1 = ddd.material(name="PlantsX1", texture_path="assets/scene/props/city-props-plantsx1.png", texture_normal_path="assets/scene/props/city-props-plantsx1_n.png", extra={'godot:obj:scale': 0.2} ) ddd.mats.obj_plantsx3 = ddd.material(name="PlantsX3", texture_path="assets/scene/props/city-props-plantsx3.png", texture_normal_path="assets/scene/props/city-props-plantsx3_n.png", extra={'godot:obj:scale': 0.2} ) ddd.mats.obj_flowerpot = ddd.material(name="FlowerPot", texture_path="assets/scene/props/city-props-flowerpot.png", texture_normal_path="assets/scene/props/city-props-flowerpot_n.png", extra={'godot:obj:scale': 0.25} ) ddd.mats.obj_flowers1 = ddd.material(name="Flowers1", texture_path="assets/scene/props/city-props-flowers-1.png", texture_normal_path="assets/scene/props/city-props-flowers-1_n.png", extra={'godot:obj:scale': 0.25} ) ddd.mats.obj_flowers2 = ddd.material(name="Flowers2", texture_path="assets/scene/props/city-props-flowers-2.png", texture_normal_path="assets/scene/props/city-props-flowers-2_n.png", extra={'godot:obj:scale': 0.25} ) ddd.mats.obj_mailbox = ddd.material(name="Mailbox", texture_path="assets/scene/props/city-props-mailbox.png", texture_normal_path="assets/scene/props/city-props-mailbox_n.png", extra={'godot:obj:scale': 0.2} ) ddd.mats.obj_bin = ddd.material(name="Bin", texture_path="assets/scene/props/cityprops-bin.png", texture_normal_path="assets/scene/props/cityprops-bin_n.png", extra={'godot:obj:scale': 0.25} ) ddd.mats.obj_bench = ddd.material(name="Bench", texture_path="assets/scene/props/city-props-bench.png", texture_normal_path="assets/scene/props/city-props-bench_n.png", extra={'godot:obj:scale': 0.2} ) ddd.mats.obj_grid_panel = ddd.material(name="Grid Panel", texture_path="assets/scene/props/gridpanel.png", texture_normal_path="assets/scene/props/gridpanel_n.png" ) ddd.mats.obj_grid_panel_broken = ddd.material(name="Grid Panel Broken", texture_path="assets/scene/props/gridpanel_broken.png", texture_normal_path="assets/scene/props/gridpanel_broken_n.png" ) ddd.mats.obj_lamp_fluor = ddd.material(name="Fluor Lamp", texture_path="assets/scene/props/lamp-office-fluor.png" ) ddd.mats.obj_vines1 = ddd.material(name="Vines1", texture_path="assets/scene/props/vines1.png", texture_normal_path="assets/scene/props/vines1_n.png" ) ddd.mats.obj_vines2 = ddd.material(name="Vines2", texture_path="assets/scene/props/vines2.png", texture_normal_path="assets/scene/props/vines2_n.png" ) ddd.mats.obj_vines_h1 = ddd.material(name="Vines Hor1", texture_path="assets/scene/props/vines-h1.png", texture_normal_path="assets/scene/props/vines-h1_n.png" ) ddd.mats.obj_vines_h2 = ddd.material(name="Vines Hor2", texture_path="assets/scene/props/vines-h2.png", texture_normal_path="assets/scene/props/vines-h2_n.png" ) ddd.mats.obj_cables_h = ddd.material(name="Cables", texture_path="assets/scene/props/cables-h.png", texture_normal_path="assets/scene/props/cables-h_n.png" ) ddd.mats.obj_beam1 = ddd.material(name="Beam1", texture_path="assets/scene/props/beam1.png", texture_normal_path="assets/scene/props/beam1_n.png" ) ddd.mats.obj_beam2 = ddd.material(name="Beam2", texture_path="assets/scene/props/beam2.png", texture_normal_path="assets/scene/props/beam2_n.png" ) ddd.mats.obj_cables2 = ddd.material(name="Cable2", texture_path="assets/scene/props/cables2.png", texture_normal_path="assets/scene/props/cables2_n.png" )
def __init__(self): # Various self.logo = ddd.material(name="DDD Logo", color='#7ed956', metallic_factor=1.0, roughness_factor=0.00, # index_of_refraction=1.36, texture_path=ddd.DATA_DIR + "/materials/dddlogo.png") # Ways self.asphalt = ddd.material(name="Asphalt", color='#202020') self.pathwalk = ddd.material(name="WayPedestrian", color='#78281e') # Areas self.sea = ddd.material(name="Water4Advanced", color='#3d43b5', extra={'ddd:collider': False, 'ddd:shadows': False, 'ddd:transparent': True}) self.water = ddd.material(name="WaterBasicDaytime", color='#4d53c5', extra={'ddd:collider': False, 'ddd:shadows': False, 'ddd:transparent': True}) self.volumetricgrass = ddd.material(name="VolumetricGrass", color='#2dd355', extra={'ddd:export-as-marker': True}) # Warning: duplicated in areas_3d volumetic grass generation self.dirt = ddd.material(name="Dirt", color="#b58800") self.forest = ddd.material(name="Forest", color='#3a6e17') self.garden = ddd.material(name="Garden", color='#2f614b') self.grass = ddd.material(name="Grass", color='#2dd355') self.park = ddd.material(name="Park", color='#1db345') self.rock = ddd.material(name="Rock", color='#5f5f4d') self.rock_lightbrown = ddd.material(name="Rock Orange", color='#bd8658') self.sand = ddd.material(name="Sand", color='#fff694') self.terrain = ddd.material(name="Ground", color='#e6821e') self.wetland = ddd.material(name="Wetland", color='#54610c') self.pavement = ddd.material(name="Sidewalk", color='#c0c0b0') self.sett = ddd.material(name="Sett", color='#7b719f') self.sidewalk = ddd.material(name="Sidewalk", color='#e0d0d0') self.pitch = ddd.material(name="Pitch", color='#196118') self.pitch_blue = ddd.material(name="Pitch Blue", color='#2a69b0') # Eg. cycleways self.pitch_red = ddd.material(name="Pitch Red", color='#b34446') # Eg. leisure track self.painted_line = ddd.material(name="Painted Line", color='#ffffff', extra={'zoffset': -8.5, 'ddd:collider': False, 'ddd:shadows': False}) # Eg. leisure track # Structural / building materials self.bronze = ddd.material(name="Bronze", color='#f0cb11') self.steel = ddd.material(name="Steel", color='#78839c') self.metal = ddd.material(name="Steel", color='#68738c') self.stone = ddd.material(name="Stone", color='#9c9378') self.cement = ddd.material(name="Concrete", color='#b8b8a0') self.bricks = ddd.material(name="Bricks", color='#d49156') self.marble_white = ddd.material(name="Marble White", color='#c0c3c8', metallic_factor=0.4, roughness_factor=0.05) self.wood = ddd.material(name="Wood", color='#efae85') # Painted materials self.metal_paint_red = ddd.material("PaintRed", color='#d01010') self.metal_paint_green = ddd.material("PaintGreen", color='#265e13') self.metal_paint_yellow = ddd.material("PaintYellow", color='#ebe015') self.metal_paint_blue = ddd.material("PaintBlue", color='#184794') self.metal_paint_white = ddd.material("PaintWhite", color='#f8fbff') self.metal_paint_black = ddd.material("PaintBlack", color='#000a17') # Plastics self.plastic_transparent = ddd.material("Plastic Transparent", color='e8e0e4', metallic_factor=0.0, roughness_factor=0.7, extra={'ddd:transparent': True}) # name="PlasticTransparent", self.plastic_black = ddd.material("Plastic Black", color='#2c2936', metallic_factor=0.0, roughness_factor=0.7) self.plastic_red = ddd.material("Plastic Red", color='#cc2b2b', metallic_factor=0.0, roughness_factor=0.7) self.plastic_green = ddd.material("Plastic Green", color='#64a80a', metallic_factor=0.0, roughness_factor=0.7) self.plastic_yellow = ddd.material("Plastic Yellow", color='#fffb08', metallic_factor=0.0, roughness_factor=0.7) self.plastic_blue = ddd.material("Plastic Blue", color='#1763bf', metallic_factor=0.0, roughness_factor=0.7) self.plastic_white = ddd.material("Plastic White", color='#f2f5f7', metallic_factor=0.0, roughness_factor=0.7) # Glass self.glass = ddd.material("Glass", color='#2e4163', metallic_factor=0.0, roughness_factor=0.0) # , extra={'ddd:transparent': True} # Lights self.lightbulb = ddd.material("LightLampOff", color='e8e0e4') self.light_green = ddd.material("LightGreen", color='#00ff00') self.light_orange = ddd.material("LightOrange", color='#ffff00') self.light_red = ddd.material("LightRed", color='#ff0000') # Trees self.bark = ddd.material(name="Bark", color='#df9e75') self.treetop = ddd.material(name="Treetop", color='#1da345') # Urban props materials self.fence = ddd.material(name="Fence", color='282024', extra={'ddd:transparent': True}) self.railing = ddd.material(name="Fence", color='282024', extra={'ddd:transparent': True}) self.metallic_grid = ddd.material(name="Fence", color='#28281e', extra={'ddd:transparent': True}) # Floors self.cable_metal = ddd.material(name="CableMetal", color='#28282e') self.chain = ddd.material(name="CableMetal", color='#28282e') self.rope = ddd.material(name="Rope", color='#c7b01c') # Buildings self.building_1 = ddd.material(color='#f7f0be') self.building_2 = ddd.material(color='#bdb9a0') self.building_3 = ddd.material(color='#c49156') self.roof_tiles = ddd.material("RoofTiles", color='#f25129') # Colors self.red = ddd.material("Color Red", color='#ff0000') self.green = ddd.material("Color Green", color='#00ff00') self.blue = ddd.material("Color Blue", color='#0000ff') self.white = ddd.material("Color White", color='#ffffff') self.black = ddd.material("Color Black", color='#000000')
# Jose Juan Montes 2019-2020 from ddd.pack.sketchy import urban, landscape, industrial from ddd.ddd import ddd import math 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") items = ddd.group3() for key in ddd.mats.traffic_signs.atlas.keys(): key = 'es:' + key[ 3: -4] # Ugly way of removing .png. This shouldn't be needed (remove extension on atlas keys!) item = urban.traffic_sign(key) if item: items.append(item) items = ddd.align.grid(items) items.append(ddd.helper.all()) items.save("/tmp/test.glb") items.show() # Note that this one hangs PC if using with software renderer items.save("/tmp/test.png")
def tennis_field_lines(length=23.77, width=10.97, square_length_ratio=6.40 / 23.77, net_height_center=0.914, net_height_post=1.07, line_width=0.10): """ Playground fields are seen x: length, y: width doubles_width_official = 10.97 singles_width_official = 8.23 extra_width = 3.65 (/2?) extra_length = 6.50 (/2?) """ length = min(length, 23.77) width = min(width, 10.97) (length, width) = enforce_aspect_ratio(length, width, 23.77 / 10.97) item = ddd.group3(name="Tennis lines") rectangle = ddd.rect([-length / 2, -width / 2, length / 2, width / 2]) coords = rectangle.geom.exterior.coords width_seg = ddd.line([coords[0], coords[1]]) length_seg = ddd.line([coords[1], coords[2]]) width2_seg = ddd.line([coords[2], coords[3]]) length2_seg = ddd.line([coords[3], coords[0]]) width_l = width_seg.geom.length length_l = length_seg.geom.length exterior = rectangle.outline().buffer( line_width, cap_style=ddd.CAP_SQUARE).triangulate().material( ddd.material(color='#ffffff')) exterior.name = "Bounds line" exterior.extra['ddd:collider'] = False exterior.extra['ddd:shadows'] = False item.append(exterior) centralline_2d = ddd.line( [width_seg.geom.centroid, width2_seg.geom.centroid], name="Central line") goal_width = 4.88 # Sideline sideline_pos_ratio = 8.23 / 10.97 for side in (-1, 1): sideline = centralline_2d.translate( [0, side * width * sideline_pos_ratio * 0.5]) sideline = sideline.buffer( line_width, cap_style=ddd.CAP_SQUARE).triangulate().material( ddd.material(color='#ffffff')) sideline.extra['ddd:collider'] = False sideline.extra['ddd:shadows'] = False item.append(sideline) for side in (-1, 1): midline = ddd.line([[ side * length * square_length_ratio, -width * sideline_pos_ratio * 0.5 ], [ side * length * square_length_ratio, width * sideline_pos_ratio * 0.5 ]]) midline = midline.buffer( line_width, cap_style=ddd.CAP_SQUARE).triangulate().material( ddd.material(color='#ffffff')) midline.extra['ddd:collider'] = False midline.extra['ddd:shadows'] = False item.append(midline) item = ddd.uv.map_cubic(item) net = tennis_net(width=width + 0.5, net_height_center=net_height_center, net_height_post=net_height_post) item.append(net) return item
def basketball_field_lines(length=28, width=15, line_width=0.075): """ Note that an additional 2m around the field shall be granted. Playground fields are seen x: length, y: width """ item = ddd.group3(name="Basketball lines") length = min(length, 28) width = min(width, 15) (length, width) = enforce_aspect_ratio(length, width, 28 / 15) rectangle = ddd.rect([-length / 2, -width / 2, length / 2, width / 2]) coords = rectangle.geom.exterior.coords width_seg = ddd.line([coords[0], coords[1]]) length_seg = ddd.line([coords[1], coords[2]]) width2_seg = ddd.line([coords[2], coords[3]]) length2_seg = ddd.line([coords[3], coords[0]]) width_l = width_seg.geom.length length_l = length_seg.geom.length exterior = rectangle.outline().buffer( line_width, cap_style=ddd.CAP_SQUARE).triangulate().material( ddd.material(color='#ffffff')) exterior.name = "Bounds line" exterior.extra['ddd:collider'] = False exterior.extra['ddd:shadows'] = False midline_2d = ddd.line( [length_seg.geom.centroid, length2_seg.geom.centroid], name="Mid line") midline = midline_2d.buffer( line_width, cap_style=ddd.CAP_SQUARE).triangulate().material( ddd.material(color='#ffffff')) midline.extra['ddd:collider'] = False midline.extra['ddd:shadows'] = False midcircle_radius_ratio = (3.60 / 2) / 15 midcircle = ddd.disc(center=midline_2d.geom.centroid.coords, r=width_l * midcircle_radius_ratio).outline() midcircle = midcircle.buffer( line_width, cap_style=ddd.CAP_SQUARE).triangulate().material( ddd.material(color='#ffffff')) midcircle.extra['ddd:collider'] = False midcircle.extra['ddd:shadows'] = False item.append(exterior) item.append(midline) item.append(midcircle) centralline_2d = ddd.line( [width_seg.geom.centroid, width2_seg.geom.centroid], name="Central line") # Sides for side in (-1, 1): if width > 12.0: smallarea = ddd.line([[0, -3], [5.80, -(3 - 1.80)] ]).arc_to([5.80, 3 - 1.80], center=[5.80, 0], ccw=True).line_to([0, 3]) #smallarea = smallarea.scale([smallarea_length_ratio * length, smallarea_width_ratio * width * 0.5]) if side == 1: smallarea = smallarea.rotate(math.pi) smallarea = smallarea.translate([side * length_l / 2, 0]) smallarea = smallarea.buffer( line_width, cap_style=ddd.CAP_SQUARE).triangulate().material( ddd.material(color='#ffffff')) smallarea.extra['ddd:collider'] = False smallarea.extra['ddd:shadows'] = False item.append(smallarea) smallline = ddd.line([[5.80, -(3 - 1.80)], [5.80, 3 - 1.80]]) if side == 1: smallline = smallline.rotate(math.pi) smallline = smallline.translate([side * length_l / 2, 0]) smallline = smallline.buffer( line_width, cap_style=ddd.CAP_SQUARE).triangulate().material( ddd.material(color='#ffffff')) smallline.extra['ddd:collider'] = False smallline.extra['ddd:shadows'] = False item.append(smallline) if width > 14.0: largearea = ddd.line([[0, -6.75], [1.575, -6.75]]).arc_to([1.575, 6.75], center=[1.575, 0], ccw=True).line_to([0, 6.75]) if side == 1: largearea = largearea.rotate(math.pi) largearea = largearea.translate([side * length_l / 2, 0]) largearea = largearea.buffer( line_width, cap_style=ddd.CAP_SQUARE).triangulate().material( ddd.material(color='#ffffff')) largearea.extra['ddd:collider'] = False largearea.extra['ddd:shadows'] = False item.append(largearea) goal = basketball_hoop().rotate(ddd.ROT_TOP_CCW) if side == 1: goal = goal.rotate(ddd.ROT_TOP_HALFTURN) goal = goal.translate([side * (length_l / 2 - 1.22 - 0.15), 0, 0]) item.append(goal) item = ddd.uv.map_cubic(item) #hoop = basketball_hoop(width=width + 0.5, net_height_center=net_height_center, net_height_post=net_height_post) #item.append(hoop) return item
def football_field_lines(length=105.0, width=67.5, line_width=0.10): """ Playground fields are seen x: length, y: width """ item = ddd.group3(name="Football lines") rectangle = ddd.rect([-length / 2, -width / 2, length / 2, width / 2]) coords = rectangle.geom.exterior.coords width_seg = ddd.line([coords[0], coords[1]]) length_seg = ddd.line([coords[1], coords[2]]) width2_seg = ddd.line([coords[2], coords[3]]) length2_seg = ddd.line([coords[3], coords[0]]) width_l = width_seg.geom.length length_l = length_seg.geom.length exterior = rectangle.outline().buffer( line_width, cap_style=ddd.CAP_SQUARE).triangulate().material( ddd.material(color='#ffffff')) exterior.name = "Bounds line" exterior.extra['ddd:collider'] = False exterior.extra['ddd:shadows'] = False midline_2d = ddd.line( [length_seg.geom.centroid, length2_seg.geom.centroid], name="Mid line") midline = midline_2d.buffer( line_width, cap_style=ddd.CAP_SQUARE).triangulate().material( ddd.material(color='#ffffff')) midline.extra['ddd:collider'] = False midline.extra['ddd:shadows'] = False midcircle_radius_ratio = 9.15 / 67.5 midcircle = ddd.disc(center=midline_2d.geom.centroid.coords, r=width_l * midcircle_radius_ratio).outline() midcircle = midcircle.buffer( line_width, cap_style=ddd.CAP_SQUARE).triangulate().material( ddd.material(color='#ffffff')) midcircle.extra['ddd:collider'] = False midcircle.extra['ddd:shadows'] = False item.append(exterior) item.append(midline) item.append(midcircle) centralline_2d = ddd.line( [width_seg.geom.centroid, width2_seg.geom.centroid], name="Central line") goal_width = 7.2 smallarea_width_ratio = (goal_width + 5.5 * 2) / 67.5 smallarea_length_ratio = 5.5 / 67.5 largearea_width_ratio = 40.3 / 67.5 largearea_length_ratio = 16.5 / 105.5 for side in (-1, 1): smallarea = ddd.line([[0, -1], [1, -1], [1, 1], [0, 1]]) smallarea = smallarea.scale([ smallarea_length_ratio * length, smallarea_width_ratio * width * 0.5 ]) if side == 1: smallarea = smallarea.rotate(math.pi) smallarea = smallarea.translate([side * length_l / 2, 0]) smallarea = smallarea.buffer( line_width, cap_style=ddd.CAP_SQUARE).triangulate().material( ddd.material(color='#ffffff')) smallarea.extra['ddd:collider'] = False smallarea.extra['ddd:shadows'] = False item.append(smallarea) largearea = ddd.line([[0, -1], [1, -1], [1, 1], [0, 1]]) largearea = largearea.scale([ largearea_length_ratio * length, largearea_width_ratio * width * 0.5 ]) if side == 1: largearea = largearea.rotate(math.pi) largearea = largearea.translate([side * length_l / 2, 0]) largearea = largearea.buffer( line_width, cap_style=ddd.CAP_SQUARE).triangulate().material( ddd.material(color='#ffffff')) largearea.extra['ddd:collider'] = False largearea.extra['ddd:shadows'] = False item.append(largearea) # TIODO: shall depend on the football type, assign earlier maybe if width > 30: goal = football_goal11() elif width > 15: goal = football_goal9() elif width > 9: goal = football_goal7() else: goal = football_goal_small() goal = goal.rotate(ddd.ROT_TOP_CCW) if side == 1: goal = goal.rotate(ddd.ROT_TOP_HALFTURN) goal = goal.translate([side * length_l / 2, 0, 0]) item.append(goal) item = ddd.uv.map_cubic(item) return item
def solids_borders(root, pipeline, obj): floors = ddd.group2(name="Floors") ceilings = ddd.group2(name="Ceilings") walls = ddd.group2(name="Walls") angles_ceiling = [-math.pi / 4, math.pi / 4] angles_floor1 = [math.pi / 4 * 3, math.pi / 4 * 4] angles_floor2 = [-math.pi / 4 * 4, -math.pi / 4 * 3] polygon = obj.geom.exterior if polygon.is_ccw: polygon.coords = reversed(list(polygon.coords)) segments = zip(polygon.coords, polygon.coords[1:] + polygon.coords[:1]) for a, b in segments: angle = math.atan2(b[1] - a[1], b[0] - a[0]) if (angle > angles_floor1[0] and angle < angles_floor1[1]): floors.append(ddd.line([a, b])) if (angle > angles_floor2[0] and angle < angles_floor2[1]): floors.append(ddd.line([a, b])) if (angle > angles_ceiling[0] and angle < angles_ceiling[1]): ceilings.append(ddd.line([a, b])) ddd.mats.grass = ddd.material( name="Grass", color='#2dd355', texture_path="res://assets/scene/props/grass-texture-tiled.png", #alpha_cutoff=0.05, #extra={'ddd:collider': False, 'ddd:shadows': False, 'uv:scale': 0.05} ) floor_lines = floors floors = ddd.line([[0, 0], [1, 1]], name="Floors") floors.geom = linemerge([g.geom for g in floor_lines.children]) # Iterate merged lines floors = floors.individualize(always=True) for line in floors.children: floor = line.buffer(10.0) floor = floor.material(ddd.mats.grass) floor.extra['floor_line'] = line floor.extra['ddd:z_index'] = 40 floor = uvmapping.map_2d_path(floor, line, line_x_offset=64.0, line_x_width=64.0) #ddd.trace(locals()) print(floor.get('uv', None)) line.replace(floor) #floors.extra['ddd:z_index'] = 40 #newobj = ddd.group2([obj, floors], name="Solid") #obj.replace(newobj) root.find("/Rooms").append(floors) obj.extra['floors'] = floors ceiling_lines = ceilings lines = linemerge([g.geom for g in ceiling_lines.children]) ceilings = DDDObject2(name="Ceilings", geom=lines) ceilings.extra['ddd:z_index'] = 40 ceilings = ceilings.individualize(always=True).clean() for pc in ceilings.children: c = pc.copy() c.extra['ceiling_line'] = c.copy() c = c.buffer(15.0) c = filters.noise_random(c, scale=10.0) pc.replace(c) ceilings = ceilings.material(ddd.mats.bricks) ceilings.mat.color_rgba[3] = 128 ceilings = ceilings.clean() #newobj = ddd.group2([obj, floors], name="Solid") #obj.replace(newobj) root.find("/Rooms").append(ceilings) obj.extra['ceilings'] = ceilings
def pipeline_start(pipeline, root): 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") items = ddd.group3() item = urban.lamppost_high_mast() items.append(item) item = buildings.portal() #item = ddd.meshops.batch_by_material(item) items.append(item) #item.show() item = buildings.door() items.append(item) #item.show() item = buildings.window_with_border() items.append(item) item = common.bar_u() items.append(item) item = urban.waste_container_dome() items.append(item) item = urban.waste_container_with_lid_closed() items.append(item) item = urban.waste_container() items.append(item) item = landscape.ladder_pool() items.append(item) item = sports.golf_flag() items.append(item) item = urban.drinking_water() items.append(item) item = urban.bollard() items.append(item) item = urban.bell() items.append(item) item = urban.fire_hydrant() items.append(item) item = urban.childrens_playground_swingset() items.append(item) item = urban.childrens_playground_sandbox() items.append(item) item = urban.childrens_playground_slide() items.append(item) item = urban.childrens_playground_arc() items.append(item) item = urban.patio_table() items.append(item) item = urban.patio_chair() items.append(item) item = urban.patio_umbrella() items.append(item) item = urban.post_box() items.append(item) item = urban.lamppost() items.append(item) item = urban.busstop_small(text="Bus Stop") items.append(item) item = urban.bench() items.append(item) item = urban.sculpture() items.append(item) item = urban.sculpture_text("Test") item = urban.pedestal(item) items.append(item) item = urban.sculpture_text("Monumental test string", vertical=True, height=12) items.append(item) item = urban.trafficlights() #item = item.rotate([0, 0, (math.pi / 4) - math.pi / 2]) items.append(item) item = urban.fountain() items.append(item) item = urban.wayside_cross() items.append(item) item = urban.trash_bin() items.append(item) item = urban.trash_bin_post() items.append(item) # Road signs item = urban.traffic_sign('stop') items.append(item) #item.show() item = urban.traffic_sign('give_way') items.append(item) #item.show() item = urban.traffic_sign('es:s13') items.append(item) #item.show() item = urban.traffic_sign('es:p1') items.append(item) item = urban.traffic_sign('es:r101') items.append(item) item = urban.traffic_sign('es:r1') items.append(item) item = urban.traffic_sign('es:r2') items.append(item) item = urban.traffic_sign('es:r3') items.append(item) item = urban.traffic_sign('es:r6') items.append(item) item = urban.traffic_sign('es:r402') items.append(item) item = urban.traffic_sign('es:r500') items.append(item) item = urban.traffic_sign('es:r504') items.append(item) #item = urban.traffic_sign('es:r505-b') #items.append(item) item = urban.traffic_sign('es:r505') items.append(item) item = urban.traffic_sign('es:r506') items.append(item) #item.show() ''' # Reduced items_org = items.copy() items = ddd.meshops.reduce(items_org) items = ddd.align.grid(items) items.append(ddd.helper.all()) items.show() items = ddd.meshops.reduce_bounds(items_org) items = ddd.align.grid(items) items.append(ddd.helper.all()) items.show() ''' items = ddd.align.grid(items) items.append(ddd.helper.all()) #items.show() #items.save("/tmp/test.glb") #items = ddd.meshops.batch_by_material(items) #items.dump() items.show() #items.save("/tmp/test.json") pipeline.root = items
def generate_area_3d_gen(self, area_2d): if area_2d.geom is not None and area_2d.geom.type != "LineString" and area_2d.geom.type: if area_2d.geom.type in ('GeometryCollection', 'MultiPolygon'): logger.debug( "Generating area 3d as separate areas as it is a GeometryCollection: %s", area_2d) # FIXME: We might do this in extrude_step, like we do in triangulate and extrude, but difficult as it is in steps. # But also, we should have an individualize that work, correct iterators, and a generic cleanup/flatten method # to flatten areas, which might solve this. areas_3d = [] for a in area_2d.individualize().clean_replace().children: areas_3d.append(self.generate_area_3d(a)) return ddd.group3(areas_3d, extra=area_2d.extra) if area_2d.extra.get('ddd:area:type', None) == 'raised': area_3d = area_2d.extrude_step( area_2d.buffer(-1.0), 0.1, base=False, method=ddd.EXTRUSION_METHOD_SUBTRACT) area_3d = area_3d.extrude_step( area_2d.buffer(-3.0), 0.1, method=ddd.EXTRUSION_METHOD_SUBTRACT) elif area_2d.extra.get('ddd:area:type', None) == 'park': area_3d = area_2d.extrude_step( area_2d.buffer(-1.0), 0.1, base=False, method=ddd.EXTRUSION_METHOD_SUBTRACT) area_3d = area_3d.extrude_step( area_2d.buffer(-3.0), 0.1, method=ddd.EXTRUSION_METHOD_SUBTRACT) # Grass # TODO: Add in a separate (optional) pass if False: # For volumetric grass, as described by: https://www.bruteforce-games.com/post/grass-shader-devblog-04 grass_layers = [] colors = [ '#000000', '#222222', '#444444', '#666666', '#888888', '#aaaaaa', '#cccccc', '#eeeeee' ] for i in range(8): grass_layer = area_3d.copy(name="Grass %d: %s" % (i, area_3d.name)) grass_layer = grass_layer.material( ddd.material(name="VolumetricGrass", color=colors[i], extra={'ddd:export-as-marker': True})) #grass_layer.extra['ddd:vertex_colors'] = grass_layer = grass_layer.translate([0, 0, 0.05 * i]) #grass_layer = terrain.terrain_geotiff_elevation_apply(grass_layer, self.osm.ddd_proj) grass_layer.extra['ddd:shadows'] = False grass_layer.extra['ddd:collider'] = False grass_layer.extra['ddd:occluder'] = False grass_layers.append(grass_layer) #self.osm.other_3d.append(grass_layers) #ddd.group3([area_3d, grass_layers]) area_3d.children.extend(grass_layers) #area_3d = ddd.group([area_2d.triangulate().translate([0, 0, 0.0]), # area_2d.buffer(-1.0).triangulate().translate([0, 0, 0.2]), # area_2d.buffer(-3.0).triangulate().translate([0, 0, 0.3])]) #area_3d = area_3d.translate([0, 0, 0]) elif area_2d.extra.get('ddd:area:type', None) == 'rocky': # Raise surface, then add random noise area_3d = area_2d.extrude_step( area_2d.buffer(-0.3), 0.3, base=False, method=ddd.EXTRUSION_METHOD_SUBTRACT) area_3d = area_3d.extrude_step( area_2d.buffer(-1.5), 1.2, method=ddd.EXTRUSION_METHOD_SUBTRACT) # TODO: #last_cap_idx = result.extra.get('_extrusion_last_cap_idx', None) #if last_cap_idx is not None: # faces = faces[:last_cap_idx] # Subdivide and apply noise / tag to avoid further subdivisions (check if other surfaces can be tagged too, eg, playgrounds, etc) elif area_2d.extra.get('ddd:area:type', None) == 'bunker': area_3d = area_2d.extrude_step( area_2d.buffer(-1.0), -0.4, base=False, method=ddd.EXTRUSION_METHOD_SUBTRACT) area_3d = area_3d.extrude_step( area_2d.buffer(-3.0), -0.3, method=ddd.EXTRUSION_METHOD_SUBTRACT) elif area_2d.extra.get('ddd:area:type', None) == 'steps': # This is the steps area, not the stairs. area_3d = area_2d.extrude_step( area_2d, area_2d.extra['ddd:steps:height'], base=False) for stepidx in range(1, area_2d.extra['ddd:steps:count'] + 1): area_3d = area_3d.extrude_step( area_2d.buffer(-area_2d.extra['ddd:steps:depth'] * stepidx), 0, method=ddd.EXTRUSION_METHOD_SUBTRACT) area_3d = area_3d.extrude_step( area_2d.buffer(-area_2d.extra['ddd:steps:depth'] * stepidx), area_2d.extra['ddd:steps:height'], method=ddd.EXTRUSION_METHOD_SUBTRACT) # TODO: Crop in 3D (or as a workaround fake it as centroid cropping) elif area_2d.extra.get('ddd:area:type', None) == 'sidewalk': area_3d = None try: height = area_2d.extra.get('ddd:height', 0.2) #area_3d = area_2d.extrude(-0.5 - height).translate([0, 0, height]) #area_3d = ddd.uv.map_cubic(area_3d) add_kerb = True if add_kerb: try: interior_original = area_2d.get( 'ddd:area:original').buffer(-0.3) interior = area_2d.intersection(interior_original) if not interior.is_empty(): kerb_3d = None kerb_2d = area_2d.get( 'ddd:area:original').subtract( interior_original).intersection( area_2d).intersection( self.osm.area_crop2) kerb_2d = kerb_2d.clean(eps=-0.01) if not kerb_2d.is_empty(): kerb_3d = kerb_2d.extrude( -0.5 - height).translate( [0, 0, height]).material(ddd.mats.cement) kerb_3d = ddd.uv.map_cubic(kerb_3d) area_2d_no_kerb = area_2d.subtract( kerb_2d).clean(eps=-0.01) if not area_2d_no_kerb.is_empty(): area_3d = area_2d_no_kerb.extrude( -0.5 - height).translate( [0, 0, height]) area_3d = ddd.uv.map_cubic(area_3d) else: area_2d = area_2d.copy3() if area_3d: area_3d.copy_from(area_2d) if area_3d.get('ddd:layer', '0') == '0': area_3d = ddd.meshops.remove_faces_pointing( area_3d, ddd.VECTOR_DOWN ) # TODO: Remove bases in generic way? if kerb_3d: area_3d.append(kerb_3d) #ddd.group2([area_2d.get('ddd:area:original'), area_2d.material(ddd.MAT_HIGHLIGHT), kerb_2d.material(ddd.mats.red)]).triangulate().show() else: logger.info( "Cannot create kerb (empty interior) for area: %s", area_2d) area_3d = None except Exception as e: logger.info("Error creating kerb for area %s: %s", area_2d, e) print(traceback.format_exc()) #ddd.group2([area_2d.get('ddd:area:original'), area_2d.material(ddd.MAT_HIGHLIGHT)]).triangulate().show() area_3d = None # If no kerb or kerb could not be generated, just generate the area: if area_3d is None: logger.debug( "No kerb generated, generating simple area: %s", area_2d) area_3d = area_2d.extrude(-0.5 - height).translate( [0, 0, height]) # Remove base if area_3d.get('ddd:layer', '0') == '0': area_3d = ddd.meshops.remove_faces_pointing( area_3d, ddd.VECTOR_DOWN) area_3d = ddd.uv.map_cubic(area_3d) except Exception as e: logger.error("Could not generate area: %s (%s)", e, area_2d) area_3d = DDDObject3() elif area_2d.extra.get('ddd:area:type', None) == 'void': area_3d = area_2d.copy3("Void area: %s" % area_2d.name) else: logger.debug("Generating Area: %s" % area_2d) # Validate area (areas should be correct at this point, but this avoids core dumps in triangulate()) try: area_2d = area_2d.clean( eps=-0.01) # 0.01 didn't work for fixing errors area_2d.validate() except Exception as e: logger.warn("Invalid area %s: %s", area_2d, e) return None try: height = area_2d.extra.get( 'ddd:area:height', area_2d.extra.get('ddd:height', 0.2)) if not height: height = 0 # We extrude base_height to avoid sidewalks floating with no side triangles base_height = area_2d.get('ddd:height:base', 0) height = height + base_height if height: area_3d = area_2d.extrude(-0.5 - height).translate( [0, 0, height]) # Remove base if area_3d.get('ddd:layer', '0') == '0': area_3d = ddd.meshops.remove_faces_pointing( area_3d, ddd.VECTOR_DOWN) else: area_3d = area_2d.triangulate() area_3d = ddd.uv.map_cubic(area_3d) except Exception as e: logger.error("Could not generate area: %s (%s)", e, area_2d) area_3d = DDDObject3() else: if len(area_2d.children) == 0: logger.warning("Null area geometry (children?): %s", area_2d) area_3d = DDDObject3() # Subdivide if int(ddd.data.get('ddd:area:subdivide', 0)) > 0: #logger.debug("Subdividing: %s" % area_3d) #area_3d = area_3d.subdivide_to_size(float(ddd.data.get('ddd:area:subdivide'))) area_3d = ddd.meshops.subdivide_to_grid( area_3d, float(ddd.data.get('ddd:area:subdivide'))) area_3d.merge_vertices( ) # Smoothes surface by unifying normals (modifies in place) area_3d = ddd.uv.map_cubic(area_3d) # Apply elevation area_3d = self.generate_area_3d_apply_elevation(area_2d, area_3d) #area_3d.extra = dict(area_2d.extra) area_3d.copy_from(area_2d) area_3d.children.extend( [self.generate_area_3d(c) for c in area_2d.children]) return area_3d
def osm_materials(): # Materials used by this pipeline ddd.mats.railway = ddd.material(name="RoadRailway", color="#47443e", metallic_factor=0.9, roughness_factor=0.43, index_of_refraction=1.0, direct_lighting=0.76, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/RoadRailway/TexturesCom_Road_Railway_512_*.png", # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/RoadRailway/TexturesCom_Road_Railway_512_normal.png", # alpha_cutoff=0.05, extra={'uv:scale': 1.0}) ddd.mats.roadline = ddd.material(name="Roadline", color='#e8e8e8', texture_path=ddd.DATA_DIR + "/materials/road-lines/RoadLines_alb.png", texture_normal_path=ddd.DATA_DIR + "/materials/road-lines/RoadLines_normal.jpg", alpha_cutoff=0.05, metallic_factor=0.36, roughness_factor=0.30, bump_strength=0.25, extra={'ddd:collider': False, 'ddd:shadows': False, 'uv:scale': 0.05, 'zoffset': -8.5, 'ddd:texture:resize': 1024}) ddd.mats.roadline_red = ddd.material(name="Roadline Red", color='#f88888', texture_path=ddd.DATA_DIR + "/materials/road-lines/RoadLines_alb.png", texture_normal_path=ddd.DATA_DIR + "/materials/road-lines/RoadLines_normal.jpg", alpha_cutoff=0.05, metallic_factor=0.36, roughness_factor=0.30, bump_strength=0.35, extra={'ddd:collider': False, 'ddd:shadows': False, 'uv:scale': 0.05, 'zoffset':-8.5, 'ddd:texture:resize': 1024}) 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", texture_normal_path=ddd.DATA_DIR + "/materials/road-marks-es/TexturesCom_Atlas_RoadMarkings2_1K_normal.png", atlas_path=ddd.DATA_DIR + "/materials/road-marks-es/RoadMarkings2.plist", alpha_cutoff=0.05, metallic_factor=0.36, roughness_factor=0.25, extra={'ddd:collider': False, 'ddd:shadows': False, 'uv:scale': 1.00, 'zoffset':-25.0, 'ddd:texture:resize': 1024}) 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", texture_normal_path=ddd.DATA_DIR + "/materials/traffic-signs-es/traffic_signs_es_0_nrm.png", atlas_path=ddd.DATA_DIR + "/materials/traffic-signs-es/traffic_signs_es_0.plist", metallic_factor=0.86, roughness_factor=0.15, bump_strength=0.5, extra={'ddd:texture:resize': 1024}) ddd.mats.asphalt = ddd.material(name="Asphalt", color='#202020', extra={'uv:scale': 0.25}, # 0.25 color='#202020', metallic_factor=0.1, roughness_factor=2.5, index_of_refraction=1.0, direct_lighting=0.76, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Asphalt/Asphalt01_*.jpg",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Asphalt/Asphalt01_nrm.jpg",) ''' # Areas self.sea = ddd.material(name="Water4Advanced", color='#3d43b5', extra={'ddd:collider': False, 'ddd:shadows': False, 'ddd:transparent': True}) self.water = ddd.material(name="WaterBasicDaytime", color='#4d53c5', extra={'ddd:collider': False, 'ddd:shadows': False, 'ddd:transparent': True}) self.volumetricgrass = ddd.material(name="VolumetricGrass", color='#2dd355', extra={'ddd:export-as-marker': True}) # Warning: duplicated in areas_3d volumetic grass generation ''' ddd.mats.grass = ddd.material(name="Grass", color='#2dd355', extra={'uv:scale': 0.5}, # 0.25 # #2dd355 metallic_factor=0.35, roughness_factor=0.85, index_of_refraction=1.36, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Grass01/Grass_01_2K_*.png",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Grass01/Grass_01_2K_Normal.png", # texture_displacement_path=ddd.DATA_DIR + "/osmmaterials/Grass01/Grass_01_2K_Height.png",) ddd.mats.park = ddd.material(name="Park", color='#1db345', extra={'uv:scale': 0.25}, # 0.25 metallic_factor=0.0, roughness_factor=1.15, bump_strength=2.0, # index_of_refraction=1.36, texture_path=ddd.DATA_DIR + "/osmmaterials/Ground03/Ground03_*.jpg") # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Ground03/Ground03_nrm.jpg", # texture_displacement_path=ddd.DATA_DIR + "/osmmaterials/Ground03/Ground03_disp.jpg",) ddd.mats.forest = ddd.material(name="Forest", color='#3a6e17', extra={'uv:scale': 0.25}, # 0.25 metallic_factor=0.0, roughness_factor=1.25, bump_strength=2.0, # index_of_refraction=1.36, texture_path=ddd.DATA_DIR + "/osmmaterials/Ground03/Ground03_*.jpg",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Ground03/Ground03_nrm.jpg", # texture_displacement_path=ddd.DATA_DIR + "/osmmaterials/Ground03/Ground03_disp.jpg",) ddd.mats.garden = ddd.material(name="Garden", color='#2f614b', extra={'uv:scale': 0.25}, # 0.25 metallic_factor=0.0, roughness_factor=0.85, index_of_refraction=1.36, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Grass01/Grass_01_2K_*.png",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Grass01/Grass_01_2K_Normal.png", # texture_displacement_path=ddd.DATA_DIR + "/osmmaterials/Grass01/Grass_01_2K_Height.png",) ddd.mats.wetland = ddd.material(name="Wetland", color='#54610c', extra={'uv:scale': 0.25}, # 0.25 metallic_factor=0.4, roughness_factor=0.45, index_of_refraction=1.36, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Ground03/Ground03_*.jpg",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Ground03/Ground03_nrm.jpg", # texture_displacement_path=ddd.DATA_DIR + "/osmmaterials/Ground03/Ground03_disp.jpg",) ddd.mats.mud = ddd.material(name="Mud", color='#b49f84', extra={'uv:scale': 0.5}, # 0.2 metallic_factor=0.0, roughness_factor=1.0, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Ground025_2K-JPG/Ground025_2K_*.jpg",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Ground025_2K-JPG/Ground025_2K_Normal.jpg", # texture_displacement_path=ddd.DATA_DIR + "/osmmaterials/Ground025_2K-JPG/Ground025_2K_Displacement.jpg", ) ddd.mats.sand = ddd.material(name="Sand", color='#fff694', metallic_factor=0.0, roughness_factor=0.45, bump_strength=2.0, index_of_refraction=1.0, direct_lighting=0.76, texture_path=ddd.DATA_DIR + "/osmmaterials/Ground033_2K-JPG/Ground033_2K_*.jpg",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Ground033_2K-JPG/Ground033_2K_Normal.jpg", # texture_displacement_path=ddd.DATA_DIR + "/osmmaterials/Ground033_2K-JPG/Ground033_2K_Displacement.jpg",) ddd.mats.rock = ddd.material(name="Rock", color='#5f5f4d', extra={'uv:scale': 0.5}, metallic_factor=0.37, roughness_factor=0.8, bump_strength=3.0, texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Rock22/Rock22_*.jpg",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/[2K]Rock22/Rock22_nrm.jpg", # texture_displacement_path=ddd.DATA_DIR + "/osmmaterials/[2K]Rock22/Rock22_disp.jpg",) ddd.mats.rock_lightbrown = ddd.material(name="Rock Orange", color='#eb8602', texture_color='#ffffff', metallic_factor=0.0, roughness_factor=1.0, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Rock029_2K-JPG/Rock029_2K_*.jpg", extra={'uv:scale': 1.0, 'tags': ['orange', 'light brown', 'red', 'rock', 'stone', 'cliff', 'desert', 'ground']}) ddd.mats.lava = ddd.material(name="Lava", color='#d15e33', texture_color='#ffffff', metallic_factor=0.5, roughness_factor=1.0, bump_strength=2.0, emissive_factor=1.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Lava003_2K-JPG/Lava003_2K_*.jpg", extra={'uv:scale': 0.5, 'tags': ['orange', 'red', 'yellow', 'rock', 'stone', 'lava', 'magma']}) ddd.mats.terrain_ground = ddd.material(name="Ground Clear", color='#a48f74', extra={'uv:scale': 0.25}, # 0.2 metallic_factor=0.0, roughness_factor=1.0, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Ground044_2K-JPG/Ground044_2K_*.jpg",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Ground044_2K-JPG/Ground044_2K_Normal.jpg", # texture_displacement_path=ddd.DATA_DIR + "/osmmaterials/Ground044_2K-JPG/Ground044_2K_Displacement.jpg", ) ddd.mats.terrain_rock = ddd.mats.rock_lightbrown ddd.mats.terrain_pebbles_sparse = ddd.material(name="Ground Pebbles Sparse", color='#e6821e', texture_color='#ffffff', extra={'uv:scale': 0.25}, # 0.2 metallic_factor=0.0, roughness_factor=1.3, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Ground039_2K-JPG/Ground039_2K_*.jpg",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Ground039_2K-JPG/Ground039_2K_Normal.jpg", # texture_displacement_path=ddd.DATA_DIR + "/osmmaterials/Ground039_2K-JPG/Ground039_2K_Displacement.jpg", ) ddd.mats.terrain_veg_dead_sparse = ddd.material(name="Ground Veg Dead Sparse", color='#8c6d2a', extra={'uv:scale': 0.25}, # 0.2 metallic_factor=0.0, roughness_factor=1.0, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Ground36/Ground36_*.jpg",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/[2K]Ground36/Ground36_nrm.jpg", # texture_displacement_path=ddd.DATA_DIR + "/osmmaterials/[2K]Ground36/Ground36_disp.jpg", ) ddd.mats.terrain_autumm = ddd.material(name="Ground Autumm", color='#a89874', extra={'uv:scale': 0.25}, # 0.2 metallic_factor=0.0, roughness_factor=1.0, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Ground23/Ground23_*.jpg",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Ground23/Ground23_nrm.jpg",) ddd.mats.terrain = ddd.mats.terrain_veg_dead_sparse.copy("Ground") ddd.mats.dirt_compact_grayish = ddd.material(name="Dirt Compact Grayish", color="#b58800", extra={'uv:scale': 1.0}, # 0.25 metallic_factor=0.0, roughness_factor=1.0, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Ground32/Ground32_*.jpg",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Ground32/Ground32_nrm.jpg",) ddd.mats.dirt_pebbles = ddd.mats.terrain_pebbles_sparse ddd.mats.dirt = ddd.mats.dirt_pebbles ddd.mats.dirt.name = "Dirt" # Name enforced as is currently used by other gools # ddd.mats.pathwalk = ddd.material(name="WayPedestrian", color='#78281e', extra={'uv:scale': 1.0 }, # 0.25 # texture_path=ddd.DATA_DIR + "/osmmaterials/Tiles26/Tiles26_col.jpg", # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Tiles26/Tiles26_nrm.jpg",) # ddd.mats.pathwalk = ddd.material(name="WayPedestrian", color='#898071', texture_color='#ffffff', # Pavement tile arcs # metallic_factor=0.10, roughness_factor=0.90, bump_strength=2.0, #direct_lighting=0.76, index_of_refraction=1.0, # texture_path=ddd.DATA_DIR + "/osmmaterials/PavingStones048_2K-JPG/PavingStones048_2K_Color.jpg", # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/PavingStones048_2K-JPG/PavingStones048_2K_Normal.jpg",) ddd.mats.pathwalk = ddd.material(name="WayPedestrian", color='#898071', texture_color='#ffffff', # Tiled square blocks pavement metallic_factor=0.10, roughness_factor=0.90, bump_strength=2.0, # direct_lighting=0.76, index_of_refraction=1.0, texture_path=ddd.DATA_DIR + "/osmmaterials/PavingStones046_2K-JPG/PavingStones046_2K_*.jpg", extra={'uv:scale': 0.25}) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/PavingStones046_2K-JPG/PavingStones046_2K_Normal.jpg", # texture_displacement_path=ddd.DATA_DIR + "/osmmaterials/PavingStones046_2K-JPG/PavingStones046_2K_Displacement.jpg", # texture_roughness_path=ddd.DATA_DIR + "/osmmaterials/PavingStones046_2K-JPG/PavingStones046_2K_Roughness.jpg",) ddd.mats.sidewalk = ddd.material(name="Sidewalk", color='#f1f1f1', texture_color='#ffffff', extra={'uv:scale': 0.25}, texture_path=ddd.DATA_DIR + "/osmmaterials/Tiles38/Tiles38_*.jpg",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Tiles38/Tiles38_nrm.jpg",) ddd.mats.pavement = ddd.material(name="Pavement", color='#e1e1e1', texture_color='#ffffff', extra={'uv:scale': 0.25}, texture_path=ddd.DATA_DIR + "/osmmaterials/Tiles38/Tiles38_*.jpg",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Tiles38/Tiles38_nrm.jpg",) ddd.mats.pitch_green = ddd.material(name="Pitch", color='#196118', extra={'uv:scale': 0.5}, # 0.2 texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete17/Concrete17_*.jpg",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete17/Concrete17_nrm.jpg",) ddd.mats.pitch_blue = ddd.material(name="Pitch Blue", color='#2a69b0', extra={'uv:scale': 0.5}, # 0.2 texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete17/Concrete17_*.jpg",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete17/Concrete17_nrm.jpg",) # Eg. cycleways ddd.mats.pitch_red = ddd.material(name="Pitch Red", color='#b34446', extra={'uv:scale': 0.5}, # 0.2 texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete17/Concrete17_*.jpg",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete17/Concrete17_nrm.jpg",) # Eg. leisure track ddd.mats.pitch = ddd.mats.pitch_green ''' self.sett = ddd.material(name="Sett", color='#7b719f') ''' # Metals ddd.mats.steel = ddd.material(name="Steel", color='#78839c', texture_color='#ffffff', metallic_factor=0.975, roughness_factor=0.1, # bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Metal19/Metal19_*.jpg", extra={'uv:scale': 0.25}) ddd.mats.bronze = ddd.material(name="Bronze", color='#f0cb11', # texture_color='#ffffff', metallic_factor=0.975, roughness_factor=0.9, # bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Metal18/Metal18_*.jpg", extra={'uv:scale': 0.25, 'tags': ['metal', 'bronze', 'rusty', 'orange', 'pbr']}) ddd.mats.metal = ddd.mats.steel # Structural / Building materials ddd.mats.bricks = ddd.material(name="Bricks", color='#efae85', texture_color='#ffffff', metallic_factor=0.0, roughness_factor=1.0, # bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Bricks07/Bricks07_*.jpg", extra={'uv:scale': 0.25, 'tags': ['bricks', 'red', 'pbr']}) ddd.mats.brick = ddd.mats.bricks ddd.mats.tiles_stones = ddd.material(name="Tiles Stones", color='#7b7d69', texture_color='#ffffff', metallic_factor=0.0, roughness_factor=1.0, # bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Tiles084_2K-JPG/Tiles084_2K_*.jpg", extra={'uv:scale': 0.25}) ddd.mats.tiles_stones_veg_sparse = ddd.material(name="Tiles Stones Veg Sparse", color='#7b8d69', texture_color='#ffffff', metallic_factor=0.0, roughness_factor=1.0, # bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Tiles083_2K-JPG/Tiles083_2K_*.jpg", extra={'uv:scale': 0.25}) ddd.mats.stones_white = ddd.material(name="Stones White", color='#9c9378', texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete23/Concrete23_*.jpg", extra={'uv:scale': 0.25}) ddd.mats.stones_black = ddd.material(name="Stones Dark", color='#484846', texture_path=ddd.DATA_DIR + "/osmmaterials/Tiles093_2K-JPG/Tiles093_2K_*.jpg", extra={'uv:scale': 0.25, 'tags': ['stones', 'tiles', 'dark', 'old', 'black', 'procedural', 'pbr']}) ddd.mats.stones = ddd.mats.stones_black ddd.mats.cement = ddd.material(name="Concrete", color='#b8b8a0', extra={'uv:scale': 0.25}, # texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete17/Concrete17_*.jpg",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete17/Concrete17_nrm.jpg",) ddd.mats.concrete_white = ddd.material(name="Concrete Whiteish", color='#b8b8b0', extra={'uv:scale': 0.25}, # texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete23/Concrete23_*.jpg",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete23/Concrete23_nrm.jpg",) ddd.mats.concrete = ddd.mats.cement ddd.mats.marble_white = ddd.material(name="Marble White", color='#c0c3c8', extra={'uv:scale': 0.25}, # metallic_factor=0.4, roughness_factor=0.05, # bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Marble012/Marble012_2K_*.jpg",) ddd.mats.marble = ddd.mats.marble_white # ddd.mats.stone = ddd.material(name="Stone", color='#484846', # Solid stone material, for waycross, beams, or similar (not to be confused with stones, in plural, though may be using the same texture) # texture_path=ddd.DATA_DIR + "/osmmaterials/Tiles093_2K-JPG/Tiles093_2K_*.jpg", # extra={'uv:scale': 1.0, 'tags': []}) ddd.mats.stone = ddd.mats.tiles_stones.copy(name="Stone") ddd.mats.plaster_paint_white = ddd.material(name="Plaster Paint White", color='#d1d2cd', texture_color='#ffffff', metallic_factor=0.05, roughness_factor=0.9, # bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/PaintedPlaster017_2K-JPG/PaintedPlaster017_2K_*.jpg", extra={'uv:scale': 0.25, 'tags': ['plaster', 'paint', 'white', 'pbr', 'building', 'wall', 'tiled']}) ddd.mats.wood = ddd.material(name="Wood", color='#d49156', texture_color='#ffffff', metallic_factor=0.0, roughness_factor=1.0, # bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Wood39/Wood39_*.jpg", extra={'uv:scale': 0.25}) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/[2K]Wood39/Wood39_nrm.jpg", # texture_displacement_path=ddd.DATA_DIR + "/osmmaterials/[2K]Wood39/Wood39_disp.jpg", # texture_roughness_path=ddd.DATA_DIR + "/osmmaterials/[2K]Wood39/Wood39_rgh.jpg",) # Painted materials ddd.mats.metal_paint_green = ddd.material("PaintGreen", color='#265e13', metallic_factor=0.6, roughness_factor=0.3, # bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Paint06/Paint06_*.jpg", extra={'uv:scale': 0.5}) ddd.mats.metal_paint_yellow = ddd.material("PaintYellow", color='#ebe015', metallic_factor=0.6, roughness_factor=0.25, # bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Paint06/Paint06_*.jpg", extra={'uv:scale': 0.5}) ddd.mats.metal_paint_red = ddd.material("PaintRed", color='#d01010', metallic_factor=0.6, roughness_factor=0.25, # bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Paint06/Paint06_*.jpg", extra={'uv:scale': 0.5}) ddd.mats.metal_paint_blue = ddd.material("PaintBlue", color='#184794', metallic_factor=0.6, roughness_factor=0.25, # bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Paint04/Paint04_*.jpg", extra={'uv:scale': 0.5}) ''' self.metal_paint_white = ddd.material("PaintWhite", color='#f8fbff') self.metal_paint_black = ddd.material("PaintBlack", color='#000a17') ''' # Lights ddd.mats.lightbulb = ddd.material("LightLampOff", color='e8e0e4', metallic_factor=0.05, roughness_factor=0.90) #self.light_green = ddd.material(color='#00ff00') #self.light_orange = ddd.material(color='#ffff00') #self.light_red = ddd.material(color='#ff0000') # Plastics #self.plastic_transparent = ddd.material(color='e8e0e4', extra={'ddd:transparent': True}) # name="PlasticTransparent", #self.plastic_black = ddd.material(color='#2c2936') ddd.mats.plastic_green = ddd.material("Plastic Green", color='#64a80a', metallic_factor=0.0, roughness_factor=0.05, texture_path=ddd.DATA_DIR + "/osmmaterials/Plastic010_2K-JPG/Plastic010_2K_*.jpg", extra={'uv:scale': 0.5, 'tags': ['plastic', 'pbr', 'smooth', 'green', 'clean', 'coloured']}) ddd.mats.plastic_green_rough = ddd.material("Plastic Green Rough", color='#64a80a', metallic_factor=0.0, roughness_factor=0.05, texture_path=ddd.DATA_DIR + "/osmmaterials/Plastic004_2K-JPG/Plastic004_2K_*.jpg", extra={'uv:scale': 0.5, 'tags': ['plastic', 'pbr', 'rough', 'green', 'coloured']}) # Glass ddd.mats.glass = ddd.material("Glass", color='#2e4163', # color='#b3b7c0', # extra={'ddd:transparent': True} metallic_factor=0.0, roughness_factor=0.0) # , # index_of_refraction=1.36,)# # Vegetation (trees, hedges) ddd.mats.bark = ddd.material(name="Bark", color='#df9e75', extra={'uv:scale': 1.0}, metallic_factor=0.0, roughness_factor=1.0, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Bark06/Bark06_*.jpg",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/[2K]Bark06/Bark06_nrm.jpg",) ddd.mats.treetop = ddd.material(name="Treetop", color='#1da345', extra={'uv:scale': 0.25}, metallic_factor=0.0, roughness_factor=1.0, bump_strength=2.0, # index_of_refraction=1.36, texture_path=ddd.DATA_DIR + "/osmmaterials/Grass01/Grass_01_2K_*.png",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Grass01/Grass_01_2K_Normal.png",) ddd.mats.hedge = ddd.material(name="Hedge", color='#1d9335', extra={'uv:scale': 1.0}, # 0.25 metallic_factor=0.35, roughness_factor=0.85, index_of_refraction=1.36, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Grass01/Grass_01_2K_*.png",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Grass01/Grass_01_2K_Normal.png",) # Grass and flowers blades ddd.mats.flowers_blue_blade = ddd.material(name="Flowers Blue", color='#51b8da', metallic_factor=0.0, roughness_factor=0.90, # index_of_refraction=1.36, texture_path=ddd.DATA_DIR + "/osmmaterials/Grass/flowers_blue.png", double_sided=True, alpha_mode='MASK', # alpha_cutoff=0.1, extra={'ddd:collider': False}) ddd.mats.flowers_roses_blade = ddd.material(name="Flowers Roses", color='#e96969', metallic_factor=0.0, roughness_factor=0.95, # index_of_refraction=1.36, texture_path=ddd.DATA_DIR + "/osmmaterials/Grass/flowers_roses.png", double_sided=True, alpha_mode='MASK', # alpha_cutoff=0.1, extra={'ddd:collider': False}) ddd.mats.grass_blade = ddd.material(name="Grass Blade", color='#2de355', metallic_factor=0.0, roughness_factor=1.00, # index_of_refraction=1.36, texture_path=ddd.DATA_DIR + "/osmmaterials/Grass/grass_billboard.png", double_sided=True, alpha_mode='MASK', # alpha_cutoff=0.1, extra={'ddd:collider': False}) ddd.mats.grass_blade_dry = ddd.material(name="Grass Blade Dry", color='#956542', metallic_factor=0.0, roughness_factor=1.00, # index_of_refraction=1.36, texture_path=ddd.DATA_DIR + "/osmmaterials/Grass/grass_billboard2.png", double_sided=True, alpha_mode='MASK', # alpha_cutoff=0.1, extra={'ddd:collider': False}) # Urban props materials ddd.mats.fence = ddd.material(name="Fence", color='282024', extra={'uv:scale': 0.5, 'ddd:transparent': True}, texture_color='#ffffff', texture_path=ddd.DATA_DIR + "/osmmaterials/MetalWalkway002_2K-JPG/MetalWalkway002_2K_*.png", # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/MetalWalkway002_2K-JPG/MetalWalkway002_2K_Normal.jpg", alpha_cutoff=0.5) ddd.mats.railing = ddd.mats.fence ddd.mats.metallic_grid = ddd.material(name="MetallicGrid", color='#28281e', extra={'ddd:transparent': True}) # Floors ''' self.cable_metal = ddd.material(name="CableMetal", color='#28282e') self.chain = ddd.material(name="CableMetal", color='#28282e') self.rope = ddd.material(name="Rope", color='#c7b01c') # Buildings ''' ddd.mats.building_1 = ddd.mats.stones_white # ddd.material("Building Stone Tiles White", color='#f7f0be', ddd.mats.building_2 = ddd.mats.tiles_stones # ddd.material(color='#bdb9a0') ddd.mats.building_3 = ddd.mats.cement # ddd.material(color='#c49156') ddd.mats.building_4 = ddd.mats.bricks ddd.mats.building_5 = ddd.mats.plaster_paint_white ddd.mats.roof_tiles_round = ddd.material("RoofTilesRound", color='f25129', extra={'uv:scale': 0.25}, # 0.25 # color='#f19f70', metallic_factor=0.0, roughness_factor=0.7, index_of_refraction=1.08, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]RoofingTiles05/RoofingTiles05_*.jpg",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/[2K]RoofingTiles05/RoofingTiles05_nrm.jpg",) ddd.mats.roof_tiles = ddd.material("RoofTiles", color='f25129', extra={'uv:scale': 1 / 3}, # 0.25 # color='#f19f70', metallic_factor=0.0, roughness_factor=0.7, index_of_refraction=1.08, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/RoofingTiles007_2K-JPG/RoofingTiles007_2K_*.jpg",) # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/RoofingTiles007_2K-JPG/RoofingTiles007_2K_Normal.jpg", # texture_displacement_path=ddd.DATA_DIR + "/osmmaterials/RoofingTiles007_2K-JPG/RoofingTiles007_2K_Displacement.jpg", # texture_roughness_path=ddd.DATA_DIR + "/osmmaterials/RoofingTiles007_2K-JPG/RoofingTiles007_2K_Roughness.jpg",) '''
import math import random import webbrowser row = ddd.group2() for i in range(3, 12 + 1): area = ddd.regularpolygon(i, 1.0, name="%d-Polygon" % i) area.extra['sides'] = i area.extra['text'] = "Sample text to test SVG metadata export (áéíóúñç)" row.append(area) row = ddd.align.grid(row, 2.5, 1) row = row.rotate(math.pi / 2) items = ddd.group2() top_row = row items.append(top_row) mat_red = ddd.material(color="#ff0000", extra={'svg:fill-opacity': 1.0}) row_r = row.material(mat_red) row_g = row.material(ddd.mats.green).translate([-0.2, -0.2]) row_b = row.material(ddd.mats.blue).translate([0.2, -0.2]) colors = ddd.group2([row_r, row_g, row_b], name="Mixed colors") items.append(colors) items = ddd.align.grid(items, 2.5, 1) items.save('/tmp/test.svg') webbrowser.open("file:///tmp/test.svg") #items.show()
def generate_area_3d_gen(self, area_2d): if area_2d.geom is not None and area_2d.geom.type != "LineString" and area_2d.geom.type: if area_2d.geom.type in ('GeometryCollection', 'MultiPolygon'): logger.debug( "Generating area 3d as separate areas as it is a GeometryCollection: %s", area_2d) # FIXME: We might do this in extrude_step, like we do in triangulate and extrude, but difficult as it is in steps. # But also, we should have an individualize that work, correct iterators, and a generic cleanup/flatten method # to flatten areas, which might solve this. areas_3d = [] for a in area_2d.individualize().clean_replace().children: areas_3d.append(self.generate_area_3d(a)) return ddd.group3(areas_3d, extra=area_2d.extra) if area_2d.extra.get('ddd:area:type', None) == 'park': area_3d = area_2d.extrude_step( area_2d.buffer(-1.0), 0.1, base=False, method=ddd.EXTRUSION_METHOD_SUBTRACT) area_3d = area_3d.extrude_step( area_2d.buffer(-3.0), 0.1, method=ddd.EXTRUSION_METHOD_SUBTRACT) # Grass # TODO: Add in a separate (optional) pass if False: # For volumetric grass, as described by: https://www.bruteforce-games.com/post/grass-shader-devblog-04 grass_layers = [] colors = [ '#000000', '#222222', '#444444', '#666666', '#888888', '#aaaaaa', '#cccccc', '#eeeeee' ] for i in range(8): grass_layer = area_3d.copy(name="Grass %d: %s" % (i, area_3d.name)) grass_layer = grass_layer.material( ddd.material(name="VolumetricGrass", color=colors[i], extra={'ddd:export-as-marker': True})) #grass_layer.extra['ddd:vertex_colors'] = grass_layer = grass_layer.translate([0, 0, 0.05 * i]) #grass_layer = terrain.terrain_geotiff_elevation_apply(grass_layer, self.osm.ddd_proj) grass_layer.extra['ddd:shadows'] = False grass_layer.extra['ddd:collider'] = False grass_layer.extra['ddd:occluder'] = False grass_layers.append(grass_layer) #self.osm.other_3d.append(grass_layers) #ddd.group3([area_3d, grass_layers]) area_3d.children.extend(grass_layers) #area_3d = ddd.group([area_2d.triangulate().translate([0, 0, 0.0]), # area_2d.buffer(-1.0).triangulate().translate([0, 0, 0.2]), # area_2d.buffer(-3.0).triangulate().translate([0, 0, 0.3])]) #area_3d = area_3d.translate([0, 0, 0]) ''' elif area_2d.extra.get('ddd:area:type', None) == 'steps': area_3d = area_2d.extrude_step(area_2d, area_2d.extra['ddd:steps:height'], base=False) for stepidx in range(1, area_2d.extra['ddd:steps:count'] + 1): area_3d = area_3d.extrude_step(area_2d.buffer(-area_2d.extra['ddd:steps:depth'] * stepidx), 0, method=ddd.EXTRUSION_METHOD_SUBTRACT) area_3d = area_3d.extrude_step(area_2d.buffer(-area_2d.extra['ddd:steps:depth'] * stepidx), area_2d.extra['ddd:steps:height'], method=ddd.EXTRUSION_METHOD_SUBTRACT) # TODO: Crop in 3D (or as a workaround fake it as centroid cropping) ''' elif area_2d.extra.get('ddd:area:type', None) == 'sidewalk': area_3d = None try: height = area_2d.extra.get('ddd:height', 0.2) #area_3d = area_2d.extrude(-0.5 - height).translate([0, 0, height]) #area_3d = ddd.uv.map_cubic(area_3d) if True: try: interior = area_2d.get('ddd:crop:original').buffer( -0.3).intersection(self.osm.area_crop2) if not interior.is_empty(): # TODO: Remove bases in a more generic way, without breaking meshes or UV mapping area_3d = interior.extrude(-0.5 - height).translate( [0, 0, height]) if area_3d.get('ddd:layer', '0') == '0': area_3d = ddd.meshops.remove_faces_pointing( area_3d, ddd.VECTOR_DOWN ) # TODO: Remove bases in generic way? area_3d = ddd.uv.map_cubic(area_3d) kerb_3d = area_2d.get( 'ddd:crop:original').subtract( interior).intersection( self.osm.area_crop2).extrude( -0.5 - height).translate( [0, 0, height]) if kerb_3d.get('ddd:layer', '0') == '0': kerb_3d = ddd.meshops.remove_faces_pointing( kerb_3d, ddd.VECTOR_DOWN ) # TODO: Remove bases in generic way? kerb_3d = ddd.uv.map_cubic(kerb_3d).material( ddd.mats.cement) #if area_3d.mesh: # area_3d = terrain.terrain_geotiff_elevation_apply(area_3d, self.osm.ddd_proj) # kerb_3d = terrain.terrain_geotiff_elevation_apply(kerb_3d, self.osm.ddd_proj).material(ddd.mats.cement) #area_3d.append(kerb_3d) #kerb_3d = terrain.terrain_geotiff_elevation_apply(kerb_3d, self.osm.ddd_proj) area_3d.append(kerb_3d) else: logger.info( "Cannot create kerb (empty interior) for area: %s", area_2d) area_3d = None except Exception as e: logger.info("Error creating kerb for area %s: %s", area_2d, e) area_3d = None # If no kerb or kerb could not be generated, just generate the area: if area_3d is None: area_3d = area_2d.extrude(-0.5 - height).translate( [0, 0, height]) # Remove base if area_3d.get('ddd:layer', '0') == '0': area_3d = ddd.meshops.remove_faces_pointing( area_3d, ddd.VECTOR_DOWN) area_3d = ddd.uv.map_cubic(area_3d) except Exception as e: logger.error("Could not generate area: %s (%s)", e, area_2d) area_3d = DDDObject3() else: try: height = area_2d.extra.get('ddd:height', 0.2) if height: area_3d = area_2d.extrude(-0.5 - height).translate( [0, 0, height]) # Remove base if area_3d.get('ddd:layer', '0') == '0': area_3d = ddd.meshops.remove_faces_pointing( area_3d, ddd.VECTOR_DOWN) else: area_3d = area_2d.triangulate() area_3d = ddd.uv.map_cubic(area_3d) except Exception as e: logger.error("Could not generate area: %s (%s)", e, area_2d) area_3d = DDDObject3() else: if len(area_2d.children) == 0: logger.warning("Null area geometry (children?): %s", area_2d) area_3d = DDDObject3() # Test (doesn't work, subdividing causes bad behavior in large trams): area_3d = area_3d.subdivide_to_size(20.0) area_3d = ddd.uv.map_cubic(area_3d) # Apply elevation area_3d = self.generate_area_3d_apply_elevation(area_2d, area_3d) area_3d.extra = dict(area_2d.extra) area_3d.children.extend( [self.generate_area_3d(c) for c in area_2d.children]) return area_3d
def generate_building_3d_amenities(self, building_3d): """ """ ''' if 'ddd:building:items' not in building_3d.extra: # FIXME: This is happening as building parents with children don't contain items information themselves atm logger.warn("Building with no linked items (ddd:building:items): %s", building_3d) return ''' # Find children amenities, but link them to the whole building (so no interiors are used) # TODO: This shall be resolved earlier, in order to assign facade segments to amenities, shops. portals, windows... for bp in building_3d.select('["ddd:building:items"]', recurse=False).children: for item_1d in bp.extra['ddd:building:items']: if item_1d.extra.get('osm:amenity', None) == 'pharmacy': # Side sign item = urban.sign_pharmacy_side(size=1.0) item.copy_from(item_1d, copy_metadata_to_children=True) ''' # Plain sign (front view on facade) item = urban.sign_pharmacy(size=1.2) item = item.translate([0, -0.25, 2.0]) # no post ''' item.extra['ddd:item'] = item_1d item = self.snap_to_building(item, building_3d) if item: item = item.translate([0, 0, 3.0]) # no post #item = terrain.terrain_geotiff_min_elevation_apply(item, self.osm.ddd_proj) building_3d.children.append(item) elif item_1d.extra.get('osm:amenity', None) and item_1d.extra.get('osm:amenity', None) not in ('fountain', 'taxi', 'post_box', 'bench', 'toilets', 'parking_entrance'): # Except parking? #coords = amenity.geom.centroid.coords[0] #panel_text = amenity.extra['amenity'] if amenity.extra['amenity'] else None panel_text = item_1d.extra['osm:name'] if item_1d.extra.get('osm:name', None) else (item_1d.extra['osm:amenity'].upper() if item_1d.extra['osm:amenity'] else None) item = urban.panel(width=3.2, height=0.9, text=panel_text) item.copy_from(item_1d, copy_metadata_to_children=True) item.extra['ddd:item'] = item_1d item.name = "Panel: %s %s" % (item_1d.extra['osm:amenity'], item_1d.extra.get('osm:name', None)) item = self.snap_to_building(item, building_3d) if item: item = item.translate([0, 0, 3.2]) # no post color = random.choice(["#d41b8d", "#a7d42a", "#e2de9f", "#9f80e2"]) item.children[0] = item.children[0].material(ddd.material(color=color), include_children=False) #item = terrain.terrain_geotiff_min_elevation_apply(item, self.osm.ddd_proj) building_3d.children.append(item) else: logger.info("Could not snap item to building (skipping item): %s", item_1d) #building_3d.show() elif item_1d.extra.get('osm:shop', None): #coords = item_1d.geom.centroid.coords[0] panel_text = (item_1d.extra['osm:name'] if item_1d.extra.get('osm:name', None) else item_1d.extra['osm:shop']) item = urban.panel(width=2.5, height=0.8, text=panel_text) item.copy_from(item_1d, copy_metadata_to_children=True) item.extra['ddd:item'] = item_1d item.name = "Shop Panel: %s %s" % (item_1d.extra['osm:shop'], item_1d.extra.get('osm:name', None)) item = self.snap_to_building(item, building_3d) if item: item = item.translate([0, 0, 3.1]) # no post color = random.choice(["#c41a7d", "#97c41a", "#f2ee0f", "#0f90f2"]) item.children[0] = item.children[0].material(ddd.material(color=color), include_children=False) #item = terrain.terrain_geotiff_min_elevation_apply(item, self.osm.ddd_proj) building_3d.children.append(item) else: logger.info("Could not snap item to building (skipping item): %s", item) else: logger.debug("Unknown building-related item: %s", item_1d)
def osm_materials(): # Materials used by this pipeline ddd.mats.railway = ddd.material( name="RoadRailway", color="#47443e", metallic_factor=1.0, roughness_factor=0.43, index_of_refraction=1.0, direct_lighting=0.76, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/RoadRailway/TexturesCom_Road_Railway_512_albedo.png", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/RoadRailway/TexturesCom_Road_Railway_512_normal.png", #alpha_cutoff=0.05, extra={}) ddd.mats.roadline = ddd.material( name="Roadline", color='#e8e8e8', texture_path=ddd.DATA_DIR + "/materials/road_signs/RoadLines_alb.png", texture_normal_path=ddd.DATA_DIR + "/materials/road_signs/RoadLines_normal.jpg", alpha_cutoff=0.05, extra={ 'ddd:collider': False, 'ddd:shadows': False, 'uv:scale': 0.05, 'zoffset': -8.5 }) ddd.mats.roadline_red = ddd.material( name="Roadline Red", color='#f8a8a8', texture_path=ddd.DATA_DIR + "/materials/road_signs/RoadLines_alb.png", texture_normal_path=ddd.DATA_DIR + "/materials/road_signs/RoadLines_normal.jpg", alpha_cutoff=0.05, extra={ 'ddd:collider': False, 'ddd:shadows': False, 'uv:scale': 0.05, 'zoffset': -8.5 }) ddd.mats.roadmarks = ddd.material( name="Roadmarks", color='#e8e8e8', texture_path=ddd.DATA_DIR + "/osmmaterials/RoadMarks/TexturesCom_Atlas_RoadMarkings2_White_1K_albedo_with_alpha.png", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/RoadMarks/TexturesCom_Atlas_RoadMarkings2_1K_normal.png", alpha_cutoff=0.05, extra={ 'ddd:collider': False, 'ddd:shadows': False, 'uv:scale': 1.00, 'zoffset': -8.5 }) 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") ddd.mats.asphalt = ddd.material( name="Asphalt", color='#202020', extra={'uv:scale': 1.0}, # 0.25 color='#202020', metallic_factor=0.0, roughness_factor=0.43, index_of_refraction=1.0, direct_lighting=0.76, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Asphalt/Asphalt01_col.jpg", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Asphalt/Asphalt01_nrm.jpg", ) #ddd.mats.pathwalk = ddd.material(name="WayPedestrian", color='#78281e', extra={'uv:scale': 1.0 }, # 0.25 # texture_path=ddd.DATA_DIR + "/osmmaterials/Tiles26/Tiles26_col.jpg", # texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Tiles26/Tiles26_nrm.jpg",) #ddd.mats.paving_stones_arc = ddd.mats.pathwalk = ddd.material( name="WayPedestrian", color='#898071', texture_color='#ffffff', metallic_factor=0.10, roughness_factor=0.90, bump_strength=2.0, #direct_lighting=0.76, index_of_refraction=1.0, texture_path=ddd.DATA_DIR + "/osmmaterials/PavingStones048_2K-JPG/PavingStones048_2K_Color.jpg", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/PavingStones048_2K-JPG/PavingStones048_2K_Normal.jpg", ) ''' # Areas self.sea = ddd.material(name="Water4Advanced", color='#3d43b5', extra={'ddd:collider': False, 'ddd:shadows': False, 'ddd:transparent': True}) self.water = ddd.material(name="WaterBasicDaytime", color='#4d53c5', extra={'ddd:collider': False, 'ddd:shadows': False, 'ddd:transparent': True}) self.volumetricgrass = ddd.material(name="VolumetricGrass", color='#2dd355', extra={'ddd:export-as-marker': True}) # Warning: duplicated in areas_3d volumetic grass generation ''' ddd.mats.dirt = ddd.material( name="Dirt", color="#b58800", extra={'uv:scale': 1.0}, # 0.25 metallic_factor=0.0, roughness_factor=1.0, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Ground32/Ground32_col.jpg", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Ground32/Ground32_nrm.jpg", ) ddd.mats.grass = ddd.material( name="Grass", color='#2dd355', extra={'uv:scale': 1.0}, # 0.25 metallic_factor=0.35, roughness_factor=0.85, index_of_refraction=1.36, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Grass01/Grass_01_2K_Base_Color.png", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Grass01/Grass_01_2K_Normal.png", ) ddd.mats.park = ddd.material( name="Park", color='#1db345', extra={'uv:scale': 1.0}, # 0.25 metallic_factor=0.3, roughness_factor=0.85, index_of_refraction=1.36, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Ground03/Ground03_col.jpg", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Ground03/Ground03_nrm.jpg", ) ddd.mats.forest = ddd.material( name="Forest", color='#3a6e17', extra={'uv:scale': 1.0}, # 0.25 metallic_factor=0.0, roughness_factor=1.0, bump_strength=2.0, #index_of_refraction=1.36, texture_path=ddd.DATA_DIR + "/osmmaterials/Ground03/Ground03_col.jpg", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Ground03/Ground03_nrm.jpg", ) ddd.mats.garden = ddd.material( name="Garden", color='#2f614b', extra={'uv:scale': 1.0}, # 0.25 metallic_factor=0.0, roughness_factor=0.85, index_of_refraction=1.36, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Grass01/Grass_01_2K_Base_Color.png", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Grass01/Grass_01_2K_Normal.png", ) ddd.mats.wetland = ddd.material( name="Wetland", color='#54610c', extra={'uv:scale': 1.0}, # 0.25 metallic_factor=0.4, roughness_factor=0.45, index_of_refraction=1.36, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Ground03/Ground03_col.jpg", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Ground03/Ground03_nrm.jpg", ) ddd.mats.terrain = ddd.material( name="Ground", color='#e6821e', extra={'uv:scale': 1.0}, # 0.2 metallic_factor=0.0, roughness_factor=1.0, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Ground23/Ground23_col.jpg", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Ground23/Ground23_nrm.jpg", ) ddd.mats.sidewalk = ddd.material( name="Sidewalk", color='#f1f1f1', extra={'uv:scale': 1.0}, # 0.2 texture_path=ddd.DATA_DIR + "/osmmaterials/Tiles38/Tiles38_col.jpg", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Tiles38/Tiles38_nrm.jpg", ) ddd.mats.pavement = ddd.material( name="Pavement", color='#e1e1e1', extra={'uv:scale': 1.0}, # 0.2 texture_path=ddd.DATA_DIR + "/osmmaterials/Tiles38/Tiles38_col.jpg", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Tiles38/Tiles38_nrm.jpg", ) ddd.mats.pitch_green = ddd.material( name="Pitch", color='#196118', extra={'uv:scale': 1.0}, # 0.2 texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete17/Concrete17_col.jpg", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete17/Concrete17_nrm.jpg", ) ddd.mats.pitch_blue = ddd.material( name="Pitch Blue", color='#2a69b0', extra={'uv:scale': 1.0}, # 0.2 texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete17/Concrete17_col.jpg", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete17/Concrete17_nrm.jpg", ) # Eg. cycleways ddd.mats.pitch_red = ddd.material( name="Pitch Red", color='#b34446', extra={'uv:scale': 1.0}, # 0.2 texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete17/Concrete17_col.jpg", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete17/Concrete17_nrm.jpg", ) # Eg. leisure track ddd.mats.pitch = ddd.mats.pitch_green ddd.mats.sand = ddd.material( name="Sand", color='#fff694', metallic_factor=0.0, roughness_factor=0.45, bump_strength=2.0, index_of_refraction=1.0, direct_lighting=0.76, texture_path=ddd.DATA_DIR + "/osmmaterials/Ground033_2K-JPG/Ground033_2K_Color.jpg", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Ground033_2K-JPG/Ground033_2K_Normal.jpg", ) ''' self.rock = ddd.material(name="Rock", color='#5f5f4d') self.sett = ddd.material(name="Sett", color='#7b719f') # Structural / building materials self.bronze = ddd.material(name="Bronze", color='#f0cb11') self.steel = ddd.material(name="Steel", color='#78839c') self.metal = ddd.material(name="Steel", color='#68738c') ''' ddd.mats.cement = ddd.material( name="Concrete", color='#b8b8a0', extra={'uv:scale': 1.0}, # texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete17/Concrete17_col.jpg", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete17/Concrete17_nrm.jpg", ) ddd.mats.concrete_white = ddd.material( name="Concrete Whiteish", color='#b8b8b0', extra={'uv:scale': 1.0}, # texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete23/Concrete23_col.jpg", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete23/Concrete23_nrm.jpg", ) ddd.mats.stone_white = ddd.material( name="Stone", color='#9c9378', texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete23/Concrete23_col.jpg", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/[2K]Concrete23/Concrete23_nrm.jpg", ) ddd.mats.stone = ddd.mats.stone_white ''' self.bricks = ddd.material(name="Bricks", color='#d49156') self.wood = ddd.material(name="Wood", color='#efae85') # Painted materials self.metal_paint_red = ddd.material("PaintRed", color='#d01010') self.metal_paint_green = ddd.material("PaintGreen", color='#265e13') self.metal_paint_yellow = ddd.material("PaintYellow", color='#ebe015') self.metal_paint_blue = ddd.material("PaintBlue", color='#184794') self.metal_paint_white = ddd.material("PaintWhite", color='#f8fbff') self.metal_paint_black = ddd.material("PaintBlack", color='#000a17') # Plastics self.plastic_transparent = ddd.material(color='e8e0e4', extra={'ddd:transparent': True}) # name="PlasticTransparent", self.plastic_black = ddd.material(color='#2c2936') # Glass self.glass = ddd.material("Glass", color='#baf3f5') # , extra={'ddd:transparent': True} # Lights self.lightbulb = ddd.material("LightLampOff", color='e8e0e4') self.light_green = ddd.material(color='#00ff00') self.light_orange = ddd.material(color='#ffff00') self.light_red = ddd.material(color='#ff0000') ''' # Vegetation (trees, hedges) ddd.mats.bark = ddd.material( name="Bark", color='#df9e75', extra={'uv:scale': 1.0}, # 0.25 metallic_factor=0.0, roughness_factor=1.0, bump_strength=2.0, # index_of_refraction=1.36, texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]Bark06/Bark06_col.jpg", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/[2K]Bark06/Bark06_nrm.jpg", ) ddd.mats.treetop = ddd.material( name="Treetop", color='#1da345', extra={'uv:scale': 1.0}, # 0.25 metallic_factor=0.0, roughness_factor=1.0, bump_strength=2.0, # index_of_refraction=1.36, texture_path=ddd.DATA_DIR + "/osmmaterials/Grass01/Grass_01_2K_Base_Color.png", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Grass01/Grass_01_2K_Normal.png", ) ddd.mats.hedge = ddd.material( name="Hedge", color='#1d9335', extra={'uv:scale': 1.0}, # 0.25 metallic_factor=0.35, roughness_factor=0.85, index_of_refraction=1.36, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/Grass01/Grass_01_2K_Base_Color.png", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/Grass01/Grass_01_2K_Normal.png", ) # Grass and flowers blades ddd.mats.flowers_blue_blade = ddd.material( name="Flowers Blue", color='#51b8da', metallic_factor=0.0, roughness_factor=0.90, # index_of_refraction=1.36, texture_path=ddd.DATA_DIR + "/osmmaterials/Grass/flowers_blue.png", double_sided=True, alpha_mode='BLEND', alpha_cutoff=0.1, extra={'ddd:collider': False}) ddd.mats.flowers_roses_blade = ddd.material( name="Flowers Roses", color='#e96969', metallic_factor=0.0, roughness_factor=0.95, #index_of_refraction=1.36, texture_path=ddd.DATA_DIR + "/osmmaterials/Grass/flowers_roses.png", double_sided=True, alpha_mode='BLEND', alpha_cutoff=0.1, extra={'ddd:collider': False}) ddd.mats.grass_blade = ddd.material( name="Grass Blade", color='#2de355', metallic_factor=0.0, roughness_factor=0.95, index_of_refraction=1.36, texture_path=ddd.DATA_DIR + "/osmmaterials/Grass/grass_billboard.png", double_sided=True, alpha_mode='BLEND', alpha_cutoff=0.1, extra={'ddd:collider': False}) # Urban props materials ddd.mats.fence = ddd.material( name="Fence", color='282024', extra={'ddd:transparent': True}, texture_color='#ffffff', texture_path=ddd.DATA_DIR + "/osmmaterials/MetalWalkway002_2K-JPG/MetalWalkway002_2K_ColorAlpha.png", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/MetalWalkway002_2K-JPG/MetalWalkway002_2K_Normal.jpg", alpha_cutoff=0.05) ddd.mats.railing = ddd.mats.fence ddd.mats.metallic_grid = ddd.material(name="MetallicGrid", color='#28281e', extra={'ddd:transparent': True}) # Floors ''' self.cable_metal = ddd.material(name="CableMetal", color='#28282e') self.chain = ddd.material(name="CableMetal", color='#28282e') self.rope = ddd.material(name="Rope", color='#c7b01c') # Buildings self.building_1 = ddd.material(color='#f7f0be') self.building_2 = ddd.material(color='#bdb9a0') self.building_3 = ddd.material(color='#c49156') ''' ddd.mats.roof_tiles = ddd.material( "RoofTiles", color='f25129', extra={'uv:scale': 1.0}, # 0.25 # color='#f19f70', metallic_factor=0.0, roughness_factor=0.7, index_of_refraction=1.08, bump_strength=2.0, texture_path=ddd.DATA_DIR + "/osmmaterials/[2K]RoofingTiles05/RoofingTiles05_col.jpg", texture_normal_path=ddd.DATA_DIR + "/osmmaterials/[2K]RoofingTiles05/RoofingTiles05_nrm.jpg", ) '''