PhysicsVehicle.lua 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. require "Physics3D/PhysicsSceneEntity"
  2. class "PhysicsVehicle" (PhysicsSceneEntity)
  3. function PhysicsVehicle:__index__(name)
  4. if name == "tuning" then
  5. retVal = Physics3D.PhysicsVehicle_get_tuning(self.__ptr)
  6. if Polycore.__ptr_lookup[retVal] ~= nil then
  7. return Polycore.__ptr_lookup[retVal]
  8. else
  9. Polycore.__ptr_lookup[retVal] = btRaycastVehicle::btVehicleTuning("__skip_ptr__")
  10. Polycore.__ptr_lookup[retVal].__ptr = retVal
  11. return Polycore.__ptr_lookup[retVal]
  12. end
  13. end
  14. end
  15. function PhysicsVehicle:__set_callback(name,value)
  16. return false
  17. end
  18. function PhysicsVehicle:PhysicsVehicle(...)
  19. if type(arg[1]) == "table" and count(arg) == 1 then
  20. if ""..arg[1]:class() == "PhysicsSceneEntity" then
  21. self.__ptr = arg[1].__ptr
  22. return
  23. end
  24. end
  25. for k,v in pairs(arg) do
  26. if type(v) == "table" then
  27. if v.__ptr ~= nil then
  28. arg[k] = v.__ptr
  29. end
  30. end
  31. end
  32. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  33. self.__ptr = Physics3D.PhysicsVehicle(unpack(arg))
  34. Polycore.__ptr_lookup[self.__ptr] = self
  35. end
  36. end
  37. function PhysicsVehicle:addWheel(entity, connection, direction, axle, suspentionRestLength, wheelRadius, isFrontWheel, suspensionStiffness, suspensionDamping, suspensionCompression, wheelFriction, rollInfluence)
  38. local retVal = Physics3D.PhysicsVehicle_addWheel(self.__ptr, entity.__ptr, connection.__ptr, direction.__ptr, axle.__ptr, suspentionRestLength, wheelRadius, isFrontWheel, suspensionStiffness, suspensionDamping, suspensionCompression, wheelFriction, rollInfluence)
  39. end
  40. function PhysicsVehicle:applyEngineForce(force, wheelIndex)
  41. local retVal = Physics3D.PhysicsVehicle_applyEngineForce(self.__ptr, force, wheelIndex)
  42. end
  43. function PhysicsVehicle:setSteeringValue(value, wheelIndex)
  44. local retVal = Physics3D.PhysicsVehicle_setSteeringValue(self.__ptr, value, wheelIndex)
  45. end
  46. function PhysicsVehicle:setBrake(value, wheelIndex)
  47. local retVal = Physics3D.PhysicsVehicle_setBrake(self.__ptr, value, wheelIndex)
  48. end
  49. function PhysicsVehicle:ResetVehicle()
  50. local retVal = Physics3D.PhysicsVehicle_ResetVehicle(self.__ptr)
  51. end
  52. function PhysicsVehicle:Update()
  53. local retVal = Physics3D.PhysicsVehicle_Update(self.__ptr)
  54. end
  55. function PhysicsVehicle:__delete()
  56. Polycore.__ptr_lookup[self.__ptr] = nil
  57. Physics3D.delete_PhysicsVehicle(self.__ptr)
  58. end