def add_house(self, house, no_walls=False, no_ceil=False, no_floor=False, use_separate_walls=False, static=False): for node in house.nodes: if not node.valid: continue if not hasattr(node, 'body'): node.body = None if node.type == 'Object': node.body = self.add_object(node, static=static) if node.type == 'Room': ceil = False if no_ceil else not (hasattr(node, 'hideCeiling') and node.hideCeiling == 1) wall = False if (no_walls or use_separate_walls) else not ( hasattr(node, 'hideWalls') and node.hideWalls == 1) floor = False if no_floor else not (hasattr(node, 'hideFloor') and node.hideFloor == 1) node.body = self.add_room(node, wall=wall, floor=floor, ceiling=ceil) if node.type == 'Box': half_widths = list(map(lambda x: 0.5 * x, node.dimensions)) node.body = self.add_box(obj_id=node.id, half_extents=half_widths, transform=Transform.from_node(node), static=static) if use_separate_walls and not no_walls: for wall in house.walls: wall['body'] = self.add_wall(wall)
def add_house_room_only(self, house, room, no_walls=False, no_ceil=True, no_floor=False, use_separate_walls=False, only_architecture=False, static=False): #walls, ceil, floor logic not fleshed out due to current limited use case room_node = [node for node in house.nodes if node.id == room.id] if len(room_node) < 1: raise Exception("Missing Room") if only_architecture: house.nodes = room_node else: house.nodes = [node for node in room.nodes] house.nodes.append(room_node[0]) for node in house.nodes: if not node.valid: continue if not hasattr(node, 'body'): node.body = None if node.type == 'Object': node.body = self.add_object(node, static=static) if node.type == 'Room': ceil = False if no_ceil else not (hasattr(node, 'hideCeiling') and node.hideCeiling == 1) wall = False if (no_walls or use_separate_walls) else not ( hasattr(node, 'hideWalls') and node.hideWalls == 1) floor = False if no_floor else not (hasattr(node, 'hideFloor') and node.hideFloor == 1) node.body = self.add_room(node, wall=wall, floor=floor, ceiling=ceil) if node.type == 'Box': half_widths = list(map(lambda x: 0.5 * x, node.dimensions)) node.body = self.add_box(obj_id=node.id, half_extents=half_widths, transform=Transform.from_node(node), static=static) if use_separate_walls and not no_walls: for wall in house.walls: wall['body'] = self.add_wall(wall)
def add_object(self, node, create_vis_mesh=False, static=False): model_id = node.modelId.replace( '_mirror', '') # TODO: need to otherwise account for mirror? object_dir = os.path.join(self._data_dir_base, 'object') basename = f'{object_dir}/{model_id}/{model_id}' vis_obj_filename = f'{basename}.obj' if create_vis_mesh else None col_obj_filename = f'{basename}.vhacd.obj' if not os.path.exists(col_obj_filename): print( 'WARNING: collision mesh {col_obj_filename} unavailable, using visual mesh instead.' ) col_obj_filename = f'{basename}.obj' return self.add_mesh(obj_id=node.id, obj_file=col_obj_filename, transform=Transform.from_node(node), vis_mesh_file=vis_obj_filename, static=static)