from Togra import * from TograUtil import * import Image GL_RGB = 0x1907 SLICES=30 SEGS=20 im = Image.open("IMG_1716.JPG") im = im.resize((1024, 1024)) scene = init() pauseQuitKeystrokes(scene) my_sphere = sphere(0, 0, 0, 10, SLICES, SEGS) sphere_texCoords_top = FloatList() sphere_texCoords_bottom = FloatList() sphere_texCoords_top.append(0.5) sphere_texCoords_top.append(0.0) sphere_texCoords_bottom.append(0.5) sphere_texCoords_bottom.append(1.0) for i in range(SEGS + 1): sphere_texCoords_top.append(1 - i/float(SEGS)) sphere_texCoords_top.append(1/float(SLICES)) sphere_texCoords_bottom.append(i/float(SEGS)) sphere_texCoords_bottom.append(1 - 1/float(SLICES)) for i in range(SLICES - 2): tc_temp = FloatList() for j in range(SEGS + 1): tc_temp.append(j / float(SEGS)) tc_temp.append((i+2)/float(SLICES)) tc_temp.append(j / float(SEGS)) tc_temp.append((i+1)/float(SLICES)) my_sphere[i + 1].textureCoords = tc_temp my_sphere[0].textureCoords = sphere_texCoords_top my_sphere[SLICES-1].textureCoords = sphere_texCoords_bottom m = Material(0.5, 0.5, 0.5, 1) m.setTexture(im.tostring(), 1024, 1024, GL_RGB) my_sphere.setMaterial(m) my_sphere.setPath(rotatePath(Vector(0,1,0), 6500)) scene.baseContainer.append(my_sphere) scene.baseContainer.setPath(rotatePath(Vector(0,0,1), 10000)) scene.run()