Exemple #1
0
#
# Rasperry rain demonstrates pi3d sprites over the desktop.
# The sprites make use of the z value in a perspective view

import time, random
import pi3d

# Setup display and initialise pi3d
display = pi3d.display()
display.create3D(0,0,1900,1200)

# Set last value (alpha) to zero for a transparent background!
display.setBackColour(0,0.7,1,0)	

# Load textures
raspimg = pi3d.loadTextureAlpha("textures/Raspi256x256.png")
	
pino=20

# 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 = pi3d.key()

# Display scene and rotate cuboid
while 1:
	display.clear()
Exemple #2
0
#
# before running this example
#

import pi3d

# Setup display and initialise pi3d
display = pi3d.display()
display.create3D(100,100,1600,900)   	# x,y,width,height
display.setBackColour(0,0,0,1)    	# r,g,b,alpha

# Load textures

# Setting 2nd param to True renders 'True' Blending
# (this can be changed later to 'False' with 'cloudimg.blend = False')
cloudimg = pi3d.loadTextureAlpha("textures/earth_clouds.png",True)   
earthimg = pi3d.loadTexture("textures/world_map.jpg")
moonimg = pi3d.loadTexture("textures/moon.jpg")
starsimg = pi3d.loadTexture("textures/stars2.jpg")
watimg = pi3d.loadTexture("textures/water.jpg")
	
mysphere = pi3d.createSphere(2,24,24,0.0,"earth",0,0,0)
mysphere2 = pi3d.createSphere(2.05,24,24,0.0,"clouds",0,0,0)
mymoon = pi3d.createSphere(0.4,16,16,0.0,"moon",0,0,0)
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()
Exemple #3
0
speed=1
widex=60
widey = 8
cloudno = 50
cloud_depth = 60.0
zd = cloud_depth / cloudno

# Setup display and initialise pi3d
scnx = 800
scny = 600
display = pi3d.display()
display.create3D()
display.setBackColour(0,0.7,1,1)

