updated lua bindings

This commit is contained in:
turanszkij
2015-09-21 23:31:59 +02:00
parent 14063a7ba0
commit d307a8f01e
3 changed files with 46 additions and 24 deletions
+14
View File
@@ -144,5 +144,19 @@ end
function math.lerp(a,b,t)
return (a + (b-a)*t);
end
-- clamp number between min,max
function clamp(x,min,max)
if(x < min) then
return min
elseif(x > max) then
return max
else
return x
end
end
-- clamp number between 0,1
function saturate(x)
return clamp(x,0,1)
end
)";
+30 -24
View File
@@ -54,6 +54,8 @@ namespace wiRenderer_BindLua
wiLua::GetGlobal()->RunText("PICK_OPAQUE = 0");
wiLua::GetGlobal()->RunText("PICK_TRANSPARENT = 1");
wiLua::GetGlobal()->RunText("PICK_WATER = 2");
wiLua::GetGlobal()->RegisterFunc("ClearWorld", ClearWorld);
}
}
@@ -404,38 +406,36 @@ namespace wiRenderer_BindLua
}
return 0;
}
int DrawLine(lua_State* L)
{
int argc = wiLua::SGetArgCount(L);
if (argc > 1)
{
Vector_BindLua* a = Luna<Vector_BindLua>::lightcheck(L, 1);
Vector_BindLua* b = Luna<Vector_BindLua>::lightcheck(L, 2);
if (a && b)
int argc = wiLua::SGetArgCount(L);
if (argc > 1)
{
XMFLOAT3 xa, xb;
XMFLOAT4 xc = XMFLOAT4(1, 1, 1, 1);
XMStoreFloat3(&xa, a->vector);
XMStoreFloat3(&xb, b->vector);
if (argc > 2)
Vector_BindLua* a = Luna<Vector_BindLua>::lightcheck(L, 1);
Vector_BindLua* b = Luna<Vector_BindLua>::lightcheck(L, 2);
if (a && b)
{
Vector_BindLua* c = Luna<Vector_BindLua>::lightcheck(L, 3);
if (c)
XMStoreFloat4(&xc, c->vector);
else
wiLua::SError(L, "DrawLine(Vector origin,end, opt Vector color) one or more arguments are not vectors!");
XMFLOAT3 xa, xb;
XMFLOAT4 xc = XMFLOAT4(1, 1, 1, 1);
XMStoreFloat3(&xa, a->vector);
XMStoreFloat3(&xb, b->vector);
if (argc > 2)
{
Vector_BindLua* c = Luna<Vector_BindLua>::lightcheck(L, 3);
if (c)
XMStoreFloat4(&xc, c->vector);
else
wiLua::SError(L, "DrawLine(Vector origin,end, opt Vector color) one or more arguments are not vectors!");
}
wiRenderer::linesTemp.push_back(new Lines(xa, xb, xc));
}
wiRenderer::linesTemp.push_back(new Lines(xa, xb, xc));
else
wiLua::SError(L, "DrawLine(Vector origin,end, opt Vector color) one or more arguments are not vectors!");
}
else
wiLua::SError(L, "DrawLine(Vector origin,end, opt Vector color) one or more arguments are not vectors!");
wiLua::SError(L, "DrawLine(Vector origin,end, opt Vector color) not enough arguments!");
return 0;
}
else
wiLua::SError(L, "DrawLine(Vector origin,end, opt Vector color) not enough arguments!");
return 0;
}
int PutWaterRipple(lua_State* L)
{
int argc = wiLua::SGetArgCount(L);
@@ -456,4 +456,10 @@ namespace wiRenderer_BindLua
wiLua::SError(L, "PutWaterRipple(String imagename, Vector position) not enough arguments!");
return 0;
}
int ClearWorld(lua_State* L)
{
wiRenderer::CleanUpStaticTemp();
return 0;
}
};
+2
View File
@@ -37,5 +37,7 @@ namespace wiRenderer_BindLua
int Pick(lua_State* L);
int DrawLine(lua_State* L);
int PutWaterRipple(lua_State* L);
int ClearWorld(lua_State* L);
};