print(vars(parser.parse_args())) return args if __name__ == '__main__': # args = get_collide_args("collide") # print([m.name for m in MODEL_LIBRARIES['models_full.json'].records \ # if 'incline' == m.wcategory]) # c = SceneLibrarian() # print([r.name for r in c.search_records(search="room")]) c = MaterialLibrarian() ms = c.get_material_types() print(ms) print([m.name for m in c.get_all_materials_of_type("Plastic")]) # metal = [m for m in c.get_all_materials_of_type("Metal") if "steel_rusty" in m.name] # print(metal[0], metal[0].name) # for m in ms: # more_ms = c.get_all_materials_of_type(m) # print(m, [_m.name for _m in more_ms]) # C = MultiDominoes() # m = C.get_add_material("steel_rusty") # print(m)
from tdw.output_data import OutputData, Transforms from tdw_physics.rigidbodies_dataset import (RigidbodiesDataset, get_random_xyz_transform, get_range, handle_random_transform_args) from tdw_physics.util import (MODEL_LIBRARIES, get_parser, xyz_to_arr, arr_to_xyz, str_to_xyz, none_or_str, none_or_int, int_or_bool) from tdw_physics.target_controllers.dominoes import Dominoes, MultiDominoes, get_args from tdw_physics.postprocessing.labels import is_trial_valid MODEL_NAMES = [r.name for r in MODEL_LIBRARIES['models_flex.json'].records] M = MaterialLibrarian() MATERIAL_TYPES = M.get_material_types() MATERIAL_NAMES = {mtype: [m.name for m in M.get_all_materials_of_type(mtype)] \ for mtype in MATERIAL_TYPES} def get_gravity_args(dataset_dir: str, parse=True): common = get_parser(dataset_dir, get_help=False) domino, domino_postproc = get_args(dataset_dir, parse=False) parser = ArgumentParser(parents=[common, domino], conflict_handler='resolve', fromfile_prefix_chars='@') parser.add_argument( "--ramp", type=int, default=1,
def run(self): self.start() # Create an empty room. self.communicate(TDWUtils.create_empty_room(12, 12)) material_librarian = MaterialLibrarian() # Fetch a random wood material record. wood_records = material_librarian.get_all_materials_of_type("Wood") wood_record: MaterialRecord = choice(wood_records) # Fetch a random concrete record material. concrete_records = material_librarian.get_all_materials_of_type( "Concrete") concrete_record: MaterialRecord = choice(concrete_records) # Set the floor material. # Set the floor material texture scale. # Set the walls material. # Set the wall material texture scale. self.communicate([ self.get_add_material(wood_record.name), self.get_add_material(concrete_record.name), { "$type": "set_proc_gen_floor_material", "name": wood_record.name }, { "$type": "set_proc_gen_floor_texture_scale", "scale": { "x": 8, "y": 8 } }, { "$type": "set_proc_gen_walls_material", "name": concrete_record.name }, { "$type": "set_proc_gen_walls_texture_scale", "scale": { "x": 2, "y": 8 } } ]) # Create a random table. model_librarian = ModelLibrarian() wnids = model_librarian.get_model_wnids_and_wcategories() table_wnid = [wnid for wnid in wnids if wnids[wnid] == "table"][0] table_records = model_librarian.get_all_models_in_wnid(table_wnid) # Filter out unusable tables. table_records = [t for t in table_records if not t.do_not_use] table_record: ModelRecord = choice(table_records) # Add the table. table_id = self.add_object(table_record.name) # Set a random visual material for each sub-object in the model. commands = list() for sub_object in table_record.substructure: for i in range(len(sub_object["materials"])): material_record: MaterialRecord = choice( material_librarian.records) commands.extend([ self.get_add_material(material_record.name), { "$type": "set_visual_material", "id": table_id, "material_name": material_record.name, "object_name": sub_object["name"], "material_index": i } ]) self.communicate(commands) # Create the avatar. self.communicate( TDWUtils.create_avatar(position={ "x": 4, "y": 3, "z": 2 }, look_at=TDWUtils.VECTOR3_ZERO))