clouds = []
clouds.append(pi3d.loadTextureAlpha("textures/cloud2.png",True))
clouds.append(pi3d.loadTextureAlpha("textures/cloud3.png",True))
clouds.append(pi3d.loadTextureAlpha("textures/cloud4.png",True))
clouds.append(pi3d.loadTextureAlpha("textures/cloud5.png",True))
clouds.append(pi3d.loadTextureAlpha("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 = pi3d.key()
Exemple #4
0
#      $ sudo apt-get install python-imaging
#
# before running this example
#

import pi3d,math,random

rads = 0.017453292512  # degrees to radians

# Setup display and initialise pi3d
display = pi3d.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
tree2img = pi3d.loadTextureAlpha("textures/tree2.png")
tree1img = pi3d.loadTextureAlpha("textures/tree1.png")
grassimg = pi3d.loadTextureAlpha("textures/grass.png")
hb2img = pi3d.loadTextureAlpha("textures/hornbeam2.png")

#load environment cube
ectex = pi3d.loadECfiles("textures/ecubes","sbox_interstellar")
myecube = pi3d.createEnvironmentCube(900.0,"FACES")

# Create elevation map
mapwidth=1000.0
mapdepth=1000.0
mapheight=60.0
mountimg1 = pi3d.loadTexture("textures/mars_colour.png")
mymap = pi3d.createElevationMapFromTexture("textures/mars_height.png",mapwidth,mapdepth,mapheight,128,128) #testislands.jpg
Exemple #5
0
# $ sudo apt-get install python-imaging
#
# before running this example
#

import pi3d,math,random

rads = 0.017453292512 # degrees to radians

# Setup display and initialise pi3d
display = pi3d.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
tree2img = pi3d.loadTextureAlpha("textures/tree2.png")
tree1img = pi3d.loadTextureAlpha("textures/tree1.png")
hb2img = pi3d.loadTextureAlpha("textures/hornbeam2.png")

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)
Exemple #6
0
scny=1200
display = pi3d.display()
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
maxballs = 15
maxballsize = 150
minballsize = 5
maxspeed = 30

balltex = []
balltex.append(pi3d.loadTextureAlpha("textures/red_ball.png"))
balltex.append(pi3d.loadTextureAlpha("textures/grn_ball.png"))
balltex.append(pi3d.loadTextureAlpha("textures/blu_ball.png"))

#create balls and positions and make sure they don't touch to start with
balls = []
b=0
hit = True
for b in range (0,maxballs):
    
    r = random.random() * maxballsize+minballsize
    x = random.random() * scnx
    y = random.random() * scny
     
    vx = random.random() * 20.0-10.0
    vy = random.random() * 20.0-10.0
Exemple #7
0
# $ sudo apt-get install python-imaging
#
# before running this example
#

import pi3d,math,random

rads = 0.017453292512 # degrees to radians

# Setup display and initialise pi3d
display = pi3d.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
tree2img = pi3d.loadTextureAlpha("textures/tree2.png")
tree1img = pi3d.loadTextureAlpha("textures/tree1.png")
hb2img = pi3d.loadTextureAlpha("textures/hornbeam2.png")

ectex = pi3d.loadTexture("textures/SkyBox.png")
myecube = pi3d.createEnvironmentCube(900.0,"CROSS")

# Create elevation map
mapwidth=1000.0
mapdepth=1000.0
mapheight=60.0
mountimg1 = pi3d.loadTexture("textures/mountains3_512.jpg")
surface1 = pi3d.loadTextureAlpha("textures/gravel3.png")
mymap = pi3d.createElevationMapFromTexture("textures/mountainsHgt.jpg",mapwidth,mapdepth,mapheight,64,64) #testislands.jpg
mymap2 = pi3d.createElevationMapFromTexture("textures/mountainsHgt.jpg",mapwidth,mapdepth,mapheight,64,64, 128)
Exemple #8
0
# Setup display and initialise pi3d
scnx=1280
scny=1024
display = pi3d.display()
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.8)    	
    
# Ball parameters

arialFont = pi3d.font("MicrosoftSansSerif","#ffffff")   #load AR_CENA font and set the font colour to 'raspberry'

bar = pi3d.loadTexture("textures/bar.png")
bbtitle = pi3d.loadTextureAlpha("textures/pi3dbbd.png",True)
coffee = pi3d.loadTexture("textures/COFFEE.PNG")

# Fetch key presses
mykeys = pi3d.key()
scshots = 1

while True:
	
    display.clear()
   
    #draw a bar at the top of the screen
    pi3d.rectangle(bar,0,scny,scnx,32)
    pi3d.rectangle(bbtitle,5,scny,256+5,32)
    pi3d.rectangle(coffee,200,600,400,400)
    pi3d.drawString(arialFont, "`Test arial font!", 300, 300, 0, 0.0, 1.0,1.0)
Exemple #9
0
# Ball size (scale), ball image reference
bs=[]
bi=[]

# Setup ball positions, sizes, directions and colours
for b in range (0, maxballs):
    bx.append(random.random() * scnx)
    by.append(random.random() * scny)
    dx.append((random.random() - 0.5) * maxspeed)
    dy.append((random.random() - 0.5) * maxspeed)
    bs.append(random.random() * maxballsize + minballsize)
    bi.append(int(random.random() * 3))

ball = []
ball.append(pi3d.loadTextureAlpha("textures/red_ball.png"))
ball.append(pi3d.loadTextureAlpha("textures/grn_ball.png"))
ball.append(pi3d.loadTextureAlpha("textures/blu_ball.png"))
bar = pi3d.loadTexture("textures/bar.png")
bbtitle = pi3d.loadTextureAlpha("textures/pi3dbbd.png",True)

# Fetch key presses
mykeys = pi3d.key()
scshots = 1

while True:
	
    display.clear()
	
    for b in range (0, maxballs):