Esempio n. 1
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:
Esempio n. 2
0
# Version 0.02 - 03Jul12
# 
# This example does not reflect the finished pi3d module in any way whatsoever!
# It merely aims to demonstrate a working concept in simplfying 3D programming on the Pi
#
# 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,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)
Esempio n. 3
0
# =================================================
# Copyright (c) 2012 - Tim Skillman
# Version 0.01 - 08Dec12
# 
# This example does not reflect the finished pi3d module in any way whatsoever!
# It merely aims to demonstrate a working concept in simplfying 3D programming on the Pi

import pi3d

#Create a Tkinter window
winx,winy,winw,winh = 200,200,800,600
win = pi3d.tkwin("Hello world in a Window",winx,winy,winw,winh)
win.update() #show window now (with default splash)

# Setup display and initialise pi3d
display = pi3d.display(winx,winy,winw,winh)
display.setBackColour(0,0,0,1)    	# r,g,b,alpha

# Load textures
texs=pi3d.textures()
cloudimg = texs.loadTexture("textures/earth_clouds.png",True)   
earthimg = texs.loadTexture("textures/world_map.jpg")

# Create shapes
mysphere = pi3d.createSphere(2,24,24,0.0,"earth",0,0,-6)
mysphere2 = pi3d.createSphere(2.05,24,24,0.0,"clouds",0,0,-6)

#create a light
mylight = pi3d.createLight(0,1,1,1,"",10,10,50, .8,.8,.8)
mylight.on()
Esempio n. 4
0
# This example does not reflect the finished pi3d module in any way whatsoever!
# It merely aims to demonstrate a working concept in simplfying 3D programming on the Pi
#
# PLEASE INSTALL PIL imaging with:
#
#      $ 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
texs = pi3d.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 = pi3d.loadECfiles("textures/ecubes", "sbox_interstellar", texs)
myecube = pi3d.createEnvironmentCube(900.0, "FACES")
Esempio n. 5
0
import pi3d, random, time

z = 0
x = 0
speed = 1
widex = 60
widey = 8
cloudno = 50
cloud_depth = 60.0
zd = cloud_depth / cloudno

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

texs = pi3d.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(
Esempio n. 6
0
# This example does not reflect the finished pi3d module in any way whatsoever!
# It merely aims to demonstrate a working concept in simplfying 3D programming on the Pi


import pi3d,math,random, time

rads = 0.017453292512  # degrees to radians

#Create a Tkinter window
winx,winy,winw,winh = 360,150,1200,800          #64MB GPU memory setting
#winx,winy,winw,winh = 0,0,1920,1080            #128MB GPU memory setting
win = pi3d.tkwin("Mars Station in Pi3D",winx,winy,winw,winh)
win.update()  #requires a window update first so that window sizes can be retreived

# Setup display and initialise pi3d viewport over the window
display = pi3d.display(winx,winy,winw,winh,24,0.5,2200,60)
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/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
Esempio n. 7
0
# =========================================
# Copyright (c) 2012 - Tim Skillman
# Version 0.02 - 20Jul12
# 
# Demonstrates offset camera to view an avatar moving about a map.  Also includes tiled mapping on landscape
#
# This example does not reflect the finished pi3d module in any way whatsoever!
# It merely aims to demonstrate a working concept in simplfying 3D programming on the Pi


import pi3d,math,random

rads = 0.017453292512  # degrees to radians

# Setup display and initialise pi3d
display = pi3d.display(100,100,1600,800)

# Load textures
texs = pi3d.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 = pi3d.loadECfiles("textures/ecubes/Interstellar","interstellar_256","png",texs)
myecube = pi3d.createEnvironmentCube(900.0,"FACES")

# Create elevation map
mapwidth=1000.0
mapdepth=1000.0
Esempio n. 8
0
# Earth and example shapes using pi3d module
# ==========================================
# Copyright (c) 2012 - Tim Skillman
# Version 0.03 - 20Jul12
# 
# This example does not reflect the finished pi3d module in any way whatsoever!
# It merely aims to demonstrate a working concept in simplfying 3D programming on the Pi

import pi3d

# Setup display and initialise pi3d
display = pi3d.display(100,100,1720,1000)
display.setBackColour(0,0,0,1)    	# r,g,b,alpha

# Load textures
texs=pi3d.textures()
# Setting 2nd param to True renders 'True' Blending
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 = 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","#aaffaa")   #load AR_CENA font and set the font colour to 'raspberry'

# Fetch key presses
Esempio n. 9
0
# Raspberry Rain example using pi3d module
# ========================================
# Copyright (c) 2012 - Tim Skillman
# Version 0.04 - 20Jul12
# 
# This example does not reflect the finished pi3d module in any way whatsoever!
# It merely aims to demonstrate a working concept in simplfying 3D programming on the Pi

import time, random
import pi3d

# Setup display and initialise pi3d
display = pi3d.display(0,0,1920,1200,16)

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

# Load textures
texs = pi3d.textures()
raspimg = texs.loadTexture("textures/Raspi256x256.png")
    
# No of raspberries!    
pino=15

# 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()
Esempio n. 10
0
# Collision balls example using pi3d module
# =========================================
# Copyright (c) 2012 - Tim Skillman
# Version 0.02 - 03Jul12
# 
# This example does not reflect the finished pi3d module in any way whatsoever!
# It merely aims to demonstrate a working concept in simplfying 3D programming on the Pi

import pi3d, sys, random, array

# Setup display and initialise pi3d
scnx=1920
scny=1200
display = pi3d.display(0,0,scnx,scny,0)
display.setOrthographic()

# 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

texs=pi3d.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"))
Esempio n. 11
0
# Loading EGG model
# =================
# This example - Copyright (c) 2012 - Tim Skillman
# EGG loader code by Paddy Gaunt, Copyright (c) 2012
# Version 0.01 - 03Jul12
# 
# This example does not reflect the finished pi3d module in any way whatsoever!
# It merely aims to demonstrate a working concept in simplfying 3D programming on the Pi

import pi3d, math

rads = 0.017453292512  # degrees to radians

# Setup display and initialise pi3d
display = pi3d.display(100,100,1400,800) # x,y,width,height
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 "=============================================================="

texs = pi3d.textures()
ectex = pi3d.loadECfiles("textures/ecubes","sbox","jpg",texs,True)
myecube = pi3d.createEnvironmentCube(900.0,"FACES")

# load model_loadmodel