Sfoglia il codice sorgente

Merge pull request #1008 from kwhatmough/next

Update Lua bindings for GamePlay.
Sean Paul Taylor 12 anni fa
parent
commit
1464a208e6

+ 57 - 0
gameplay/src/lua/lua_Game.cpp

@@ -44,6 +44,7 @@ void luaRegister_Game()
         {"getGamepadCount", lua_Game_getGamepadCount},
         {"getHeight", lua_Game_getHeight},
         {"getPhysicsController", lua_Game_getPhysicsController},
+        {"getRawSensorValues", lua_Game_getRawSensorValues},
         {"getScriptController", lua_Game_getScriptController},
         {"getState", lua_Game_getState},
         {"getViewport", lua_Game_getViewport},
@@ -1069,6 +1070,62 @@ int lua_Game_getPhysicsController(lua_State* state)
     return 0;
 }
 
+int lua_Game_getRawSensorValues(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 7:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TLIGHTUSERDATA) &&
+                (lua_type(state, 3) == LUA_TTABLE || lua_type(state, 3) == LUA_TLIGHTUSERDATA) &&
+                (lua_type(state, 4) == LUA_TTABLE || lua_type(state, 4) == LUA_TLIGHTUSERDATA) &&
+                (lua_type(state, 5) == LUA_TTABLE || lua_type(state, 5) == LUA_TLIGHTUSERDATA) &&
+                (lua_type(state, 6) == LUA_TTABLE || lua_type(state, 6) == LUA_TLIGHTUSERDATA) &&
+                (lua_type(state, 7) == LUA_TTABLE || lua_type(state, 7) == LUA_TLIGHTUSERDATA))
+            {
+                // Get parameter 1 off the stack.
+                gameplay::ScriptUtil::LuaArray<float> param1 = gameplay::ScriptUtil::getFloatPointer(2);
+
+                // Get parameter 2 off the stack.
+                gameplay::ScriptUtil::LuaArray<float> param2 = gameplay::ScriptUtil::getFloatPointer(3);
+
+                // Get parameter 3 off the stack.
+                gameplay::ScriptUtil::LuaArray<float> param3 = gameplay::ScriptUtil::getFloatPointer(4);
+
+                // Get parameter 4 off the stack.
+                gameplay::ScriptUtil::LuaArray<float> param4 = gameplay::ScriptUtil::getFloatPointer(5);
+
+                // Get parameter 5 off the stack.
+                gameplay::ScriptUtil::LuaArray<float> param5 = gameplay::ScriptUtil::getFloatPointer(6);
+
+                // Get parameter 6 off the stack.
+                gameplay::ScriptUtil::LuaArray<float> param6 = gameplay::ScriptUtil::getFloatPointer(7);
+
+                Game* instance = getInstance(state);
+                instance->getRawSensorValues(param1, param2, param3, param4, param5, param6);
+                
+                return 0;
+            }
+
+            lua_pushstring(state, "lua_Game_getRawSensorValues - Failed to match the given parameters to a valid function signature.");
+            lua_error(state);
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 7).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_Game_getScriptController(lua_State* state)
 {
     // Get the number of parameters.

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

@@ -27,6 +27,7 @@ int lua_Game_getGamepad(lua_State* state);
 int lua_Game_getGamepadCount(lua_State* state);
 int lua_Game_getHeight(lua_State* state);
 int lua_Game_getPhysicsController(lua_State* state);
+int lua_Game_getRawSensorValues(lua_State* state);
 int lua_Game_getScriptController(lua_State* state);
 int lua_Game_getState(lua_State* state);
 int lua_Game_getViewport(lua_State* state);

+ 2 - 2
gameplay/src/lua/lua_Global.cpp

@@ -753,8 +753,8 @@ void luaRegister_lua_Global()
         gameplay::ScriptUtil::registerConstantString("BLEND_ONE_MINUS_CONSTANT_ALPHA", "BLEND_ONE_MINUS_CONSTANT_ALPHA", scopePath);
         gameplay::ScriptUtil::registerConstantString("BLEND_SRC_ALPHA_SATURATE", "BLEND_SRC_ALPHA_SATURATE", scopePath);
     }
