aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/jin.exebin1597440 -> 1597440 bytes
-rw-r--r--build/vc++/3rdparty/luax/luax.vcxproj123
-rw-r--r--build/vc++/3rdparty/luax/luax.vcxproj.filters6
-rw-r--r--build/vc++/3rdparty/luax/luax.vcxproj.user4
-rw-r--r--build/vc++/jin.sln11
-rw-r--r--build/vc++/libjin/libjin.vcxproj3
-rw-r--r--build/vc++/libjin/libjin.vcxproj.filters9
-rw-r--r--src/libjin/common/je_utf8.cpp42
-rw-r--r--src/libjin/common/je_utf8.h34
-rw-r--r--src/libjin/graphics/particles/je_particle_system.cpp8
-rw-r--r--src/libjin/graphics/particles/je_particle_system.h4
-rw-r--r--src/libjin/utils/je_log.h1
-rw-r--r--src/lua/common/je_lua.cpp5
-rw-r--r--src/lua/common/je_lua.h5
-rw-r--r--src/lua/modules/filesystem/je_lua_filesystem.cpp1
-rw-r--r--src/lua/modules/graphics/je_lua_particle_system.cpp387
-rw-r--r--src/lua/modules/graphics/je_lua_particle_system.h21
-rw-r--r--src/lua/modules/graphics/je_lua_shader.cpp2
-rw-r--r--src/lua/modules/net/je_lua_net.cpp2
19 files changed, 572 insertions, 96 deletions
diff --git a/bin/jin.exe b/bin/jin.exe
index f877bf3..290bd9a 100644
--- a/bin/jin.exe
+++ b/bin/jin.exe
Binary files differ
diff --git a/build/vc++/3rdparty/luax/luax.vcxproj b/build/vc++/3rdparty/luax/luax.vcxproj
new file mode 100644
index 0000000..354e437
--- /dev/null
+++ b/build/vc++/3rdparty/luax/luax.vcxproj
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <VCProjectVersion>15.0</VCProjectVersion>
+ <ProjectGuid>{C6B16179-5640-4D41-8756-0525D25EB569}</ProjectGuid>
+ <RootNamespace>luax</RootNamespace>
+ <WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <PlatformToolset>v141</PlatformToolset>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>MultiByte</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="Shared">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup />
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <SDLCheck>true</SDLCheck>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ <Link>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <SDLCheck>true</SDLCheck>
+ <ConformanceMode>true</ConformanceMode>
+ </ClCompile>
+ <Link>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\..\..\src\3rdparty\luax\luax.h" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/build/vc++/3rdparty/luax/luax.vcxproj.filters b/build/vc++/3rdparty/luax/luax.vcxproj.filters
new file mode 100644
index 0000000..0fb5905
--- /dev/null
+++ b/build/vc++/3rdparty/luax/luax.vcxproj.filters
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <ClInclude Include="..\..\..\..\src\3rdparty\luax\luax.h" />
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/build/vc++/3rdparty/luax/luax.vcxproj.user b/build/vc++/3rdparty/luax/luax.vcxproj.user
new file mode 100644
index 0000000..be25078
--- /dev/null
+++ b/build/vc++/3rdparty/luax/luax.vcxproj.user
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup />
+</Project> \ No newline at end of file
diff --git a/build/vc++/jin.sln b/build/vc++/jin.sln
index 326f92a..ed41fc7 100644
--- a/build/vc++/jin.sln
+++ b/build/vc++/jin.sln
@@ -45,6 +45,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LuaJIT-2.0.5", "3rdparty\Lu
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tinyxml2", "3rdparty\tinyxml2\tinyxml2.vcxproj", "{A5B92785-7D5A-4910-AA54-C0872F3C605D}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "luax", "3rdparty\luax\luax.vcxproj", "{C6B16179-5640-4D41-8756-0525D25EB569}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
@@ -173,6 +175,14 @@ Global
{A5B92785-7D5A-4910-AA54-C0872F3C605D}.Release|x64.Build.0 = Release|x64
{A5B92785-7D5A-4910-AA54-C0872F3C605D}.Release|x86.ActiveCfg = Release|Win32
{A5B92785-7D5A-4910-AA54-C0872F3C605D}.Release|x86.Build.0 = Release|Win32
+ {C6B16179-5640-4D41-8756-0525D25EB569}.Debug|x64.ActiveCfg = Debug|x64
+ {C6B16179-5640-4D41-8756-0525D25EB569}.Debug|x64.Build.0 = Debug|x64
+ {C6B16179-5640-4D41-8756-0525D25EB569}.Debug|x86.ActiveCfg = Debug|Win32
+ {C6B16179-5640-4D41-8756-0525D25EB569}.Debug|x86.Build.0 = Debug|Win32
+ {C6B16179-5640-4D41-8756-0525D25EB569}.Release|x64.ActiveCfg = Release|x64
+ {C6B16179-5640-4D41-8756-0525D25EB569}.Release|x64.Build.0 = Release|x64
+ {C6B16179-5640-4D41-8756-0525D25EB569}.Release|x86.ActiveCfg = Release|Win32
+ {C6B16179-5640-4D41-8756-0525D25EB569}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -195,6 +205,7 @@ Global
{3191C07B-085A-46BC-9436-469B4E2BF5F0} = {6FC112F9-B317-4444-B4FB-2E0BF70328F1}
{45AC0438-98A8-4369-A21D-BBCBE7995B34} = {2A2F610D-E42B-426F-8DC8-79E0C6FCCDD2}
{A5B92785-7D5A-4910-AA54-C0872F3C605D} = {65DFFFA6-F434-47FB-9DB2-DCF019060B92}
+ {C6B16179-5640-4D41-8756-0525D25EB569} = {65DFFFA6-F434-47FB-9DB2-DCF019060B92}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {633D8D43-3349-43F7-8835-7D7F58BAD2A8}
diff --git a/build/vc++/libjin/libjin.vcxproj b/build/vc++/libjin/libjin.vcxproj
index c59405e..ecd048c 100644
--- a/build/vc++/libjin/libjin.vcxproj
+++ b/build/vc++/libjin/libjin.vcxproj
@@ -153,7 +153,6 @@
<ClInclude Include="..\..\..\src\libjin\Common\je_stringmap.hpp" />
<ClInclude Include="..\..\..\src\libjin\Common\je_subsystem.hpp" />
<ClInclude Include="..\..\..\src\libjin\Common\je_types.h" />
- <ClInclude Include="..\..\..\src\libjin\Common\je_utf8.h" />
<ClInclude Include="..\..\..\src\libjin\core\je_configuration.h" />
<ClInclude Include="..\..\..\src\libjin\core\je_version.h" />
<ClInclude Include="..\..\..\src\libjin\Filesystem\je_buffer.h" />
@@ -223,7 +222,6 @@
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\src\libjin\core\README.md" />
- <None Include="..\..\..\src\libjin\math\README.md" />
<None Include="..\..\..\src\libjin\README.md" />
</ItemGroup>
<ItemGroup>
@@ -234,7 +232,6 @@
<ClCompile Include="..\..\..\src\libjin\Audio\SDL\je_sdl_source.cpp" />
<ClCompile Include="..\..\..\src\libjin\Audio\je_source.cpp" />
<ClCompile Include="..\..\..\src\libjin\Common\je_exception.cpp" />
- <ClCompile Include="..\..\..\src\libjin\Common\je_utf8.cpp" />
<ClCompile Include="..\..\..\src\libjin\Filesystem\je_asset_database.cpp" />
<ClCompile Include="..\..\..\src\libjin\Game\je_gameobject.cpp" />
<ClCompile Include="..\..\..\src\libjin\Game\je_application.cpp" />
diff --git a/build/vc++/libjin/libjin.vcxproj.filters b/build/vc++/libjin/libjin.vcxproj.filters
index c50f0be..78db345 100644
--- a/build/vc++/libjin/libjin.vcxproj.filters
+++ b/build/vc++/libjin/libjin.vcxproj.filters
@@ -177,9 +177,6 @@
<ClInclude Include="..\..\..\src\libjin\Common\je_types.h">
<Filter>source\common</Filter>
</ClInclude>
- <ClInclude Include="..\..\..\src\libjin\Common\je_utf8.h">
- <Filter>source\common</Filter>
- </ClInclude>
<ClInclude Include="..\..\..\src\libjin\Audio\je_source.h">
<Filter>source\audio</Filter>
</ClInclude>
@@ -323,9 +320,6 @@
<None Include="..\..\..\src\libjin\README.md">
<Filter>source</Filter>
</None>
- <None Include="..\..\..\src\libjin\math\README.md">
- <Filter>source\common</Filter>
- </None>
<None Include="..\..\..\src\libjin\core\README.md">
<Filter>source\core</Filter>
</None>
@@ -391,9 +385,6 @@
<ClCompile Include="..\..\..\src\libjin\Common\je_exception.cpp">
<Filter>source\common</Filter>
</ClCompile>
- <ClCompile Include="..\..\..\src\libjin\Common\je_utf8.cpp">
- <Filter>source\common</Filter>
- </ClCompile>
<ClCompile Include="..\..\..\src\libjin\Audio\je_source.cpp">
<Filter>source\audio</Filter>
</ClCompile>
diff --git a/src/libjin/common/je_utf8.cpp b/src/libjin/common/je_utf8.cpp
deleted file mode 100644
index bd7ce94..0000000
--- a/src/libjin/common/je_utf8.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-#include "../core/je_configuration.h"
-#if jin_os == jin_os_windows
-
-#include "je_utf8.h"
-
-namespace JinEngine
-{
-
- std::string to_utf8(LPCWSTR wstr)
- {
- size_t wide_len = wcslen(wstr) + 1;
-
- // Get size in UTF-8.
- int utf8_size = WideCharToMultiByte(CP_UTF8, 0, wstr, wide_len, 0, 0, 0, 0);
-
- char * utf8_str = new char[utf8_size];
-
- // Convert to UTF-8.
- int ok = WideCharToMultiByte(CP_UTF8, 0, wstr, wide_len, utf8_str, utf8_size, 0, 0);
-
- if (!ok)
- {
- delete[] utf8_str;
- }
-
- return ok ? std::string(utf8_str) : std::string();
- }
-
- void replace_char(std::string & str, char find, char replace)
- {
- int length = str.length();
-
- for (int i = 0; i<length; i++)
- {
- if (str[i] == find)
- str[i] = replace;
- }
- }
-
-} // namespace JinEngine
-
-#endif // jin_os == jin_os_windows \ No newline at end of file
diff --git a/src/libjin/common/je_utf8.h b/src/libjin/common/je_utf8.h
deleted file mode 100644
index a720640..0000000
--- a/src/libjin/common/je_utf8.h
+++ /dev/null
@@ -1,34 +0,0 @@
-#ifndef __JE_COMMON_UTF8_H__
-#define __JE_COMMON_UTF8_H__
-
-#include "../core/je_configuration.h"
-#if jin_os == jin_os_windows
-
-#include <string>
-#include <windows.h>
-
-namespace JinEngine
-{
-
- ///
- /// Convert the wide string to a UTF-8 encoded string.
- ///
- /// @param wstr The wide-char string.
- /// @return A UTF-8 string.
- ///
- std::string to_utf8(LPCWSTR wstr);
-
- ///
- /// Replace all occurences of 'find' with 'replace' in a string.
- ///
- /// @param str The string to modify.
- /// @param find The character to match.
- /// @param replace The character to replace matches.
- ///
- void replace_char(std::string & str, char find, char replace);
-
-} // namespace JinEngine
-
-#endif // jin_os == jin_os_windows
-
-#endif // __JE_COMMON_UTF8_H__ \ No newline at end of file
diff --git a/src/libjin/graphics/particles/je_particle_system.cpp b/src/libjin/graphics/particles/je_particle_system.cpp
index a6e9460..cb2472f 100644
--- a/src/libjin/graphics/particles/je_particle_system.cpp
+++ b/src/libjin/graphics/particles/je_particle_system.cpp
@@ -192,6 +192,14 @@ namespace JinEngine
va_end(args);
}
+ void ParticleSystem::addParticleSprites(const std::vector<const Sprite*>& sprs)
+ {
+ for (const Sprite* spr : sprs)
+ {
+ addParticleSprite(spr);
+ }
+ }
+
void ParticleSystem::removeParticleSprite(uint i)
{
mDef.particleDef.spritesDef.sprites.erase(mDef.particleDef.spritesDef.sprites.begin() + i);
diff --git a/src/libjin/graphics/particles/je_particle_system.h b/src/libjin/graphics/particles/je_particle_system.h
index 56043a5..4734313 100644
--- a/src/libjin/graphics/particles/je_particle_system.h
+++ b/src/libjin/graphics/particles/je_particle_system.h
@@ -131,6 +131,7 @@ namespace JinEngine
void setParticleSpritesMode(SpriteMode mode);
void addParticleSprite(const Sprite* sprite);
void addParticleSprites(uint count, ...);
+ void addParticleSprites(const std::vector<const Sprite*>& sprs);
void removeParticleSprite(uint i);
void enableParticleBlendAdditive(bool enable);
@@ -148,7 +149,6 @@ namespace JinEngine
void removeParticleTransparencyPoint(uint i);
private:
-
friend class ParticleEmitter;
///
@@ -190,6 +190,6 @@ namespace JinEngine
} // namespace Particles
} // namespace Graphics
-} // namespace JinEngine
+} // namespace JinEngine
#endif \ No newline at end of file
diff --git a/src/libjin/utils/je_log.h b/src/libjin/utils/je_log.h
index f81bbae..3d34943 100644
--- a/src/libjin/utils/je_log.h
+++ b/src/libjin/utils/je_log.h
@@ -45,7 +45,6 @@ private:
static std::ofstream fs; // ļ
};
-
typedef Loghelper::Level Loglevel;
#if defined(jin_debug)
diff --git a/src/lua/common/je_lua.cpp b/src/lua/common/je_lua.cpp
index 0b6c498..73f671c 100644
--- a/src/lua/common/je_lua.cpp
+++ b/src/lua/common/je_lua.cpp
@@ -33,6 +33,11 @@ namespace JinEngine
return obj;
}
+ LuaObject* luax_checkobject(lua_State* L, int idx, const char* type)
+ {
+ return (LuaObject*)luax_checktype(L, idx, type);
+ }
+
LuaObject* luax_copyinstance(lua_State* to, LuaObject* src)
{
if (to == src->state)
diff --git a/src/lua/common/je_lua.h b/src/lua/common/je_lua.h
index 24f89fe..b390e4c 100644
--- a/src/lua/common/je_lua.h
+++ b/src/lua/common/je_lua.h
@@ -28,6 +28,11 @@ namespace JinEngine
LuaObject* luax_copyinstance(lua_State* to, LuaObject* src);
///
+ ///
+ ///
+ LuaObject* luax_checkobject(lua_State* L, int idx, const char* type);
+
+ ///
/// Access lua object by object pointer.
///
int luax_getobject(lua_State* L, SharedBase* shared);
diff --git a/src/lua/modules/filesystem/je_lua_filesystem.cpp b/src/lua/modules/filesystem/je_lua_filesystem.cpp
index 8bc3a69..e73d1ad 100644
--- a/src/lua/modules/filesystem/je_lua_filesystem.cpp
+++ b/src/lua/modules/filesystem/je_lua_filesystem.cpp
@@ -133,7 +133,6 @@ namespace JinEngine
};
luax_newlib(L, methods);
luax_registersearcher(L, loader, 1);
-
return 0;
}
diff --git a/src/lua/modules/graphics/je_lua_particle_system.cpp b/src/lua/modules/graphics/je_lua_particle_system.cpp
index b0cb221..53611a9 100644
--- a/src/lua/modules/graphics/je_lua_particle_system.cpp
+++ b/src/lua/modules/graphics/je_lua_particle_system.cpp
@@ -1,11 +1,396 @@
+#include <vector>
+
+#include "common/je_lua_object.h"
+#include "common/je_lua_common.h"
#include "libjin/jin.h"
+#include "je_lua_sprite.h"
+#include "je_lua_particle_system.h"
+
+using namespace std;
+using namespace JinEngine::Math;
+using namespace JinEngine::Graphics;
+using namespace JinEngine::Graphics::Particles;
+
namespace JinEngine
{
namespace Lua
{
+ const char* Jin_Lua_ParticleSystem = "ParticleSystem";
+
+ typedef Shared<ParticleSystem>& SharedParticleSystem;
+
+ LUA_IMPLEMENT inline SharedParticleSystem checkPS(lua_State* L)
+ {
+ LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem);
+ return luaObj->getShared<ParticleSystem>();
+ }
+
+ LUA_IMPLEMENT int l_gc(lua_State* L)
+ {
+ LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem);
+ luaObj->release();
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_update(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ float dt = luax_checknumber(L, 2);
+ ps->update(dt);
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_render(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ ps->render();
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_setPosition(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ float x = luax_checknumber(L, 2);
+ float y = luax_checknumber(L, 3);
+ ps->setPosition(x, y);
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_setScale(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ float sx = luax_checknumber(L, 2);
+ float sy = luax_checknumber(L, 3);
+ ps->setScale(sx, sy);
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_pause(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ bool b = luax_checkbool(L, 2);
+ ps->pause(b);
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_clear(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ ps->clear();
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_setEmitRate(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ if (luax_gettop(L) >= 3)
+ {
+ float floor = luax_checknumber(L, 2);
+ float ceil = luax_checknumber(L, 3);
+ ps->setEmitRate(floor, ceil);
+ }
+ else if (luax_gettop(L) >= 2)
+ {
+ float n = luax_checknumber(L, 2);
+ ps->setEmitRate(n);
+ }
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_setEmitForce(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ if (luax_gettop(L) >= 3)
+ {
+ float floor = luax_checknumber(L, 2);
+ float ceil = luax_checknumber(L, 3);
+ ps->setEmitForce(floor, ceil);
+ }
+ else if (luax_gettop(L) >= 2)
+ {
+ float n = luax_checknumber(L, 2);
+ ps->setEmitForce(n);
+ }
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_setEmitDirection(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ if (luax_gettop(L) >= 3)
+ {
+ float floor = luax_checknumber(L, 2);
+ float ceil = luax_checknumber(L, 3);
+ ps->setEmitDirection(floor, ceil);
+ }
+ else if (luax_gettop(L) >= 2)
+ {
+ float n = luax_checknumber(L, 2);
+ ps->setEmitDirection(n);
+ }
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_setEmitPosition(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ if (luax_gettop(L) >= 3)
+ {
+ if (!luax_istable(L, 2))
+ {
+ luax_typerror(L, 2, "table");
+ return 1;
+ }
+ if (!luax_istable(L, 3))
+ {
+ luax_typerror(L, 3, "table");
+ return 1;
+ }
+ Vector2<float> floor, ceil;
+ floor.x = luax_rawgetnumber(L, 2, 1);
+ floor.y = luax_rawgetnumber(L, 2, 2);
+ ceil.x = luax_rawgetnumber(L, 3, 1);
+ ceil.y = luax_rawgetnumber(L, 3, 2);
+ ps->setEmitPosition(floor, ceil);
+ }
+ else if (luax_gettop(L) >= 2)
+ {
+ if (!luax_istable(L, 2))
+ {
+ luax_typerror(L, 2, "table");
+ return 1;
+ }
+ Vector2<float> pos;
+ pos.x = luax_rawgetnumber(L, 2, 1);
+ pos.y = luax_rawgetnumber(L, 2, 2);
+ ps->setEmitPosition(pos);
+ }
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_setParticleLife(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ if (luax_gettop(L) >= 3)
+ {
+ float floor = luax_checknumber(L, 2);
+ float ceil = luax_checknumber(L, 3);
+ ps->setParticleLife(floor, ceil);
+ }
+ else if (luax_gettop(L) >= 2)
+ {
+ float n = luax_checknumber(L, 2);
+ ps->setParticleLife(n);
+ }
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_setParticleLinearAccelaration(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ if (!luax_istable(L, 2))
+ {
+ luax_typerror(L, 2, "table");
+ return 1;
+ }
+ Vector2<float> ac;
+ ac.x = luax_rawgetnumber(L, 2, 1);
+ ac.y = luax_rawgetnumber(L, 2, 2);
+ ps->setParticleLinearAccelaration(ac);
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_setParticleRadialAccelaration(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ float ra = luax_checknumber(L, 2);
+ ps->setParticleRadialAccelaration(ra);
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_setParticleAngularSpeed(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ if (luax_gettop(L) >= 3)
+ {
+ float floor = luax_checknumber(L, 2);
+ float ceil = luax_checknumber(L, 3);
+ ps->setParticleAngularSpeed(floor, ceil);
+ }
+ else if (luax_gettop(L) >= 2)
+ {
+ float n = luax_checknumber(L, 2);
+ ps->setParticleAngularSpeed(n);
+ }
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_setParticleSpritesMode(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ int n = luax_checkinteger(L, 2);
+ SpriteMode mode = static_cast<SpriteMode>(n);
+ ps->setParticleSpritesMode(mode);
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_addParticleSprite(lua_State* L)
+ {
+ LuaObject* obj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem);
+ SharedParticleSystem ps = obj->getShared<ParticleSystem>();
+ LuaObject* objSpr = luax_checkobject(L, 2, Jin_Lua_Sprite);
+ Sprite* spr = objSpr->getObject<Sprite>();
+ ps->addParticleSprite(spr);
+ int depn = (*obj).getDependenciesCount();
+ (*obj).setDependency((int)ParticleSystemDependency::DEP_SPRITES + depn, objSpr->getSharedBase());
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_addParticleSprites(lua_State* L)
+ {
+ LuaObject* obj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem);
+ SharedParticleSystem ps = obj->getShared<ParticleSystem>();
+ if (!luax_istable(L, 2))
+ {
+ luax_typerror(L, 2, "sprites table");
+ return 1;
+ }
+ int n = luax_tableidxlen(L, 2);
+ int depn = (*obj).getDependenciesCount();
+ for (int i = 1; i <= n; ++i)
+ {
+ luax_rawgeti(L, 2, i);
+ LuaObject* objSpr = luax_checkobject(L, -1, Jin_Lua_Sprite);
+ luax_pop(L, 1);
+ Sprite* spr = objSpr->getObject<Sprite>();
+ ps->addParticleSprite(spr);
+ (*obj).setDependency((int)ParticleSystemDependency::DEP_SPRITES + depn + i - 1, objSpr->getSharedBase());
+ }
+ return 0;
+ }
+
+ // From 0
+ LUA_IMPLEMENT int l_removeParticleSprite(lua_State* L)
+ {
+ LuaObject* obj = luax_checkobject(L, 1, Jin_Lua_ParticleSystem);
+ SharedParticleSystem ps = obj->getShared<ParticleSystem>();
+ int n = luax_checkinteger(L, 2);
+ ps->removeParticleSprite(n);
+ (*obj).removeDependency((int)ParticleSystemDependency::DEP_SPRITES + n);
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_enableParticleBlendAdditive(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ bool enable = luax_checkbool(L, 2);
+ ps->enableParticleBlendAdditive(enable);
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_setParticleScale(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ float scale = luax_checknumber(L, 2);
+ ps->setParticleScale(scale);
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_addParticleScalePoint(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ float scale = luax_checknumber(L, 2);
+ float t = luax_checknumber(L, 3);
+ ps->addParticleScalePoint(scale, t);
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_removeParticleScalePoint(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ int i = luax_checkinteger(L, 2);
+ ps->removeParticleScalePoint(i);
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_setParticleColor(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ if (!luax_istable(L, 2))
+ {
+ luax_typerror(L, 2, "color table");
+ return 1;
+ }
+ Color c;
+ c.r = luax_rawgetnumber(L, 2, 1);
+ c.g = luax_rawgetnumber(L, 2, 2);
+ c.b = luax_rawgetnumber(L, 2, 3);
+ c.a = luax_rawgetnumber(L, 2, 4);
+ ps->setParticleColor(c);
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_addParticleColorPoint(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ if (!luax_istable(L, 2))
+ {
+ luax_typerror(L, 2, "color table");
+ return 1;
+ }
+ Color c;
+ c.r = luax_rawgetnumber(L, 2, 1);
+ c.g = luax_rawgetnumber(L, 2, 2);
+ c.b = luax_rawgetnumber(L, 2, 3);
+ c.a = luax_rawgetnumber(L, 2, 4);
+ float t = luax_checknumber(L, 3);
+ ps->addParticleColorPoint(c, t);
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_removeParticleColorPoint(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ int i = luax_checkinteger(L, 2);
+ ps->removeParticleColorPoint(i);
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_setParticleTransparency(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ float transparency = luax_checknumber(L, 2);
+ ps->setParticleTransparency(transparency);
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_addParticleTransparencyPoint(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ float transparency = luax_checknumber(L, 2);
+ float t = luax_checknumber(L, 3);
+ ps->addParticleTransparencyPoint(transparency, t);
+ return 0;
+ }
+
+ LUA_IMPLEMENT int l_removeParticleTransparencyPoint(lua_State* L)
+ {
+ SharedParticleSystem ps = checkPS(L);
+ int i = luax_checkinteger(L, 2);
+ ps->removeParticleTransparencyPoint(i);
+ return 0;
+ }
+ LUA_EXPORT void luaopen_ParticleSystem(lua_State* L)
+ {
+ luaL_Reg methods[] = {
+ { "__gc", l_gc },
+ { 0, 0 }
+ };
+ luax_newtype(L, Jin_Lua_ParticleSystem, methods);
+ }
- } // Lua
+ } // namespace Lua
} // namespace JinEngine \ No newline at end of file
diff --git a/src/lua/modules/graphics/je_lua_particle_system.h b/src/lua/modules/graphics/je_lua_particle_system.h
index e69de29..b75b569 100644
--- a/src/lua/modules/graphics/je_lua_particle_system.h
+++ b/src/lua/modules/graphics/je_lua_particle_system.h
@@ -0,0 +1,21 @@
+#ifndef __JE_LUA_PARTICLESYSTEM_H__
+#define __JE_LUA_PARTICLESYSTEM_H__
+
+namespace JinEngine
+{
+ namespace Lua
+ {
+
+ enum class ParticleSystemDependency
+ {
+ DEP_SPRITES = 1,
+ };
+
+ extern const char* Jin_Lua_ParticleSystem;
+
+ void luaopen_ParticleSystem(lua_State* L);
+
+ }
+}
+
+#endif \ No newline at end of file
diff --git a/src/lua/modules/graphics/je_lua_shader.cpp b/src/lua/modules/graphics/je_lua_shader.cpp
index 8bef1bf..f4a4231 100644
--- a/src/lua/modules/graphics/je_lua_shader.cpp
+++ b/src/lua/modules/graphics/je_lua_shader.cpp
@@ -23,7 +23,7 @@ namespace JinEngine
LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Shader);
return luaObj->getShared<Shader>();
}
-
+
/**
* jsl:sendNumber("variable", 0.1)
*/
diff --git a/src/lua/modules/net/je_lua_net.cpp b/src/lua/modules/net/je_lua_net.cpp
index e631827..5db4722 100644
--- a/src/lua/modules/net/je_lua_net.cpp
+++ b/src/lua/modules/net/je_lua_net.cpp
@@ -65,7 +65,6 @@ namespace JinEngine
{
luaopen_Socket(L);
luaopen_Buffer(L);
-
luaL_Reg methods[] = {
{ "init", l_initNetwork },
{ "newSocket", l_Socket },
@@ -73,7 +72,6 @@ namespace JinEngine
{ 0, 0 }
};
luax_newlib(L, methods);
-
return 1;
}