1 puts "================================="
2 puts "0031704: Visualization - add an interactive object AIS_LightSource representing a light source"
3 puts "================================="
5 pload MODELING VISUALIZATION
7 vinit View1 -width 1280 -height 720
9 vbackground -color GRAY
10 vrenderparams -shadingModel PBR
11 box b 10 10 10 30 30 30
12 vdisplay b -dispMode 1
13 vaspects b -material Brass
16 puts "=== Add light sources and display their presentations ==="
17 vlight -add ambient -color WHITE -name AMBIENT -display
18 vlight -add directional -dir 0 1 0 -name DIR -color GREEN -display
19 vlight -add spotlight -pos 50 25 25 -dir -1 0 0 -intensity 1000000000 -name SPOT -color RED -display
20 vlight -add positional -pos 25 25 50 -intensity 10000000000 -range 20 -name POSITIONAL -color BLUE -display
22 vdump $imagedir/${casename}_def.png
24 puts "=== Turn off light sources ==="
25 set mouse_pick_amb {105 97}
26 set mouse_pick_spot {897 508}
27 set mouse_pick_pos {640 62}
28 set mouse_pick_dir {330 536}
29 vselect {*}$mouse_pick_amb
30 vselect {*}$mouse_pick_spot
31 vselect {*}$mouse_pick_pos
32 vselect {*}$mouse_pick_dir
33 vdump $imagedir/${casename}_off.png
35 set aColor_spot [vreadpixel 796 454 rgb name]
36 set aColor_pos [vreadpixel 630 177 rgb name]
37 if { "$aColor_spot" != "LIGHTSALMON3" } { puts "Error: expected color near the light spot is LIGHTSALMON3" }
38 if { "$aColor_pos" != "THISTLE4"} { puts "Error: expected color near the positional light is THISTLE4" }
40 puts "=== Delete presentations of light sources ==="
41 vremove AMBIENT DIR SPOT POSITIONAL
43 puts "=== Display all light sources ==="
44 vlight -change 0 -display
45 vlight -change 1 -display
46 vlight -change 2 -display -showRange 1
47 vlight -change 3 -display -showRange 1
48 vdump $imagedir/${casename}_on.png
50 puts "=== Turn on light sources ==="
51 vselect {*}$mouse_pick_amb
52 vselect {*}$mouse_pick_spot
53 vselect {*}$mouse_pick_pos
54 vselect {*}$mouse_pick_dir
55 set aColor_spot [vreadpixel 796 454 rgb name]
56 set aColor_pos [vreadpixel 630 177 rgb name]
57 set aColor_dir [vreadpixel 453 453 rgb name]
58 if { "$aColor_spot" != "CORAL" } { puts "Error: expected color near the light spot is CORAL" }
59 if { "$aColor_pos" != "LIGHTSLATEBLUE"} { puts "Error: expected color near the positional light is LIGHTSLATEBLUE" }
60 if { "$aColor_dir" != "BURLYWOOD3" } { puts "Error: expected color near the directional light is BURLYWOOD3" }
63 #vdump $imagedir/${casename}_cleared.png