def make_mesh(self, subdivision_level=1): from math3d_point_cloud import PointCloud from math3d_transform import AffineTransform spine = self.line_segment.point_b - self.line_segment.point_a spine_length = spine.length() transform = AffineTransform().make_frame(spine, self.line_segment.point_a) count = 4 * (subdivision_level + 1) point_cloud = PointCloud() for i in range(count): angle = 2.0 * math.pi * float(i) / float(count) vertex = Vector(self.radius * math.cos(angle), self.radius * math.sin(angle), 0.0) point_cloud.point_list.append(transform(vertex)) point_cloud.point_list.append( transform(vertex + Vector(0.0, 0.0, spine_length))) return point_cloud.find_convex_hull()
def __init__(self, x_axis=None, y_axis=None, z_axis=None, translation=None): super().__init__() self.linear_transform = LinearTransform(x_axis, y_axis, z_axis) self.translation = translation.clone( ) if translation is not None else Vector(0.0, 0.0, 0.0)
def _render_puzzle(self, mesh_list): glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) viewport = glGetIntegerv(GL_VIEWPORT) width = viewport[2] height = viewport[3] aspect_ratio = float(width) / float(height) glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(60.0, aspect_ratio, 0.1, 1000.0) glMatrixMode(GL_MODELVIEW) glLoadIdentity() gluLookAt(0.0, 0.0, 4.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0) orient = Vector(35.0, -45.0, 0.0) glPushMatrix() glRotatef(orient.x, 1.0, 0.0, 0.0) glRotatef(orient.y, 0.0, 1.0, 0.0) glRotatef(orient.z, 0.0, 0.0, 1.0) #glEnable(GL_LIGHTING) glDisable(GL_LIGHTING) for mesh in mesh_list: if mesh.alpha > 0.0: mesh.render() glDisable(GL_LIGHTING) for mesh in mesh_list: if mesh.alpha > 0.0: mesh.render_border() glPopMatrix() glFlush()