-    
-    // Register enumeration RenderState::CullFaceSide
+
+    // Register enumeration RenderState::CullFaceSide.
     {
         std::vector<std::string> scopePath;
         scopePath.push_back("RenderState");

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

@@ -15,6 +15,7 @@
 #include "Technique.h"
 #include "lua_RenderStateAutoBinding.h"
 #include "lua_RenderStateBlend.h"
+#include "lua_RenderStateCullFaceSide.h"
 #include "lua_RenderStateDepthFunction.h"
 
 namespace gameplay

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

@@ -12,6 +12,7 @@
 #include "Technique.h"
 #include "lua_RenderStateAutoBinding.h"
 #include "lua_RenderStateBlend.h"
+#include "lua_RenderStateCullFaceSide.h"
 #include "lua_RenderStateDepthFunction.h"
 
 namespace gameplay

+ 1 - 1
gameplay/src/lua/lua_RenderState.cpp

@@ -11,8 +11,8 @@
 #include "Technique.h"
 #include "lua_RenderStateAutoBinding.h"
 #include "lua_RenderStateBlend.h"
-#include "lua_RenderStateDepthFunction.h"
 #include "lua_RenderStateCullFaceSide.h"
+#include "lua_RenderStateDepthFunction.h"
 
 namespace gameplay
 {

+ 2 - 1
gameplay/src/lua/lua_RenderStateCullFaceSide.cpp

@@ -32,4 +32,5 @@ const char* lua_stringFromEnum_RenderStateCullFaceSide(RenderState::CullFaceSide
     return enumStringEmpty;
 }
 
-}
+}
+

+ 5 - 5
gameplay/src/lua/lua_RenderStateStateBlock.cpp

@@ -11,8 +11,8 @@
 #include "Technique.h"
 #include "lua_RenderStateAutoBinding.h"
 #include "lua_RenderStateBlend.h"
-#include "lua_RenderStateDepthFunction.h"
 #include "lua_RenderStateCullFaceSide.h"
+#include "lua_RenderStateDepthFunction.h"
 
 namespace gameplay
 {
@@ -372,8 +372,9 @@ int lua_RenderStateStateBlock_setCullFaceSide(lua_State* state)
     // Get the number of parameters.
     int paramCount = lua_gettop(state);
 
-    //Attempt to match the parameters to a valid binding.
-    switch (paramCount) {
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
         case 2:
         {
             if ((lua_type(state, 1) == LUA_TUSERDATA) &&
@@ -384,11 +385,10 @@ int lua_RenderStateStateBlock_setCullFaceSide(lua_State* state)
 
                 RenderState::StateBlock* instance = getInstance(state);
                 instance->setCullFaceSide(param1);
-
+                
                 return 0;
             }
 
-
             lua_pushstring(state, "lua_RenderStateStateBlock_setCullFaceSide - Failed to match the given parameters to a valid function signature.");
             lua_error(state);
             break;

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

@@ -12,6 +12,7 @@
 #include "Technique.h"
 #include "lua_RenderStateAutoBinding.h"
 #include "lua_RenderStateBlend.h"
+#include "lua_RenderStateCullFaceSide.h"
 #include "lua_RenderStateDepthFunction.h"
 
 namespace gameplay

+ 3 - 1
tools/luagen/README.md

@@ -1,4 +1,6 @@
 ## Usage
+Make sure that you have [doxygen](http://www.doxygen.org/) installed.
+
 To generate the Lua script bindings for gameplay, run the generate-doxygen-xml.bat (or .sh) script. Then, on Windows, open the gameplay-luagen Visual Studio solution and build and run the gameplay-luagen project. On Mac, open the gameplay-luagen XCode workspace and build and run the gameplay-luagen project.
 
 There are also prebuilt binaries in the gameplay/bin folder.
@@ -23,4 +25,4 @@ INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 
-OTHER DEALINGS IN THE SOFTWARE.
+OTHER DEALINGS IN THE SOFTWARE.