mymoon2 = pi3d.createSphere(0.1,16,16,0.0,"moon2",0,0,0) arialFont = pi3d.font("AR_CENA","#dd00aa") #load AR_CENA font and set the font colour to 'raspberry' destineFont = pi3d.font("AR_DELANEY", "#0055ff") # Fetch key presses mykeys = pi3d.key() mtrx = pi3d.matrix() rot=0.0 rot1=0.0 rot2=0.0 #create a light mylight = pi3d.createLight(0,1,1,1,"",10,10,50, .8,.8,.8) # Display scene while 1: display.clear() mylight.off() pi3d.sprite(starsimg, 0,0,-20, 25,25,rot) rot=rot+0.02 mylight.on() mtrx.identity() mtrx.translate(0,0,-6) mysphere.draw(earthimg) mysphere.rotateIncY( 0.1 ) mysphere2.draw(cloudimg)
avhgt = 2.0 xm = 0.0 zm = 0.0 ym = -(mymap.calcHeight(xm, zm) + avhgt) # Fetch key presses mykeys = pi3d.key() mymouse = pi3d.mouse() mymouse.start() mtrx = pi3d.matrix() omx = mymouse.x omy = mymouse.y myfog = pi3d.fog(0.002, (0.3, 0.8, 0.6, 0.5)) mylight = pi3d.createLight(0, 1, 1, 1, "", 10, 10, 10, .9, .7, .6) # Display scene and rotate cuboid while 1: display.clear() mtrx.identity() #tilt can be used as a means to prevent the view from going under the landscape! if tilt < -1: sf = 1.0 / -tilt else: sf = 1.0 mtrx.translate(0, -10 * sf - 5.0, -40 * sf) #zoom camera out so we can see our robot mtrx.rotate(tilt, 0, 0) #Robot still affected by scene tilt #draw robot mylight.on()
import pi3d # Setup display and initialise pi3d display = pi3d.display(100,100,1200,900) display.setBackColour(0.2,0.4,0.6,1) # r,g,b,alpha # load model_loadmodel texs = pi3d.textures() mymodel = pi3d.loadModel("models/Triceratops/Triceratops.egg",texs,"Triceratops", 0,-1,-40, -90,0,0, .005,.005,.005) # Fetch key presses mykeys = pi3d.key() #create a light mylight = pi3d.createLight(0,1,1,1,"",10,10,0) mylight.on() while 1: display.clear() mymodel.draw() mymodel.rotateIncY(3) k = mykeys.read() if k >-1: if k==112: display.screenshot("Triceratops.jpg") elif k==27: mykeys.close() texs.deleteAll() display.destroy()
arialFont = pi3d.font( "AR_CENA", "#dd00aa") #load AR_CENA font and set the font colour to 'raspberry' destineFont = pi3d.font("AR_DELANEY", "#0055ff") # Fetch key presses mykeys = pi3d.key() mtrx = pi3d.matrix() rot = 0.0 rot1 = 0.0 rot2 = 0.0 #create a light mylight = pi3d.createLight(0, 1, 1, 1, "", 10, 10, 50, .8, .8, .8) # Display scene while 1: display.clear() mylight.off() pi3d.sprite(starsimg, 0, 0, -20, 25, 25, rot) rot = rot + 0.02 mylight.on() mtrx.identity() mtrx.translate(0, 0, -6) mysphere.draw(earthimg) mysphere.rotateIncY(0.1) mysphere2.draw(cloudimg)
avhgt = 2.0 xm=0.0 zm=0.0 ym= -(mymap.calcHeight(xm,zm)+avhgt) # Fetch key presses mykeys = pi3d.key() mymouse = pi3d.mouse() mymouse.start() mtrx = pi3d.matrix() omx=mymouse.x omy=mymouse.y myfog = pi3d.fog(0.002,(0.3,0.8,0.6,0.5)) mylight = pi3d.createLight(0,1,1,1,"",10,10,10, .9,.7,.6) # Display scene and rotate cuboid while 1: display.clear() mtrx.identity() #tilt can be used as a means to prevent the view from going under the landscape! if tilt<-1: sf=1.0/-tilt else: sf=1.0 mtrx.translate(0,-10*sf-5.0,-40*sf) #zoom camera out so we can see our robot mtrx.rotate(tilt,0,0) #Robot still affected by scene tilt #draw robot mylight.on() robot.drawAll(metalimg)
ectex = pi3d.loadTexture("textures/ecubes/skybox_stormydays.jpg") myecube = pi3d.createEnvironmentCube(900.0,"CROSS") # Create elevation map mapwidth=1000.0 mapdepth=1000.0 mapheight=60.0 landimg = pi3d.loadTexture("textures/stonygrass.jpg") #surface1 = pi3d.loadTextureAlpha("textures/gravel3.png") mymap = pi3d.createElevationMapFromTexture("textures/mountainsHgt.jpg",mapwidth,mapdepth,mapheight,64,64,10.0) #testislands.jpg #mymap2 = pi3d.createElevationMapFromTexture("textures/mountainsHgt.jpg",mapwidth,mapdepth,mapheight,64,64, 128) myclip = pi3d.clipPlane() light = pi3d.createLight(0, 10,10,10, "", 0,100,0) light.on() #Create tree models treeplane = pi3d.createPlane(4.0,5.0) treemodel1 = pi3d.createMergeShape("baretree") treemodel1.add(treeplane, 0,0,0) treemodel1.add(treeplane, 0,0,0, 0,90,0) treemodel2 = pi3d.createMergeShape("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
import pi3d # Setup display and initialise pi3d display = pi3d.display() display.create3D(100, 100, 1200, 900) # x,y,width,height display.setBackColour(0.2, 0.4, 0.6, 1) # r,g,b,alpha # load model_loadmodel mymodel = pi3d.loadModel("models/teapot.egg", "teapot", 0, -1, 0) # Fetch key presses mykeys = pi3d.key() # setup matrices mtrx = pi3d.matrix() #create a light mylight = pi3d.createLight(0, 1, 1, 1, "", 10, 10, 0) mylight.on() while 1: display.clear() mtrx.identity() mtrx.translate(0, 0, -10) mymodel.draw() mymodel.rotateIncY(3.0) display.swapBuffers()
mymouse = pi3d.mouse() mymouse.start() #screenshot number scshots = 1 #avatar camera rot = 0.0 tilt = 0.0 avhgt = 2.0 xm = 0.0 zm = 0.0 ym = -avhgt #create a light mylight = pi3d.createLight(0, 1, 1, 1, "", 0, 200, 200, 0.4, 0.4, 0.4) mtrx = pi3d.matrix() omx = mymouse.x omy = mymouse.y while 1: display.clear() mtrx.identity() mtrx.rotate(tilt, rot, 0) mtrx.translate(xm, ym, zm) mtrx.push() mtrx.rotate(0, 180, 0) myecube.draw(ectex, xm, ym, zm) mtrx.pop()
myecube = pi3d.createEnvironmentCube(900.0,"CROSS") #ball radius = 1 ball = pi3d.createSphere(radius,12,12,0.0,"sphere",-4,2,-7) #monster monster = pi3d.createPlane(5.0, 5.0, "monster", 0,0,0, 0,0,0) # Create elevation map mapwidth=50.0 mapdepth=50.0 maphalf=23.0 mapheight=20.0 #set smooth to give proper normals mymap = pi3d.createElevationMapFromTexture("textures/pong.jpg",mapwidth,mapdepth,mapheight,64,64,2,"sub",0,0,0, smooth=True) # lighting. The default light is a point light but I have made the position method capable of creating # a directional light and this is what I do inside the loop. If you want a torch you don't need to move it about light = pi3d.createLight(0, 2, 2, 1, "", 1,2,3, 0.1,0.1,0.2) #yellowish 'torch' or 'sun' with low level blueish ambient light.position(1,2,3,0) # set to directional light by settin position with 0 fourth parameter light.on() #avatar camera rot=0.0 tilt=0.0 avhgt = 2.0 xm=0.0 zm=0.0 ym=mapheight lastX0=0.0 lastZ0=0.0 #sphere loc and speed sx, sy, sz = 0, 5, 0
mymouse = pi3d.mouse() mymouse.start() #screenshot number scshots = 1 #avatar camera rot=0.0 tilt=0.0 avhgt = 2.0 xm=0.0 zm=0.0 ym= -avhgt #create a light mylight = pi3d.createLight(0,1,1,1,"",0,200,200,0.4,0.4,0.4) omx=mymouse.x omy=mymouse.y while 1: display.clear() pi3d.identity() pi3d.rotate(tilt,0,0) pi3d.rotate(0,rot,0) pi3d.position(xm,ym,zm) myecube.draw(ectex,xm,ym,zm) mylight.on() mymodel.draw()
for i in range(20): xval = (random.random()-0.5)*50 + 19 xArr.append(xval) zval = (random.random()-0.5)*50 - 19 zArr.append(zval) yArr.append(mymap.calcHeight(-xval, -zval)) rArr.append(180.0 + random.random()*45) for g in shed.vGroup: thisAbbGp = pi3d.createMergeShape("shed") for i in range(len(xArr)): thisAbbGp.add(shed.vGroup[g], xArr[i], yArr[i], zArr[i], 0, rArr[i], 0) shedgp[g] = thisAbbGp # lighting. The default light is a point light but I have made the position method capable of creating # a directional light and this is what I do inside the loop. If you want a torch you don't need to move it about light = pi3d.createLight(0, 4, 4, 2, "", 0,1,2, 0.1,0.1,0.2) #yellowish 'torch' or 'sun' (could be blueish ambient with different env cube) light.on() #screenshot number scshots = 1 #energy counter hp = 25 #avatar camera rot=0.0 tilt=0.0 avhgt = 2.0 xm=0.0 zm=0.0 ym= -(mymap.calcHeight(xm,zm)+avhgt) lastX0=0.0
ectex = texs.loadTexture("textures/ecubes/skybox_stormydays.jpg") myecube = pi3d.createEnvironmentCube(900.0,"CROSS") # Create elevation map mapwidth=1000.0 mapdepth=1000.0 mapheight=60.0 landimg = texs.loadTexture("textures/stonygrass.jpg") #surface1 = pi3d.loadTextureAlpha("textures/gravel3.png") mymap = pi3d.createElevationMapFromTexture("textures/mountainsHgt.jpg",mapwidth,mapdepth,mapheight,64,64,10.0) #testislands.jpg #mymap2 = pi3d.createElevationMapFromTexture("textures/mountainsHgt.jpg",mapwidth,mapdepth,mapheight,64,64, 128) myclip = pi3d.clipPlane() light = pi3d.createLight(0, 10,10,10, "", 0,100,0) light.on() #Create tree models treeplane = pi3d.createPlane(4.0,5.0) treemodel1 = pi3d.createMergeShape("baretree") treemodel1.add(treeplane, 0,0,0) treemodel1.add(treeplane, 0,0,0, 0,90,0) treemodel2 = pi3d.createMergeShape("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