Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions vrjugglua/lua/nav-app-skeleton.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,36 @@ function osgnav:latePreFrame()
end
end

function osgnav:setupDefaultLighting()
local WorldStateSet = RelativeTo.World:getOrCreateStateSet()
--Light 0
local light0 = osg.Light()
light0:setAmbient(osg.Vec4(0.8, 0.8, 0.8, 0.8))
local lightsource0 = osg.LightSource()
lightsource0:setLight(light0)
lightsource0:setLocalStateSetModes(osg.StateAttribute.Values.ON)
WorldStateSet:setAssociatedModes(light0, osg.StateAttribute.Values.ON)
RelativeTo.Room:addChild(lightsource0)
light0:setPosition(osg.Vec4(0, 10, 0, 1.0))

--Light 1
local light1 = osg.Light()
light1:setLightNum(1)
light1:setAmbient(osg.Vec4(.8, .8, 0.6, .50))
local lightsource1 = osg.LightSource()
lightsource1:setLight(light1)
lightsource1:setLocalStateSetModes(osg.StateAttribute.Values.ON)
WorldStateSet:setAssociatedModes(light1, osg.StateAttribute.Values.ON)
RelativeTo.Room:addChild(lightsource1)
light1:setPosition(osg.Vec4(1.5, 2, 0, 1.0))

function osgnav:clearDefaultLighting()
RelativeTo.Room:removeChild(lightsource0)
RelativeTo.Room:removeChild(lightsource1)
WorldStateSet:setAssociatedModes(light1, osg.StateAttribute.Values.OFF)
end
end


print("Setting up scenegraph")
navtransform = osg.PositionAttitudeTransform()
Expand All @@ -86,6 +116,8 @@ osgnav.appProxy:setAppDelegate(osgnav)
print("Setting kernel application")
osgnav.appProxy:setActiveApplication()

print("Setting up default lighting (lights 0 and 1). Call osgnav:clearDefaultLighting() to remove light sources from graph and disable light #1.")
osgnav:setupDefaultLighting()



Expand Down