Explorar o código

Updated lua bindings.

sgrenier %!s(int64=12) %!d(string=hai) anos
pai
achega
ee79eb901a

+ 1 - 1
gameplay/src/Material.h

@@ -62,7 +62,7 @@ public:
      * @param cookie Optional custom parameter to be passed to the callback function.
      *
      * @return A new Material or NULL if there was an error.
-     * @script{create}
+     * @script{ignore}
      */
     static Material* create(const char* url, PassCallback callback, void* cookie = NULL);
 

+ 43 - 0
gameplay/src/lua/lua_Material.cpp

@@ -40,6 +40,7 @@ void luaRegister_Material()
         {"getTechniqueCount", lua_Material_getTechniqueCount},
         {"release", lua_Material_release},
         {"removeParameter", lua_Material_removeParameter},
+        {"setNodeBinding", lua_Material_setNodeBinding},
         {"setParameterAutoBinding", lua_Material_setParameterAutoBinding},
         {"setStateBlock", lua_Material_setStateBlock},
         {"setTechnique", lua_Material_setTechnique},
@@ -615,6 +616,48 @@ int lua_Material_removeParameter(lua_State* state)
     return 0;
 }
 
+int lua_Material_setNodeBinding(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                bool param1Valid;
+                gameplay::ScriptUtil::LuaArray<Node> param1 = gameplay::ScriptUtil::getObjectPointer<Node>(2, "Node", false, &param1Valid);
+                if (!param1Valid)
+                {
+                    lua_pushstring(state, "Failed to convert parameter 1 to type 'Node'.");
+                    lua_error(state);
+                }
+
+                Material* instance = getInstance(state);
+                instance->setNodeBinding(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Material_setNodeBinding - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_Material_setParameterAutoBinding(lua_State* state)
 {
     // Get the number of parameters.

+ 1 - 0
gameplay/src/lua/lua_Material.h

@@ -18,6 +18,7 @@ int lua_Material_getTechniqueByIndex(lua_State* state);
 int lua_Material_getTechniqueCount(lua_State* state);
 int lua_Material_release(lua_State* state);
 int lua_Material_removeParameter(lua_State* state);
+int lua_Material_setNodeBinding(lua_State* state);
 int lua_Material_setParameterAutoBinding(lua_State* state);
 int lua_Material_setStateBlock(lua_State* state);
 int lua_Material_setTechnique(lua_State* state);

+ 43 - 0
gameplay/src/lua/lua_Pass.cpp

@@ -38,6 +38,7 @@ void luaRegister_Pass()
         {"getVertexAttributeBinding", lua_Pass_getVertexAttributeBinding},
         {"release", lua_Pass_release},
         {"removeParameter", lua_Pass_removeParameter},
+        {"setNodeBinding", lua_Pass_setNodeBinding},
         {"setParameterAutoBinding", lua_Pass_setParameterAutoBinding},
         {"setStateBlock", lua_Pass_setStateBlock},
         {"setVertexAttributeBinding", lua_Pass_setVertexAttributeBinding},
@@ -602,6 +603,48 @@ int lua_Pass_removeParameter(lua_State* state)
     return 0;
 }
 
+int lua_Pass_setNodeBinding(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                bool param1Valid;
+                gameplay::ScriptUtil::LuaArray<Node> param1 = gameplay::ScriptUtil::getObjectPointer<Node>(2, "Node", false, &param1Valid);
+                if (!param1Valid)
+                {
+                    lua_pushstring(state, "Failed to convert parameter 1 to type 'Node'.");
+                    lua_error(state);
+                }
+
+                Pass* instance = getInstance(state);
+                instance->setNodeBinding(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Pass_setNodeBinding - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_Pass_setParameterAutoBinding(lua_State* state)
 {
     // Get the number of parameters.

+ 1 - 0
gameplay/src/lua/lua_Pass.h

@@ -19,6 +19,7 @@ int lua_Pass_getStateBlock(lua_State* state);
 int lua_Pass_getVertexAttributeBinding(lua_State* state);
 int lua_Pass_release(lua_State* state);
 int lua_Pass_removeParameter(lua_State* state);
+int lua_Pass_setNodeBinding(lua_State* state);
 int lua_Pass_setParameterAutoBinding(lua_State* state);
 int lua_Pass_setStateBlock(lua_State* state);
 int lua_Pass_setVertexAttributeBinding(lua_State* state);

+ 43 - 0
gameplay/src/lua/lua_RenderState.cpp

@@ -33,6 +33,7 @@ void luaRegister_RenderState()
         {"getStateBlock", lua_RenderState_getStateBlock},
         {"release", lua_RenderState_release},
         {"removeParameter", lua_RenderState_removeParameter},
+        {"setNodeBinding", lua_RenderState_setNodeBinding},
         {"setParameterAutoBinding", lua_RenderState_setParameterAutoBinding},
         {"setStateBlock", lua_RenderState_setStateBlock},
         {NULL, NULL}
@@ -440,6 +441,48 @@ int lua_RenderState_removeParameter(lua_State* state)
     return 0;
 }
 
+int lua_RenderState_setNodeBinding(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                bool param1Valid;
+                gameplay::ScriptUtil::LuaArray<Node> param1 = gameplay::ScriptUtil::getObjectPointer<Node>(2, "Node", false, &param1Valid);
+                if (!param1Valid)
+                {
+                    lua_pushstring(state, "Failed to convert parameter 1 to type 'Node'.");
+                    lua_error(state);
+                }
+
+                RenderState* instance = getInstance(state);
+                instance->setNodeBinding(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_RenderState_setNodeBinding - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_RenderState_setParameterAutoBinding(lua_State* state)
 {
     // Get the number of parameters.

+ 1 - 0
gameplay/src/lua/lua_RenderState.h

@@ -15,6 +15,7 @@ int lua_RenderState_getRefCount(lua_State* state);
 int lua_RenderState_getStateBlock(lua_State* state);
 int lua_RenderState_release(lua_State* state);
 int lua_RenderState_removeParameter(lua_State* state);
+int lua_RenderState_setNodeBinding(lua_State* state);
 int lua_RenderState_setParameterAutoBinding(lua_State* state);
 int lua_RenderState_setStateBlock(lua_State* state);
 

+ 43 - 0
gameplay/src/lua/lua_Technique.cpp

@@ -38,6 +38,7 @@ void luaRegister_Technique()
         {"getStateBlock", lua_Technique_getStateBlock},
         {"release", lua_Technique_release},
         {"removeParameter", lua_Technique_removeParameter},
+        {"setNodeBinding", lua_Technique_setNodeBinding},
         {"setParameterAutoBinding", lua_Technique_setParameterAutoBinding},
         {"setStateBlock", lua_Technique_setStateBlock},
         {NULL, NULL}
@@ -611,6 +612,48 @@ int lua_Technique_removeParameter(lua_State* state)
     return 0;
 }
 
+int lua_Technique_setNodeBinding(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                bool param1Valid;
+                gameplay::ScriptUtil::LuaArray<Node> param1 = gameplay::ScriptUtil::getObjectPointer<Node>(2, "Node", false, &param1Valid);
+                if (!param1Valid)
+                {
+                    lua_pushstring(state, "Failed to convert parameter 1 to type 'Node'.");
+                    lua_error(state);
+                }
+
+                Technique* instance = getInstance(state);
+                instance->setNodeBinding(param1);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Technique_setNodeBinding - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_Technique_setParameterAutoBinding(lua_State* state)
 {
     // Get the number of parameters.

+ 1 - 0
gameplay/src/lua/lua_Technique.h

@@ -19,6 +19,7 @@ int lua_Technique_getRefCount(lua_State* state);
 int lua_Technique_getStateBlock(lua_State* state);
 int lua_Technique_release(lua_State* state);
 int lua_Technique_removeParameter(lua_State* state);
+int lua_Technique_setNodeBinding(lua_State* state);
 int lua_Technique_setParameterAutoBinding(lua_State* state);
 int lua_Technique_setStateBlock(lua_State* state);
 

+ 62 - 1
gameplay/src/lua/lua_Terrain.cpp

@@ -879,9 +879,70 @@ int lua_Terrain_static_create(lua_State* state)
             lua_error(state);
             break;
         }
+        case 7:
+        {
+            do
+            {
+                if ((lua_type(state, 1) == LUA_TUSERDATA || lua_type(state, 1) == LUA_TTABLE || lua_type(state, 1) == LUA_TNIL) &&
+                    (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL) &&
+                    lua_type(state, 3) == LUA_TNUMBER &&
+                    lua_type(state, 4) == LUA_TNUMBER &&
+                    lua_type(state, 5) == LUA_TNUMBER &&
+                    (lua_type(state, 6) == LUA_TSTRING || lua_type(state, 6) == LUA_TNIL) &&
+                    (lua_type(state, 7) == LUA_TSTRING || lua_type(state, 7) == LUA_TNIL))
+                {
+                    // Get parameter 1 off the stack.
+                    bool param1Valid;
+                    gameplay::ScriptUtil::LuaArray<HeightField> param1 = gameplay::ScriptUtil::getObjectPointer<HeightField>(1, "HeightField", false, &param1Valid);
+                    if (!param1Valid)
+                        break;
+
+                    // Get parameter 2 off the stack.
+                    bool param2Valid;
+                    gameplay::ScriptUtil::LuaArray<Vector3> param2 = gameplay::ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true, &param2Valid);
+                    if (!param2Valid)
+                        break;
+
+                    // Get parameter 3 off the stack.
+                    unsigned int param3 = (unsigned int)luaL_checkunsigned(state, 3);
+
+                    // Get parameter 4 off the stack.
+                    unsigned int param4 = (unsigned int)luaL_checkunsigned(state, 4);
+
+                    // Get parameter 5 off the stack.
+                    float param5 = (float)luaL_checknumber(state, 5);
+
+                    // Get parameter 6 off the stack.
+                    const char* param6 = gameplay::ScriptUtil::getString(6, false);
+
+                    // Get parameter 7 off the stack.
+                    const char* param7 = gameplay::ScriptUtil::getString(7, false);
+
+                    void* returnPtr = (void*)Terrain::create(param1, *param2, param3, param4, param5, param6, param7);
+                    if (returnPtr)
+                    {
+                        gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
+                        object->instance = returnPtr;
+                        object->owns = true;
+                        luaL_getmetatable(state, "Terrain");
+                        lua_setmetatable(state, -2);
+                    }
+                    else
+                    {
+                        lua_pushnil(state);
+                    }
+
+                    return 1;
+                }
+            } while (0);
+
+            lua_pushstring(state, "lua_Terrain_static_create - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
         default:
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 1, 2, 3, 4, 5 or 6).");
+            lua_pushstring(state, "Invalid number of parameters (expected 1, 2, 3, 4, 5, 6 or 7).");
             lua_error(state);
             break;
         }