示例#1
0
from pi3d.Keyboard import Keyboard
from pi3d.Mouse import Mouse
from pi3d.Texture import Textures

from pi3d.context.Light import Light

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")
示例#2
0
#      $ sudo apt-get install python-imaging
#
# before running this example
#

from pi3d.util import Utility
from pi3d.Display import Display
from pi3d.Keyboard import Keyboard
from pi3d.Texture import Textures

from pi3d.context.Light import Light

from pi3d.shape.Model import Model

# Setup display and initialise pi3d
display = Display()
display.create3D(50,50,display.max_width-100,display.max_height-100)   	# x,y,width,height
display.setBackColour(0.2,0.4,0.6,1)    # r,g,b,alpha

# load model_loadmodel
texs = Textures()
mymodel = Model("models/Triceratops/Triceratops.egg",texs,"Triceratops", 0,-1,0, -90,0,0, .005,.005,.005)

# Fetch key presses
mykeys = Keyboard()

# mastrix and rotate variables
rot=0

#create a light
mylight = Light(0,1,1,1,"",10,10,0)
示例#3
0
#
# before running this example
#
# Rasperry rain demonstrates pi3d sprites over the desktop.
# The sprites make use of the z value in a perspective view

import random, time

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))
示例#4
0
文件: LoadModel.py 项目: JamesR1/pi3d
#
#    $ sudo apt-get install python-imaging
#
# before running this example
#

from pi3d.Display import Display
from pi3d.Keyboard import Keyboard
from pi3d.Texture import Textures

from pi3d.context.Light import Light
from pi3d.shape.Model import Model
from pi3d.util.Matrix import Matrix

# Setup display and initialise pi3d
display = Display()
display.create3D(100,100,1200,900)    # x,y,width,height
display.setBackColour(0.2,0.4,0.6,1)      # r,g,b,alpha

texs = Textures()

# load model_loadmodel
mymodel = Model("models/teapot.egg",texs ,"teapot", 0,-1,0)

# Fetch key presses
mykeys = Keyboard()

# setup matrices
mtrx = Matrix()

#create a light
示例#5
0
import random
import sys

from pi3d import Keyboard

from pi3d.Display import Display
from pi3d.DisplayLoop import DisplayLoop
from pi3d.Texture import Textures

from pi3d.sprite.Ball import Ball

# Setup display and initialise pi3d
display = Display()
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"))
示例#6
0
文件: Clouds3d.py 项目: JamesR1/pi3d
from pi3d.Keyboard import Keyboard
from pi3d.Texture import Textures

from pi3d.util import Draw

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
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
示例#7
0
文件: Pong.py 项目: JamesR1/pi3d
from pi3d.shape.ElevationMap import ElevationMap
from pi3d.shape.EnvironmentCube import EnvironmentCube
from pi3d.shape.Plane import Plane
from pi3d.shape.Sphere import Sphere

from pi3d.util import Draw
from pi3d.util.Matrix import Matrix

#helpful messages
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
示例#8
0
# before running this example
#

from pi3d.Display import Display
from pi3d.Keyboard import Keyboard
from pi3d.Mouse import Mouse
from pi3d.Texture import Textures

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:
示例#9
0
from pi3d.context.Fog import Fog
from pi3d.context.Light import Light

from pi3d.shape.Cuboid import Cuboid
from pi3d.shape.Cylinder import Cylinder
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
示例#10
0
文件: Shapes.py 项目: JamesR1/pi3d
from pi3d.shape.Cone import Cone
from pi3d.shape.Cylinder import Cylinder
from pi3d.shape.Extrude import Extrude
from pi3d.shape.Helix import Helix
from pi3d.shape.Lathe import Lathe
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)
示例#11
0
文件: Earth.py 项目: JamesR1/pi3d
#
from math import sin, cos

from pi3d.Display import Display
from pi3d.Keyboard import Keyboard
from pi3d.Texture import Textures

from pi3d.context.Light import Light

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)
示例#12
0
from pi3d.Display import Display
from pi3d.Keyboard import Keyboard
from pi3d.Mouse import Mouse
from pi3d.Texture import Textures

from pi3d.context.Light import Light

from pi3d.shape.EnvironmentCube import loadECfiles
from pi3d.shape.EnvironmentCube import EnvironmentCube
from pi3d.shape.Model import Model

from pi3d.util.Matrix import Matrix

# Setup display and initialise pi3d
display = Display()
display.create3D(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 = Textures()
ectex = loadECfiles("textures/ecubes","sbox",texs)
myecube = EnvironmentCube(900.0,"FACES")
示例#13
0
文件: Amazing.py 项目: JamesR1/pi3d
print "############################################################"
print "Esc to quit, W to go forward, Mouse to steer, Space to jump."

print "N.B. W now works as a TOGGLE one press to go one to stop."

print "At the edge you will turn into a ghost and be able to fly "
print "and pass through rocks! There are limited numbers of jumps."
print "Good turnings are often greener and tend to be near"
print "(but in the opposite direction to) big holes"
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