PhysicsSceneEntity.lua 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. require "Physics3D/CollisionSceneEntity"
  2. class "PhysicsSceneEntity" (CollisionSceneEntity)
  3. SHAPE_BOX = 0
  4. SHAPE_TERRAIN = 1
  5. SHAPE_SPHERE = 2
  6. SHAPE_MESH = 3
  7. CHARACTER_CONTROLLER = 4
  8. SHAPE_CAPSULE = 5
  9. SHAPE_PLANE = 6
  10. SHAPE_CONE = 7
  11. SHAPE_CYLINDER = 8
  12. function PhysicsSceneEntity:__index__(name)
  13. if name == "enabled" then
  14. return Physics3D.PhysicsSceneEntity_get_enabled(self.__ptr)
  15. end
  16. end
  17. function PhysicsSceneEntity:__set_callback(name,value)
  18. if name == "enabled" then
  19. Physics3D.PhysicsSceneEntity_set_enabled(self.__ptr, value)
  20. return true
  21. end
  22. return false
  23. end
  24. function PhysicsSceneEntity:PhysicsSceneEntity(...)
  25. if type(arg[1]) == "table" and count(arg) == 1 then
  26. if ""..arg[1]:class() == "CollisionSceneEntity" then
  27. self.__ptr = arg[1].__ptr
  28. return
  29. end
  30. end
  31. for k,v in pairs(arg) do
  32. if type(v) == "table" then
  33. if v.__ptr ~= nil then
  34. arg[k] = v.__ptr
  35. end
  36. end
  37. end
  38. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  39. self.__ptr = Physics3D.PhysicsSceneEntity(unpack(arg))
  40. Polycore.__ptr_lookup[self.__ptr] = self
  41. end
  42. end
  43. function PhysicsSceneEntity:getSceneEntity()
  44. local retVal = Physics3D.PhysicsSceneEntity_getSceneEntity(self.__ptr)
  45. if retVal == nil then return nil end
  46. if Polycore.__ptr_lookup[retVal] ~= nil then
  47. return Polycore.__ptr_lookup[retVal]
  48. else
  49. Polycore.__ptr_lookup[retVal] = SceneEntity("__skip_ptr__")
  50. Polycore.__ptr_lookup[retVal].__ptr = retVal
  51. return Polycore.__ptr_lookup[retVal]
  52. end
  53. end
  54. function PhysicsSceneEntity:Update()
  55. local retVal = Physics3D.PhysicsSceneEntity_Update(self.__ptr)
  56. end
  57. function PhysicsSceneEntity:setFriction(friction)
  58. local retVal = Physics3D.PhysicsSceneEntity_setFriction(self.__ptr, friction)
  59. end
  60. function PhysicsSceneEntity:getType()
  61. local retVal = Physics3D.PhysicsSceneEntity_getType(self.__ptr)
  62. return retVal
  63. end
  64. function PhysicsSceneEntity:__delete()
  65. Polycore.__ptr_lookup[self.__ptr] = nil
  66. Physics3D.delete_PhysicsSceneEntity(self.__ptr)
  67. end