Skip to content

Commit

Permalink
updated lua bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
turanszkij committed Sep 8, 2015
1 parent 60a9595 commit 9a41615
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
57 changes: 57 additions & 0 deletions WickedEngine/Matrix_BindLua.cpp
Expand Up @@ -15,6 +15,9 @@ Luna<Matrix_BindLua>::FunctionType Matrix_BindLua::methods[] = {
lunamethod(Matrix_BindLua, RotationZ),
lunamethod(Matrix_BindLua, RotationQuaternion),
lunamethod(Matrix_BindLua, Scale),
lunamethod(Matrix_BindLua, LookTo),
lunamethod(Matrix_BindLua, LookAt),

lunamethod(Matrix_BindLua, Add),
lunamethod(Matrix_BindLua, Multiply),
lunamethod(Matrix_BindLua, Transpose),
Expand Down Expand Up @@ -180,6 +183,60 @@ int Matrix_BindLua::Scale(lua_State* L)
return 1;
}

int Matrix_BindLua::LookTo(lua_State* L)
{
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Vector_BindLua* pos = Luna<Vector_BindLua>::lightcheck(L, 1);
Vector_BindLua* dir = Luna<Vector_BindLua>::lightcheck(L, 2);
if (pos != nullptr && dir != nullptr)
{
XMVECTOR Up;
if (argc > 3)
{
Vector_BindLua* up = Luna<Vector_BindLua>::lightcheck(L, 3);
Up = up->vector;
}
else
Up = XMVectorSet(0, 1, 0, 0);
Luna<Matrix_BindLua>::push(L, new Matrix_BindLua(XMMatrixLookToLH(pos->vector, dir->vector, Up)));
}
else
wiLua::SError(L, "LookTo(Vector eye, Vector direction, opt Vector up) argument is not a Vector!");
}
else
wiLua::SError(L, "LookTo(Vector eye, Vector direction, opt Vector up) not enough arguments!");
return 1;
}

int Matrix_BindLua::LookAt(lua_State* L)
{
int argc = wiLua::SGetArgCount(L);
if (argc > 0)
{
Vector_BindLua* pos = Luna<Vector_BindLua>::lightcheck(L, 1);
Vector_BindLua* dir = Luna<Vector_BindLua>::lightcheck(L, 2);
if (dir != nullptr)
{
XMVECTOR Up;
if (argc > 3)
{
Vector_BindLua* up = Luna<Vector_BindLua>::lightcheck(L, 3);
Up = up->vector;
}
else
Up = XMVectorSet(0, 1, 0, 0);
Luna<Matrix_BindLua>::push(L, new Matrix_BindLua(XMMatrixLookAtLH(pos->vector, dir->vector, Up)));
}
else
wiLua::SError(L, "LookAt(Vector eye, Vector focusPos, opt Vector up) argument is not a Vector!");
}
else
wiLua::SError(L, "LookAt(Vector eye, Vector focusPos, opt Vector up) not enough arguments!");
return 1;
}

int Matrix_BindLua::Multiply(lua_State* L)
{
int argc = wiLua::SGetArgCount(L);
Expand Down
2 changes: 2 additions & 0 deletions WickedEngine/Matrix_BindLua.h
Expand Up @@ -25,6 +25,8 @@ class Matrix_BindLua
int RotationZ(lua_State* L);
int RotationQuaternion(lua_State* L);
int Scale(lua_State* L);
int LookTo(lua_State* L);
int LookAt(lua_State* L);

int Multiply(lua_State* L);
int Add(lua_State* L);
Expand Down
2 changes: 2 additions & 0 deletions WickedEngine/wiLoader_BindLua.cpp
Expand Up @@ -789,6 +789,8 @@ void Armature_BindLua::Bind()
const char Ray_BindLua::className[] = "Ray";

Luna<Ray_BindLua>::FunctionType Ray_BindLua::methods[] = {
lunamethod(Ray_BindLua, GetOrigin),
lunamethod(Ray_BindLua, GetDirection),
{ NULL, NULL }
};
Luna<Ray_BindLua>::PropertyType Ray_BindLua::properties[] = {
Expand Down

0 comments on commit 9a41615

Please sign in to comment.