Example #1
0
def pipeline_start(pipeline, root):
    """
    """

    items = ddd.group3()

    heights = (3.0, 5.0, 10.0, 15.0)

    for h in heights:
        item = plants.reed(height=h)
        items.append(item)

    for h in heights:
        item = plants.tree_default(height=h)
        items.append(item)

    for h in heights:
        item = plants.tree_palm(height=h)
        items.append(item)

    for h in heights:
        item = plants.tree_fir(height=h)
        items.append(item)

    items_org = items.copy()

    # Original
    items = items_org.copy()
    items = ddd.align.grid(items)
    items.append(ddd.helper.all())
    items.show()

    # Simplify using convex hull
    items = ddd.meshops.reduce(items_org)
    items = ddd.align.grid(items)
    items.append(ddd.helper.all())
    items.show()

    # Simplify using bounds
    items = ddd.meshops.reduce_bounds(items_org)
    items = ddd.align.grid(items)
    items.append(ddd.helper.all())
    items.show()

    # Simplify using quadric decimation
    items = ddd.meshops.reduce_quadric_decimation(items_org, target_ratio=0.25)
    items = ddd.align.grid(items)
    items.append(ddd.helper.all())
    items.show()

    root.append(items)
Example #2
0
    def generate_item_3d_tree(self, item_2d):

        coords = item_2d.geom.coords[0]

        #invalid = ddd.group([self.osm.ways_2d["0"], self.osm.buildings_2d])
        #if not self.osm.osmops.placement_valid(ddd.disc(coords, r=0.4), invalid=invalid):
        #    return None

        numvariants = 5  # 7
        '''
        tree_type = item_2d.extra.get('osm:tree:type')
        if tree_type is None:
            tree_type = random.choice(['default', 'palm'])
        '''

        tree_type = item_2d.get('osm:tree:type')
        if isinstance(tree_type, dict):
            tree_type = weighted_choice(tree_type)

        key = "tree-%s-%d" % (
            tree_type, random.choice([x + 1 for x in range(numvariants)]))

        item_3d = self.osm.catalog.instance(key)
        if not item_3d:
            plant_height = random.normalvariate(8.0, 3.0)
            if plant_height < 4.0: plant_height = random.uniform(4.0, 6.5)
            if plant_height > 35.0: plant_height = random.uniform(30.0, 35.0)

            if tree_type == 'default':
                plant_height += 3
                item_3d = plants.tree_default(height=plant_height)
            elif tree_type == 'palm':
                plant_height += 6
                item_3d = plants.tree_palm(height=plant_height)
            elif tree_type == 'fir':
                item_3d = plants.tree_fir(height=plant_height)
            elif tree_type == 'bush':
                item_3d = plants.tree_bush(height=plant_height)
            elif tree_type == 'reed':
                item_3d = plants.reed()
            else:
                raise DDDException("Unknown tree type %r for object %s" %
                                   (tree_type, item_2d))

            item_3d = self.osm.catalog.add(key, item_3d)

        item_3d = item_3d.rotate([0.0, 0.0, random.uniform(0, math.pi * 2)])
        item_3d = item_3d.translate([coords[0], coords[1], 0.0])
        item_3d.name = 'Tree: %s' % item_2d.name
        return item_3d
Example #3
0
def pipeline_start(pipeline, root):

    items = ddd.group3()

    heights = (3.0, 5.0, 10.0, 15.0)

    for h in heights:
        item = landscape.rock([h * 0.2, h * 0.2, h * 0.1])
        items.append(item)

    for h in heights:
        item = plants.reed(height=h)
        items.append(item)

    for h in heights:
        item = plants.tree_default(height=h)
        items.append(item)

    for h in heights:
        item = plants.tree_palm(height=h)
        items.append(item)

    for h in heights:
        item = plants.tree_fir(height=h)
        items.append(item)

    for h in heights:
        item = plants.tree_bush(height=h * 0.2)
        items.append(item)

    items = ddd.align.grid(items, width=4)
    items.append(ddd.helper.all(size=40.0, center=[5, 5, 0]).twosided())

    #items.save("/tmp/test.glb")
    #items.save("/tmp/test.json")
    pipeline.root = items

    pipeline.root.show()
Example #4
0
# Jose Juan Montes 2019-2020

from ddd.pack.sketchy import urban, landscape, industrial, plants
from ddd.ddd import ddd
import math

items = ddd.group3()

heights = (3.0, 5.0, 10.0, 15.0)

for h in heights:
    item = plants.reed(height=h)
    items.append(item)

for h in heights:
    item = plants.tree_default(height=h)
    items.append(item)

for h in heights:
    item = plants.tree_palm(height=h)
    items.append(item)

for h in heights:
    item = plants.tree_fir(height=h)
    items.append(item)

items = ddd.align.grid(items)
items.append(ddd.helper.all())
items.show()

items.save("/tmp/test.glb")