-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlightSource.py
More file actions
29 lines (26 loc) · 1.09 KB
/
lightSource.py
File metadata and controls
29 lines (26 loc) · 1.09 KB
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
import numpy as np
class LightSource:
'''
Base class for maintaining a light source in the scene. Inheriting from Sphere allows to visualize the light
source position easily.
'''
def __init__(self, scene, position=[2.,2.,0.], Ia=[0.2,0.2,0.2], Id=[0.9,0.9,0.9], Is=[1.0,1.0,1.0]):
'''
:param scene: The scene in which the light source exists.
:param position: the position of the light source
:param Ia: The ambiant illumination it provides (may not be dependent on the light source itself)
:param Id: The diffuse illumination
:param Is: The specular illumination
:param visible: Whether the light should be represented as a sphere in the scene (default: False)
'''
self.position = np.array(position,'f')
self.Ia = Ia
self.Id = Id
self.Is = Is
def update(self, position=None):
'''
update the position of the light source.
:param position: [optional] sets the current light source position.
'''
if position is not None:
self.position = position