diff options
author | chai <chaifix@163.com> | 2021-10-29 13:36:49 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-29 13:36:49 +0800 |
commit | 91c32cb173201ac8803a1e4452e8342969b8e484 (patch) | |
tree | 5e78c485b5fcfcf839a2348667597d7e10476214 /Runtime/Lua/LuaHelper.cpp | |
parent | 1f92d4c389cceba6f90261d9cb29885c8a3ca24c (diff) |
*GLSL test
Diffstat (limited to 'Runtime/Lua/LuaHelper.cpp')
-rw-r--r-- | Runtime/Lua/LuaHelper.cpp | 132 |
1 files changed, 123 insertions, 9 deletions
diff --git a/Runtime/Lua/LuaHelper.cpp b/Runtime/Lua/LuaHelper.cpp index a47d528..e7247c0 100644 --- a/Runtime/Lua/LuaHelper.cpp +++ b/Runtime/Lua/LuaHelper.cpp @@ -1,27 +1,141 @@ #include "LuaHelper.h"
+#include "Runtime/Math/Vector2.h"
+#include "Runtime/Math/Vector3.h"
+#include "Runtime/Math/Vector4.h"
+#include "Runtime/Math/Matrix44.h"
+
using namespace LuaBind;
template <>
-Rect State::GetValue < Rect >(int idx, const Rect value)
+Internal::Rect State::GetValue < Internal::Rect >(int idx, const Internal::Rect value)
{
- Rect rect;
- rect.x = GetField<float>(idx, 1, 0);
- rect.y = GetField<float>(idx, 2, 0);
- rect.width = GetField<float>(idx, 3, 0);
- rect.height = GetField<float>(idx, 4, 0);
+ Internal::Rect rect = value;
+ if (LuaHelper::IsType(*this, "GameLab.Engine.Math.Rect", idx))
+ {
+ rect.x = GetField<float>(idx, "x", 0);
+ rect.y = GetField<float>(idx, "y", 0);
+ rect.width = GetField<float>(idx, "z", 0);
+ rect.height = GetField<float>(idx, "w", 0);
+ }
+ else
+ {
+ rect.x = GetField<float>(idx, 1, 0);
+ rect.y = GetField<float>(idx, 2, 0);
+ rect.width = GetField<float>(idx, 3, 0);
+ rect.height = GetField<float>(idx, 4, 0);
+ }
return rect;
}
template <>
Internal::Vector2 State::GetValue < Internal::Vector2 >(int idx, const Internal::Vector2 value)
{
- Internal::Vector2 v2;
- v2.x = GetField<float>(idx, 1, 0);
- v2.y = GetField<float>(idx, 2, 0);
+ Internal::Vector2 v2 = value;
+ if (LuaHelper::IsType(*this, "GameLab.Engine.Math.Vector2", idx))
+ {
+ v2.x = GetField<float>(idx, "x", 0);
+ v2.y = GetField<float>(idx, "y", 0);
+ }
+ else
+ {
+ v2.x = GetField<float>(idx, 1, 0);
+ v2.y = GetField<float>(idx, 2, 0);
+ }
return v2;
}
+template <>
+Internal::Vector3 State::GetValue < Internal::Vector3 >(int idx, const Internal::Vector3 value)
+{
+ Internal::Vector3 v3 = value;
+ if (LuaHelper::IsType(*this, "GameLab.Engine.Math.Vector3", idx))
+ {
+ v3.x = GetField<float>(idx, "x", 0);
+ v3.y = GetField<float>(idx, "y", 0);
+ v3.z = GetField<float>(idx, "z", 0);
+ }
+ else
+ {
+ v3.x = GetField<float>(idx, 1, 0);
+ v3.y = GetField<float>(idx, 2, 0);
+ v3.z = GetField<float>(idx, 3, 0);
+ }
+ return v3;
+}
+
+template <>
+Internal::Vector4 State::GetValue < Internal::Vector4 >(int idx, const Internal::Vector4 value)
+{
+ Internal::Vector4 v4 = value;
+ if (LuaHelper::IsType(*this, "GameLab.Engine.Math.Vector4", idx))
+ {
+ v4.x = GetField<float>(idx, "x", 0);
+ v4.y = GetField<float>(idx, "y", 0);
+ v4.z = GetField<float>(idx, "z", 0);
+ v4.w = GetField<float>(idx, "w", 0);
+ }
+ else
+ {
+ v4.x = GetField<float>(idx, 1, 0);
+ v4.y = GetField<float>(idx, 2, 0);
+ v4.z = GetField<float>(idx, 3, 0);
+ v4.w = GetField<float>(idx, 4, 0);
+ }
+ return v4;
+}
+
+template <>
+Internal::Matrix44 State::GetValue < Internal::Matrix44 >(int idx, const Internal::Matrix44 value)
+{
+ Internal::Matrix44 m4 = value;
+ if (LuaHelper::IsType(*this, "GameLab.Engine.Math.Matrix44", idx))
+ {
+ m4.m[0][0] = GetField<float>(idx, "m00", 0);
+ m4.m[0][1] = GetField<float>(idx, "m01", 0);
+ m4.m[0][2] = GetField<float>(idx, "m02", 0);
+ m4.m[0][3] = GetField<float>(idx, "m03", 0);
+
+ m4.m[1][0] = GetField<float>(idx, "m10", 0);
+ m4.m[1][1] = GetField<float>(idx, "m11", 0);
+ m4.m[1][2] = GetField<float>(idx, "m12", 0);
+ m4.m[1][3] = GetField<float>(idx, "m13", 0);
+
+ m4.m[2][0] = GetField<float>(idx, "m20", 0);
+ m4.m[2][1] = GetField<float>(idx, "m21", 0);
+ m4.m[2][2] = GetField<float>(idx, "m22", 0);
+ m4.m[2][3] = GetField<float>(idx, "m23", 0);
+
+ m4.m[3][0] = GetField<float>(idx, "m30", 0);
+ m4.m[3][1] = GetField<float>(idx, "m31", 0);
+ m4.m[3][2] = GetField<float>(idx, "m32", 0);
+ m4.m[3][3] = GetField<float>(idx, "m33", 0);
+ }
+ else
+ {
+ m4.m[0][0] = GetField<float>(idx, 1, 0);
+ m4.m[0][1] = GetField<float>(idx, 2, 0);
+ m4.m[0][2] = GetField<float>(idx, 3, 0);
+ m4.m[0][3] = GetField<float>(idx, 4, 0);
+
+ m4.m[1][0] = GetField<float>(idx, 5, 0);
+ m4.m[1][1] = GetField<float>(idx, 6, 0);
+ m4.m[1][2] = GetField<float>(idx, 7, 0);
+ m4.m[1][3] = GetField<float>(idx, 8, 0);
+
+ m4.m[2][0] = GetField<float>(idx, 9, 0);
+ m4.m[2][1] = GetField<float>(idx, 10, 0);
+ m4.m[2][2] = GetField<float>(idx, 11, 0);
+ m4.m[2][3] = GetField<float>(idx, 12, 0);
+
+ m4.m[3][0] = GetField<float>(idx, 13, 0);
+ m4.m[3][1] = GetField<float>(idx, 14, 0);
+ m4.m[3][2] = GetField<float>(idx, 15, 0);
+ m4.m[3][3] = GetField<float>(idx, 16, 0);
+ }
+ return m4;
+}
+
int LuaHelper::Call(const char* func, const char* params, ...)
{
return 1;
|