forked from panda3d/panda3d
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_lightattrib.py
More file actions
74 lines (54 loc) · 2.21 KB
/
test_lightattrib.py
File metadata and controls
74 lines (54 loc) · 2.21 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
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
from panda3d import core
# Some dummy lights we can use for our light attributes.
spot = core.NodePath(core.Spotlight("spot"))
point = core.NodePath(core.PointLight("point"))
ambient = core.NodePath(core.AmbientLight("ambient"))
def test_lightattrib_compose_add():
# Tests a case in which a child node adds another light.
lattr1 = core.LightAttrib.make()
lattr1 = lattr1.add_on_light(spot)
lattr2 = core.LightAttrib.make()
lattr2 = lattr2.add_on_light(point)
lattr3 = lattr1.compose(lattr2)
assert lattr3.get_num_on_lights() == 2
assert spot in lattr3.on_lights
assert point in lattr3.on_lights
def test_lightattrib_compose_subtract():
# Tests a case in which a child node disables a light.
lattr1 = core.LightAttrib.make()
lattr1 = lattr1.add_on_light(spot)
lattr1 = lattr1.add_on_light(point)
lattr2 = core.LightAttrib.make()
lattr2 = lattr2.add_off_light(ambient)
lattr2 = lattr2.add_off_light(point)
lattr3 = lattr1.compose(lattr2)
assert lattr3.get_num_on_lights() == 1
assert spot in lattr3.on_lights
assert point not in lattr3.on_lights
assert ambient not in lattr3.on_lights
def test_lightattrib_compose_both():
# Tests a case in which a child node both enables and disables a light.
lattr1 = core.LightAttrib.make()
lattr1 = lattr1.add_on_light(spot)
lattr1 = lattr1.add_on_light(point)
lattr2 = core.LightAttrib.make()
lattr2 = lattr2.add_on_light(ambient)
lattr2 = lattr2.add_on_light(spot)
lattr2 = lattr2.add_off_light(point)
lattr3 = lattr1.compose(lattr2)
assert lattr3.get_num_on_lights() == 2
assert spot in lattr3.on_lights
assert point not in lattr3.on_lights
assert ambient in lattr3.on_lights
def test_lightattrib_compose_alloff():
# Tests a case in which a child node disables all lights.
lattr1 = core.LightAttrib.make()
lattr1 = lattr1.add_on_light(spot)
lattr1 = lattr1.add_on_light(point)
assert lattr1.get_num_on_lights() == 2
lattr2 = core.LightAttrib.make_all_off()
assert lattr2.has_all_off()
lattr3 = lattr1.compose(lattr2)
assert lattr3.get_num_on_lights() == 0
assert lattr3.get_num_off_lights() == 0
assert lattr3.has_all_off()