added more samples/tests and scripts
This commit is contained in:
@@ -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]
|
||||
<a href="https://twitter.com/intent/follow?screen_name=turanszkij">
|
||||
<img src="https://img.shields.io/twitter/follow/turanszkij.svg?style=social"
|
||||
alt="follow on Twitter"></a>
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -68,6 +68,11 @@ namespace wiRenderer_BindLua
|
||||
return 1;
|
||||
}
|
||||
|
||||
int GetCamera(lua_State* L)
|
||||
{
|
||||
Luna<CameraComponent_BindLua>::push(L, new CameraComponent_BindLua(&wiRenderer::GetCamera()));
|
||||
return 1;
|
||||
}
|
||||
int GetScene(lua_State* L)
|
||||
{
|
||||
Luna<Scene_BindLua>::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);
|
||||
|
||||
|
||||
@@ -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<Scene_BindLua>::Register(L);
|
||||
Luna<NameComponent_BindLua>::Register(L);
|
||||
Luna<LayerComponent_BindLua>::Register(L);
|
||||
Luna<TransformComponent_BindLua>::Register(L);
|
||||
Luna<CameraComponent_BindLua>::Register(L);
|
||||
Luna<AnimationComponent_BindLua>::Register(L);
|
||||
}
|
||||
}
|
||||
@@ -53,6 +55,7 @@ Luna<Scene_BindLua>::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<CameraComponent_BindLua>::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<TransformComponent_BindLua>::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<CameraComponent_BindLua>::FunctionType CameraComponent_BindLua::methods[] = {
|
||||
lunamethod(CameraComponent_BindLua, UpdateCamera),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<CameraComponent_BindLua>::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<TransformComponent_BindLua>::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<AnimationComponent_BindLua>::FunctionType AnimationComponent_BindLua::methods[] = {
|
||||
|
||||
@@ -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<CameraComponent_BindLua>::FunctionType methods[];
|
||||
static Luna<CameraComponent_BindLua>::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:
|
||||
|
||||
@@ -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
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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)
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user