From d17a3f1fbe5f2f486d2a7bdeed0ced1776d2ee47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tur=C3=A1nszki=20J=C3=A1nos?= Date: Thu, 23 Jun 2022 10:39:25 +0200 Subject: [PATCH] scripting updates --- Content/Content.vcxitems | 1 + Content/Content.vcxitems.filters | 3 +++ .../Documentation/ScriptingAPI-Documentation.md | 1 + Content/scripts/spawn_many_lights.lua | 3 ++- WickedEngine/wiScene_BindLua.cpp | 15 +++++++++++++++ WickedEngine/wiScene_BindLua.h | 1 + 6 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Content/Content.vcxitems b/Content/Content.vcxitems index 65c901d0d..f4d7b7407 100644 --- a/Content/Content.vcxitems +++ b/Content/Content.vcxitems @@ -595,6 +595,7 @@ true true + diff --git a/Content/Content.vcxitems.filters b/Content/Content.vcxitems.filters index d9ba4158d..a7b233078 100644 --- a/Content/Content.vcxitems.filters +++ b/Content/Content.vcxitems.filters @@ -201,6 +201,9 @@ scripts + + scripts + diff --git a/Content/Documentation/ScriptingAPI-Documentation.md b/Content/Documentation/ScriptingAPI-Documentation.md index 375dc5674..5e7363f77 100644 --- a/Content/Documentation/ScriptingAPI-Documentation.md +++ b/Content/Documentation/ScriptingAPI-Documentation.md @@ -585,6 +585,7 @@ Describes an orientation in 3D space. - SetEnergy(float value) - SetColor(Vector value) - SetCastShadow(bool value) +- SetVolumetricsEnabled(bool value) - SetFOV(float value) - GetType() : int result diff --git a/Content/scripts/spawn_many_lights.lua b/Content/scripts/spawn_many_lights.lua index b9b4d2d41..41c991ab1 100644 --- a/Content/scripts/spawn_many_lights.lua +++ b/Content/scripts/spawn_many_lights.lua @@ -12,7 +12,7 @@ local bounds_max = scene.GetBounds().GetMax() for i=1,200 do local entity = CreateEntity() entities[i] = entity - velocities[i] = math.lerp(0.1, 0.5, math.random()) + velocities[i] = math.lerp(0.1, 0.2, math.random()) local light_transform = scene.Component_CreateTransform(entity) light_transform.Translate(Vector( math.lerp(bounds_min.GetX(), bounds_max.GetX(), math.random()), @@ -25,6 +25,7 @@ for i=1,200 do light_component.SetEnergy(6) light_component.SetColor(Vector(1,0.5,0)) -- orange color --light_component.SetColor(Vector(math.random(),math.random(),math.random())) -- random color + --light_component.SetVolumetricsEnabled(true) light_component.SetCastShadow(true) end diff --git a/WickedEngine/wiScene_BindLua.cpp b/WickedEngine/wiScene_BindLua.cpp index 44933ea49..1c396e388 100644 --- a/WickedEngine/wiScene_BindLua.cpp +++ b/WickedEngine/wiScene_BindLua.cpp @@ -2160,6 +2160,7 @@ Luna::FunctionType LightComponent_BindLua::methods[] = { lunamethod(LightComponent_BindLua, SetEnergy), lunamethod(LightComponent_BindLua, SetColor), lunamethod(LightComponent_BindLua, SetCastShadow), + lunamethod(LightComponent_BindLua, SetVolumetricsEnabled), lunamethod(LightComponent_BindLua, GetType), lunamethod(LightComponent_BindLua, SetFOV), { NULL, NULL } @@ -2262,6 +2263,20 @@ int LightComponent_BindLua::SetCastShadow(lua_State* L) return 0; } +int LightComponent_BindLua::SetVolumetricsEnabled(lua_State* L) +{ + int argc = wi::lua::SGetArgCount(L); + if (argc > 0) + { + component->SetVolumetricsEnabled(wi::lua::SGetBool(L, 1)); + } + else + { + wi::lua::SError(L, "SetVolumetricsEnabled(bool value) not enough arguments!"); + } + + return 0; +} int LightComponent_BindLua::SetFOV(lua_State* L) { int argc = wi::lua::SGetArgCount(L); diff --git a/WickedEngine/wiScene_BindLua.h b/WickedEngine/wiScene_BindLua.h index 1d509d24c..037ea2919 100644 --- a/WickedEngine/wiScene_BindLua.h +++ b/WickedEngine/wiScene_BindLua.h @@ -280,6 +280,7 @@ namespace wi::lua::scene int SetEnergy(lua_State* L); int SetColor(lua_State* L); int SetCastShadow(lua_State* L); + int SetVolumetricsEnabled(lua_State* L); int SetFOV(lua_State* L); int GetType(lua_State* L);