diff --git a/README.md b/README.md
index d23e3ea76..f94a05691 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
# Wicked Engine
-[![Build status][s1]][av] [![Download][s4]][do] [![License: MIT][s3]][li] [![Join the chat at https://gitter.im/WickedEngine/Lobby][s2]][gi]
+[![Build status][s1]][av] [![DownloadEditor][s4]][do] [![DownloadTests][s5]][dt] [![License: MIT][s3]][li] [![Join the chat at https://gitter.im/WickedEngine/Lobby][s2]][gi]
@@ -11,11 +11,13 @@
[s2]: https://badges.gitter.im/WickedEngine/Lobby.svg
[s3]: https://img.shields.io/badge/License-MIT-yellow.svg
[s4]: https://img.shields.io/badge/download%20build-editor-blue.svg
+[s5]: https://img.shields.io/badge/download%20build-samples-blue.svg
[av]: https://ci.appveyor.com/project/turanszkij/wickedengine
[gi]: https://gitter.im/WickedEngine/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
[li]: https://opensource.org/licenses/MIT
[do]: https://ci.appveyor.com/api/projects/turanszkij/wickedengine/artifacts/WickedEngineEditor.zip?branch=master
+[dt]: https://ci.appveyor.com/api/projects/turanszkij/wickedengine/artifacts/WickedEngineTests.zip?branch=master
[ba]: https://github.com/turanszkij/WickedEngine/tree/old-system-backup
### Overview:
@@ -123,6 +125,7 @@ When everything is initialized properly, you should see a black screen. From thi
- ./Documentation/ - Documentation files
- ./logo/ - Logo artwork images
- ./models/ - Sample model files
+- ./scripts/ - Sample LUA script files
- ./WickedEngine/ - Wicked Engine Library project
- ./Editor/ - Editor project
- ./Tests/ - Testing framework project
diff --git a/Tests/Tests.cpp b/Tests/Tests.cpp
index 9b03ca653..058145d22 100644
--- a/Tests/Tests.cpp
+++ b/Tests/Tests.cpp
@@ -30,6 +30,11 @@ void Tests::Initialize()
TestsRenderer::TestsRenderer()
{
+ setSSREnabled(false);
+ setSSAOEnabled(false);
+ setReflectionsEnabled(true);
+ setFXAAEnabled(false);
+
float screenW = (float)wiRenderer::GetDevice()->GetScreenWidth();
float screenH = (float)wiRenderer::GetDevice()->GetScreenHeight();
@@ -57,9 +62,13 @@ TestsRenderer::TestsRenderer()
testSelector->AddItem("EmittedParticle 2");
testSelector->AddItem("HairParticle");
testSelector->AddItem("Lua Script");
+ testSelector->AddItem("Water Test");
+ testSelector->AddItem("Shadows Test");
testSelector->OnSelect([=](wiEventArgs args) {
+ wiRenderer::SetTemporalAAEnabled(false);
wiRenderer::ClearWorld();
+ wiRenderer::GetScene().weather = WeatherComponent();
this->clearSprites();
wiLua::GetGlobal()->KillProcesses();
@@ -76,6 +85,7 @@ TestsRenderer::TestsRenderer()
break;
}
case 1:
+ wiRenderer::SetTemporalAAEnabled(true);
wiRenderer::LoadModel("../models/teapot.wiscene");
break;
case 2:
@@ -88,8 +98,17 @@ TestsRenderer::TestsRenderer()
wiRenderer::LoadModel("../models/hairparticle_torus.wiscene", XMMatrixTranslation(0, 1, 0));
break;
case 5:
+ wiRenderer::SetTemporalAAEnabled(true);
wiLua::GetGlobal()->RunFile("test_script.lua");
break;
+ case 6:
+ wiRenderer::SetTemporalAAEnabled(true);
+ wiRenderer::LoadModel("../models/water_test.wiscene", XMMatrixTranslation(0, 1, 0));
+ break;
+ case 7:
+ wiRenderer::SetTemporalAAEnabled(true);
+ wiRenderer::LoadModel("../models/shadows_test.wiscene", XMMatrixTranslation(0, 1, 0));
+ break;
}
});
diff --git a/Tests/test_script.lua b/Tests/test_script.lua
index 21c71f939..1021f729f 100644
--- a/Tests/test_script.lua
+++ b/Tests/test_script.lua
@@ -64,7 +64,7 @@ runProcess(function()
-- Rotate teapot by parent transform:
local transform = scene.Component_GetTransform(parent);
- transform.Rotate(Vector(0, 0.01, 0.001));
+ transform.Rotate(Vector(0, 0.01, 0));
fixedupdate(); -- wait for new frame
diff --git a/WickedEngine/wiRenderer_BindLua.cpp b/WickedEngine/wiRenderer_BindLua.cpp
index 142555c2e..433e61046 100644
--- a/WickedEngine/wiRenderer_BindLua.cpp
+++ b/WickedEngine/wiRenderer_BindLua.cpp
@@ -68,6 +68,11 @@ namespace wiRenderer_BindLua
return 1;
}
+ int GetCamera(lua_State* L)
+ {
+ Luna::push(L, new CameraComponent_BindLua(&wiRenderer::GetCamera()));
+ return 1;
+ }
int GetScene(lua_State* L)
{
Luna::push(L, new Scene_BindLua(&wiRenderer::GetScene()));
@@ -370,6 +375,7 @@ namespace wiRenderer_BindLua
wiLua::GetGlobal()->RegisterFunc("GetScreenWidth", GetScreenWidth);
wiLua::GetGlobal()->RegisterFunc("GetScreenHeight", GetScreenHeight);
+ wiLua::GetGlobal()->RegisterFunc("GetCamera", GetCamera);
wiLua::GetGlobal()->RegisterFunc("GetScene", GetScene);
wiLua::GetGlobal()->RegisterFunc("LoadModel", LoadModel);
diff --git a/WickedEngine/wiSceneSystem_BindLua.cpp b/WickedEngine/wiSceneSystem_BindLua.cpp
index 7795c5d0c..900a75c42 100644
--- a/WickedEngine/wiSceneSystem_BindLua.cpp
+++ b/WickedEngine/wiSceneSystem_BindLua.cpp
@@ -29,11 +29,13 @@ void Bind()
lua_State* L = wiLua::GetGlobal()->GetLuaState();
wiLua::GetGlobal()->RegisterFunc("CreateEntity", CreateEntity_BindLua);
+ wiLua::GetGlobal()->RunText("INVALID_ENTITY = 0");
Luna::Register(L);
Luna::Register(L);
Luna::Register(L);
Luna::Register(L);
+ Luna::Register(L);
Luna::Register(L);
}
}
@@ -53,6 +55,7 @@ Luna::FunctionType Scene_BindLua::methods[] = {
lunamethod(Scene_BindLua, Component_GetName),
lunamethod(Scene_BindLua, Component_GetLayer),
lunamethod(Scene_BindLua, Component_GetTransform),
+ lunamethod(Scene_BindLua, Component_GetCamera),
lunamethod(Scene_BindLua, Component_GetAnimation),
lunamethod(Scene_BindLua, Component_Attach),
lunamethod(Scene_BindLua, Component_Detach),
@@ -228,6 +231,23 @@ int Scene_BindLua::Component_GetTransform(lua_State* L)
}
return 0;
}
+int Scene_BindLua::Component_GetCamera(lua_State* L)
+{
+ int argc = wiLua::SGetArgCount(L);
+ if (argc > 0)
+ {
+ Entity entity = (Entity)wiLua::SGetInt(L, 1);
+
+ CameraComponent* component = scene->cameras.GetComponent(entity);
+ Luna::push(L, new CameraComponent_BindLua(component));
+ return 1;
+ }
+ else
+ {
+ wiLua::SError(L, "Scene::Component_GetCamera(Entity entity) not enough arguments!");
+ }
+ return 0;
+}
int Scene_BindLua::Component_GetAnimation(lua_State* L)
{
int argc = wiLua::SGetArgCount(L);
@@ -406,6 +426,7 @@ Luna::FunctionType TransformComponent_BindLua::metho
lunamethod(TransformComponent_BindLua, MatrixTransform),
lunamethod(TransformComponent_BindLua, GetMatrix),
lunamethod(TransformComponent_BindLua, ClearTransform),
+ lunamethod(TransformComponent_BindLua, UpdateTransform),
lunamethod(TransformComponent_BindLua, GetPosition),
lunamethod(TransformComponent_BindLua, GetRotation),
lunamethod(TransformComponent_BindLua, GetScale),
@@ -614,6 +635,11 @@ int TransformComponent_BindLua::ClearTransform(lua_State* L)
component->ClearTransform();
return 0;
}
+int TransformComponent_BindLua::UpdateTransform(lua_State* L)
+{
+ component->UpdateTransform();
+ return 0;
+}
int TransformComponent_BindLua::GetPosition(lua_State* L)
{
XMVECTOR V = component->GetPositionV();
@@ -642,6 +668,58 @@ int TransformComponent_BindLua::GetScale(lua_State* L)
+const char CameraComponent_BindLua::className[] = "CameraComponent";
+
+Luna::FunctionType CameraComponent_BindLua::methods[] = {
+ lunamethod(CameraComponent_BindLua, UpdateCamera),
+ { NULL, NULL }
+};
+Luna::PropertyType CameraComponent_BindLua::properties[] = {
+ { NULL, NULL }
+};
+
+CameraComponent_BindLua::CameraComponent_BindLua(lua_State *L)
+{
+ owning = true;
+ component = new CameraComponent;
+}
+CameraComponent_BindLua::~CameraComponent_BindLua()
+{
+ if (owning)
+ {
+ delete component;
+ }
+}
+
+int CameraComponent_BindLua::UpdateCamera(lua_State* L)
+{
+ int argc = wiLua::SGetArgCount(L);
+ if (argc > 0)
+ {
+ TransformComponent_BindLua* transform = Luna::lightcheck(L, 1);
+ if (transform != nullptr)
+ {
+ component->UpdateCamera(transform->component);
+ return 0;
+ }
+ else
+ {
+ wiLua::SError(L, "UpdateCamera(opt TransformComponent transform) invalid argument!");
+ }
+ }
+ component->UpdateCamera();
+ return 0;
+}
+
+
+
+
+
+
+
+
+
+
const char AnimationComponent_BindLua::className[] = "AnimationComponent";
Luna::FunctionType AnimationComponent_BindLua::methods[] = {
diff --git a/WickedEngine/wiSceneSystem_BindLua.h b/WickedEngine/wiSceneSystem_BindLua.h
index 3b5995739..841803373 100644
--- a/WickedEngine/wiSceneSystem_BindLua.h
+++ b/WickedEngine/wiSceneSystem_BindLua.h
@@ -33,6 +33,7 @@ namespace wiSceneSystem_BindLua
int Component_GetName(lua_State* L);
int Component_GetLayer(lua_State* L);
int Component_GetTransform(lua_State* L);
+ int Component_GetCamera(lua_State* L);
int Component_GetAnimation(lua_State* L);
int Component_Attach(lua_State* L);
@@ -98,11 +99,29 @@ namespace wiSceneSystem_BindLua
int MatrixTransform(lua_State* L);
int GetMatrix(lua_State* L);
int ClearTransform(lua_State* L);
+ int UpdateTransform(lua_State* L);
int GetPosition(lua_State* L);
int GetRotation(lua_State* L);
int GetScale(lua_State* L);
};
+ class CameraComponent_BindLua
+ {
+ public:
+ bool owning = false;
+ wiSceneSystem::CameraComponent* component = nullptr;
+
+ static const char className[];
+ static Luna::FunctionType methods[];
+ static Luna::PropertyType properties[];
+
+ CameraComponent_BindLua(wiSceneSystem::CameraComponent* component) :component(component) {}
+ CameraComponent_BindLua(lua_State *L);
+ ~CameraComponent_BindLua();
+
+ int UpdateCamera(lua_State* L);
+ };
+
class AnimationComponent_BindLua
{
public:
diff --git a/appveyor.yml b/appveyor.yml
index 03d8eb917..094b80378 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -11,6 +11,10 @@ build:
after_build:
- cmd: move %APPVEYOR_BUILD_FOLDER%\x64\Release\Editor.exe %APPVEYOR_BUILD_FOLDER%\Editor
- cmd: 7z a WickedEngineEditor.zip WickedEngine\shaders\ WickedEngine\fonts\ logo\ models\ scripts\ shadercompilers\ Documentation\ *.py *.txt *.md Editor\Editor.exe Editor\images\ Editor\*.ini Editor\*.ico Editor\*.lua
+- cmd: move %APPVEYOR_BUILD_FOLDER%\x64\Release\Tests.exe %APPVEYOR_BUILD_FOLDER%\Tests
+- cmd: 7z a WickedEngineTests.zip WickedEngine\shaders\ WickedEngine\fonts\ logo\ models\ scripts\ shadercompilers\ Documentation\ *.py *.txt *.md Tests\Tests.exe Tests\images\ Tests\*.ini Tests\*.ico Tests\*.lua
artifacts:
- path: WickedEngineEditor.zip
name: Editor
+- path: WickedEngineTests.zip
+ name: Tests
diff --git a/models/cameras.wiscene b/models/cameras.wiscene
new file mode 100644
index 000000000..7825681ff
Binary files /dev/null and b/models/cameras.wiscene differ
diff --git a/models/shadows_test.wiscene b/models/shadows_test.wiscene
new file mode 100644
index 000000000..a10dffa40
Binary files /dev/null and b/models/shadows_test.wiscene differ
diff --git a/models/sky.dds b/models/sky.dds
new file mode 100644
index 000000000..da0ab84cd
Binary files /dev/null and b/models/sky.dds differ
diff --git a/models/water_plane.wiscene b/models/water_plane.wiscene
new file mode 100644
index 000000000..45f166a03
Binary files /dev/null and b/models/water_plane.wiscene differ
diff --git a/models/water_test.wiscene b/models/water_test.wiscene
new file mode 100644
index 000000000..15b757f21
Binary files /dev/null and b/models/water_test.wiscene differ
diff --git a/scripts/camera_animation_clamped.lua b/scripts/camera_animation_clamped.lua
new file mode 100644
index 000000000..fa7138900
--- /dev/null
+++ b/scripts/camera_animation_clamped.lua
@@ -0,0 +1,74 @@
+-- This script will play a camera animation chain from "cam0" -to "camN" named camera proxies in the scene
+-- To use this, first place four cameras into the scene and name them cam0, cam1, cam2 and cam3, then press F8 to start
+-- The animation will repeat infinitely, but it will cut from last to first proxy at the end
+
+-- Get the main camera:
+local cam = GetCamera()
+
+-- This will be the transform that we grab the camera by:
+local target = TransformComponent()
+
+-- Get the main scene:
+local scene = GetScene()
+
+-- Camera speed overridable from outer scope too:
+scriptableCameraSpeed = 0.4
+
+-- Animation state:
+local tt = 0.0
+local play = false
+local rot = 0
+
+-- Gather camera proxy entities in the scene from "cam0" to "cam1", "cam2", ... "camN":
+local proxies={}
+local it = 0
+while true do
+ local entity = scene.Entity_FindByName("cam" .. it)
+ if(entity == INVALID_ENTITY) then
+ break
+ end
+ it = it + 1
+ proxies[it] = entity
+end
+
+runProcess(function()
+ while true do
+
+ if(input.Press(VK_F8)) then
+ -- Reset animation:
+ tt = 0.0
+ play = not play
+ rot = 0
+ end
+ if(play) then
+ -- Play animation:
+ local count = len(proxies)
+
+ -- Place main camera on spline:
+ local a = scene.Component_GetTransform(proxies[math.clamp(rot - 1, 0, count - 1) + 1])
+ local b = scene.Component_GetTransform(proxies[math.clamp(rot, 0, count - 1) + 1])
+ local c = scene.Component_GetTransform(proxies[math.clamp(rot + 1, 0, count - 1) + 1])
+ local d = scene.Component_GetTransform(proxies[math.clamp(rot + 2, 0, count - 1) + 1])
+ target.CatmullRom(a, b, c, d, tt)
+ target.UpdateTransform()
+ cam.UpdateCamera(target)
+
+ -- Advance animation state:
+ tt = tt + scriptableCameraSpeed * getDeltaTime()
+ if(tt >= 1.0) then
+ tt = 0.0
+ rot = rot + 1
+ end
+ if(rot >= count - 1) then
+ rot = 0
+ end
+
+ end
+
+ -- Wait for render() tick from Engine
+ -- We should wait for update() normally, but Editor tends to update the camera already from update()
+ -- and it would overridethe scrips...
+ render()
+
+ end
+end)
\ No newline at end of file
diff --git a/scripts/camera_animation_repeat.lua b/scripts/camera_animation_repeat.lua
new file mode 100644
index 000000000..f842f6f7a
--- /dev/null
+++ b/scripts/camera_animation_repeat.lua
@@ -0,0 +1,71 @@
+-- This script will play a camera animation chain from "cam0" -to "camN" named camera proxies in the scene
+-- To use this, first place four cameras into the scene and name them cam0, cam1, cam2 and cam3, then press F8 to start
+-- The animation will repeat infinitely, but it will cut from last to first proxy at the end
+
+-- Get the main camera:
+local cam = GetCamera()
+
+-- This will be the transform that we grab the camera by:
+local target = TransformComponent()
+
+-- Get the main scene:
+local scene = GetScene()
+
+-- Camera speed overridable from outer scope too:
+scriptableCameraSpeed = 0.4
+
+-- Animation state:
+local tt = 0.0
+local play = false
+local rot = 0
+
+-- Gather camera proxy entities in the scene from "cam0" to "cam1", "cam2", ... "camN":
+local proxies={}
+local it = 0
+while true do
+ local entity = scene.Entity_FindByName("cam" .. it)
+ if(entity == INVALID_ENTITY) then
+ break
+ end
+ it = it + 1
+ proxies[it] = entity
+end
+
+runProcess(function()
+ while true do
+
+ if(input.Press(VK_F8)) then
+ -- Reset animation:
+ tt = 0.0
+ play = not play
+ rot = 0
+ end
+ if(play) then
+ -- Play animation:
+ local count = len(proxies)
+
+ -- Place main camera on spline:
+ local a = scene.Component_GetTransform(proxies[(rot - 1) % count + 1])
+ local b = scene.Component_GetTransform(proxies[rot % count + 1])
+ local c = scene.Component_GetTransform(proxies[(rot + 1) % count + 1])
+ local d = scene.Component_GetTransform(proxies[(rot + 2) % count + 1])
+ target.CatmullRom(a, b, c, d, tt)
+ target.UpdateTransform()
+ cam.UpdateCamera(target)
+
+ -- Advance animation state:
+ tt = tt + scriptableCameraSpeed * getDeltaTime()
+ if(tt >= 1.0) then
+ tt = 0.0
+ rot = rot + 1
+ end
+
+ end
+
+ -- Wait for render() tick from Engine
+ -- We should wait for update() normally, but Editor tends to update the camera already from update()
+ -- and it would overridethe scrips...
+ render()
+
+ end
+end)
\ No newline at end of file