iFiles = glob.glob("textures/water/n_norm???.png") iFiles.sort() # order is vital to animation! for f in iFiles: waterbump.append(Texture(f)) num_n = len(waterbump) shapeshine = Texture("textures/stars.jpg") #Create shape myshape = MergeShape() num = (2, 2) asphere = Sphere(sides=32) for i in range(num[0]): for j in range(num[1]): myshape.add(asphere, -num[0]*0.9 + 1.8*i, -num[1]*0.9 +1.8*j, 0.0) myshape.position(0.0, 0.0, 5) myshape.set_draw_details(shader, [shapeimg, shapebump, shapeshine], 1.0, 0.1) myshape.set_material((1.0, 0.5, 0.2, 0.5)) mywater = Plane(w=130.0, h=130.0) mywater.set_draw_details(matsh, [waterbump[0], shapeshine], 12.0, 0.6) mywater.set_material((0.0, 0.05, 0.1)) mywater.set_fog((0.4, 0.6, 0.8, 0.0),150) mywater.rotateToX(90.001) mywater.position(0.0, -2.0, 0.0) arialFont = Ttffont("fonts/FreeMonoBoldOblique.ttf", "#dd00aa") #load ttf font and set the font colour to 'raspberry' mystring = String(font=arialFont, string="Now the Raspberry Pi really does rock") mystring.translate(0.0, 0.0, 1) mystring.set_shader(flatsh)
Light((0, 5, 0)) #create shaders shader = Shader("shaders/uv_reflect") flatsh = Shader("shaders/uv_flat") defocus = Defocus() #Create textures shapeimg = Texture("textures/straw1.jpg") shapebump = Texture("textures/floor_nm.jpg", True) shapeshine = Texture("textures/pong3.png") #Create shape myshape = MergeShape(camera=persp_cam) #specify perspective view asphere = Sphere(sides=16, slices=16) myshape.radialCopy(asphere, step=72) myshape.position(0.0, 0.0, 5.0) myshape.set_draw_details(shader, [shapeimg, shapebump, shapeshine], 8.0, 0.1) mysprite = Sprite(w=10.0, h=10.0, camera=persp_cam) mysprite.position(0.0, 0.0, 15.0) mysprite.set_draw_details(flatsh, [shapebump]) tick=0 next_time = time.time()+2.0 #load ttf font and set the font colour to 'raspberry' arialFont = Ttffont("fonts/FreeMonoBoldOblique.ttf", "#dd00aa") mystring = String(font=arialFont, string="blurring with distance!", camera=ortho_cam, z=1.0, is_3d=False) # orthographic view mystring.set_shader(flatsh)
iFiles.sort() # order is vital to animation! for f in iFiles: waterbump.append(Texture(f)) num_n = len(waterbump) shapeshine = Texture("textures/stars.jpg") #Create shape myshape = MergeShape() num = (2, 2) asphere = Sphere(sides=32) for i in range(num[0]): for j in range(num[1]): myshape.add(asphere, -num[0] * 0.9 + 1.8 * i, -num[1] * 0.9 + 1.8 * j, 0.0) myshape.position(0.0, 0.0, 5) myshape.set_draw_details(shader, [shapeimg, shapebump, shapeshine], 1.0, 0.1) myshape.set_material((1.0, 0.5, 0.2, 0.5)) mywater = Plane(w=130.0, h=130.0) mywater.set_draw_details(matsh, [waterbump[0], shapeshine], 12.0, 0.6) mywater.set_material((0.0, 0.05, 0.1)) mywater.set_fog((0.4, 0.6, 0.8, 0.0), 150) mywater.rotateToX(90.001) mywater.position(0.0, -2.0, 0.0) arialFont = Ttffont( "fonts/FreeMonoBoldOblique.ttf", "#dd00aa") #load ttf font and set the font colour to 'raspberry' mystring = String(font=arialFont, string="Now the Raspberry Pi really does rock")
Light((0, 5, 0)) #create shaders shader = Shader("shaders/uv_reflect") flatsh = Shader("shaders/uv_flat") defocus = Defocus() #Create textures shapeimg = Texture("textures/straw1.jpg") shapebump = Texture("textures/floor_nm.jpg", True) shapeshine = Texture("textures/pong3.png") #Create shape myshape = MergeShape(camera=persp_cam) #specify perspective view asphere = Sphere(sides=16, slices=16) myshape.radialCopy(asphere, step=72) myshape.position(0.0, 0.0, 5.0) myshape.set_draw_details(shader, [shapeimg, shapebump, shapeshine], 8.0, 0.1) mysprite = Sprite(w=10.0, h=10.0, camera=persp_cam) mysprite.position(0.0, 0.0, 15.0) mysprite.set_draw_details(flatsh, [shapebump]) tick = 0 next_time = time.time() + 2.0 #load ttf font and set the font colour to 'raspberry' arialFont = Ttffont("fonts/FreeMonoBoldOblique.ttf", "#dd00aa") mystring = String(font=arialFont, string="blurring with distance!", camera=ortho_cam, z=1.0,
# Display scene and rotate cuboid CAMERA = Camera.instance() while DISPLAY.loop_running(): CAMERA.reset() #tilt can be used as a means to prevent the view from going under the landscape! if tilt < -1: sf = 15 - 12.5/abs(tilt) else: sf = 2.5 xoff = sf*math.sin(math.radians(rot)) yoff = abs(1.25*sf*math.sin(math.radians(tilt))) + 3.25 zoff = -sf*math.cos(math.radians(rot)) CAMERA.rotate(tilt, rot, 0) CAMERA.position((xm + xoff, ym + yoff, zm + zoff)) #zoom CAMERA out so we can see our robot #draw robot robot.position(xm, ym, zm) robot.rotateToY(-rot) robot.draw() station.draw() mymap.draw() #Draw the landscape myecube.draw() #Draw environment cube myecube.position(xm, ym, zm) mx, my = mymouse.position() #if mx>DISPLAY.left and mx<DISPLAY.right and my>DISPLAY.top and my<DISPLAY.bottom: rot -= (mx-omx) * 0.2 tilt += (my-omy) * 0.1 omx = mx omy = my
CAMERA = Camera.instance() while DISPLAY.loop_running(): CAMERA.reset() #tilt can be used as a means to prevent the view from going under the landscape! if tilt < -1: sf = 15 - 12.5 / abs(tilt) else: sf = 2.5 xoff = sf * math.sin(math.radians(rot)) yoff = abs(1.25 * sf * math.sin(math.radians(tilt))) + 3.25 zoff = -sf * math.cos(math.radians(rot)) CAMERA.rotate(tilt, rot, 0) CAMERA.position((xm + xoff, ym + yoff, zm + zoff)) #zoom CAMERA out so we can see our robot #draw robot robot.position(xm, ym, zm) robot.rotateToY(-rot) robot.draw() station.draw() mymap.draw() #Draw the landscape myecube.draw() #Draw environment cube myecube.position(xm, ym, zm) mx, my = mymouse.position() #if mx>DISPLAY.left and mx<DISPLAY.right and my>DISPLAY.top and my<DISPLAY.bottom: rot -= (mx - omx) * 0.2 tilt += (my - omy) * 0.1 omx = mx omy = my