forked from tipam/pi3d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TriceratopsModel.py
57 lines (46 loc) · 1.25 KB
/
TriceratopsModel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# 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
#
# 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,1200,900) # x,y,width,height
display.setBackColour(0.2,0.4,0.6,1) # r,g,b,alpha
# load model_loadmodel
mymodel = pi3d.loadModel("models/Triceratops/Triceratops.egg","Triceratops", 0,-1,0, -90,0,0, .005,.005,.005)
# Fetch key presses
mykeys = pi3d.key()
# mastrix and rotate variables
rot=0
#create a light
mylight = pi3d.createLight(0,1,1,1,"",10,10,0)
mylight.on()
while 1:
display.clear()
pi3d.identity()
pi3d.position(0,0,-40)
pi3d.rotate(0,rot,0)
rot += 3
mymodel.draw()
k = mykeys.read()
if k >-1:
if k==112: display.screenshot("Triceratops.jpg")
elif k==27:
display.destroy()
mykeys.close()
break
else:
print k
display.swapBuffers()