PhysicsVehicle.lua 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. require "Physics3D/PhysicsSceneEntity"
  2. class "PhysicsVehicle" (PhysicsSceneEntity)
  3. function PhysicsVehicle:PhysicsVehicle(...)
  4. if type(arg[1]) == "table" and count(arg) == 1 then
  5. if ""..arg[1]:class() == "PhysicsSceneEntity" then
  6. self.__ptr = arg[1].__ptr
  7. return
  8. end
  9. end
  10. for k,v in pairs(arg) do
  11. if type(v) == "table" then
  12. if v.__ptr ~= nil then
  13. arg[k] = v.__ptr
  14. end
  15. end
  16. end
  17. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  18. self.__ptr = Physics3D.PhysicsVehicle(unpack(arg))
  19. Polycore.__ptr_lookup[self.__ptr] = self
  20. end
  21. end
  22. function PhysicsVehicle:addWheel(entity, connection, direction, axle, suspentionRestLength, wheelRadius, isFrontWheel, suspensionStiffness, suspensionDamping, suspensionCompression, wheelFriction, rollInfluence)
  23. local retVal = Physics3D.PhysicsVehicle_addWheel(self.__ptr, entity.__ptr, connection.__ptr, direction.__ptr, axle.__ptr, suspentionRestLength, wheelRadius, isFrontWheel, suspensionStiffness, suspensionDamping, suspensionCompression, wheelFriction, rollInfluence)
  24. end
  25. function PhysicsVehicle:applyEngineForce(force, wheelIndex)
  26. local retVal = Physics3D.PhysicsVehicle_applyEngineForce(self.__ptr, force, wheelIndex)
  27. end
  28. function PhysicsVehicle:setSteeringValue(value, wheelIndex)
  29. local retVal = Physics3D.PhysicsVehicle_setSteeringValue(self.__ptr, value, wheelIndex)
  30. end
  31. function PhysicsVehicle:setBrake(value, wheelIndex)
  32. local retVal = Physics3D.PhysicsVehicle_setBrake(self.__ptr, value, wheelIndex)
  33. end
  34. function PhysicsVehicle:Update()
  35. local retVal = Physics3D.PhysicsVehicle_Update(self.__ptr)
  36. end
  37. function PhysicsVehicle:__delete()
  38. Polycore.__ptr_lookup[self.__ptr] = nil
  39. Physics3D.delete_PhysicsVehicle(self.__ptr)
  40. end