from pi3d.shape.ElevationMap import ElevationMap from pi3d.shape.EnvironmentCube import EnvironmentCube from pi3d.shape.EnvironmentCube import loadECfiles from pi3d.shape.MergeShape import MergeShape from pi3d.shape.Plane import Plane from pi3d.util.Matrix import Matrix # Setup display and initialise pi3d display = Display() display.create3D(100,100,800,600, 0.5, 800.0, 60.0) # x,y,width,height,near,far,aspect display.setBackColour(0.4,0.8,0.8,1) # r,g,b,alpha # Load textures texs = Textures() tree2img = texs.loadTexture("textures/tree2.png") tree1img = texs.loadTexture("textures/tree1.png") grassimg = texs.loadTexture("textures/grass.png") hb2img = texs.loadTexture("textures/hornbeam2.png") #myecube = EnvironmentCube(900.0,"HALFCROSS") ectex=loadECfiles("textures/ecubes","sbox",texs) myecube = EnvironmentCube(900.0,"FACES") light = Light(0, 10,10,10, "", 0,100,0) light.on() # Create elevation map mapwidth=1000.0 mapdepth=1000.0
from pi3d.Display import Display from pi3d.Keyboard import Keyboard from pi3d.Texture import Textures from pi3d.util import Draw # Setup display and initialise pi3d display = Display() display.create3D(0,0) # Set last value (alpha) to zero for a transparent background! display.setBackColour(0,0.7,1,0) # Load textures texs = Textures() raspimg = texs.loadTexture("textures/Raspi256x256.png") pino=10 # Setup array of random x,y,z coords and initial rotation xyz=[] for b in range (0, pino): xyz.append((random.random()*8-4,random.random() * 8,random.random() * 4 + 3, random.random() * 360)) # Fetch key presses mykeys = Keyboard() # Display scene and rotate cuboid while 1: display.clear()
from pi3d.shape.ElevationMap import ElevationMap from pi3d.shape.EnvironmentCube import EnvironmentCube from pi3d.shape.MergeShape import MergeShape from pi3d.shape.Plane import Plane from pi3d.util.Matrix import Matrix # Setup display and initialise pi3d display = Display() display.create3D(100,100,1600,800, 0.5, 800.0, 60.0) # x,y,width,height,near,far,aspect display.setBackColour(0.4,0.8,0.8,1) # r,g,b,alpha # Load textures texs = Textures() tree2img = texs.loadTexture("textures/tree2.png") tree1img = texs.loadTexture("textures/tree1.png") hb2img = texs.loadTexture("textures/hornbeam2.png") ectex = texs.loadTexture("textures/ecubes/skybox_stormydays.jpg") myecube = EnvironmentCube(900.0,"CROSS") # Create elevation map mapwidth=1000.0 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()
scnx = display.max_width scny = display.max_height display.create2D(0,0,scnx,scny,0) # Set last value (alpha) to zero for a transparent background! display.setBackColour(0,0.2,0.6,0) # Ball parameters MAX_BALLS = 15 MIN_BALL_SIZE = 5 MAX_BALL_SIZE = 100 MAX_RANDOMIZATION_TRIES = 20 texs = Textures() balltex = [] balltex.append(texs.loadTexture("textures/red_ball.png")) balltex.append(texs.loadTexture("textures/grn_ball.png")) balltex.append(texs.loadTexture("textures/blu_ball.png")) class RandomBall(Ball): def __init__(self, texture): super(RandomBall, self).__init__(texture, 1.0, 0, 0, random.uniform(-10.0, 10.0), random.uniform(-10.0, 10.0)) self.texture = texture self.randomize() def randomize(self): self.radius = random.uniform(MIN_BALL_SIZE, MAX_BALL_SIZE) self.mass = self.radius * self.radius self.x = random.uniform(0.0, scnx)
widey = 8 cloudno = 50 cloud_depth = 60.0 zd = cloud_depth / cloudno # Setup display and initialise pi3d display = Display() margin = 100 scnx = display.max_width - 2*margin scny = display.max_height - 2*margin display.create3D(margin,margin,scnx,scny) display.setBackColour(0,0.7,1,1) texs = Textures() clouds = [] clouds.append(texs.loadTexture("textures/cloud2.png",True)) clouds.append(texs.loadTexture("textures/cloud3.png",True)) clouds.append(texs.loadTexture("textures/cloud4.png",True)) clouds.append(texs.loadTexture("textures/cloud5.png",True)) clouds.append(texs.loadTexture("textures/cloud6.png",True)) # Setup cloud positions and cloud image refs z = 0.0 cxyz = [] for b in range (0, cloudno): cxyz.append([random.random() * widex - widex*.5, -random.random() * widey, cloud_depth-z, int(random.random() * 4) + 1]) z = z + zd # Fetch key presses mykeys = Keyboard()
print "############################################################" print "Mouse to move left and right and up and down" print "############################################################" print # Setup display and initialise pi3d display = Display() #display.create3D(10,10,900,700, 0.5, 800.0, 60.0) # x,y,width,height,near,far,aspect display.create3D(10,10,1200,900, 0.5, 800.0, 60.0) # x,y,width,height,near,far,aspect display.setBackColour(0.4,0.8,0.8,1) # r,g,b,alpha # Load textures texs = Textures() # Setting 2nd param to True renders 'True' Blending # (this can be changed later to 'False' with 'rockimg2.blend = False') groundimg = texs.loadTexture("textures/stripwood.jpg") monstimg = texs.loadTexture("textures/pong3.png") ballimg = texs.loadTexture("textures/cloud6.png", True) # environment cube ectex = texs.loadTexture("textures/ecubes/skybox_stormydays.jpg") myecube = EnvironmentCube(900.0,"CROSS") #ball maxdsz = 0.3 radius = 1.0 ball = Sphere(radius,12,12,0.0,"sphere",-4,8,-7) #monster monster = Plane(5.0, 5.0, "monster", 0,0,0, 0,0,0) # Create elevation map mapwidth=50.0 mapdepth=50.0
from pi3d.shape.EnvironmentCube import EnvironmentCube from pi3d.shape.EnvironmentCube import loadECfiles from pi3d.util.Matrix import Matrix from pi3d.util import Utility # Setup display and initialise pi3d display = Display() display.create3D(50,50,display.max_width-100,display.max_height-100, 0.5, 800.0, 60.0) # x,y,width,height,near,far,aspect #select the environment cube with 'box'... box=3 texs=Textures() if box==0: ectex = texs.loadTexture("textures/ecubes/skybox_interstellar.jpg") myecube = EnvironmentCube(900.0,"CROSS") elif box==1: ectex = texs.loadTexture("textures/ecubes/SkyBox.jpg") myecube = EnvironmentCube(900.0,"HALFCROSS") elif box==2: ectex=loadECfiles("textures/ecubes","sbox_interstellar",texs) myecube = EnvironmentCube(900.0,"FACES") else: ectex=loadECfiles("textures/ecubes","skybox_hall",texs) myecube = EnvironmentCube(900.0,"FACES") rot=0.0 tilt=0.0 # Fetch key presses
from pi3d.shape.ElevationMap import ElevationMap from pi3d.shape.EnvironmentCube import EnvironmentCube from pi3d.shape.EnvironmentCube import loadECfiles from pi3d.shape.MergeShape import MergeShape from pi3d.shape.Sphere import Sphere from pi3d.util.Matrix import Matrix # Setup display and initialise pi3d display = Display() display.create3D(50,50,display.max_width-100,display.max_height-100, 0.5, 800.0, 60.0) # x,y,width,height,near,far,aspect display.setBackColour(0.4,0.8,0.8,1) # r,g,b,alpha # Load textures texs = Textures() tree2img = texs.loadTexture("textures/tree2.png") tree1img = texs.loadTexture("textures/tree1.png") grassimg = texs.loadTexture("textures/grass.png") hb2img = texs.loadTexture("textures/hornbeam2.png") #load environment cube ectex = loadECfiles("textures/ecubes","sbox_interstellar",texs) myecube = EnvironmentCube(900.0,"FACES") # 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
print "Mouse to move left and right and up and down" print "############################################################" print # Setup display and initialise pi3d display = Display() display.create3D(10,10,1200,900, 0.5, 800.0, 60.0) # x,y,width,height,near,far,aspect #display.create3D(10,10,1200,900, 0.5, 800.0, 60.0) # x,y,width,height,near,far,aspect display.setBackColour(0.4,0.8,0.8,1) # r,g,b,alpha # Load textures texs=Textures() # Setting 2nd param to True renders 'True' Blending # (this can be changed later to 'False' with 'rockimg2.blend = False') groundimg = texs.loadTexture("textures/piom2.jpg") monstimg = texs.loadTexture("textures/piom3.jpg") # environment cube ectex = texs.loadTexture("textures/ecubes/skybox_stormydays.jpg") myecube = EnvironmentCube(900.0,"CROSS") #monster radius = 1 ball = Sphere(radius,12,12,0.0,"sphere",-4,2,-7) # Create elevation map mapwidth=50.0 mapdepth=50.0 maphalf=23.0 mapheight=8 #set smooth to give proper normals
from pi3d.shape.Sphere import Sphere from pi3d.shape.TCone import TCone from pi3d.shape.Torus import Torus from pi3d.shape.Tube import Tube from pi3d.shape.Plane import Plane from pi3d.util import Draw # Setup display and initialise pi3d display = Display() display.create3D(0,0) # x,y,width,height display.setBackColour(0,0,0,1) # r,g,b,alpha # Load textures texs = Textures() patimg = texs.loadTexture("textures/PATRN.PNG") coffimg = texs.loadTexture("textures/COFFEE.PNG") #Create inbuilt shapes mysphere = Sphere(1,24,24,0.0,"sphere",-4,2,-7) mytcone = TCone(0.8,0.6,1,24,"TCone", -2,2,-7) myhelix = Helix(0.4,0.1,12,24,1.5,3.0,"helix", 0,2,-7) mytube = Tube(0.4,0.1,1.5,24,"tube",2,2,-7, 30,0,0) myextrude = Extrude( ((-0.5, 0.5), (0.5,0.7), (0.9,0.2), (0.2,0.05), (1.0,0.0), (0.5,-0.7), (-0.5, -0.5)), 0.5,"Extrude",4,2,-7) mycone = Cone(1,2,24,"Cone",-4,-1,-7) mycylinder = Cylinder(.7,1.5,24,"Cyli",-2,-1,-7) myhemisphere = Sphere(1,24,24,0.5,"hsphere",0,-1,-7) mytorus = Torus(1,0.3,12,24,"Torus", 2,-1,-7) #NB Lathe needs to start at the top otherwise normals are calculated in reverse, also inside surfaces need to be defined otherwise normals are wrong mylathe = Lathe( ((0,1),(0.6,1.2),(0.8,1.4),(1.09,1.7), (1.1,1.7),(0.9, 1.4),(0.7,1.2),(0.08,1),(0.08,0.21),(0.1,0.2),(1,0.05),(1,0),(0,0)), 24,"Cup",4,-1,-7, 0,0,0, 0.8,0.8,0.8)
from pi3d.shape.Sphere import Sphere from pi3d.shape.Plane import Plane from pi3d.util import Draw # Setup display and initialise pi3d display = Display() display.create3D(0,0) # x,y,width,height defaults to full screen if w,h ommitted display.setBackColour(0,0,0,1) # r,g,b,alpha # Load textures texs=Textures() # Setting 2nd param to True renders 'True' Blending # (this can be changed later to 'False' with 'cloudimg.blend = False') cloudimg = texs.loadTexture("textures/earth_clouds.png",True) earthimg = texs.loadTexture("textures/world_map.jpg") moonimg = texs.loadTexture("textures/moon.jpg") starsimg = texs.loadTexture("textures/stars2.jpg") watimg = texs.loadTexture("textures/water.jpg") mysphere = Sphere(2,24,24,0.0,"earth",0,0,-5.8) mysphere2 = Sphere(2.05,24,24,0.0,"clouds",0,0,-5.8) mymoon = Sphere(0.4,16,16,0.0,"moon",0,0,0) mymoon2 = Sphere(0.1,16,16,0.0,"moon2",0,0,0) myplane = Plane(50,50, "stars", 0,0,-10) # Fetch key presses mykeys = Keyboard() rot=0.0
print "############################################################" print "If you get touched by a monster you will return to the start!" print "############################################################" print # Setup display and initialise pi3d display = Display() #display.create3D(10,10,display.max_width-20,display.max_height-100, 0.5, 800.0, 60.0) # x,y,width,height,near,far,aspect display.create3D(10,10,800,600, 0.5, 800.0, 60.0) # small window so terminal can be viewed for errors! display.setBackColour(0.4,0.8,0.8,1) # r,g,b,alpha # Load textures texs = Textures() # Setting 2nd param to True renders 'True' Blending # (this can be changed later to 'False' with 'rockimg2.blend = False') rockimg1 = texs.loadTexture("textures/techy1.jpg") rockimg2 = texs.loadTexture("textures/rock1.png", True) tree2img = texs.loadTexture("textures/tree2.png") raspimg = texs.loadTexture("textures/Raspi256x256.png") monstimg = texs.loadTexture("textures/pong2.jpg") # environment cube ectex = texs.loadTexture("textures/ecubes/skybox_stormydays.jpg") myecube = EnvironmentCube(900.0,"CROSS") # 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)