File: scene.py

package info (click to toggle)
swig 1.1p5-1
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 9,448 kB
  • ctags: 5,025
  • sloc: cpp: 21,599; ansic: 13,333; yacc: 3,297; python: 2,794; makefile: 2,197; perl: 1,984; tcl: 1,583; sh: 736; lisp: 201; objc: 143
file content (44 lines) | stat: -rw-r--r-- 962 bytes parent folder | download | duplicates (4)
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
from image3d import *
import math

class Scene(Image3D):
	def __init__(self):
		Image3D.__init__(self,-5,-5,-5,5,5,5)
		self.title = "Scene"
		self.lookat(20)
		self.autoperspective(40)

	# Draw a few primitives

	def draw(self):
		self.newplot()
		self.solidquad(0,0,0,0,2,0,2,2,0,2,0,0,BLUE)
		self.solidquad(0,0,2,0,2,2,2,2,2,2,0,2,WHITE)
		self.solidquad(0,0,0,0,2,0,0,2,2,0,0,2,RED)
		self.solidquad(2,0,0,2,2,0,2,2,2,2,0,2,CYAN)
		self.solidquad(0,0,0,0,0,2,2,0,2,2,0,0,YELLOW)
		self.solidquad(0,2,0,0,2,2,2,2,2,2,2,0,GREEN)
		self.solidtriangle(-5,-5,-5,5,3,5,-5,-5,5,BLUE)
	        z = 0.0
		dz = 0.1
		for j in range(0,50):
			dx = 0.1
			lastx = -5.0
			lasty = math.sin(lastx)
			x = lastx
			for i in range(0,100):
				x = x + dx
				y = math.sin(x)
				self.quad(lastx,lasty,lasty+z,x,y,y+z,
					       x,y,y+z-dz,lastx,lasty,lasty+z-dz,4*j)
				lastx = x
				lasty = y
			z = z + dz
		

			
s = Scene()
s.rotr(30)
s.rotd(20)
s.zoom(160)
s.show()