Add point lights

This commit is contained in:
Dane Johnson
2021-03-04 14:29:48 -06:00
parent c80696320b
commit 135b075aa1
9 changed files with 174 additions and 13 deletions

View File

@@ -44,6 +44,8 @@ function init()
light:SetSpecular(0.1)
couch.Node.GetRoot():AddChild(light:Instance())
init_point_lights()
local skybox = couch.Skybox.FromFiles(
"../resources/skybox/px.png",
"../resources/skybox/nx.png",
@@ -176,6 +178,22 @@ function update(delta)
end
end
function init_point_lights()
local colors = {couch.Vector3(1.0, 0.0, 0.0), couch.Vector3(0.0, 1.0, 0.0), couch.Vector3(0.0, 0.0, 1.0)}
for i, color in ipairs(colors) do
local pointLight = couch.PointLight();
pointLight:Translate(couch.Vector3(i * -10.0, 0, -10))
pointLight:SetRadius(10.0)
pointLight:SetColor(color)
pointLight:SetAmbient(1.0)
pointLight:SetSpecular(0.1)
local lightBox = couch.Mesh.FromFile("../resources/cube.obj")
lightBox:UniformScale(0.5);
pointLight:AddChild(lightBox);
couch.Node.GetRoot():AddChild(pointLight:Instance())
end
end
function action_dir(key, action, pos, neg, curr)
if key == pos and action == couch.ACTION_PRESS then
return 1.0