def create(radius, diffuse = (1,1,1,1)): """ Creates a sphere of given radius. Origin at the center of the sphere. """ v = [[c * radius for c in vertex] for vertex in Sphere.vertices] mesh = Mesh(v, Sphere.faces, Sphere.normals, diffuse) mesh.aabb = ((2*radius, 2*radius, 2*radius), (-2*radius, -2*radius, -2*radius)) return mesh
def create(radius, diffuse=(1, 1, 1, 1)): """ Creates a sphere of given radius. Origin at the center of the sphere. """ v = [[c * radius for c in vertex] for vertex in Sphere.vertices] mesh = Mesh(v, Sphere.faces, Sphere.normals, diffuse) mesh.aabb = ((2 * radius, 2 * radius, 2 * radius), (-2 * radius, -2 * radius, -2 * radius)) return mesh
def create(sizex, sizey, sizez, diffuse = (1,1,1,1)): """ Creates a box, centered around the origin. To create a cube, set sizex=sizey=sizez. """ sizex = float(sizex)/2 sizey = float(sizey)/2 sizez = float(sizez)/2 v = [[vertex[0] * sizex, vertex[1] * sizey, vertex[2] * sizez] for vertex in Box.vertices] mesh = Mesh(v, Box.faces, Box.normals, diffuse) mesh.aabb = ((sizex, sizey, sizez), (-sizex, -sizey, -sizez)) return mesh
def create(sizex, sizey, sizez, diffuse=(1, 1, 1, 1)): """ Creates a box, centered around the origin. To create a cube, set sizex=sizey=sizez. """ sizex = float(sizex) / 2 sizey = float(sizey) / 2 sizez = float(sizez) / 2 v = [[vertex[0] * sizex, vertex[1] * sizey, vertex[2] * sizez] for vertex in Box.vertices] mesh = Mesh(v, Box.faces, Box.normals, diffuse) mesh.aabb = ((sizex, sizey, sizez), (-sizex, -sizey, -sizez)) return mesh