# 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) mylight.on()
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")) class RandomBall(Ball): def __init__(self, texture):
# 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)) # Fetch key presses mykeys = Keyboard()
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) mycone = Cone(1,2,24,"Cone",-4,-1,-7) mycylinder = Cylinder(.7,1.5,24,"Cyli",-2,-1,-7)