light = Light(0, 10,10,10, "", 0,100,0) light.on() # Create elevation map mapwidth=1000.0 mapdepth=1000.0 mapheight=60.0 mountimg1 = texs.loadTexture("textures/mountains3_512.jpg") mymap = ElevationMap("textures/mountainsHgt.jpg",mapwidth,mapdepth,mapheight,64,64) #testislands.jpg #Create tree models treeplane = Plane(4.0,5.0) treemodel1 = MergeShape("baretree") treemodel1.add(treeplane, 0,0,0) treemodel1.add(treeplane, 0,0,0, 0,90,0) treemodel2 = MergeShape("bushytree") treemodel2.add(treeplane, 0,0,0) treemodel2.add(treeplane, 0,0,0, 0,60,0) treemodel2.add(treeplane, 0,0,0, 0,120,0) #Create grass model grassplane = Plane(1.0,0.3,"",0,-2,0) grassmodel = MergeShape("grass") grassmodel.add(grassplane, 0,0,0) grassmodel.add(grassplane, 0,0,0, 0,60,0) grassmodel.add(grassplane, 0,0,0, 0,120,0) #Scatter them on map using Merge shape's cluster function
mapdepth=1000.0 mapheight=60.0 landimg = texs.loadTexture("textures/stonygrass.jpg") mymap = ElevationMap("textures/mountainsHgt.jpg", mapwidth, mapdepth, mapheight, 64, 64, 10.0, "fw", 0,0,0,0,0,0,1,1,1,0,0,0,True) #testislands.jpg #mymap2 = ElevationMap("textures/mountainsHgt.jpg",mapwidth,mapdepth,mapheight,64,64, 128) myclip = ClipPlane() light = Light(0, 2,2,3, "", 5,5,0) light.on() #Create tree models treeplane = Plane(4.0,5.0) treemodel1 = MergeShape("baretree") treemodel1.add(treeplane, 0,0,0) treemodel1.add(treeplane, 0,0,0, 0,90,0) treemodel2 = MergeShape("bushytree") treemodel2.add(treeplane, 0,0,0) treemodel2.add(treeplane, 0,0,0, 0,60,0) treemodel2.add(treeplane, 0,0,0, 0,120,0) #Scatter them on map using Merge shape's cluster function mytrees1 = MergeShape("trees1") mytrees1.cluster(treemodel1, mymap,0.0,0.0,200.0,200.0,30,"",8.0,3.0) # (shape,elevmap,xpos,zpos,w,d,count,options,minscl,maxscl) mytrees2 = MergeShape("trees2") mytrees2.cluster(treemodel2, mymap,0.0,0.0,200.0,200.0,30,"",6.0,3.0) # (shape,elevmap,xpos,zpos,w,d,count,options,minscl,maxscl)
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) 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)
# Create elevation map mapwidth = 1000.0 mapdepth = 1000.0 mapheight = 60.0 mountimg1 = Texture("textures/mountains3_512.jpg") mymap = ElevationMap("textures/mountainsHgt.jpg", name="map", width=mapwidth, depth=mapdepth, height=mapheight, divx=32, divy=32) #testislands.jpg mymap.buf[0].set_draw_details(shader, [mountimg1, bumpimg, reflimg], 128.0, 0.0) mymap.set_fog(*FOG) #Create tree models treeplane = Plane(w=4.0, h=5.0) treemodel1 = MergeShape(name="baretree") treemodel1.add(treeplane.buf[0], 0,0,0) treemodel1.add(treeplane.buf[0], 0,0,0, 0,90,0) treemodel2 = MergeShape(name="bushytree") treemodel2.add(treeplane.buf[0], 0,0,0) treemodel2.add(treeplane.buf[0], 0,0,0, 0,60,0) treemodel2.add(treeplane.buf[0], 0,0,0, 0,120,0) #Scatter them on map using Merge shape's cluster function mytrees1 = MergeShape(name="trees1") mytrees1.cluster(treemodel1.buf[0], mymap,0.0,0.0,200.0,200.0,20,"",8.0,3.0) 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,200.0,200.0,20,"",6.0,3.0)
width=mapwidth, depth=mapdepth, height=mapheight, divx=128, divy=128, name="sub") mymap.set_draw_details(shader, [rockimg1, rockimg2, shineimg], 128.0, 0.05) # Create fog for more realistic fade in distance. This can be turned on and off between drawing different object (i.e backgound not foggy) mymap.set_fog((0.1, 0.1, 0.1, 1.0), 200.0) #Create tree models treeplane = Plane(w=4.0, h=5.0) treemodel1 = MergeShape(name="baretree") treemodel1.add(treeplane.buf[0], 0, 0, 0) treemodel1.add(treeplane.buf[0], 0, 0, 0, 0, 90, 0) #Scatter them on map using Merge shape's cluster function mytrees1 = MergeShape(name="trees1") mytrees1.cluster(treemodel1.buf[0], mymap, 0.0, 0.0, 900.0, 900.0, 10, "", 8.0, 3.0) mytrees1.buf[0].set_draw_details(shader, [tree2img, rockimg2], 4.0, 0.0) mytrees1.set_fog((0.1, 0.1, 0.1, 1.0), 200.0) raspberry = MergeShape(name="rasp") raspberry.cluster(treemodel1.buf[0], mymap, -250, +250, 470.0, 470.0, 5, "", 8.0, 1.0) raspberry.buf[0].set_draw_details(shader, [raspimg, raspimg], 1.0, 0.0) raspberry.set_fog((0.1, 0.1, 0.1, 1.0), 200.0) """ MergeShape can be used to join a number of Model object for much greater
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) arialFont = Ttffont( "fonts/FreeMonoBoldOblique.ttf", "#dd00aa") #load ttf font and set the font colour to 'raspberry'
mymap = ElevationMap("textures/mountainsHgt.jpg", name="map", width=mapwidth, depth=mapdepth, height=mapheight, divx=32, divy=32) #testislands.jpg mymap.buf[0].set_draw_details(shader, [mountimg1, bumpimg, reflimg], 128.0, 0.0) mymap.set_fog(*FOG) #Create tree models treeplane = Plane(w=4.0, h=5.0) treemodel1 = MergeShape(name="baretree") treemodel1.add(treeplane.buf[0], 0, 0, 0) treemodel1.add(treeplane.buf[0], 0, 0, 0, 0, 90, 0) treemodel2 = MergeShape(name="bushytree") treemodel2.add(treeplane.buf[0], 0, 0, 0) treemodel2.add(treeplane.buf[0], 0, 0, 0, 0, 60, 0) treemodel2.add(treeplane.buf[0], 0, 0, 0, 0, 120, 0) #Scatter them on map using Merge shape's cluster function mytrees1 = MergeShape(name="trees1") mytrees1.cluster(treemodel1.buf[0], mymap, 0.0, 0.0, 120.0, 120.0, 30, "", 8.0, 3.0) mytrees1.set_draw_details(flatsh, [tree2img], 0.0, 0.0) mytrees1.set_fog(*TFOG) mytrees2 = MergeShape(name="trees2")
mapwidth = 1000.0 mapdepth = 1000.0 mapheight = 100.0 mymap = ElevationMap("textures/maze1.jpg", width=mapwidth, depth=mapdepth, height=mapheight, divx=128, divy=128, name="sub") mymap.set_draw_details(shader, [rockimg1, rockimg2, shineimg], 128.0, 0.05) # Create fog for more realistic fade in distance. This can be turned on and off between drawing different object (i.e backgound not foggy) mymap.set_fog((0.1,0.1,0.1,1.0), 200.0) #Create tree models treeplane = Plane(w=4.0, h=5.0) treemodel1 = MergeShape(name="baretree") treemodel1.add(treeplane.buf[0], 0,0,0) treemodel1.add(treeplane.buf[0], 0,0,0, 0,90,0) #Scatter them on map using Merge shape's cluster function mytrees1 = MergeShape(name="trees1") mytrees1.cluster(treemodel1.buf[0], mymap,0.0,0.0,900.0,900.0,10,"",8.0,3.0) mytrees1.buf[0].set_draw_details(shader, [tree2img, rockimg2], 4.0, 0.0) mytrees1.set_fog((0.1,0.1,0.1,1.0), 200.0) raspberry = MergeShape(name="rasp") raspberry.cluster(treemodel1.buf[0], mymap,-250,+250,470.0,470.0,5,"",8.0,1.0) raspberry.buf[0].set_draw_details(shader, [raspimg, raspimg], 1.0, 0.0) raspberry.set_fog((0.1,0.1,0.1,1.0), 200.0) """ MergeShape can be used to join a number of Model object for much greater rendering speed however, because Models can contain multiple Buffers,
# Create elevation map mapwidth=1000.0 mapdepth=1000.0 mapheight=60.0 mountimg1 = texs.loadTexture("textures/mars_colour.png") mymap = ElevationMap("textures/mars_height.png",mapwidth,mapdepth,mapheight,128,128) #testislands.jpg #create robot metalimg = texs.loadTexture("textures/metalhull.jpg") robot_head= Sphere(2.0,12,12,0.5,"",0,3,0) robot_body = Cylinder(2.0,4,12,"",0,1,0) robot_leg = Cuboid(0.7,4.0,1.0,"",0,0.8,0) robot = MergeShape() robot.add(robot_head) robot.add(robot_body) robot.add(robot_leg, -2.1,0,0) robot.add(robot_leg, 2.1,0,0) #create space station ssphere = Sphere(10,16,16) scorrid = Cylinder(4,22,12) station = MergeShape("",0,mymap.calcHeight(0,0),0, 0,0,0, 4,4,4) station.add(ssphere, -20,0,-20) station.add(ssphere, 20,0,-20) station.add(ssphere, 20,0,20) station.add(ssphere, -20,0,20) station.add(scorrid, -20,0,0, 90,0,0) station.add(scorrid, 0,0,20, 90,90,0)
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) station.add(ssphere.buf[0], -20, 0, 20) station.add(ssphere.buf[0], 20, 0, 20) station.add(ssphere.buf[0], 20, 0, -20) station.add(ssphere.buf[0], -20, 0, -20) station.add(scorrid.buf[0], -20, 0, 0, 90, 0, 0)
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) station.add(ssphere.buf[0], -20, 0, 20) station.add(ssphere.buf[0], 20, 0, 20) station.add(ssphere.buf[0], 20, 0, -20) station.add(ssphere.buf[0], -20, 0, -20) station.add(scorrid.buf[0], -20, 0, 0, 90, 0, 0)
# Create elevation map mapwidth=1000.0 mapdepth=1000.0 mapheight=100.0 mymap = ElevationMap("textures/maze1.jpg",mapwidth,mapdepth,mapheight,128,128,1,"sub",0,0,0, smooth=True) mymap2 = ElevationMap("textures/maze1.jpg",mapwidth,mapdepth,mapheight+0.1,128,128 ,64,"detail",0.0, 0.01, 0.0, smooth=True) # Crete fog for more realistic fade in distance. This can be turned on and off between drawing different object (i.e backgound not foggy) myfog = Fog(0.02, (0.1,0.1,0.1,1.0)) #Create tree models treeplane = Plane(4.0,5.0) treemodel1 = MergeShape("baretree") treemodel1.add(treeplane, 0,0,0) treemodel1.add(treeplane, 0,0,0, 0,90,0) shed = Model("models/shed1.obj",texs,"shed",0,3,0, 0,0,0, 2,2,2) #Scatter them on map using Merge shape's cluster function mytrees1 = MergeShape("trees1") mytrees1.cluster(treemodel1, mymap,0.0,0.0,900.0,900.0,10,"",8.0,3.0) # (shape,elevmap,xpos,zpos,w,d,count,options,minscl,maxscl) raspberry = MergeShape("rasp") raspberry.cluster(treemodel1, mymap,-250,+250,470.0,470.0,5,"",8.0,1.0) # createMergeShape can be used to join loadModel object for much greater rendering speed # however, because these objects can contain multiple vGroups, each with their own texture image # it is necessary to make a merge for each vGroup and, later, draw each merged object using each # of the textures