lua_SceneRendererForward.cpp 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. #include "Base.h"
  2. #include "ScriptController.h"
  3. #include "lua_SceneRendererForward.h"
  4. #include "Base.h"
  5. #include "Form.h"
  6. #include "Model.h"
  7. #include "ParticleEmitter.h"
  8. #include "SceneRenderer.h"
  9. #include "SceneRendererForward.h"
  10. #include "Terrain.h"
  11. namespace gameplay
  12. {
  13. void luaRegister_SceneRendererForward()
  14. {
  15. const luaL_Reg lua_members[] =
  16. {
  17. {"isWireframe", lua_SceneRendererForward_isWireframe},
  18. {"render", lua_SceneRendererForward_render},
  19. {"setWireframe", lua_SceneRendererForward_setWireframe},
  20. {NULL, NULL}
  21. };
  22. const luaL_Reg lua_statics[] =
  23. {
  24. {"create", lua_SceneRendererForward_static_create},
  25. {NULL, NULL}
  26. };
  27. std::vector<std::string> scopePath;
  28. gameplay::ScriptUtil::registerClass("SceneRendererForward", lua_members, NULL, NULL, lua_statics, scopePath);
  29. }
  30. static SceneRendererForward* getInstance(lua_State* state)
  31. {
  32. void* userdata = luaL_checkudata(state, 1, "SceneRendererForward");
  33. luaL_argcheck(state, userdata != NULL, 1, "'SceneRendererForward' expected.");
  34. return (SceneRendererForward*)((gameplay::ScriptUtil::LuaObject*)userdata)->instance;
  35. }
  36. int lua_SceneRendererForward_isWireframe(lua_State* state)
  37. {
  38. // Get the number of parameters.
  39. int paramCount = lua_gettop(state);
  40. // Attempt to match the parameters to a valid binding.
  41. switch (paramCount)
  42. {
  43. case 1:
  44. {
  45. if ((lua_type(state, 1) == LUA_TUSERDATA))
  46. {
  47. SceneRendererForward* instance = getInstance(state);
  48. bool result = instance->isWireframe();
  49. // Push the return value onto the stack.
  50. lua_pushboolean(state, result);
  51. return 1;
  52. }
  53. lua_pushstring(state, "lua_SceneRendererForward_isWireframe - Failed to match the given parameters to a valid function signature.");
  54. lua_error(state);
  55. break;
  56. }
  57. default:
  58. {
  59. lua_pushstring(state, "Invalid number of parameters (expected 1).");
  60. lua_error(state);
  61. break;
  62. }
  63. }
  64. return 0;
  65. }
  66. int lua_SceneRendererForward_render(lua_State* state)
  67. {
  68. // Get the number of parameters.
  69. int paramCount = lua_gettop(state);
  70. // Attempt to match the parameters to a valid binding.
  71. switch (paramCount)
  72. {
  73. case 2:
  74. {
  75. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  76. (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TTABLE || lua_type(state, 2) == LUA_TNIL))
  77. {
  78. // Get parameter 1 off the stack.
  79. bool param1Valid;
  80. gameplay::ScriptUtil::LuaArray<VisibleSet> param1 = gameplay::ScriptUtil::getObjectPointer<VisibleSet>(2, "VisibleSet", false, &param1Valid);
  81. if (!param1Valid)
  82. {
  83. lua_pushstring(state, "Failed to convert parameter 1 to type 'VisibleSet'.");
  84. lua_error(state);
  85. }
  86. SceneRendererForward* instance = getInstance(state);
  87. unsigned int result = instance->render(param1);
  88. // Push the return value onto the stack.
  89. lua_pushunsigned(state, result);
  90. return 1;
  91. }
  92. lua_pushstring(state, "lua_SceneRendererForward_render - Failed to match the given parameters to a valid function signature.");
  93. lua_error(state);
  94. break;
  95. }
  96. default:
  97. {
  98. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  99. lua_error(state);
  100. break;
  101. }
  102. }
  103. return 0;
  104. }
  105. int lua_SceneRendererForward_setWireframe(lua_State* state)
  106. {
  107. // Get the number of parameters.
  108. int paramCount = lua_gettop(state);
  109. // Attempt to match the parameters to a valid binding.
  110. switch (paramCount)
  111. {
  112. case 2:
  113. {
  114. if ((lua_type(state, 1) == LUA_TUSERDATA) &&
  115. lua_type(state, 2) == LUA_TBOOLEAN)
  116. {
  117. // Get parameter 1 off the stack.
  118. bool param1 = gameplay::ScriptUtil::luaCheckBool(state, 2);
  119. SceneRendererForward* instance = getInstance(state);
  120. instance->setWireframe(param1);
  121. return 0;
  122. }
  123. lua_pushstring(state, "lua_SceneRendererForward_setWireframe - Failed to match the given parameters to a valid function signature.");
  124. lua_error(state);
  125. break;
  126. }
  127. default:
  128. {
  129. lua_pushstring(state, "Invalid number of parameters (expected 2).");
  130. lua_error(state);
  131. break;
  132. }
  133. }
  134. return 0;
  135. }
  136. int lua_SceneRendererForward_static_create(lua_State* state)
  137. {
  138. // Get the number of parameters.
  139. int paramCount = lua_gettop(state);
  140. // Attempt to match the parameters to a valid binding.
  141. switch (paramCount)
  142. {
  143. case 0:
  144. {
  145. void* returnPtr = (void*)SceneRendererForward::create();
  146. if (returnPtr)
  147. {
  148. gameplay::ScriptUtil::LuaObject* object = (gameplay::ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(gameplay::ScriptUtil::LuaObject));
  149. object->instance = returnPtr;
  150. object->owns = false;
  151. luaL_getmetatable(state, "SceneRendererForward");
  152. lua_setmetatable(state, -2);
  153. }
  154. else
  155. {
  156. lua_pushnil(state);
  157. }
  158. return 1;
  159. break;
  160. }
  161. default:
  162. {
  163. lua_pushstring(state, "Invalid number of parameters (expected 0).");
  164. lua_error(state);
  165. break;
  166. }
  167. }
  168. return 0;
  169. }
  170. }