class DummyTkWin(object): def __init__(self): self.tkKeyboard = Keyboard() self.ev = "" self.key = "" self.winx, self.winy = 0, 0 self.width, self.height = 1920, 1180 self.event_list = [] def update(self): if PLATFORM == PLATFORM_WINDOWS or pi3d.USE_PYGAME: #uses pygame UI k = self.tkKeyboard.read() if k == -1: self.key = "" self.ev = "" else: if k == 27: self.key = "Escape" else: self.key = chr(k) self.ev = "key" else: self.key = self.tkKeyboard.read_code() if self.key == "": self.ev = "" else: self.ev = "key"
def __init__(self): self.tkKeyboard = Keyboard() self.ev = "" self.key = "" self.winx, self.winy = 0, 0 self.width, self.height = 1920, 1180 self.event_list = []
class DummyTkWin(object): def __init__(self): self.tkKeyboard = Keyboard() self.ev = "" self.key = "" self.winx, self.winy = 0, 0 self.width, self.height = 1920, 1180 self.event_list = [] def update(self): if pi3d.PLATFORM == pi3d.PLATFORM_WINDOWS or pi3d.USE_PYGAME: #uses pygame UI k = self.tkKeyboard.read() if k == -1: self.key = "" self.ev = "" else: if k == 27: self.key = "Escape" else: self.key = chr(k) self.ev = "key" else: self.key = self.tkKeyboard.read_code() if self.key == "": self.ev = "" else: self.ev = "key"
class DummyTkWin(object): def __init__(self): self.tkKeyboard = Keyboard() self.ev = "" self.key = "" self.winx, self.winy = 0, 0 self.width, self.height = 1920, 1180 self.event_list = [] def update(self): self.key = self.tkKeyboard.read_code() if self.key == "": self.ev = "" else: self.ev = "key"
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() while 1: display.clear() Utility.load_identity() Utility.translatef(0,0, -40) Utility.rotatef(rot, 0, 1, 0) rot += 3
shader = Shader('shaders/uv_light') #======================================== # load model_loadmodel mymodel = Model(file_string='models/Triceratops/Triceratops.egg', name='Triceratops', x=0, y=-1, z=40, sx=0.005, sy=0.005, sz=0.005) mymodel.set_shader(shader) # Fetch key presses mykeys = Keyboard() while 1: DISPLAY.clear() mymodel.draw() mymodel.rotateIncZ(0.001) mymodel.rotateIncX(-0.00317543) mymodel.rotateIncY(0.11) k = mykeys.read() if k > -1: if k == 112: screenshot('Triceratops.jpg') elif k == 27: mykeys.close() DISPLAY.destroy()
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() while True: display.clear() maxDepth = 0 axDepthIndex = 0 # this is easier to understand, the z position of each cloud is (only) held in cxyz[][2] # it stops the clouds appearing in front of nearer clouds! # first go through the clouds to find index of furthest away for i in range(len(cxyz)): cxyz[i][2] = (cxyz[i][2] - speed) % cloud_depth if (cxyz[i][2] > maxDepth): maxDepth = cxyz[i][2] maxDepthIndex = i
size = 0.5 + random.random() / 2.0 cloud = Sprite(w=size * widex, h=size * widey, x=150.0 * (random.random() - 0.5), y=0.0, z=cloud_depth - cz) cloud.set_draw_details(shader, [cloudTex[int(random.random() * 4.99999)]], 0.0, 0.0) clouds.append(cloud) cz = cz + zd CAMERA = Camera.instance() CAMERA.position((0.0, 0.0, 50.0)) CAMERA.was_moved = False # Fetch key presses mykeys = Keyboard() while DISPLAY.loop_running(): # the z position of each cloud is held in clouds[i].unif[2] returned by cloud.z() # it stops the clouds being drawn behind nearer clouds and pixels being # discarded by the shader! that should be blended. # first go through the clouds to find index of furthest away maxDepthIndex = 0 maxDepth = -100 for i, cloud in enumerate(clouds): if cloud.z() > maxDepth: maxDepth = cloud.z() maxDepthIndex = i # paint the clouds from background to foreground # normally not the most efficient order but has to be done this way for low alpha