def plinths(fish, num_plinths, z_offset, v_offset, edge_x, edge_y, edge_z) : alpha = len(fish.vertex) print('plinths starting @ vertex #', alpha) # radians for rotations theta = math.radians(360/num_plinths) # divide circle into num_plinths segments # 1st plinth first_pt = [0.0, v_offset, z_offset] fish.append_vertex(first_pt[0], first_pt[1], first_pt[2]) #0 fish.append_vertex(first_pt[0] + edge_x, first_pt[1], first_pt[2]) #1 fish.append_vertex(first_pt[0] + edge_x, first_pt[1] + edge_y, first_pt[2]) #2 fish.append_vertex(first_pt[0] + edge_x, first_pt[1] + edge_y, first_pt[2] + edge_z) #3 fish.append_vertex(first_pt[0], first_pt[1] + edge_y, first_pt[2] + edge_z) #4 fish.append_vertex(first_pt[0], first_pt[1], first_pt[2] + edge_z) #5 fish.append_vertex(first_pt[0] + edge_x, first_pt[1], first_pt[2] + edge_z) #6 fish.append_vertex(first_pt[0], first_pt[1] + edge_y, first_pt[2]) #7 for i in range(num_plinths) : # vertices for pt in range(8) : new_vert = simple3d.rotY(fish.vertex[alpha+pt], theta) fish.append_vertex(new_vert[0], new_vert[1], new_vert[2]) # edges color = simple3d.getRandomDarkColor() fish.append_edge(alpha, alpha + 1, color[0], color[1], color[2], 1.) fish.append_edge(alpha + 1, alpha + 2, color[0], color[1], color[2], 1.) fish.append_edge(alpha + 2, alpha + 3, color[0], color[1], color[2], 1.) fish.append_edge(alpha + 3, alpha + 4, color[0], color[1], color[2], 1.) fish.append_edge(alpha + 4, alpha + 5, color[0], color[1], color[2], 1.) fish.append_edge(alpha + 5, alpha + 6, color[0], color[1], color[2], 1.) fish.append_edge(alpha, alpha + 7, color[0], color[1], color[2], 1.) fish.append_edge(alpha, alpha + 5, color[0], color[1], color[2], 1.) fish.append_edge(alpha + 6, alpha + 1, color[0], color[1], color[2], 1.) fish.append_edge(alpha + 6, alpha + 3, color[0], color[1], color[2], 1.) fish.append_edge(alpha + 7, alpha + 4, color[0], color[1], color[2], 1.) fish.append_edge(alpha + 7, alpha + 2, color[0], color[1], color[2], 1.) # faces # ...front colorf = simple3d.getRandomColor() fish.append_face(alpha, alpha + 2, alpha + 1, colorf[0], colorf[1], colorf[2], 1.) fish.append_face(alpha, alpha + 7, alpha + 2, colorf[0], colorf[1], colorf[2], 1.) # ...back colorf = simple3d.getRandomColor() fish.append_face(alpha + 3, alpha + 4, alpha + 5, colorf[0], colorf[1], colorf[2], 1.) fish.append_face(alpha + 3, alpha + 5, alpha + 6, colorf[0], colorf[1], colorf[2], 1.) # ...left colorf = simple3d.getRandomColor() fish.append_face(alpha + 4, alpha + 7, alpha, colorf[0], colorf[1], colorf[2], 1.) fish.append_face(alpha + 4, alpha, alpha + 5, colorf[0], colorf[1], colorf[2], 1.) # ...right colorf = simple3d.getRandomColor() fish.append_face(alpha + 1, alpha + 3, alpha + 6, colorf[0], colorf[1], colorf[2], 1.) fish.append_face(alpha + 1, alpha + 2, alpha + 3, colorf[0], colorf[1], colorf[2], 1.) # ...top colorf = simple3d.getRandomColor() fish.append_face(alpha + 2, alpha + 4, alpha + 3, colorf[0], colorf[1], colorf[2], 1.) fish.append_face(alpha + 2, alpha + 7, alpha + 4, colorf[0], colorf[1], colorf[2], 1.) # ...bottom colorf = simple3d.getRandomColor() fish.append_face(alpha, alpha + 1, alpha + 5, colorf[0], colorf[1], colorf[2], 1.) fish.append_face(alpha + 1, alpha + 6, alpha + 5, colorf[0], colorf[1], colorf[2], 1.) alpha += 8
color = simple3d.getRandomDarkColor() fish.append_edge(alpha, alpha + 1, color[0], color[1], color[2], 1.) fish.append_edge(alpha + 1, alpha + 2, color[0], color[1], color[2], 1.) fish.append_edge(alpha + 2, alpha + 3, color[0], color[1], color[2], 1.) fish.append_edge(alpha + 3, alpha + 4, color[0], color[1], color[2], 1.) fish.append_edge(alpha + 4, alpha + 5, color[0], color[1], color[2], 1.) fish.append_edge(alpha + 5, alpha + 6, color[0], color[1], color[2], 1.) fish.append_edge(alpha, alpha + 7, color[0], color[1], color[2], 1.) fish.append_edge(alpha, alpha + 5, color[0], color[1], color[2], 1.) fish.append_edge(alpha + 6, alpha + 1, color[0], color[1], color[2], 1.) fish.append_edge(alpha + 6, alpha + 3, color[0], color[1], color[2], 1.) fish.append_edge(alpha + 7, alpha + 4, color[0], color[1], color[2], 1.) fish.append_edge(alpha + 7, alpha + 2, color[0], color[1], color[2], 1.) # faces # front colorf = simple3d.getRandomColor() fish.append_face(alpha, alpha + 2, alpha + 1, colorf[0], colorf[1], colorf[2], 1.) fish.append_face(alpha, alpha + 7, alpha + 2, colorf[0], colorf[1], colorf[2], 1.) # back colorf = simple3d.getRandomColor() fish.append_face(alpha + 3, alpha + 4, alpha + 5, colorf[0], colorf[1], colorf[2], 1.) fish.append_face(alpha + 3, alpha + 5, alpha + 6, colorf[0], colorf[1], colorf[2], 1.) # left colorf = simple3d.getRandomColor() fish.append_face(alpha + 4, alpha + 7, alpha, colorf[0], colorf[1], colorf[2], 1.) fish.append_face(alpha + 4, alpha, alpha + 5, colorf[0], colorf[1],
fish.append_vertex(first_pt[0], first_pt[1], first_pt[2]) new_pt = first_pt last_pt_idx = 0 for lat in range(lat_lines): new_pt = simple3d.rotZ(new_pt, theta) fish.append_vertex(new_pt[0], new_pt[1], new_pt[2]) last_pt_idx += 1 #fish.connect_last(0.0, 0.0, 0.0, 1.) lat_start = last_pt_idx new_lat_pt = new_pt for long in range(long_lines): new_lat_pt = simple3d.rotY(new_lat_pt, rho) fish.append_vertex(new_lat_pt[0], new_lat_pt[1], new_lat_pt[2]) last_pt_idx += 1 fish.connect_last(0.0, 0.0, 0.0, 1.) color = simple3d.getRandomColor() if lat_start + long + (long_lines + 1) <= (long_lines + 1) * lat_lines: fish.append_edge(last_pt_idx, lat_start + long, 0.0, 0.0, 0.0, 1.) fish.append_edge(last_pt_idx, lat_start + long + (long_lines + 1), 0.0, 0.0, 0.0, 1.) fish.append_face(last_pt_idx, lat_start + long, lat_start + long + (long_lines + 1), color[0], color[1], color[2], 1.) fish.append_edge(lat_start, last_pt_idx, 0.0, 0.0, 0.0, 1.0) # closes the circle if lat_start + (long_lines + 1) + long_lines <= (long_lines + 1) * lat_lines: fish.append_edge(lat_start, last_pt_idx, 0.0, 0.0, 0.0, 1.0) fish.append_edge(lat_start, lat_start + (long_lines + 1) + long_lines, 0.0, 0.0, 0.0, 1.0) #fish.append_face(lat_start, last_pt_idx, lat_start + (long_lines+1) + long_lines, 0.0, 0.0, 0.0, 1.0)