def main(): args = parse_args() origin = (0, 0, 0) # color for the core (land): green = (130, 253, 194) # color for the air: light_blue = (130, 194, 253) with WDB(args.db_file, "Globe Database") as globe_db: globe_db.sphere("land.s", center=origin, radius=args.initial_size) # the core is a region (is_region=True) and it has the shader set: globe_db.combination( "land.r", tree="land.s", is_region=True, rgb_color=green, shader="plastic {di .8 sp .2}", ) # each layer is formed by subtracting the former sphere from the current sphere # the core land is the first "former sphere": prev_solid = "land.s" counter = 0 current_size = args.initial_size + args.step_size # this will collect the air layers: air_list = [] while current_size < args.final_size: crt_solid = "air.{}.s".format(counter) crt_comb = "air.{}.c".format(counter) crt_air = "air.{}.r".format(counter) globe_db.sphere(crt_solid, center=origin, radius=current_size) globe_db.combination(crt_comb, tree=subtract(crt_solid, prev_solid)) # Each layer is a region with it's own transparency setting: globe_db.combination(crt_air, tree=crt_comb, is_region=True, shader="plastic {{tr {}}}".format( current_size / args.final_size), rgb_color=light_blue, air_code=counter, region_id=counter) air_list.append(crt_air) prev_solid = crt_solid current_size += args.step_size counter += 1 # the air layers are grouped here in a combination, # not in a region as they are already regions on their own: globe_db.combination( "air.g", tree=union(air_list), ) # the final group of core land + air layers (no region, the leafs are already regions): globe_db.combination( "globe.g", tree=union("land.r", "air.g"), )
def main(argv): with wdb.WDB(argv[1], "My Database") as brl_db: # All units in the database file are stored in millimeters. This constrains # the arguments to the mk_* routines to also be in millimeters. # make a sphere centered at 1.0, 2.0, 3.0 with radius 0.75 brl_db.sphere("ball.s", center=(1, 2, 3), radius=0.75) # Make an rpp under the sphere (partly overlapping). Note that this really # makes an arb8, but gives us a shortcut for specifying the parameters. brl_db.rpp("box.s", pmin=(0, 0, 0), pmax=(2, 4, 2.5)) # Make a region that is the union of these two objects. To accomplish # this, we don't need anymore to create any linked list of the items ;-). brl_db.combination("box_n_ball.r", is_region=True, tree=union("ball.s", "box.s"), shader="plastic {di=.8 sp=.2}", rgb_color=(64, 180, 96)) # Makes a hole from one corner to the other of the box # Note that you can provide a single combination name or a list in the # obj_list parameter, it will be handled correctly, all the tedious list # building is done under the hood: brl_db.hole(hole_start=(0, 0, 0), hole_depth=(2, 4, 2.5), hole_radius=0.75, obj_list="box_n_ball.r")
def main(argv): with wdb.WDB(argv[1], "My Database") as brl_db: # All units in the database file are stored in millimeters. This constrains # the arguments to the mk_* routines to also be in millimeters. # make a sphere centered at 1.0, 2.0, 3.0 with radius 0.75 brl_db.sphere("ball.s", center=(1, 2, 3), radius=0.75) # Make an rpp under the sphere (partly overlapping). Note that this really # makes an arb8, but gives us a shortcut for specifying the parameters. brl_db.rpp("box.s", pmin=(0, 0, 0), pmax=(2, 4, 2.5)) # Make a region that is the union of these two objects. To accomplish # this, we don't need anymore to create any linked list of the items ;-). brl_db.combination( "box_n_ball.r", is_region=True, tree=union("ball.s", "box.s"), shader="plastic {di=.8 sp=.2}", rgb_color=(64, 180, 96) ) # Makes a hole from one corner to the other of the box # Note that you can provide a single combination name or a list in the # obj_list parameter, it will be handled correctly, all the tedious list # building is done under the hood: brl_db.hole( hole_start=(0, 0, 0), hole_depth=(2, 4, 2.5), hole_radius=0.75, obj_list="box_n_ball.r" )
def main(): args = parse_args() origin = (0, 0, 0) # color for the core (land): green = (130, 253, 194) # color for the air: light_blue = (130, 194, 253) with WDB(args.db_file, "Globe Database") as globe_db: globe_db.sphere("land.s", center=origin, radius=args.initial_size) # the core is a region (is_region=True) and it has the shader set: globe_db.combination("land.r", tree="land.s", is_region=True, rgb_color=green, shader="plastic {di .8 sp .2}") # each layer is formed by subtracting the former sphere from the current sphere # the core land is the first "former sphere": prev_solid = "land.s" counter = 0 current_size = args.initial_size + args.step_size # this will collect the air layers: air_list = [] while current_size < args.final_size: crt_solid = "air.{}.s".format(counter) crt_comb = "air.{}.c".format(counter) crt_air = "air.{}.r".format(counter) globe_db.sphere(crt_solid, center=origin, radius=current_size) globe_db.combination(crt_comb, tree=subtract(crt_solid, prev_solid)) # Each layer is a region with it's own transparency setting: globe_db.combination( crt_air, tree=crt_comb, is_region=True, shader="plastic {{tr {}}}".format(current_size / args.final_size), rgb_color=light_blue, air_code=counter, region_id=counter, ) air_list.append(crt_air) prev_solid = crt_solid current_size += args.step_size counter += 1 # the air layers are grouped here in a combination, # not in a region as they are already regions on their own: globe_db.combination("air.g", tree=union(air_list)) # the final group of core land + air layers (no region, the leafs are already regions): globe_db.combination("globe.g", tree=union("land.r", "air.g"))
def rounder_rcc(c_radius, c_length, rounding_radius): sanity_check(c_radius, c_length, rounding_radius) origin = (0, 0, 0) base = (0, 0, rounding_radius) filler = (0, 0, c_length) top_tor = (0, 0, c_length - rounding_radius) height = (0, 0, c_length - 2 * rounding_radius) neg_z_dir, pos_z_dir = (0, 0, -1), (0, 0, 1) brl_db.rcc("cylinder.rcc", base, height, c_radius) brl_db.rcc("fillend.rcc", origin, filler, c_radius - rounding_radius) brl_db.torus("bottom.tor", base, neg_z_dir, c_radius - rounding_radius, rounding_radius) brl_db.torus("top.tor", top_tor, pos_z_dir, c_radius - rounding_radius, rounding_radius) union_list = ["cylinder.rcc", "fillend.rcc", "top.tor", "bottom.tor"] brl_db.combination( "cylinder3.r", is_region=False, tree=union(union_list) )