-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaterial.py
More file actions
32 lines (24 loc) · 953 Bytes
/
material.py
File metadata and controls
32 lines (24 loc) · 953 Bytes
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
from color import Color
class Material:
def __init__(self, color=Color.from_hex('#FFFFFF'), ambient=0.5, diffuse=1.0, specular=1.0, reflection=0.5):
self.color = color
self.ambient = ambient
self.diffuse = diffuse
self.specular = specular
self.reflection = reflection
def color_at(self, position):
return self.color
class ChequeredMaterial:
def __init__(self, color1=Color.from_hex('#FFFFFF'), color2=Color.from_hex('#000000'), ambient=0.5, diffuse=1.0,
specular=1.0, reflection=0.5):
self.color1 = color1
self.color2 = color2
self.ambient = ambient
self.diffuse = diffuse
self.specular = specular
self.reflection = reflection
def color_at(self, position):
if int((position.x + 5.0) * 3.0) % 2 == int((position.z + 5.0) * 3.0) % 2:
return self.color1
else:
return self.color2