# Setting 2nd param to True renders 'True' Blending # (this can be changed later to 'False' with 'rockimg2.blend = False') groundimg = Texture("textures/stripwood.jpg") monstimg = Texture("textures/pong3.png") ballimg = Texture("textures/pong2.jpg") # environment cube ectex = Texture("textures/ecubes/skybox_stormydays.jpg") myecube = EnvironmentCube(camera, light, 900.0, "CROSS") myecube.set_draw_details(flatsh, [ectex]) #ball maxdsz = 0.3 radius = 1.0 ball = Sphere(camera, light, radius, 12, 12, 0.0, "sphere", -4, 8, -7) # Shape.set_draw_details is a wrapper for calling the method on each item in buf # as is done explicitly here for no reason than to show that it can be done! ball.buf[0].set_draw_details(shader, [ballimg], 0.0, 0.0) #monster monster = Plane(camera, light, 5.0, 5.0, "monster", 0, 0, 0, 0, 0, 0) monster.buf[0].set_draw_details(flatsh, [monstimg]) # Create elevation map mapwidth = 50.0 mapdepth = 50.0 maphalf = 22.0 mapheight = 40.0 mymap = ElevationMap("textures/pong.jpg",
mytrees1.set_draw_details(flatsh, [tree2img], 0.0, 0.0) mytrees1.set_fog(*TFOG) mytrees2 = MergeShape(name="trees2") mytrees2.cluster(treemodel2.buf[0], mymap, 0.0, 0.0, 100.0, 100.0, 30, "", 6.0, 3.0) mytrees2.set_draw_details(flatsh, [tree1img], 0.0, 0.0) mytrees2.set_fog(*TFOG) mytrees3 = MergeShape(name="trees3") mytrees3.cluster(treemodel2, mymap, 0.0, 0.0, 300.0, 300.0, 30, "", 4.0, 2.0) mytrees3.set_draw_details(flatsh, [hb2img], 0.0, 0.0) mytrees3.set_fog(*TFOG) #Create monolith monolith = Sphere(radius=8.0, slices=12, sides=48, sy=10.0, name="monolith") monolith.translate(100.0, -mymap.calcHeight(100.0, 350) + 10.0, 350.0) monolith.set_draw_details(shader, [rockimg, bumpimg, reflimg], 32.0, 0.3) monolith.set_fog(*FOG) #screenshot number scshots = 1 #avatar camera rot = 0.0 tilt = 0.0 avhgt = 3.5 xm = 0.0 zm = 0.0 ym = mymap.calcHeight(xm, zm) + avhgt
#setup textures, light position and initial model position 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!",
#Create textures shapeimg = Texture("textures/straw1.jpg") shapebump = Texture("textures/mudnormal.jpg") waterbump = [] 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)
mapdepth = 1000.0 mapheight = 60.0 mountimg1 = Texture("textures/mars_colour.png") bumpimg = Texture("textures/mudnormal.jpg") mymap = ElevationMap(mapfile="textures/mars_height.png", width=mapwidth, depth=mapdepth, height=mapheight, divx=128, divy=128) mymap.set_draw_details(shader, [mountimg1, bumpimg], 128.0, 0.0) mymap.set_fog((0.3, 0.15, 0.1, 0.1), 300.0) #create robot metalimg = Texture("textures/metalhull.jpg") robot_head = Sphere(radius=1.0) robot_body = Cylinder(radius=1.0, height=2.0, sides=12) robot_leg = Cuboid(w=0.35, h=2.0) robot = MergeShape() robot.add(robot_head.buf[0], 0.0, 1.6) robot.add(robot_body.buf[0], 0.0, 0.5) robot.add(robot_leg.buf[0], -1.04, 0, 0) robot.add(robot_leg.buf[0], 1.05, 0, 0) robot.set_draw_details(shader, [metalimg, metalimg, reflcn], 0.0, 0.5) #create space station ssphere = Sphere(radius=10, slices=16, sides=16) scorrid = Cylinder(radius=4, height=22) station = MergeShape(y=mymap.calcHeight(0, 0), rx=4, ry=4, rz=4)