-
Notifications
You must be signed in to change notification settings - Fork 0
/
lights.lua
55 lines (47 loc) · 1.8 KB
/
lights.lua
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
worldStateSet = RelativeTo.World:getOrCreateStateSet()
function createLight1()
-- create a light object
light1 = osg.Light()
-- set light number (openGL and osg can have up to eight lights in a scene #0-7)
light1:setLightNum(0)
-- create a lightsource object
lightsource1 = osg.LightSource()
-- turn the light source on
lightsource1:setLocalStateSetModes(osg.StateAttribute.Values.ON)
-- set light l1 to light source ls1
lightsource1:setLight(light1)
--set light attributes
light1:setAmbient(osg.Vec4(0.8, 0.8, 0.8, 0.5))
light1:setDiffuse(osg.Vec4(0.8, 0.8, 0.8, 0.8))
light1:setSpecular(osg.Vec4(0.8, 0.8, 0.8, 0.8))
-- turn the light on in the relativeto.world state set
worldStateSet:setAssociatedModes(light1, osg.StateAttribute.Values.ON)
--add lightsource to scene (room)
RelativeTo.Room:addChild(lightsource1)
-- set position of light
light1:setPosition(osg.Vec4(0, 3, -5, 1.0))
end
function createLight2()
-- create a light object
light2 = osg.Light()
-- set light number (openGL and osg can have up to eight lights in a scene #0-7)
light2:setLightNum(1)
-- create a lightsource object
lightsource2 = osg.LightSource()
-- turn the light source on
lightsource2:setLocalStateSetModes(osg.StateAttribute.Values.ON)
-- set light light2 to lightsource lightsource2
lightsource2:setLight(light2)
--set light attributes
light2:setAmbient(osg.Vec4(.8, .8, 0.6, .50))
-- turn the light on in the relativeto.world state set
worldStateSet:setAssociatedModes(light2, osg.StateAttribute.Values.OFF)
--add lightsource to scene (room)
RelativeTo.Room:addChild(lightsource2)
-- set position of light
light2:setPosition(osg.Vec4(1.5, 2, 2, 1.0))
end
--calls to turn create lights functions (by extension creates them and turns them ON)
createLight1()
createLight2()
print("Added lights to scene")