PhysicsSceneEntity.lua 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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 Polycore.__ptr_lookup[retVal] ~= nil then
  46. return Polycore.__ptr_lookup[retVal]
  47. else
  48. Polycore.__ptr_lookup[retVal] = SceneEntity("__skip_ptr__")
  49. Polycore.__ptr_lookup[retVal].__ptr = retVal
  50. return Polycore.__ptr_lookup[retVal]
  51. end
  52. end
  53. function PhysicsSceneEntity:Update()
  54. local retVal = Physics3D.PhysicsSceneEntity_Update(self.__ptr)
  55. end
  56. function PhysicsSceneEntity:setFriction(friction)
  57. local retVal = Physics3D.PhysicsSceneEntity_setFriction(self.__ptr, friction)
  58. end
  59. function PhysicsSceneEntity:getType()
  60. local retVal = Physics3D.PhysicsSceneEntity_getType(self.__ptr)
  61. return retVal
  62. end
  63. function PhysicsSceneEntity:__delete()
  64. Polycore.__ptr_lookup[self.__ptr] = nil
  65. Physics3D.delete_PhysicsSceneEntity(self.__ptr)
  66. end