Vector2f.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef ROCKETCORELUAVECTOR2F_H
  2. #define ROCKETCORELUAVECTOR2F_H
  3. /*
  4. Declares Vector2f in the Lua global namespace. It implements the below (examples using Lua syntax) :
  5. Vector2f.new(float,float) creates a new Vector2f, and gets deleted when Lua garbage collects
  6. everything after this will assume that you have a local variable named 'vect', declared something similar to
  7. local vect = Vector2f.new(3.5,2.3)
  8. operators (the types that it can operate on are on the right):
  9. vect * float
  10. vect / float
  11. vect + Vector2f
  12. vect - Vector2f
  13. vect == Vector2f
  14. methods:
  15. float var = vect:DotProduct(Vector2f)
  16. Vector2f var = vect:Normalise()
  17. Vector2f var = vect:Rotate(float)
  18. get and set attributes:
  19. vect.x
  20. vect.y
  21. get attributes:
  22. vect.magnitude
  23. */
  24. #include <Rocket/Core/Lua/lua.hpp>
  25. #include <Rocket/Core/Lua/LuaType.h>
  26. #include <Rocket/Core/Types.h>
  27. using Rocket::Core::Vector2f;
  28. namespace Rocket {
  29. namespace Core {
  30. namespace Lua {
  31. template<> void LuaType<Vector2f>::extra_init(lua_State* L, int metatable_index);
  32. int Vector2fnew(lua_State* L);
  33. int Vector2f__mul(lua_State* L);
  34. int Vector2f__div(lua_State* L);
  35. int Vector2f__add(lua_State* L);
  36. int Vector2f__sub(lua_State* L);
  37. int Vector2f__eq(lua_State* L);
  38. int Vector2fDotProduct(lua_State* L, Vector2f* obj);
  39. int Vector2fNormalise(lua_State* L, Vector2f* obj);
  40. int Vector2fRotate(lua_State* L, Vector2f* obj);
  41. int Vector2fGetAttrx(lua_State*L);
  42. int Vector2fGetAttry(lua_State*L);
  43. int Vector2fGetAttrmagnitude(lua_State*L);
  44. int Vector2fSetAttrx(lua_State*L);
  45. int Vector2fSetAttry(lua_State*L);
  46. RegType<Vector2f> Vector2fMethods[];
  47. luaL_reg Vector2fGetters[];
  48. luaL_reg Vector2fSetters[];
  49. /*
  50. template<> const char* GetTClassName<Vector2f>() { return "Vector2f"; }
  51. template<> RegType<Vector2f>* GetMethodTable<Vector2f>() { return Vector2fMethods; }
  52. template<> luaL_reg* GetAttrTable<Vector2f>() { return Vector2fGetters; }
  53. template<> luaL_reg* SetAttrTable<Vector2f>() { return Vector2fSetters; }
  54. */
  55. }
  56. }
  57. }
  58. #endif