def MIT_stair(system, center, H, SPEEDMODE): stair_r = 0.3 # Radius stair_h = 2 * H + 1 # Hight stair_d = 1 # Density stepNum = 21 # Number of steps dh = (H - 0.1) / stepNum # Heigth between each step rad = 1 / 360 * 2 * np.pi # Degrees to radians texture = 'textures/white concrete.jpg' pos_stair = center + np.array([ 0, stair_h / 2, 0 ]) #chrono.ChVectorD(0, stair_h/2, 0) # Correction for stair position pos_disk = center + np.array([0, stair_h + 0.025, 0 ]) #chrono.ChVectorD(0, stair_h+0.025, 0) # Add center cylinder of stair MiroAPI.add_cylinderShape(system, stair_r, stair_h, stair_d, pos_stair, texture, [10, 10]) # If SPEEDMODE is activated, stop here if SPEEDMODE: return # Top disk MiroAPI.add_cylinderShape(system, stair_r + 0.01, 0.05, 1, pos_disk, 'textures/MIT_stone_floor.jpg', [1 / 8, 1 / 8]) # Add fake stair to base floor MiroAPI.add_cylinderShape(system, stair_r + 1.7, 0.001, stair_d, center, 'textures/black.jpg', [1, 1]) # Add steps to 3rd floor for step in range(stepNum): h = step * dh theta_f = rad * (90 + 270 * step / stepNum ) # Angle between each front step theta_b = rad * (90 + 270 * (step + 1) / stepNum) # Angle between each back step add_stairStep(system, center, stair_r, h, theta_f, theta_b, dh, step, stepNum, True) add_stairStep(system, center, stair_r, 0, theta_f, theta_b, 0, step, stepNum, False) # Add fence post for stair if step % 2 == 0: add_stairPosts(system, center, stair_r, h, theta_f, theta_b) add_stairPosts(system, center, stair_r, 0, theta_f, theta_b) # Add steps to 4th floor for step in range(stepNum): h = step * dh theta_f = rad * (90 + 270 * step / stepNum ) # Angle between each front step theta_b = rad * (90 + 270 * (step + 1) / stepNum) # Angle between each back step pos = center + np.array([0, H, 0]) add_stairStep(system, pos, stair_r, h, theta_f, theta_b, dh, step, stepNum, True) # Add fence post for stair if step % 2 == 0: add_stairPosts(system, pos, stair_r, h, theta_f, theta_b)
def eyeball(MiroSystem, pos, radius=0.1): MiroAPI.add_sphereShape(MiroSystem, radius, [pos[0], pos[1]+radius, pos[2]], texture='eyeball.png', density = 100, Fixed=False, rotY=-30)
def coin(MiroSystem, target, angle = 0): h = 0.0012 r = 0.012 pos_coin = np.array([target[0], target[1]+h/2, target[2]]) MiroAPI.add_cylinderShape(MiroSystem, r, h, 150, pos_coin, rotY=angle, texture='gammal5kr.png', Fixed=False, scale=[1,-1])
def Set_Camera(self): '''This sets the camera during simulation. For internal usage when the simulation is being run, use SetPerspective to configure the camera before running the simulation.''' if self.freecam: return if self.cycle: self.cam_to_obs = MiroAPI.rotateVector(self.cam_to_obs, self.cycle_angle / self.fps, [0, 1, 0], rotDegrees=False) self.cam_to_obs = (49 * self.cam_to_obs + self.followmod.GetCenterOfMassVelocity()) / 50 self.cam_to_obs = self.cam_to_obs / np.linalg.norm(self.cam_to_obs) self.cam_pos = self.obs_pos - self.cam_to_obs MiroAPI.SetCamera(self.system_list, self.cam_pos, self.obs_pos) if self.follow_default: if np.linalg.norm(self.followmod.GetCenterOfMassVelocity()) > 1e-2: #oldest working #cam_to_obs[0] = cam_to_obs[0] * np.cos(self.follow_angle) #cam_to_obs[1] = cam_to_obs[0] * np.sin(self.follow_angle) #cam_to_obs[2] = cam_to_obs[2] * np.cos(self.follow_angle) self.obs_pos = (12 * self.obs_pos + self.followmod.GetCenterOfMass()) / 13 self.cam_up = (9 * self.cam_up + np.array([0, 1, 0])) / 10 cam_to_obs = ( self.followmod.GetCenterOfMassVelocity() / np.linalg.norm(self.followmod.GetCenterOfMassVelocity())) cam_to_obs *= self.follow_distance cam_pos = self.obs_pos - self.cam_to_obs cam_pos[1] += self.follow_height self.cam_pos = (9 * self.cam_pos + cam_pos) / 10 # good val = 1/2 MiroAPI.SetCamera(self.system_list, self.cam_pos, self.obs_pos, self.cam_up) cam_to_obs = (49 * self.cam_to_obs + cam_to_obs) / (49 + 1) self.cam_to_obs = cam_to_obs if self.camera_sweep: i = self.sweepstep sweep_divs = 100 self.cam_pos = ( (sweep_divs - i) * self.sweep_cam[self.sweepnr - 1] + (i) * self.sweep_cam[self.sweepnr]) / sweep_divs self.obs_pos = ( (sweep_divs - i) * self.sweep_obs[self.sweepnr - 1] + (i) * self.sweep_obs[self.sweepnr]) / sweep_divs MiroAPI.SetCamera(self.system_list, self.cam_pos, self.obs_pos) self.sweepstep += 1 if self.sweepstep > sweep_divs: self.sweepstep = 0 self.sweepnr += 1 if self.sweepnr >= self.sweepsteps: self.camera_sweep = False if not self.cycle and not self.follow: return
def chair_back(MiroSystem, pos_back, size_back_x,size_back_y, size_back_z): return MiroAPI.add_boxShape(MiroSystem, size_back_x, size_back_y, size_back_z, pos_back, 'MITstol.jpg', Fixed=FIXED)
def add_fence(system, H, postNum, floor_w, floor_w_2, floor, floor_t, handle_l): # Add fence post, as a cylinder fence_r = 0.02 # Radius fence_h = 1.04 # Hight fence_d = 1 # Density texture = 'textures/white concrete.jpg' fence_corr = np.array([0, fence_h / 2, 0]) # Correction for fence post postition # Add handle for each floor handle_r = 0.0175 # Radius # handle_d = 1 # Density n_x = np.array([1, 0, 0]) # Normalvector in x direction n_z = np.array([0, 0, 1]) # Normalvector in z direction # Handle pos_rail_1 = np.array([-0.75, H + fence_h * 0.925, 6.58 - floor_w]) # Fence 3rd floor left of stair pos_rail_2 = np.array( [10.45 + 2.11 - floor_w_2, H + fence_h * 0.925, -4.4]) # Fence 3rd floor pos_rail_3 = np.array( [10.45 + 2.11 - floor_w_2, 2 * H + fence_h * 0.925, -4.4]) # Fence 4th floor pos_rail_4 = np.array([6.5, 2 * H + fence_h * 0.925, 4.2]) # Fence by the stair 4th floor # Rail pos_rail_5 = np.array([-0.75, H + 3 / 4 * fence_h, 6.58 - floor_w]) # Fence 3rd floor left of stair pos_rail_6 = np.array( [10.45 + 2.11 - floor_w_2, H + 3 / 4 * fence_h, -4.4]) # Fence 3rd floor pos_rail_7 = np.array( [10.45 + 2.11 - floor_w_2, 2 * H + 3 / 4 * fence_h, -4.4]) # Fence 4th floor pos_rail_8 = np.array([6.5, 2 * H + 3 / 4 * fence_h, 4.2]) # Fence by the stair 4th floor pos_h = [pos_rail_1, pos_rail_2, pos_rail_3, pos_rail_4] pos_r = [pos_rail_5, pos_rail_6, pos_rail_7, pos_rail_8] dirr = [n_z, n_x, n_x, n_x] handle_length = [handle_l, handle_l, handle_l, 2] dl = (handle_l) / postNum # Delta lenght between each post # Handle rail for num in range(len(pos_h)): pos_rail = pos_h[num] n = dirr[num] length = handle_length[num] MiroAPI.add_cylinderShape(system, handle_r, length, 1, pos_rail, 'textures/wood_floor.jpg', rotAngle=np.pi / 2, rotAxis=n, rotDegrees=False) # Support rail for num in range(len(pos_r)): pos_rail = pos_r[num] n = dirr[num] length = handle_length[num] MiroAPI.add_cylinderShape(system, fence_r, length, 1, pos_rail, 'textures/white concrete.jpg', rotAngle=np.pi / 2, rotAxis=n, rotDegrees=False) for post in range(postNum): y_pos = floor * H - floor_t pos_l = np.array([(-0.7 - handle_l / 2) + post * dl, H - floor_t, 6.58 - floor_w]) + fence_corr # Left side stair pos_r = np.array([ 10.45 + 2.11 - floor_w_2, y_pos, (-4.4 - handle_l / 2) + post * dl ]) + fence_corr # Right side stair MiroAPI.add_cylinderShape(system, fence_r, fence_h, fence_d, pos_r, texture) MiroAPI.add_cylinderShape(system, fence_r, fence_h, fence_d, pos_l, texture) for post in range(3): pos = np.array([6.5, 2 * H - floor_t, 3.5 + post * dl]) + fence_corr MiroAPI.add_cylinderShape(system, fence_r, fence_h, fence_d, pos, texture)
def Set_Idle(self): MiroAPI.rotateBody(self.bulb, rotAngle=180, rotAxis=self.bulb_pos)
def FullEntrance(MiroSystem, pos_south, pos_north): d = 0.08 l = 3.02 # Pole in front of doors p = np.array([pos_south[0] + 2.89, 1.51, pos_south[2] - 0.6]) MiroAPI.add_boxShape(MiroSystem, 2 * d, l, 2 * d, p, texture='white concrete.jpg', scale=[4, 12]) # Emergency exit sign p = np.array([pos_south[0] + 2.89, 2.7, pos_south[2] - 0.6 - d - 0.01]) MiroAPI.add_boxShape(MiroSystem, 0.568 * 0.7, 0.285 * 0.7, 0.02, p, texture='exit.png') # Inner doorframe greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + (1 / 2) * d, 1.51, pos_south[2]]) greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 0.68, 1.51, pos_south[2]]) greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 2.72, 1.51, pos_south[2]]) greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 3.06, 1.51, pos_south[2]]) greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 5.10, 1.51, pos_south[2]]) greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 5.44, 1.51, pos_south[2]]) greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 6.58, 1.51, pos_south[2]]) greenpole(MiroSystem, d, l, 0, 0, [pos_north[0] - (1 / 2) * d, 1.51, pos_north[2]]) # Horizontal parts greenpole(MiroSystem, d, (pos_north[0] - pos_south[0]), 0, 90, [ (pos_north[0] + pos_south[0]) / 2, 2.5 + d / 2, pos_north[2] - d / 20 ]) greenpole(MiroSystem, d, (pos_north[0] - pos_south[0]), 0, 90, [ (pos_north[0] + pos_south[0]) / 2, 3.0 - d / 2, pos_north[2] - d / 20 ]) # Small bits on floor for s in [[(1 / 2) * d, 0.68], [2.72, 3.06], [5.10, 5.44], [6.58, pos_north[0] - pos_south[0] - (1 / 2) * d]]: greenpole(MiroSystem, d, (s[1] - s[0] - d), 0, 90, [pos_south[0] + (s[1] + s[0]) / 2, d / 2, pos_north[2]]) # Revolving doors revolute_door(MiroSystem, d, 0.98, 15, [pos_south[0] + 1.70, 2.4 - d / 2, pos_south[2]]) revolute_door(MiroSystem, d, 0.98, 50, [pos_south[0] + 4.08, 2.4 - d / 2, pos_south[2]]) # Side door, inner normal_door(MiroSystem, d, 1.1 - d, 232, [pos_south[0] + 6.58 - d, 2.5 - d / 2, pos_south[2]]) ########### INNER PART STOPS HERE ########### width = pos_north[0] - pos_south[0] + 3.04 depth = 5 inner_depth = 2.8 p = np.array( [pos_south[0] - 2 + width / 2, -0.08, pos_south[2] + depth / 2]) MiroAPI.add_boxShape(MiroSystem, width, 0.16, 5, p, 'MIT_stone_floor.jpg') p = np.array([p[0], 3.08, p[2]]) MiroAPI.add_boxShape(MiroSystem, width, 0.16, 5, p, 'MIT_stone_floor.jpg') # Outer door frames z = pos_south[2] + inner_depth greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 0.00 + d / 2, 1.51, z]) greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 0.33, 1.51, z]) greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 1.51, 1.51, z]) greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 1.59, 1.51, z]) greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 2.77, 1.51, z]) greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 3.25, 1.51, z]) greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 4.43, 1.51, z]) greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 4.51, 1.51, z]) greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 5.69, 1.51, z]) greenpole(MiroSystem, d, l, 0, 0, [pos_south[0] + 6.02 - d / 2, 1.51, z]) # Outer doors normal_door(MiroSystem, d, 1.1 - d, -42, [pos_south[0] + 0.33 + d, 2.5 - d / 2, z]) # south outward normal_door(MiroSystem, d, 1.1 - d, 180, [pos_south[0] + 2.77 - d, 2.5 - d / 2, z]) # south inward normal_door(MiroSystem, d, 1.1 - d, -0, [pos_south[0] + 3.25 + d, 2.5 - d / 2, z]) # north outward normal_door(MiroSystem, d, 1.1 - d, 180, [pos_south[0] + 5.69 - d, 2.5 - d / 2, z]) # north inward greenpole(MiroSystem, d, 6.02, 0, 90, [pos_south[0] + 3.01, 2.5 + d / 2, z - d / 20]) greenpole(MiroSystem, d, 6.02, 0, 90, [pos_south[0] + 3.01, 3.0 - d / 2, z - d / 20]) # Small bits on floor for s in [[d / 2, 0.33], [2.77, 3.25], [5.69, 6.02 - d / 2]]: greenpole(MiroSystem, d, (s[1] - s[0] - d), 0, 90, [pos_south[0] + (s[1] + s[0]) / 2, d / 2, z]) # south wall p = np.array( [pos_south[0] - 0.05, 1.51, pos_south[2] + inner_depth / 2 - 0.89 / 2]) MiroAPI.add_boxShape(MiroSystem, 0.1, 3.02, inner_depth + 0.89, p, 'yellow_brick.jpg', scale=[7, 9]) # north wall np.array([pos_north[0] + 0.05, 1.51, pos_south[2] + inner_depth / 2]) MiroAPI.add_boxShape(MiroSystem, 0.1, 3.02, inner_depth, p, 'yellow_brick.jpg', scale=[6, 9]) # WEST WALL w = 2 dw = 0.96 p = np.array([pos_north[0] + w / 2 - dw, 1.51, z]) MiroAPI.add_boxShape(MiroSystem, w, 3.02, 0.16, p, 'yellow_brick.jpg', scale=[2, 9], color=[0.6, 0.4, 0.0]) p = np.array([pos_south[0] - dw, 1.51, z]) MiroAPI.add_boxShape(MiroSystem, w, 3.02, 0.16, p, 'yellow_brick.jpg', scale=[2, 9], color=[0.6, 0.4, 0.0]) # Cement pillars outside r = 0.12 p = np.array( [pos_south[0] - 1, 1.51, z - r + (depth - inner_depth) * (3 / 4)]) MiroAPI.add_cylinderShape(MiroSystem, r, 3.02, 1000, p, 'white concrete.jpg', color=[0.8, 0.8, 0.8]) p = np.array([ pos_north[0] + 1 - 0.96, 1.51, z - r + (depth - inner_depth) * (3 / 4) ]) MiroAPI.add_cylinderShape(MiroSystem, r, 3.02, 1000, p, 'white concrete.jpg', color=[0.8, 0.8, 0.8]) p = np.array([pos_south[0] + 1.6, 1.51, z - r + (depth - inner_depth)]) MiroAPI.add_cylinderShape(MiroSystem, r, 3.02, 1000, p, 'white concrete.jpg', color=[0.8, 0.8, 0.8]) p = np.array( [pos_north[0] - 1.6 - 0.96, 1.51, z - r + (depth - inner_depth)]) MiroAPI.add_cylinderShape(MiroSystem, r, 3.02, 1000, p, 'white concrete.jpg', color=[0.8, 0.8, 0.8])
def MIT_door(MiroSystem, pos, rot = 0): b = 1.0 h = 2.1 pos = [pos[0], pos[1]+h/2, pos[2]] MiroAPI.add_boxShape(MiroSystem, b, h, 0.16, pos, rotY=rot, texture='MIT_door.png', Collide=False)
def normal_door(MiroSystem, d, l, spin, pos): top = pos[1] mid = pos[1] / 2 + d / 4 bot = d / 2 # vertical frame poles pos[1] = mid greenpole(MiroSystem, d, top - bot + d, spin, 0, pos) p = [ pos[0] + np.cos(np.deg2rad(spin)) * (l - d / 2), mid, pos[2] - np.sin(np.deg2rad(spin)) * (l - d / 2) ] greenpole(MiroSystem, d, top - bot + d, spin, 0, p) # top and bottom frame p = [ pos[0] + (1 / 2) * np.cos(np.deg2rad(spin)) * (l - d / 2), top, pos[2] - (1 / 2) * np.sin(np.deg2rad(spin)) * (l - d / 2) ] greenpole(MiroSystem, d, l - d, spin, 90, p) p[1] = bot greenpole(MiroSystem, d, l - d, spin, 90, p) # handle r = 0.02 h = 0.40 dist = 0.30 # poles through door pb = [ pos[0] + np.cos(np.deg2rad(spin)) * (l - d / 2) * 0.86, mid + h * (1 / 3), pos[2] - np.sin(np.deg2rad(spin)) * (l - d / 2) * 0.86 ] MiroAPI.add_cylinderShape(MiroSystem, r / 2, dist, 2500, pb, 'textures/chrome.png', rotY=spin - 90, rotZ=90, rotOrder=['x', 'z', 'y'], Collide=False, scale=[2, 2], color=[0.9, 0.9, 0.9]) pb[1] = mid - h * (1 / 3) # rotY=-spin, rotX=90 MiroAPI.add_cylinderShape(MiroSystem, r / 2, dist, 2500, pb, 'chrome.png', rotY=spin - 90, rotZ=90, rotOrder=['z', 'y'], Collide=False, scale=[2, 2], color=[0.9, 0.9, 0.9]) # disks on door MiroAPI.add_cylinderShape(MiroSystem, r * 1.2, 0.01, 2500, pb, 'brushsteel.png', rotY=spin - 90, rotZ=90, rotOrder=['z', 'y'], Collide=False, scale=[2, 2], color=[0.85, 0.85, 0.85]) pb[1] = mid + h * (1 / 3) MiroAPI.add_cylinderShape(MiroSystem, r * 1.2, 0.01, 2500, pb, 'brushsteel.png', rotY=spin - 90, rotZ=90, rotOrder=['z', 'y'], Collide=False, scale=[2, 2], color=[0.85, 0.85, 0.85]) # handle bars ph1 = [ pb[0] + np.cos(np.deg2rad(spin + 90)) * (dist / 2), mid, pb[2] - np.sin(np.deg2rad(spin + 90)) * (dist / 2) ] ph2 = [ pb[0] - np.cos(np.deg2rad(spin + 90)) * (dist / 2), mid, pb[2] + np.sin(np.deg2rad(spin + 90)) * (dist / 2) ] MiroAPI.add_cylinderShape(MiroSystem, r, h, 2500, ph1, 'chrome.png', scale=[2, 2], color=[0.9, 0.9, 0.9]) MiroAPI.add_cylinderShape(MiroSystem, r, h, 2500, ph2, 'chrome.png', scale=[2, 2], color=[0.9, 0.9, 0.9])
def revolute_door(MiroSystem, d, l, spin, pos): # Revolving door bottom ring pos_down = np.array([pos[0], 0.0, pos[2]]) disk_bot = MiroAPI.add_cylinderShape(MiroSystem, l, 0.01, 1000, pos_down, 'MITentrance_floor.png', Collide=False) # Revolving door top ring pos_up = np.array([pos[0], pos[1] + 0.1 / 2 + d / 2, pos[2]]) disk_top = MiroAPI.add_cylinderShape(MiroSystem, l, 0.1, 1000, pos_up, 'MITentrance.png') l = l - 0.03 eps = 0.004 top = pos[1] - eps mid = pos[1] / 2 + d / 4 bot = d / 2 + eps dh = np.array([0, d / 2, 0]) # middle pole pos[1] = mid mid_pole = greenpole(MiroSystem, d, top - bot - d, spin, 0, pos, Fixed=FIXED) # top cross pos[1] = top top_x = greenpole(MiroSystem, d, 2 * (l - d), spin, 90, pos, Fixed=FIXED) top_y = greenpole(MiroSystem, d, 2 * (l - d), spin + 90, 90, pos, Fixed=FIXED) if not FIXED: dir1 = [np.cos(np.deg2rad(spin)), 0, np.sin(np.deg2rad(spin))] dir2 = [ np.cos(np.deg2rad(spin + 90)), 0, np.sin(np.deg2rad(spin + 90)) ] MiroAPI.LinkBodies_Hinge(top_x, top_y, pos, dir1, MiroSystem) MiroAPI.LinkBodies_Hinge(top_x, top_y, pos, dir2, MiroSystem) MiroAPI.LinkBodies_Hinge(top_x, mid_pole, pos - dh, dir1, MiroSystem) MiroAPI.LinkBodies_Hinge(top_x, disk_top, pos + dh, [0, 1, 0], MiroSystem) MiroAPI.LinkBodies_Hinge(top_y, disk_top, pos + dh, [0, 1, 0], MiroSystem) # bottom cross pos[1] = bot bot_x = greenpole(MiroSystem, d, 2 * (l - d), spin, 90, pos, Fixed=FIXED) bot_y = greenpole(MiroSystem, d, 2 * (l - d), spin + 90, 90, pos, Fixed=FIXED) if not FIXED: MiroAPI.LinkBodies_Hinge(bot_x, bot_y, pos, dir1, MiroSystem) MiroAPI.LinkBodies_Hinge(bot_x, bot_y, pos, dir2, MiroSystem) MiroAPI.LinkBodies_Hinge(bot_x, mid_pole, pos + dh, dir1, MiroSystem) MiroAPI.LinkBodies_Hinge(bot_x, disk_top, pos - dh, [0, -1, 0], MiroSystem) MiroAPI.LinkBodies_Hinge(bot_y, disk_top, pos - dh, [0, -1, 0], MiroSystem) cross = [[top_x, bot_x], [top_y, bot_y]] p = np.array([pos[0], mid, pos[2]]) for phi in [0, 90, 180, 270]: angle = spin + phi dp = np.array([ np.cos(np.deg2rad(angle)) * (l - d / 2), 0, -np.sin(np.deg2rad(angle)) * (l - d / 2) ]) rod = greenpole(MiroSystem, d, top - bot + d, angle, 0, p + dp, Fixed=FIXED) if not FIXED: dh = np.array([0, (top - bot + d) / 2, 0]) top_bar = cross[round(phi / 90) % 2][0] bot_bar = cross[round(phi / 90) % 2][1] MiroAPI.LinkBodies_Hinge(top_bar, rod, p + dp + dh, -dp, MiroSystem) MiroAPI.LinkBodies_Hinge(bot_bar, rod, p + dp - dh, -dp, MiroSystem) # side walls wid = 0.4 thick = 0.02 angle = -13 height = top - bot + d + 2 * eps p = np.array([pos[0] - (l + 0.03 + thick / 2), mid, pos[2]]) p[0] = p[0] - np.sin(np.deg2rad(angle)) * wid / 2 p[2] = p[2] - np.cos(np.deg2rad(angle)) * wid / 2 MiroAPI.add_boxShape(MiroSystem, thick, height, wid, p, 'MITentrance.png', rotY=angle, color=[0.02, 0.1, 0.01]) p[2] = p[2] + np.cos(np.deg2rad(angle)) * wid MiroAPI.add_boxShape(MiroSystem, thick, height, wid, p, 'MITentrance.png', rotY=-angle, color=[0.02, 0.1, 0.01]) p[0] = p[0] + np.sin(np.deg2rad(angle)) * wid + 2 * (l + 0.03 + thick / 2) MiroAPI.add_boxShape(MiroSystem, thick, height, wid, p, 'MITentrance.png', rotY=angle, color=[0.02, 0.1, 0.01]) p[2] = p[2] - np.cos(np.deg2rad(angle)) * wid MiroAPI.add_boxShape(MiroSystem, thick, height, wid, p, 'MITentrance.png', rotY=-angle, color=[0.02, 0.1, 0.01])
def build(MiroSystem, SPEEDMODE=False): frame_h = 1.0 dy = 2 / 3 xspan = [-5.25, 8.35] yspan = [9.96, 13.96] zspan = [-8.9, 5.1] dec = -(yspan[1] - yspan[0] - frame_h) / (zspan[1] - zspan[0]) dy = yspan[1] - yspan[0] - frame_h #sides p1 = np.array([-dy / 2, 0, 0]) p2 = np.array([0.16 + dy / 2, 0, 0]) d1 = np.array([0, 0, -1]) d2 = np.array([dec, 0, -1]) s = 0.98 # sideS = MiroAPI.stepShape(p1,d1, p2,d2, zspan[1]-zspan[0], 0.2, [s,s,s]) # sideN = MiroAPI.stepShape(p1,d1, p2,d2, zspan[1]-zspan[0], 0.2, [s,s,s]) # MiroAPI.rotateBody(sideS, rotZ=90) # MiroAPI.rotateBody(sideN, rotZ=90) # MiroAPI.MoveBodyTo(sideS, np.array([xspan[0]-0.05, yspan[0]+frame_h + (yspan[1]-yspan[0]-frame_h)/2, zspan[1]+0.1])) # MiroAPI.MoveBodyTo(sideN, np.array([xspan[1]+0.25, yspan[0]+frame_h + (yspan[1]-yspan[0]-frame_h)/2, zspan[1]+0.1])) # MiroSystem.Add(sideS) # MiroSystem.Add(sideN) # # Top beams # beams = 4 # dx = (xspan[1] - xspan[0])/(beams-1) # for b in range(beams): # p1 = np.array([xspan[0] + dx*b - 0.06, yspan[1]-0.12, zspan[1]-0.06]) # p2 = np.array([xspan[0] + dx*b + 0.06, yspan[1]-0.12, zspan[1]-0.06]) # d1 = np.array([0,dec,-1]) # d2 = np.array([0,dec,-1]) # MiroAPI.add_stepShape(MiroSystem, p1,d1, p2,d2, (zspan[1]-zspan[0])*(np.sqrt(1+dec**2)), 0.2) # beams = 5 # h_0 = yspan[1]+0.12*dec # dz = (zspan[1]-zspan[0])/(beams-1) - 0.28/beams # for b in range(beams): # pos = np.array([(xspan[0]+xspan[1])/2, h_0+dec*dz*b, zspan[1]-0.12-dz*b]) # MiroAPI.add_boxShapeHemi(MiroSystem, (xspan[1]-xspan[0])/2+0.06, 0.06, 0.06, pos, 'white_smere.jpg', rotX=np.sin(dec), scale=[100, 1.5]) # # Windows # beams = 10 # dx = (xspan[1] - xspan[0])/(beams-1) # for b in range(beams): # pos = np.array([xspan[0] + dx*b, (yspan[1] + yspan[0] + frame_h)/2, zspan[1]]) # MiroAPI.add_boxShapeHemi(MiroSystem, 0.05, (yspan[1] - yspan[0] - frame_h)/2, 0.05, pos, 'white_smere.jpg', scale=[100, 1.5]) # beams = 5 # dy = (yspan[1]-yspan[0]-frame_h)/(beams-1) # for b in range(beams): # pos = np.array([(xspan[0]+xspan[1])/2, yspan[0]+frame_h+0.06+dy*b, zspan[1]]) # MiroAPI.add_boxShapeHemi(MiroSystem, (xspan[1]-xspan[0])/2+0.06, 0.06, 0.06, pos, 'white_smere.jpg', scale=[100, 1.5]) # West wall pos = np.array([(xspan[0] + xspan[1]) / 2, yspan[0] + frame_h / 2, zspan[1]]) MiroAPI.add_boxShapeHemi(MiroSystem, (xspan[1] - xspan[0] + 0.5) / 2, frame_h / 2, 0.1, pos, 'white concrete.jpg', scale=[40, 5]) # East wall pos = np.array([(xspan[0] + xspan[1]) / 2, yspan[0] + frame_h / 2, zspan[0]]) MiroAPI.add_boxShapeHemi(MiroSystem, (xspan[1] - xspan[0] + 0.5) / 2, frame_h / 2, 0.1, pos, 'white concrete.jpg', scale=[40, 5]) # South wall pos = np.array( [xspan[0] - 0.15, yspan[0] + frame_h / 2, (zspan[1] + zspan[0]) / 2]) MiroAPI.add_boxShapeHemi(MiroSystem, 0.1, frame_h / 2, (zspan[1] - zspan[0]) / 2 - 0.1, pos, 'white concrete.jpg', scale=[40, 5]) # North wall pos = np.array( [xspan[1] + 0.15, yspan[0] + frame_h / 2, (zspan[1] + zspan[0]) / 2]) MiroAPI.add_boxShapeHemi(MiroSystem, 0.1, frame_h / 2, (zspan[1] - zspan[0]) / 2 - 0.1, pos, 'white concrete.jpg', scale=[40, 5]) # MA roof roofMA_width = 6.6 pos = np.array( [xspan[1] + roofMA_width / 2 + 0.052, yspan[0] + 0.098, -0.2]) MiroAPI.add_boxShapeHemi(MiroSystem, roofMA_width / 2, 0.1, 12.5, pos, 'white concrete.jpg', scale=[40, 80]) # MC roof roofMC_width = 3.165 pos = np.array([(xspan[1] + xspan[0]) / 2, yspan[0] + 0.098, zspan[1] + roofMC_width / 2 + 0.1]) MiroAPI.add_boxShapeHemi(MiroSystem, (xspan[1] - xspan[0]) / 2 + 0.052, 0.1, roofMC_width / 2, pos, 'white concrete.jpg', scale=[80, 10]) # Computer Science roof roofMC_width = 3.165 pos = np.array([6.85, yspan[0] + 0.098, zspan[1] + roofMC_width + 2.092]) MiroAPI.add_boxShapeHemi(MiroSystem, 1.552, 0.1, 1.992, pos, 'white concrete.jpg', scale=[80, 10])
def MIT_Officewalls(MiroSystem, H, wall_t, posW, posE, posS): corner_windowpane0 = np.array([-5.29, 2 * H + 1.5, 4.99]) first_windowpane0 = np.array([ corner_windowpane0[0] + 0.10, corner_windowpane0[1], corner_windowpane0[2] ]) corner_windowpane1 = np.array([-0.7, 2 * H + 1.5, 4.99]) first_windowpane1 = np.array([ corner_windowpane1[0] + 0.25, corner_windowpane1[1], corner_windowpane1[2] ]) corner_windowpane2 = np.array([4.125, 2 * H + 1.5, 4.99]) first_windowpane2 = np.array([ corner_windowpane2[0] + 0.25, corner_windowpane2[1], corner_windowpane2[2] ]) v_windowpane_size = np.array([0.05, 3, 0.01]) #vertical window pane size pos_down = np.array([posW[0], posW[1] - 1.26, posW[2]]) pos_up = np.array([posW[0], posW[1] + 1.51, posW[2]]) #concrete part under and over windows MiroAPI.add_boxShape(MiroSystem, 11.8, 0.8, 0.2, pos_down, texture='white concrete.jpg', scale=[9, 12]) MiroAPI.add_boxShape(MiroSystem, 11.8, 0.3, 0.2, pos_up, texture='white concrete.jpg', scale=[9, 12]) #1st window vertical MiroAPI.add_boxShape(MiroSystem, v_windowpane_size[0], v_windowpane_size[1], v_windowpane_size[2], corner_windowpane0, texture='wood_ikea_style.png') spacingA = 0.61 for k in range(0, 8): tmp = np.array([spacingA * k, 0, 0]) MiroAPI.add_boxShape(MiroSystem, v_windowpane_size[0], v_windowpane_size[1], v_windowpane_size[2], tmp + first_windowpane0, texture='wood_ikea_style.png') if k == 3: MiroAPI.add_boxShape(MiroSystem, v_windowpane_size[0], v_windowpane_size[1], v_windowpane_size[2], np.array([spacingA / 2, 0, 0]) + tmp + first_windowpane0, texture='wood_ikea_style.png') #2nd window vertical MiroAPI.add_boxShape(MiroSystem, v_windowpane_size[0], v_windowpane_size[1], v_windowpane_size[2], corner_windowpane1, texture='wood_ikea_style.png') MiroAPI.add_boxShape(MiroSystem, v_windowpane_size[0], v_windowpane_size[1], v_windowpane_size[2], first_windowpane1, texture='wood_ikea_style.png') spacingB = 0.685 for k in range(0, 7): tmp = np.array([spacingB * k, 0, 0]) MiroAPI.add_boxShape(MiroSystem, v_windowpane_size[0], v_windowpane_size[1], v_windowpane_size[2], tmp + first_windowpane1, texture='wood_ikea_style.png') if k == 1: MiroAPI.add_boxShape(MiroSystem, v_windowpane_size[0], v_windowpane_size[1], v_windowpane_size[2], np.array([spacingB / 2, 0, 0]) + tmp + first_windowpane1, texture='wood_ikea_style.png') if k == 4: MiroAPI.add_boxShape(MiroSystem, v_windowpane_size[0], v_windowpane_size[1], v_windowpane_size[2], np.array([spacingB / 2, 0, 0]) + tmp + first_windowpane1, texture='wood_ikea_style.png') if k == 6: MiroAPI.add_boxShape(MiroSystem, v_windowpane_size[0], v_windowpane_size[1], v_windowpane_size[2], np.array([0.25, 0, 0]) + tmp + first_windowpane1, texture='wood_ikea_style.png') #3rd window vertical MiroAPI.add_boxShape(MiroSystem, v_windowpane_size[0], v_windowpane_size[1], v_windowpane_size[2], corner_windowpane2, texture='wood_ikea_style.png') MiroAPI.add_boxShape(MiroSystem, v_windowpane_size[0], v_windowpane_size[1], v_windowpane_size[2], first_windowpane2, texture='wood_ikea_style.png') spacingC = 0.685 for k in range(0, 4): tmp = np.array([spacingC * k, 0, 0]) MiroAPI.add_boxShape(MiroSystem, v_windowpane_size[0], v_windowpane_size[1], v_windowpane_size[2], tmp + first_windowpane2, texture='wood_ikea_style.png') if k == 2: MiroAPI.add_boxShape(MiroSystem, v_windowpane_size[0], v_windowpane_size[1], v_windowpane_size[2], np.array([spacingC / 2, 0, 0]) + tmp + first_windowpane2, texture='wood_ikea_style.png') #horizontal windowpanes h_windowpane_size = np.array([0.05, 4.255, 0.01]) #horizontal window pane size #2nd window horizontal MiroAPI.add_boxShape(MiroSystem, h_windowpane_size[0], h_windowpane_size[1] + 0.6, h_windowpane_size[2], [1.51, 2 * H + 0.015, 4.985], rotZ=90, texture='wood_ikea_style.png') MiroAPI.add_boxShape(MiroSystem, h_windowpane_size[0], h_windowpane_size[1] + 0.6, h_windowpane_size[2], [1.51, 2 * H + 0.8, 4.985], rotZ=90, texture='wood_ikea_style.png') MiroAPI.add_boxShape(MiroSystem, h_windowpane_size[0], h_windowpane_size[1] + 0.6, h_windowpane_size[2], [1.51, 2 * H + 3 - 0.7, 4.985], rotZ=90, texture='wood_ikea_style.png') MiroAPI.add_boxShape(MiroSystem, h_windowpane_size[0], h_windowpane_size[1] + 0.6, h_windowpane_size[2], [1.51, 2 * H + 3, 4.985], rotZ=90, texture='wood_ikea_style.png') # This box is the window window_pos = [1.51, 2 * H + 1.5 + 0.4, 4.985 + 0.0025] MiroAPI.add_boxShape(MiroSystem, 0.0025, 3.0 - 0.8, h_windowpane_size[1] + 0.6 - 0.015, window_pos, rotY=90, color=[0.5, 0.6, 0.7, 0.4]) #1st window horizontal MiroAPI.add_boxShape(MiroSystem, h_windowpane_size[0], h_windowpane_size[1] + 0.36, h_windowpane_size[2], [-3, 2 * H + 0.015, 4.985], rotZ=90, texture='wood_ikea_style.png') MiroAPI.add_boxShape(MiroSystem, h_windowpane_size[0], h_windowpane_size[1] + 0.36, h_windowpane_size[2], [-3, 2 * H + 0.8, 4.985], rotZ=90, texture='wood_ikea_style.png') MiroAPI.add_boxShape(MiroSystem, h_windowpane_size[0], h_windowpane_size[1] + 0.36, h_windowpane_size[2], [-3, 2 * H + 3 - 0.7, 4.985], rotZ=90, texture='wood_ikea_style.png') MiroAPI.add_boxShape(MiroSystem, h_windowpane_size[0], h_windowpane_size[1] + 0.36, h_windowpane_size[2], [-3, 2 * H + 3, 4.985], rotZ=90, texture='wood_ikea_style.png') # This box is the window window_pos = [-3, 2 * H + 1.5 + 0.4, 4.985 + 0.0025] MiroAPI.add_boxShape(MiroSystem, 0.0025, 3.0 - 0.8, h_windowpane_size[1] + 0.36 - 0.015, window_pos, rotY=90, color=[0.5, 0.6, 0.7, 0.4]) #3rd window horizontal MiroAPI.add_boxShape(MiroSystem, h_windowpane_size[0], h_windowpane_size[1] / 2 + 0.3, h_windowpane_size[2], [5.25, 2 * H + 0.015, 4.985], rotZ=90, texture='wood_ikea_style.png') MiroAPI.add_boxShape(MiroSystem, h_windowpane_size[0], h_windowpane_size[1] / 2 + 0.3, h_windowpane_size[2], [5.25, 2 * H + 0.8, 4.985], rotZ=90, texture='wood_ikea_style.png') MiroAPI.add_boxShape(MiroSystem, h_windowpane_size[0], h_windowpane_size[1] / 2 + 0.3, h_windowpane_size[2], [5.25, 2 * H + 3 - 0.7, 4.985], rotZ=90, texture='wood_ikea_style.png') MiroAPI.add_boxShape(MiroSystem, h_windowpane_size[0], h_windowpane_size[1] / 2 + 0.3, h_windowpane_size[2], [5.25, 2 * H + 3, 4.985], rotZ=90, texture='wood_ikea_style.png') # This box is the window window_pos = [5.25, 2 * H + 1.5 + 0.4, 4.985 + 0.0025] MiroAPI.add_boxShape(MiroSystem, 0.0025, 3.0 - 0.8, h_windowpane_size[1] / 2 + 0.3 - 0.015, window_pos, rotY=90, color=[0.5, 0.6, 0.7, 0.4]) test_posS = np.array([posS[0] + 0.105, -0.16 + 0.025, posS[2]]) test_posE = np.array([posE[0], -0.16 + 0.025, posE[2] + 0.11]) make_window(v_windowpane_size[0], v_windowpane_size[1], v_windowpane_size[2], h_windowpane_size[0], h_windowpane_size[1], h_windowpane_size[2], test_posS, 'south', 0.685, MiroSystem) make_window(v_windowpane_size[0], v_windowpane_size[1], v_windowpane_size[2], h_windowpane_size[0], h_windowpane_size[1], h_windowpane_size[2], test_posE, 'east', 0.685, MiroSystem)
def make_window(size_vx, size_vy, size_vz, size_hx, size_hy, size_hz, mid_pos, wall, spacing, MiroSystem): #size_hx, size_hy, size_hz #wall sets orientation of window, set wall = 'south' or 'east' # pos sets position #and spacing sets the spacing between windowpanes H = 3.32 W = 4.6 dists = np.array([97, 207, 358, 436, 510, 654, 802, 876, 951, 1102, 1213]) dists = dists - (dists[-1] + dists[0]) / 2 dists = dists / dists[-1] * (W - 3 * 0.16) / 2 test = 0.085 if wall == 'south': #concrete part under and over windows for fl in range(3): bot_pos = mid_pos + np.array( [-0.104, 0.15 + fl * 3.32 + 0.8 / 2, 0]) top_pos = mid_pos + np.array( [-0.104, 0.15 + fl * 3.32 + 3.33 - 0.3 / 2, 0]) MiroAPI.add_boxShape(MiroSystem, 0.2, 0.8, W * 3, bot_pos, texture='white concrete.jpg', scale=[9, 12]) MiroAPI.add_boxShape(MiroSystem, 0.2, 0.3, W * 3, top_pos, texture='white concrete.jpg', scale=[9, 12]) for wid in range(3): left_pos = mid_pos + np.array( [-0.102, 1.5 * 3.32, -6.78 + wid * W]) right_pos = mid_pos + np.array( [-0.102, 1.5 * 3.32, -6.78 + W - 0.25 + wid * W]) MiroAPI.add_boxShape(MiroSystem, 0.2, 3.32 * 3, 0.25, left_pos, texture='white concrete.jpg', scale=[9, 12]) MiroAPI.add_boxShape(MiroSystem, 0.2, 3.32 * 3, 0.25, right_pos, texture='white concrete.jpg', scale=[9, 12]) for i in range(1, 6, 2): lvl_height = np.array([0, i / 2 * H, 0]) for j in [-1, 0, 1]: lvl_width = np.array([0, 0, j * W]) # This box is the windows. MiroAPI.add_boxShape(MiroSystem, 0.0025, 3.0 - 0.8, W - 3 * 0.16, mid_pos + lvl_width + lvl_height + np.array([-0.0025, 0.4, 0]), color=[0.5, 0.6, 0.7, 0.6]) for k in range(0, len(dists)): tmp = np.array([-0.005, 0, dists[k]]) result_pos = mid_pos + lvl_width + lvl_height + tmp MiroAPI.add_boxShape(MiroSystem, size_vx, size_vy, size_vz, result_pos, rotY=90, texture='wood_ikea_style.png') for n in [-1, 1]: hzt_pos = np.array([0, 3 / 2, 0]) r_hzt_pos = mid_pos + n * hzt_pos + lvl_height + lvl_width MiroAPI.add_boxShape(MiroSystem, size_hx, size_hy - test, size_hz, r_hzt_pos, rotX=90, rotZ=90, texture='wood_ikea_style.png') if n == -1: MiroAPI.add_boxShape(MiroSystem, size_hx, size_hy - test, size_hz, r_hzt_pos + np.array([0, 0.8 * n * (-1), 0]), rotX=90, rotZ=90, texture='wood_ikea_style.png') else: MiroAPI.add_boxShape(MiroSystem, size_hx, size_hy - test, size_hz, r_hzt_pos + np.array([0, 0.7 * n * (-1), 0]), rotX=90, rotZ=90, texture='wood_ikea_style.png') if wall == 'east': for fl in range(3): bot_pos = mid_pos + np.array( [0, 0.15 + fl * 3.32 + 0.8 / 2, -0.104]) top_pos = mid_pos + np.array( [0, 0.15 + fl * 3.32 + 3.32 - 0.3 / 2, -0.104]) MiroAPI.add_boxShape(MiroSystem, W * 3, 0.8, 0.2, bot_pos, texture='white concrete.jpg', scale=[9, 12]) MiroAPI.add_boxShape(MiroSystem, W * 3, 0.3, 0.2, top_pos, texture='white concrete.jpg', scale=[9, 12]) for wid in range(3): left_pos = mid_pos + np.array([-6.8 + wid * W, 1.5 * 3.32, -0.102]) right_pos = mid_pos + np.array( [-6.8 + W - 0.25 + wid * W, 1.5 * 3.32, -0.102]) MiroAPI.add_boxShape(MiroSystem, 0.25, 3.32 * 3, 0.2, left_pos, texture='white concrete.jpg', scale=[9, 12]) MiroAPI.add_boxShape(MiroSystem, 0.25, 3.32 * 3, 0.2, right_pos, texture='white concrete.jpg', scale=[9, 12]) for i in range(1, 6, 2): lvl_height = np.array([0, i / 2 * H, 0]) for j in [-1, 0, 1]: lvl_width = np.array([j * W, 0, 0]) # This box is the windows. if j != -1 or i != 5: MiroAPI.add_boxShape(MiroSystem, 0.0025, 3.0 - 0.8, W - 3 * 0.16, mid_pos + lvl_width + lvl_height + np.array([0, 0.4, -0.0025]), rotY=90, color=[0.5, 0.6, 0.7, 0.6]) for k in range(0, len(dists)): tmp = np.array([dists[k], 0, 0]) result_pos = mid_pos + lvl_width + lvl_height + tmp MiroAPI.add_boxShape(MiroSystem, size_vz, size_vy, size_vx, result_pos, rotY=90, texture='wood_ikea_style.png', Collide=(j != -1 or i != 5)) for n in [-1, 1]: hzt_pos = np.array([0, 3 / 2, -0.005]) r_hzt_pos = mid_pos + n * hzt_pos + lvl_height + lvl_width MiroAPI.add_boxShape(MiroSystem, size_hx, size_hy - test, size_hz, r_hzt_pos, rotZ=90, texture='wood_ikea_style.png') if n == -1: MiroAPI.add_boxShape(MiroSystem, size_hx, size_hy - test, size_hz, r_hzt_pos + np.array([0, 0.8 * n * (-1), 0]), rotZ=90, texture='wood_ikea_style.png') else: MiroAPI.add_boxShape(MiroSystem, size_hx, size_hy - test, size_hz, r_hzt_pos + np.array([0, 0.7 * n * (-1), 0]), rotZ=90, texture='wood_ikea_style.png')
def MIT_floors(system, H, SPEEDMODE): # Add floor, as a box floorsNum = 3 # Number of floors postNum = 19 # Number of fence post on each side of floors center position floor_l = 12 # Floor length floor_t = 0.08 # Floor thickness floor_w = 1.58 # Floor width towards NA floor_w_2 = 1.95 + 2.11 # towards technology house texture_floor = [ 'textures/MIT_stone_floor.jpg', 'textures/MIT_story_floor.jpg', 'textures/MIT_story_floor.jpg' ] texture_roof = 'textures/MIT_inner_roof.jpg' scale_roof = [80, 10] handle_l = 13.5 for floor in range(floorsNum): # Add floors y_pos = floor * H - floor_t floor_pos_1 = np.array([-3.5, y_pos, 6.58]) # Add floors towards NA floor_pos_2 = np.array([10.45 + 2.11, y_pos, -4 - 0.42 ]) # Add floors towards technology house floor_pos_3 = np.array([-10.2, y_pos, -7]) # Add floor in NTK cooriodor floor_pos_4 = np.array([1.5, y_pos, -13.45 ]) # Add floor in NTK cooriodor (-z direction) MiroAPI.add_boxShapeHemi(system, floor_l, floor_t, floor_w, floor_pos_1, texture_floor[floor], [50, 3.6]) MiroAPI.add_boxShapeHemi(system, floor_w_2, floor_t, floor_l + 0.58, floor_pos_2, texture_floor[floor], [18, 28]) MiroAPI.add_boxShapeHemi(system, 0.85, floor_t, floor_l, floor_pos_3, texture_floor[floor], [50, 3.6]) MiroAPI.add_boxShapeHemi(system, 7, floor_t, 0.85, floor_pos_4, texture_floor[floor], [18, 28]) if floor > 0 and SPEEDMODE == False: add_fence(system, H, postNum, floor_w, floor_w_2, floor, floor_t, handle_l) for roof in range(floorsNum): # Add roof y_pos = roof * H - 3 * floor_t #+0.025 roof_pos_1 = np.array([-3.5, y_pos, 6.58]) # Add roof towards NA roof_pos_2 = np.array([10.45 + 2.11, y_pos, -4 - 0.42]) # Add roof towards technology house roof_pos_3 = np.array([-10.2, y_pos, -7]) # Add roof in NTK cooriodor (-x direction) roof_pos_4 = np.array([1.5, y_pos, -13.45 ]) # Add roof in NTK cooriodor (-z direction) MiroAPI.add_boxShapeHemi(system, floor_l, floor_t, floor_w, roof_pos_1, texture_roof, [100, 10]) MiroAPI.add_boxShapeHemi(system, floor_w_2, floor_t, floor_l + 0.58, roof_pos_2, texture_roof, [35, 80]) MiroAPI.add_boxShapeHemi(system, 0.85, floor_t, floor_l, roof_pos_3, texture_roof, [35, 80]) MiroAPI.add_boxShapeHemi(system, 7, floor_t, 0.85, roof_pos_4, texture_roof, [100, 10]) # Office floors for floor in range(floorsNum): # Add floors y_pos = floor * H - floor_t floor_pos_3 = np.array([-7.425, y_pos, -7 ]) # Add roof in NTK cooriodor (-x direction) floor_pos_4 = np.array([1.5, y_pos, -10.8 ]) # Add roof in NTK cooriodor (-z direction) MiroAPI.add_boxShapeHemi(system, 1.925, floor_t, floor_l, floor_pos_3, 'wood_ikea_style.png', [35, 80]) MiroAPI.add_boxShapeHemi(system, 7, floor_t, 1.8, floor_pos_4, 'wood_ikea_style.png', [100, 10]) for roof in range(floorsNum): # Add roof y_pos = roof * H - 3 * floor_t roof_pos_3 = np.array([-7.425, y_pos, -7]) # Add roof in NTK cooriodor (-x direction) roof_pos_4 = np.array([1.5, y_pos, -10.8 ]) # Add roof in NTK cooriodor (-z direction) MiroAPI.add_boxShapeHemi(system, 1.925, floor_t, floor_l, roof_pos_3, texture_roof, [35, 80]) MiroAPI.add_boxShapeHemi(system, 7, floor_t, 1.8, roof_pos_4, texture_roof, [100, 10]) # Add floor piece by the stair floor_x = 1.03 floor_z = 1.03 for piece in range(floorsNum): y_pos = piece * H - floor_t * 0.999 floor_pos = np.array([7.5, y_pos + 0.002, 4]) MiroAPI.add_boxShapeHemi(system, floor_x, floor_t, floor_z, floor_pos, texture_floor[0], [4, 2]) for piece in range(floorsNum): if piece > 0: y_pos = piece * H - 3 * floor_t floor_pos = np.array([7.5, y_pos + 0.002, 4]) MiroAPI.add_boxShapeHemi(system, floor_x, floor_t, floor_z, floor_pos, texture_roof, [12, 9]) # Add walkway towards umu library length = 10.5 width = 2 for i in range(2): y = i * H + H - floor_t pos = np.array([10, y, 10.16]) MiroAPI.add_boxShapeHemi(system, length, floor_t, width, pos, texture_floor[1], [48.9, 6]) for i in range(2): y = i * H + H - 3 * floor_t pos = np.array([10, y, 10.16]) MiroAPI.add_boxShapeHemi(system, length, floor_t, width, pos, texture_roof, scale_roof) # Add MIT entrence floor pos = np.array([6.2, 0 - floor_t, 10.16]) MiroAPI.add_boxShapeHemi(system, 6.5, floor_t, 2, pos, texture_floor[0], [30, 6]) # Add horizontal beam along floors beam_length = 5.87 for floor in range(floorsNum): beam_corr_2 = floor_w_2 + 0.99 * floor_t / 2 # Technology beam_corr = floor_w + 0.99 * floor_t / 2 # Na if floor > 0: y_pos = floor * H - 2 * floor_t floor_pos_1 = np.array([0.63, y_pos, 6.58 - beam_corr]) # Towards NA floor_pos_2 = np.array([10.45 + 2.11 - beam_corr_2, y_pos, -2.9]) # Towards technology MiroAPI.add_boxShapeHemi(system, beam_length, 2 * floor_t, floor_t / 2, floor_pos_1, 'textures/white concrete.jpg') MiroAPI.add_boxShapeHemi(system, floor_t / 2, 2 * floor_t, beam_length, floor_pos_2, 'textures/white concrete.jpg')
def UNbox(MiroSystem, pos, goal_nr, skew): pos[1] = pos[1]+0.2 MiroAPI.add_boxShape(MiroSystem, 0.4, 0.4, 0.4, pos, density=8, rotY=skew, texture='UN_'+str(goal_nr)+'.png', Fixed=False)
def MIT_walls(system, H): # Add main walls as a box wall_t = 0.1 wall_h = 3 / 2 * H texture_wall = 'textures/yellow_brick.jpg' scale = [10, 10] # Texture scale pos_3_3 = np.array([-4.5, 0 + 3 / 2 * H, 8.16 + wall_t]) pos_3_4 = np.array([-4.5 - wall_t, 5 / 2 * H, 8.16 + wall_t]) MiroAPI.add_boxShapeHemi(system, 11, H / 2, wall_t, pos_3_3, texture_wall, [10, 10]) # Positive z direction MiroAPI.add_boxShapeHemi(system, 11 - wall_t, H / 2, wall_t, pos_3_4, texture_wall, [10, 10]) # Positive z direction # Add support colums as a box beam_h = 3 / 2 * H beam_w = 0.08 beam_pos_1 = np.array([4, 0 + beam_h, 5]) # Close left of stair beam_pos_2 = np.array([-0.8, 0 + 4 / 3 * beam_h, 5]) # Left of stair beam_pos_3 = np.array([8.5, 0 + beam_h, 0.5]) # Close right of stair beam_pos_4 = np.array([8.5, 0 + beam_h, -4.3]) # Right of stair beam_pos_5 = np.array([8.5, 0 + beam_h, 5]) # Middle beam MiroAPI.add_boxShapeHemi(system, beam_w, beam_h, beam_w, beam_pos_1, 'textures/white concrete.jpg', scale) MiroAPI.add_boxShapeHemi(system, beam_w, 2 / 3 * beam_h, beam_w, beam_pos_2, 'textures/white concrete.jpg', scale) MiroAPI.add_boxShapeHemi(system, beam_w, beam_h, beam_w, beam_pos_3, 'textures/white concrete.jpg', scale) MiroAPI.add_boxShapeHemi(system, beam_w, beam_h, beam_w, beam_pos_4, 'textures/white concrete.jpg', scale) MiroAPI.add_boxShapeHemi(system, beam_w, beam_h, beam_w, beam_pos_5, 'textures/white concrete.jpg', scale) # Beams along wall for beam in range(5): x = 12.75 + beam * 0.46 z = 8.16 + 0.05 + wall_t - beam * 4.47 beam_pos = np.array([x, 0 + beam_h, z]) MiroAPI.add_boxShapeHemi(system, beam_w, beam_h, beam_w, beam_pos, 'textures/white concrete.jpg', scale) #-------------2nd floor--------------- # Add wall, 2nd floor towards MIT place bWall_height = H / 2 - wall_t pos = np.array([-1.82, 0 + bWall_height, 5 + wall_t]) MiroAPI.add_boxShapeHemi(system, 3.48, bWall_height, wall_t, pos, 'textures/storage_wall.jpg', [12, 15]) # Add wall, 2nd floor towards NA (positive z direction) pos = np.array([-7, H / 2, 8.16 + wall_t]) MiroAPI.add_boxShapeHemi(system, 8.75 - wall_t, H / 2, wall_t, pos, 'textures/yellow_brick.jpg', [5, 5]) # Add entrence wall (positive x direction) pos = np.array([12.7 + wall_t, 0 + H / 2 - 0.1, 10.18]) MiroAPI.add_boxShapeHemi(system, wall_t, H / 2 - 0.1, 1.9, pos, 'textures/yellow_brick.jpg', [5, 5]) # Add entrence wall (negative x direction) pos = np.array([-0.4, 0 + H / 2 - 0.16, 9.86]) MiroAPI.add_boxShapeHemi(system, wall_t, H / 2 - 0.16, 1.5, pos, 'textures/door_cs.jpg', [4, 3], Collide=False) # Add entrence corridor (negative x direction) pos = np.array([0.65, 0 + H / 2 - 0.1, 11.41]) MiroAPI.add_boxShapeHemi(system, 1, H / 2 - 0.1, wall_t, pos, 'textures/white concrete.jpg', [5, 5]) # Add 2nd entrence wall (negative x direction) pos = np.array([1.6, 0 + H / 2 - 0.1, 6.5 + wall_t + 0.01 + 0.05]) MiroAPI.add_boxShapeHemi(system, wall_t, H / 2 - 0.1, 1.5 + wall_t + 0.05, pos, 'textures/yellow_brick.jpg', [5, 5]) #-------------3rd floor--------------- # Add wall, 3rd floor (negative x direction) MIT info screen pos = np.array([6.5 - wall_t, 0 + 3 / 2 * H - 0.16, 10.16 + wall_t]) MiroAPI.add_boxShapeHemi(system, wall_t, H / 2 - 0.16, 2 - wall_t, pos, 'textures/yellow_brick.jpg', [5, 5]) # Add wall, 3rd floor towards NA 1 (negative z direction) pos = np.array([-7.6, 0 + 3 / 2 * H, 5.65]) MiroAPI.add_boxShapeHemi(system, 1.75, H / 2, wall_t, pos, 'textures/white concrete.jpg', [10, 7]) # Add wall, 3rd floor towards NA 2 (negative z direction) pos = np.array([-11.3, 0 + 3 / 2 * H, 5.65]) MiroAPI.add_boxShapeHemi(system, 0.25, H / 2, wall_t, pos, 'textures/yellow_brick.jpg', [1, 1], False) # Add wall, 3rd floor corridor towards NTK (negative x direction) for wall in range(2): x = -11.05 + wall * (1.71 + wall_t) pos = np.array([x, 0 + 3 / 2 * H, 5.25]) MiroAPI.add_boxShapeHemi(system, wall_t, H / 2, 0.4, pos, 'textures/yellow_brick.jpg', [1, 1], False) # Add wall, 3rd floor NTK door (negative z direction) # pos = np.array([-10.2, 0+3/2*H, 5]) # MiroAPI.add_boxShapeHemi(system, 0.85, H/2, wall_t, pos, 'textures/door_ntk.jpg', [-4,-3], False) # Add wall, 3rd floor NA corridor end (negative x direction) pos = np.array([-11.55, 3 / 2 * H - 0.16, 6.95]) MiroAPI.add_boxShapeHemi(system, wall_t, H / 2 - 0.16, 1.25, pos, 'textures/mit_3rd_na2.jpg', [4, 3]) # Add wall, 3rd floor towards MIT fountain pos = np.array([11.65, 3 / 2 * H, 12.16 + wall_t]) MiroAPI.add_boxShapeHemi(system, 5.15, H / 2, wall_t, pos, 'textures/yellow_brick.jpg', [5, 5]) # Add wall, 3rd floor wall, left hand side towards UMU library (negative z direction) pos = np.array([18.3, 3 / 2 * H - wall_t, 12.16 + wall_t]) MiroAPI.add_boxShapeHemi(system, 1.5, H / 2 - wall_t, wall_t, pos, 'textures/white concrete.jpg', [3, 3]) # Add wall, 3rd floor UMU library end (negative x direction) pos = np.array([19.9, 3 / 2 * H - 0.16, 10.56]) MiroAPI.add_boxShapeHemi(system, wall_t, H / 2 - 0.16, 1.6, pos, 'textures/mit_3rd_sam.jpg', [-4, -3]) #-------------4th floor--------------- # Add wall, 4th floor flower pot (Negative x direction) pos = np.array([6.5 - wall_t + 0.01, 5 / 2 * H, 7.08 + wall_t + 0.01]) MiroAPI.add_boxShapeHemi(system, wall_t, H / 2, 2.08 + wall_t, pos, 'textures/white concrete.jpg', [5, 5]) # Add wall, 4th floor data cooridor (negative x direction) pos = np.array([5.5 - wall_t, 0 + 5 / 2 * H, 10.66 + wall_t]) MiroAPI.add_boxShapeHemi(system, wall_t, H / 2, 1.5 - wall_t, pos, 'textures/door_cs.jpg', [4, 3], Collide=False) # Add 4th floor wall (positive x direction) pos = np.array([12.7 + wall_t, 0 + 5 / 2 * H, 10.18]) MiroAPI.add_boxShapeHemi(system, wall_t, H / 2, 1.9, pos, 'textures/yellow_brick.jpg', [2, 2]) # Add wall, 4th floor towards NA (negative z direction) pos = np.array([-9.3 - wall_t, 0 + 5 / 2 * H, 5 - wall_t]) MiroAPI.add_boxShapeHemi(system, 4 - wall_t, H / 2, wall_t, pos, 'textures/yellow_brick.jpg', [10, 7], False) # Add wall, 4th floor wall towards MIT fountain pos = np.array([9, 5 / 2 * H, 12.16 + wall_t]) MiroAPI.add_boxShapeHemi(system, 3.5, H / 2, wall_t, pos, 'textures/white concrete.jpg', [5, 5]) #----------------Other---------------- # Add white wall extension, technology pos = np.array([9.9, 3 / 2 * H, -8.8 - wall_t]) MiroAPI.add_boxShapeHemi(system, 1.4, 3 / 2 * H, wall_t, pos, 'textures/white concrete.jpg', [5, 5]) # Add wall towards technology building (negative x direction) pos = np.array([8.5 - wall_t + 2.8, 0 + 3 / 2 * H, -11.8 - wall_t + 1.1]) MiroAPI.add_boxShapeHemi(system, wall_t, 3 / 2 * H, 1.9 - wall_t, pos, 'textures/white concrete.jpg', [10, 10]) # Add office cooridor wall (negative x direction) pos = np.array([-11.05, 0 + 3 / 2 * H, -7]) MiroAPI.add_boxShapeHemi(system, wall_t, 3 / 2 * H, 12, pos, 'textures/white concrete.jpg', [10, 10]) # Add office wall (negative x direction) pos = np.array([-9.35, 0 + 3 / 2 * H, -1.9]) MiroAPI.add_boxShapeHemi(system, wall_t, 3 / 2 * H, 6.9, pos, 'textures/white concrete.jpg', [10, 10]) # Add office wall (negative z direction) pos = np.array([1.5, 0 + 3 / 2 * H, -12.6]) MiroAPI.add_boxShapeHemi(system, 7, 3 / 2 * H, wall_t, pos, 'textures/white concrete.jpg', [10, 10]) # Add office cooridor wall (negative z direction) pos = np.array([1.5, 0 + 3 / 2 * H, -14.3]) MiroAPI.add_boxShapeHemi(system, 7, 3 / 2 * H, wall_t, pos, 'textures/white concrete.jpg', [10, 10]) # Add office end pos = np.array([-8.5, 0 + 3 / 2 * H, -19]) MiroAPI.add_boxShapeHemi(system, 2.65, 3 / 2 * H, wall_t, pos, 'textures/white concrete.jpg', [10, 10]) # Add elevator shaft for floor in range(3): y_pos = H * floor + H / 2 pos = np.array([10.7, y_pos, 12.1]) MiroAPI.add_boxShapeHemi(system, 2.034, H / 2, wall_t, pos, 'textures/elevator.png', [4, 3]) # Add end wall, towards technology texture = [ 'textures/mit_4th.jpg', 'textures/mit_4th.jpg', 'textures/mit_4th.jpg' ] for floor in range(3): y_pos = H * floor + H / 2 pos = np.array([10.5 + 2.8 - 0.23, y_pos, -17 + 2.2 + 2.2]) MiroAPI.add_boxShapeHemi(system, 1.77, H / 2, wall_t, pos, texture[floor], [-4, -3], Collide=False) #Add oblique walls n = np.array([0, 1, 0]) # Normal vector for rotation alpha = -np.arctan(211 / 1380 - 0.05) # Rotation angle for positive x wall #Add oblique wall towards umu libary pos_1 = np.array([16.3, 3 / 2 * H - wall_t, 0.34 + 8.16 + wall_t]) dim_1 = np.array([wall_t, H / 2, 3.6]) ang_1 = np.pi * (0.5 - 0.03) sca_1 = [10, 10] #Add oblique wall towards NA pos_2 = np.array([-5.6 - wall_t, 3 / 2 * H, 5.3]) dim_2 = np.array([wall_t, H / 2, 0.545]) ang_2 = -(np.pi / 4) #Main wall in positive x direction pos_3 = np.array([13.775 + wall_t, 0, -2.2]) + np.array([0, wall_h, 0]) ang_3 = alpha dim_3 = np.array([wall_t, wall_h, 10.58]) pos_ob = [pos_1, pos_2, pos_3] dim = [dim_1, dim_2, dim_3] ang = [ang_1, ang_2, ang_3] textures = [texture_wall, 'textures/white concrete.jpg', texture_wall] scale = [sca_1, sca_1, sca_1] for i in range(len(pos_ob)): # Create a box MiroAPI.add_boxShapeHemi(system, dim[i][0], dim[i][1], dim[i][2], pos_ob[i], rotY=ang[i], rotDegrees=False, texture=textures[i], scale=scale[i])
def trialsurface(MiroSystem, target): nx = 10 dz = 1.4 diag = 0.2 eps = 0.008 box_side = diag/np.sqrt(2) h = diag/2 for i in range(nx): pos = np.array([target[0] - (nx - 1 - 2*i)*diag/2, target[1]-h, target[2]]) MiroAPI.add_boxShape(MiroSystem, box_side, box_side, dz, pos, rotZ=45, texture='white concrete.jpg') th = 1.2*h pos = np.array([target[0], target[1]-h-th/2, target[2]]) MiroAPI.add_boxShape(MiroSystem, nx*diag+2*eps, th, dz+2*eps, pos, texture='wood_ikea_style.png') r = 0.03 h = target[1]-th-h d = 0.1 # [+, +] pos = np.array([target[0] + nx*diag/2 - d, h/2, target[2] + dz/2 -d]) MiroAPI.add_cylinderShape(MiroSystem, r, h, 2500, pos, 'chrome.png', scale=[2,2]) # [-, +] pos = np.array([target[0] - nx*diag/2 + d, h/2, target[2] + dz/2 -d]) MiroAPI.add_cylinderShape(MiroSystem, r, h, 2500, pos, 'chrome.png', scale=[2,2]) # [-, -] pos = np.array([target[0] - nx*diag/2 + d, h/2, target[2] - dz/2 +d]) MiroAPI.add_cylinderShape(MiroSystem, r, h, 2500, pos, 'chrome.png', scale=[2,2]) # [+, -] pos = np.array([target[0] + nx*diag/2 - d, h/2, target[2] - dz/2 +d]) MiroAPI.add_cylinderShape(MiroSystem, r, h, 2500, pos, 'chrome.png', scale=[2,2])
def AddToSystem(self, system): MiroAPI.add_boxShape(system, self.width, self.height, 0.05, self.position, 'textures/notifboard.png', rotX=self.tilt_angle, rotY=self.turn_angle, rotDegrees=False) self.bulb = MiroAPI.add_sphereShape(system, self.radius, self.position+self.bulb_pos, 'textures/notifbulb.png', rotX=self.tilt_angle+np.pi/2, rotY=self.turn_angle, rotDegrees=False)
def painting(MiroSystem, pos, text = 'DemoBengan.png', rot = 0, dims = [1, 0.6]): MiroAPI.add_boxShapeHemi(MiroSystem, dims[0], dims[1], 0.05, pos, rotY=rot, texture=text, Collide=False)
def Set_Ready(self): MiroAPI.rotateBody(self.bulb, rotAngle=-180, rotAxis=self.bulb_pos)
def pokeball(MiroSystem, pos, rot = 0): r = 0.05 MiroAPI.add_sphereShape(MiroSystem, r, [pos[0], pos[1]+r, pos[2]], texture='pokeball.jpg', density = 100, Fixed=False, rotY=rot)
def Add(self, Object): '''Adds a ChBody/agxRigidBody or similar to the underlying system.''' MiroAPI.AddObjectByAPI(self.system_list, Object)
def table_leg(MiroSystem, leg_pos, size_leg_r, size_leg_h): # creating the cylinder leg return MiroAPI.add_cylinderShape(MiroSystem, size_leg_r, size_leg_h, 1200, leg_pos, texture='chrome.png', Fixed=FIXED)