def __init__(self): self.skytex = pi3d.loadTexture("textures/SkyBox.png") #self.greentex = pi3d.loadTexture("textures/green-grid.png") self.greentex = pi3d.loadTexture("textures/mountains3_256.jpg") self.walltex = pi3d.loadTexture('textures/grey-stripe.png') self.coffeetex = pi3d.loadTexture('textures/coffee.png') self.sky = pi3d.createEnvironmentCube(900.0,'CROSS') self.ground = pi3d.createCuboid(800,400,0.1,'ground',0,0,0) self.J1 = pi3d.loadModel('j1-4.egg','J1',0,0,0, -90,0,0) self.J1G = Box('J1G',125,80,15) self.J1U = Box('J1U',105,40,10, 20,20,self.J1G.height) self.J1L = Box('J1L',15,16,6, 30,32,self.J1G.height+self.J1U.height) self.J1_f1 = Box('', 4,44,18, 50,18,self.J1G.height) self.J1_f2 = Box('', 4,44,18, 64,18,self.J1G.height) #J1 = pi3d.createMergeShape('J1') #J1.add(J1G, 0,0,0) ##J1.add(J1U, 20,20,J1G.height) ##J1.add(J1L, 30,32,J1G.height+J1U.height) ##J1.add(J1_f, 50,18,J1G.height) #J1.add(J1_f, 64,18,J1G.height) #self.j1 = J1 #self.j1 = Box('J1', 10,4,2, -6, 15) #self.j1l = Box('J1L', 2,2,1, -5, 16, 2) self.torus = pi3d.createTorus(2, 0.6, 12, 24, "Torus", -4,2,-17) self.rasp = pi3d.createTube(0.4, 0.1, 1.5, 24, "tube", 4,3,-15, 30,0,0)
# Loading EGG model # ================= # This example - Copyright (c) 2012 - Tim Skillman # EGG loader code by Paddy Gaunt, Copyright (c) 2012 # Version 0.02 - 20Jul12 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:
# map dots and settings dotsize=8 doth=dotsize*.5 reddot = texs.loadTexture("textures/red_ball.png") grndot = texs.loadTexture("textures/blu_ball.png") target = texs.loadTexture("textures/target.png") target.blend = True sniper = texs.loadTexture("textures/snipermode.png") sniper.blend = True #Enable true blending smaps=200 smph=smaps*.5 # Load tank parts tank_body = pi3d.loadModel("models/Tiger/body.obj",texs,"TigerBody", 0,0,0, 0,-90,0, .1,.1,.1) tank_gun = pi3d.loadModel("models/Tiger/gun.obj",texs,"TigerGun", 0,0,0, 0,-90,0, .1,.1,.1, 0,0,0) tank_turret = pi3d.loadModel("models/Tiger/turret.obj",texs,"TigerTurret", 0,0,0, 0,-90,0, .1,.1,.1, 0,0,0) # Load church (high/low detail) x,z = 20,-320 y = mymap.calcHeight(-x,-z) church = pi3d.loadModel("models/AllSaints/AllSaints.obj",texs,"church1", x,y,z, 0,0,0, .1,.1,.1) churchlow = pi3d.loadModel("models/AllSaints/AllSaints-lowpoly.obj",texs,"church2", x,y,z, 0,0,0, .1,.1,.1) # Load cottages x,z = 250,-40 y = mymap.calcHeight(-x,-z) cottages = pi3d.loadModel("models/Cottages/cottages_low.obj",texs,"cottagesLo", x,y,z, 0,-5,0, .1,.1,.1) #cottagesHi = pi3d.loadModel("models/Cottages/cottages.egg",texs,"cottagesHi", x,y,z, -90,-5,0, .1,.1,.1)
texs = pi3d.textures() ectex=pi3d.loadECfiles("textures/ecubes/RedPlanet","redplanet_256","png",texs,True) myecube = pi3d.createEnvironmentCube(1800.0,"FACES") # Create elevation map mapwidth=2000.0 mapdepth=2000.0 mapheight=100.0 redplanet = texs.loadTexture("textures/mars_colour.png") mymap = pi3d.createElevationMapFromTexture("textures/mars_height.png",mapwidth,mapdepth,mapheight,64,64) #Load Corridors sections x,z = 0,0 y = mymap.calcHeight(-x,-z) corridor_win = pi3d.loadModel("models/MarsStation/corridor_win_lowpoly.egg",texs,"", x,y,z, -90,0,0, .1,.1,.1) corridor = pi3d.loadModel("models/MarsStation/corridor_lowpoly.egg",texs,"", x,y,z, -90,0,0, .1,.1,.1) corridor_bend = pi3d.loadModel("models/MarsStation/bend_lowpoly.egg",texs,"", x,y,z, -90,0,0, .1,.1,.1) #LOD models room_hipoly = pi3d.loadModel("models/MarsStation/cross_room.egg",texs,"", x,y,z, -90,0,0, .1,.1,.1) room_lopoly = pi3d.loadModel("models/MarsStation/cross_room_doors.egg",texs,"", x,y,z, -90,0,0, .1,.1,.1) #position vars mouserot=0.0 tilt=0.0 avhgt = 2.0 xm=0.0 zm=0.0 ym= -(mymap.calcHeight(xm,zm)+avhgt) spc = 39.32 opendist = 120
# PLEASE INSTALL PIL imaging with: # # $ sudo apt-get install python-imaging # # before running this example # 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()
print "==============================================================" print "Instructions:" print "" print "Keys- W - Forward," print " A - Left S - Back D - right" print "" print "Move mouse to pan view. Click mouse to exit or press ESCAPE" print "==============================================================" texs = pi3d.textures() ectex = pi3d.loadECfiles("textures/ecubes", "sbox", texs) myecube = pi3d.createEnvironmentCube(900.0, "FACES") # load model_loadmodel mymodel = pi3d.loadModel("models/Buckfast Abbey/BuckfastAbbey.egg", texs, "Abbey", 0, 0, 0, -90, 160, 0, 0.03, 0.03, 0.03) # Create keyboard and mouse event objects mykeys = pi3d.key() 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
# # $ sudo apt-get install python-imaging # # before running this example # 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 texs = pi3d.textures() mymodel = pi3d.loadModel("models/Triceratops/Triceratops.egg",texs,"Triceratops", 0,-1,0, -90,0,0, .005,.005,.005) # Fetch key presses mykeys = pi3d.key() # mastrix and rotate variables rot=0 #create a light mylight = pi3d.createLight(0,1,1,1,"",10,10,0) mylight.on() while 1: display.clear() pi3d.identity()
# PLEASE INSTALL PIL imaging with: # # $ sudo apt-get install python-imaging # # before running this example # 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()
display.setBackColour(0.2,0.4,0.6,1) # r,g,b,alpha print "==============================================================" print "Instructions:" print "" print "Keys- W - Forward," print " A - Left S - Back D - right" print "" print "Move mouse to pan view. Click mouse to exit or press ESCAPE" print "==============================================================" ectex = pi3d.loadTexture("textures/SkyBox.png") myecube = pi3d.createEnvironmentCube(900.0,"CROSS") # load model_loadmodel mymodel = pi3d.loadModel("models/Buckfast Abbey/BuckfastAbbey.egg","Abbey",0,0,0, -90,160,0, 0.03,0.03,0.03) # Create keyboard and mouse event objects mykeys = pi3d.key() 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
mapwidth=1000.0 mapdepth=1000.0 mapheight=110.0 mymap = pi3d.createElevationMapFromTexture("textures/maze1.jpg",mapwidth,mapdepth,mapheight,128,128,1,"sub",0,0,0, smooth=False) mymap2 = pi3d.createElevationMapFromTexture("textures/maze1.jpg",mapwidth,mapdepth,mapheight+0.1,128,128 ,64,"detail",0.0, 0.01, 0.0, smooth=True) myfog = pi3d.fog(0.02, (0.1,0.1,0.1,1.0)) #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) shed = pi3d.loadModel("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 = pi3d.createMergeShape("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 = pi3d.createMergeShape("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 # The cluster method can be used where there is only one vGroup but with more than one the different # parts of the object get split up by the randomisation! Here I manually do the same thing as cluster # by first generating an array of random locations and y-rotations
winx,winy,winw,winh = 100,100,1200,600 #64MB GPU memory setting #winw,winh,bord = 1920,1080,0 #128MB GPU memory setting win = pi3d.tkwin("Conference Hall using baked textures in Pi3D",winx,winy,winw,winh) # Setup display and initialise pi3d viewport over the window win.update() #requires a window update first so that window sizes can be retreived display = pi3d.display(winx,winy,winw,winh,24, 0.5, 2200.0, 60.0) display.setBackColour(0.4,0.8,0.8,1) # r,g,b,alpha #texture storage for loading textures texs = pi3d.textures() ectex=pi3d.loadECfiles("textures/ecubes/Miramar","miramar_256","png",texs,True) myecube = pi3d.createEnvironmentCube(1800.0,"FACES") x,y,z = 0,-7,0 hall = pi3d.loadModel("models/ConferenceHall/conferencehall.egg",texs,"Hall", x,y,z, -90.0,0.0,0.0, 0.1,0.1,0.1) #position vars mouserot=0.0 tilt=0.0 avhgt = 2.0 xm=5.0 zm=0.0 ym=avhgt spc = 39.32 opendist = 120 # Fetch key presses mymouse = pi3d.mouse() mymouse.start() mtrx = pi3d.matrix()