updated lua bindings + renderer getters
This commit is contained in:
@@ -387,6 +387,7 @@
|
||||
<ClCompile Include="wiInputManager.cpp" />
|
||||
<ClCompile Include="wiLensFlare.cpp" />
|
||||
<ClCompile Include="wiLines.cpp" />
|
||||
<ClCompile Include="wiLoader_BindLua.cpp" />
|
||||
<ClCompile Include="wiLua.cpp" />
|
||||
<ClCompile Include="wiNetwork.cpp" />
|
||||
<ClCompile Include="Renderable3DComponent.cpp" />
|
||||
@@ -429,6 +430,7 @@
|
||||
<ClInclude Include="SpriteAnim_BindLua.h" />
|
||||
<ClInclude Include="Texture_BindLua.h" />
|
||||
<ClInclude Include="wiImageEffects_BindLua.h" />
|
||||
<ClInclude Include="wiLoader_BindLua.h" />
|
||||
<ClInclude Include="wiLuna.h" />
|
||||
<ClInclude Include="wiRenderer_BindLua.h" />
|
||||
<ClInclude Include="LUA\lapi.h" />
|
||||
|
||||
@@ -779,6 +779,9 @@
|
||||
<ClCompile Include="RenderableComponent_BindLua.cpp">
|
||||
<Filter>Lua Bindings</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="wiLoader_BindLua.cpp">
|
||||
<Filter>Lua Bindings</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="typelib.h">
|
||||
@@ -1729,6 +1732,9 @@
|
||||
<ClInclude Include="RenderableComponent_BindLua.h">
|
||||
<Filter>Lua Bindings</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="wiLoader_BindLua.h">
|
||||
<Filter>Lua Bindings</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\io_export_wicked_wi_bin.py" />
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
#include "wiLoader_BindLua.h"
|
||||
|
||||
namespace wiLoader_BindLua
|
||||
{
|
||||
void Bind()
|
||||
{
|
||||
Object_BindLua::Bind();
|
||||
}
|
||||
}
|
||||
|
||||
const char Object_BindLua::className[] = "Object";
|
||||
|
||||
Luna<Object_BindLua>::FunctionType Object_BindLua::methods[] = {
|
||||
lunamethod(Object_BindLua, SetTransparency),
|
||||
lunamethod(Object_BindLua, GetTransparency),
|
||||
lunamethod(Object_BindLua, SetColor),
|
||||
lunamethod(Object_BindLua, GetColor),
|
||||
{ NULL, NULL }
|
||||
};
|
||||
Luna<Object_BindLua>::PropertyType Object_BindLua::properties[] = {
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
Object_BindLua::Object_BindLua(Object* object) :object(object)
|
||||
{
|
||||
}
|
||||
Object_BindLua::Object_BindLua(lua_State *L)
|
||||
{
|
||||
object = nullptr;
|
||||
}
|
||||
Object_BindLua::~Object_BindLua()
|
||||
{
|
||||
}
|
||||
|
||||
int Object_BindLua::SetTransparency(lua_State *L)
|
||||
{
|
||||
if (object == nullptr)
|
||||
{
|
||||
wiLua::SError(L, "SetTransparency(float value) object is null!");
|
||||
return 0;
|
||||
}
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 1)
|
||||
{
|
||||
object->transparency = wiLua::SGetFloat(L, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "SetTransparency(float value) not enough arguments!");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int Object_BindLua::GetTransparency(lua_State *L)
|
||||
{
|
||||
if (object == nullptr)
|
||||
{
|
||||
wiLua::SError(L, "GetTransparency() object is null!");
|
||||
return 0;
|
||||
}
|
||||
wiLua::SSetFloat(L, object->transparency);
|
||||
return 1;
|
||||
}
|
||||
int Object_BindLua::SetColor(lua_State *L)
|
||||
{
|
||||
if (object == nullptr)
|
||||
{
|
||||
wiLua::SError(L, "SetColor(float r, float g, float b) object is null!");
|
||||
return 0;
|
||||
}
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 3)
|
||||
{
|
||||
object->color = wiLua::SGetFloat3(L, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "SetColor(float r, float g, float b) not enough arguments!");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int Object_BindLua::GetColor(lua_State *L)
|
||||
{
|
||||
if (object == nullptr)
|
||||
{
|
||||
wiLua::SError(L, "GetColor() object is null!");
|
||||
return 0;
|
||||
}
|
||||
wiLua::SSetFloat3(L, object->color);
|
||||
return 3;
|
||||
}
|
||||
|
||||
void Object_BindLua::Bind()
|
||||
{
|
||||
static bool initialized = false;
|
||||
if (!initialized)
|
||||
{
|
||||
initialized = true;
|
||||
Luna<Object_BindLua>::Register(wiLua::GetGlobal()->GetLuaState());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
#include "wiLua.h"
|
||||
#include "wiLuna.h"
|
||||
#include "wiLoader.h"
|
||||
|
||||
namespace wiLoader_BindLua
|
||||
{
|
||||
void Bind();
|
||||
}
|
||||
|
||||
class Object_BindLua
|
||||
{
|
||||
public:
|
||||
Object* object;
|
||||
|
||||
static const char className[];
|
||||
static Luna<Object_BindLua>::FunctionType methods[];
|
||||
static Luna<Object_BindLua>::PropertyType properties[];
|
||||
|
||||
Object_BindLua(Object* object = nullptr);
|
||||
Object_BindLua(lua_State *L);
|
||||
~Object_BindLua();
|
||||
|
||||
int SetTransparency(lua_State *L);
|
||||
int GetTransparency(lua_State *L);
|
||||
int SetColor(lua_State *L);
|
||||
int GetColor(lua_State *L);
|
||||
|
||||
static void Bind();
|
||||
};
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "wiImageEffects_BindLua.h"
|
||||
#include "SpriteAnim_BindLua.h"
|
||||
#include "wiResourceManager_BindLua.h"
|
||||
#include "wiLoader_BindLua.h"
|
||||
|
||||
wiLua *wiLua::globalLua = nullptr;
|
||||
|
||||
@@ -54,6 +55,7 @@ wiLua* wiLua::GetGlobal()
|
||||
wiImageEffects_BindLua::Bind();
|
||||
SpriteAnim_BindLua::Bind();
|
||||
wiResourceManager_BindLua::Bind();
|
||||
wiLoader_BindLua::Bind();
|
||||
}
|
||||
return globalLua;
|
||||
}
|
||||
|
||||
@@ -1607,6 +1607,43 @@ HitSphere* wiRenderer::getSphereByName(const string& get){
|
||||
return hs;
|
||||
return nullptr;
|
||||
}
|
||||
Object* wiRenderer::getObjectByName(const string& name)
|
||||
{
|
||||
for (auto& x : objects)
|
||||
{
|
||||
if (!x->name.compare(name))
|
||||
{
|
||||
return x;
|
||||
}
|
||||
}
|
||||
for (auto& x : objects_trans)
|
||||
{
|
||||
if (!x->name.compare(name))
|
||||
{
|
||||
return x;
|
||||
}
|
||||
}
|
||||
for (auto& x : objects_water)
|
||||
{
|
||||
if (!x->name.compare(name))
|
||||
{
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
Light* wiRenderer::getLightByName(const string& name)
|
||||
{
|
||||
for (auto& x : lights)
|
||||
{
|
||||
if (!x->name.compare(name))
|
||||
{
|
||||
return x;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void wiRenderer::RecursiveBoneTransform(Armature* armature, Bone* bone, const XMMATRIX& parentCombinedMat){
|
||||
float cf = armature->currentFrame;
|
||||
|
||||
@@ -344,11 +344,6 @@ protected:
|
||||
static Vertex TransformVertex(const Mesh* mesh, const SkinnedVertex& vertex, const XMMATRIX& mat = XMMatrixIdentity());
|
||||
static XMFLOAT3 VertexVelocity(const Mesh* mesh, const int& vertexI);
|
||||
|
||||
static Armature* getArmatureByName(const string& get);
|
||||
static int getActionByName(Armature* armature, const string& get);
|
||||
static int getBoneByName(Armature* armature, const string& get);
|
||||
static Material* getMaterialByName(const string& get);
|
||||
HitSphere* getSphereByName(const string& get);
|
||||
|
||||
static float GameSpeed,overrideGameSpeed;
|
||||
|
||||
@@ -387,6 +382,15 @@ public:
|
||||
static TextureView GetEnviromentMap(){ return enviroMap; }
|
||||
static void SetNoiseTexture(TextureView tex){ noiseTex = tex; }
|
||||
static TextureView GetNoiseTexture(){ return noiseTex; }
|
||||
|
||||
|
||||
static Armature* getArmatureByName(const string& get);
|
||||
static int getActionByName(Armature* armature, const string& get);
|
||||
static int getBoneByName(Armature* armature, const string& get);
|
||||
static Material* getMaterialByName(const string& get);
|
||||
HitSphere* getSphereByName(const string& get);
|
||||
static Object* getObjectByName(const string& name);
|
||||
static Light* getLightByName(const string& name);
|
||||
|
||||
private:
|
||||
static vector<TextureView> textureSlotsPS;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "wiRenderer.h"
|
||||
#include "wiLoader.h"
|
||||
#include "wiHelper.h"
|
||||
#include "wiLoader_BindLua.h"
|
||||
|
||||
namespace wiRenderer_BindLua
|
||||
{
|
||||
@@ -14,14 +15,13 @@ namespace wiRenderer_BindLua
|
||||
initialized = true;
|
||||
wiLua::GetGlobal()->RegisterFunc("GetArmatures", GetArmatures);
|
||||
wiLua::GetGlobal()->RegisterFunc("GetObjects", GetObjects);
|
||||
wiLua::GetGlobal()->RegisterFunc("GetObjectProp", GetObjectProp);
|
||||
wiLua::GetGlobal()->RegisterFunc("GetObject", GetObjectLua);
|
||||
wiLua::GetGlobal()->RegisterFunc("GetMeshes", GetMeshes);
|
||||
wiLua::GetGlobal()->RegisterFunc("GetLights", GetLights);
|
||||
wiLua::GetGlobal()->RegisterFunc("GetMaterials", GetMaterials);
|
||||
wiLua::GetGlobal()->RegisterFunc("GetGameSpeed", GetGameSpeed);
|
||||
wiLua::GetGlobal()->RegisterFunc("GetMaterials", GetMaterials);
|
||||
|
||||
wiLua::GetGlobal()->RegisterFunc("SetObjectProp", SetObjectProp);
|
||||
wiLua::GetGlobal()->RegisterFunc("SetGameSpeed", SetGameSpeed);
|
||||
|
||||
wiLua::GetGlobal()->RegisterFunc("LoadModel", LoadModel);
|
||||
@@ -58,73 +58,24 @@ namespace wiRenderer_BindLua
|
||||
wiLua::SSetString(L, ss.str());
|
||||
return 1;
|
||||
}
|
||||
int GetObjectProp(lua_State* L)
|
||||
int GetObjectLua(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 1)
|
||||
if (argc > 0)
|
||||
{
|
||||
//name,property
|
||||
string name = wiLua::SGetString(L, 1);
|
||||
string prop = wiHelper::toUpper( wiLua::SGetString(L, 2) );
|
||||
Object* found = nullptr;
|
||||
for (auto& x : wiRenderer::objects)
|
||||
Object* object = wiRenderer::getObjectByName(name);
|
||||
if (object != nullptr)
|
||||
{
|
||||
if (!x->name.compare(name))
|
||||
{
|
||||
found = x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == nullptr)
|
||||
{
|
||||
for (auto& x : wiRenderer::objects_trans)
|
||||
{
|
||||
if (!x->name.compare(name))
|
||||
{
|
||||
found = x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == nullptr)
|
||||
{
|
||||
for (auto& x : wiRenderer::objects_water)
|
||||
{
|
||||
if (!x->name.compare(name))
|
||||
{
|
||||
found = x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found != nullptr)
|
||||
{
|
||||
if (prop.find("TRANSP")!=string::npos)
|
||||
{
|
||||
wiLua::SSetFloat(L, found->transparency);
|
||||
return 1;
|
||||
}
|
||||
else if (prop.find("COLOR")!=string::npos)
|
||||
{
|
||||
wiLua::SSetFloat3(L, found->color);
|
||||
return 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "GetObjectProp(string name,string property) no such property!");
|
||||
return 0;
|
||||
}
|
||||
Luna<Object_BindLua>::push(L, new Object_BindLua(object));
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "GetObjectProp(string name,string property) no such object!");
|
||||
wiLua::SError(L, "GetObject(String name) object not found!");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "GetObjectProp(string name,string property) not enough arguments!");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int GetMeshes(lua_State* L)
|
||||
@@ -167,72 +118,6 @@ namespace wiRenderer_BindLua
|
||||
}
|
||||
|
||||
|
||||
int SetObjectProp(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
if (argc > 1)
|
||||
{
|
||||
//name,property
|
||||
string name = wiLua::SGetString(L, 1);
|
||||
string prop = wiHelper::toUpper(wiLua::SGetString(L, 2));
|
||||
Object* found = nullptr;
|
||||
for (auto& x : wiRenderer::objects)
|
||||
{
|
||||
if (!x->name.compare(name))
|
||||
{
|
||||
found = x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == nullptr)
|
||||
{
|
||||
for (auto& x : wiRenderer::objects_trans)
|
||||
{
|
||||
if (!x->name.compare(name))
|
||||
{
|
||||
found = x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == nullptr)
|
||||
{
|
||||
for (auto& x : wiRenderer::objects_water)
|
||||
{
|
||||
if (!x->name.compare(name))
|
||||
{
|
||||
found = x;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found != nullptr)
|
||||
{
|
||||
if (prop.find("TRANSP") != string::npos)
|
||||
{
|
||||
found->transparency = wiLua::SGetFloat(L, 3);
|
||||
}
|
||||
else if (prop.find("COLOR") != string::npos)
|
||||
{
|
||||
found->color = wiLua::SGetFloat3(L, 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "GetObjectProp(string name,string property) no such property!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "GetObjectProp(string name,string property) no such object!");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wiLua::SError(L, "GetObjectProp(string name,string property) not enough arguments!");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
int SetGameSpeed(lua_State* L)
|
||||
{
|
||||
int argc = wiLua::SGetArgCount(L);
|
||||
|
||||
@@ -8,13 +8,12 @@ namespace wiRenderer_BindLua
|
||||
|
||||
int GetArmatures(lua_State* L);
|
||||
int GetObjects(lua_State* L);
|
||||
int GetObjectProp(lua_State* L);
|
||||
int GetObjectLua(lua_State* L);
|
||||
int GetMeshes(lua_State* L);
|
||||
int GetLights(lua_State* L);
|
||||
int GetMaterials(lua_State* L);
|
||||
int GetGameSpeed(lua_State* L);
|
||||
|
||||
int SetObjectProp(lua_State* L);
|
||||
int SetGameSpeed(lua_State* L);
|
||||
|
||||
int LoadModel(lua_State* L);
|
||||
|
||||
Reference in New Issue
Block a user