|
| 1 | +from tdw.controller import Controller |
| 2 | +from tdw.tdw_utils import TDWUtils |
| 3 | +from tdw.add_ons.third_person_camera import ThirdPersonCamera |
| 4 | +from tdw.add_ons.image_capture import ImageCapture |
| 5 | +from tdw.librarian import ModelLibrarian |
| 6 | +from tdw.backend.paths import EXAMPLE_CONTROLLER_OUTPUT_PATH |
| 7 | + |
| 8 | +""" |
| 9 | +Set an object's material to wireframe. |
| 10 | +""" |
| 11 | + |
| 12 | +c = Controller() |
| 13 | +object_id_1 = c.get_unique_id() |
| 14 | +object_id_2 = c.get_unique_id() |
| 15 | + |
| 16 | +lib = ModelLibrarian() |
| 17 | +model_record_1 = lib.get_record("white_lounger_chair") |
| 18 | +model_record_2 = lib.get_record("chair_billiani_doll") |
| 19 | +cam = ThirdPersonCamera(position={"x": 3.6, "y": 1.6, "z": -0.6}, |
| 20 | + look_at=object_id_1) |
| 21 | +path = EXAMPLE_CONTROLLER_OUTPUT_PATH.joinpath("set_wireframe_material") |
| 22 | +print(f"Images will be saved to: {path}") |
| 23 | +cap = ImageCapture(avatar_ids=[cam.avatar_id], pass_masks=["_img"], path=path) |
| 24 | +c.add_ons.extend([cam, cap]) |
| 25 | + |
| 26 | +commands = [TDWUtils.create_empty_room(12, 12), |
| 27 | + c.get_add_object(model_name=model_record_1.name, |
| 28 | + object_id=object_id_1), |
| 29 | + c.get_add_object(model_name=model_record_2.name, |
| 30 | + object_id=object_id_2, |
| 31 | + position={"x": 2, "y": 0, "z": 0})] |
| 32 | +commands.extend(TDWUtils.set_wireframe_material(substructure=model_record_1.substructure, object_id=object_id_1, color={"r": 1.0, "g": 0, "b": 0, "a": 1.0}, thickness=0.05)) |
| 33 | +commands.extend(TDWUtils.set_wireframe_material(substructure=model_record_2.substructure, object_id=object_id_2, color={"r": 0, "g": 0, "b": 1.0, "a": 1.0}, thickness=0.035)) |
| 34 | +c.communicate(commands) |
| 35 | +c.communicate({"$type": "terminate"}) |
0 commit comments