Skip to content

rozenmad/bullet-physics-love2d

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bullet-physics-love2d

Bullet Physics for LÖVE, in development.

How to use:

local love_bullet = require 'love_bullet'

API:

World
local world = love.physics3d.newWorld(gx, gy, gz)
world:update(timeStep, maxSubSteps, fixedTimeStep)
world:update(timeStep, maxSubSteps)
tableofRaycastHit   = world:raycast(vec3Origin, vec3Direction, maxDistance)
world:addRigidBody(rbody)
world:addCharacterController(character)

world:removeRigidBody(rbody)
world:removeCharacterController(character)
CollisionObject (Base class for RigidBody and GhostObject)
local collision_object 
collision_object:getTransform(table)
collision_object:setTransform(table)
collision_object:setUserData(table)
collision_object:getUserData(table)
-- parameters for callbacks: function(tableofContactPoint, bodyA, bodyB) end
collision_object:setCallbacks(begin_contact, ongoing_contact, end_contact) 
collision_object:activate(force)
collision_object:isActive()
collision_object:setAnisotropicFriction(vec3Factor)
collision_object:setContactProcessingThreshold(value)
collision_object:setRestitution(value)
collision_object:setFriction(value)
collision_object:setRollingFriction(value)
collision_object:setSpinningFriction(value)
collision_object:setContactStiffnessAndDamping(stiffness, damping)
collision_object:setHitFraction(value)
collision_object:setCcdSweptSphereRadius(value)
collision_object:setCcdMotionThreshold(value)
shape               = collision_object:getCollisionShape()
xf, yf, zf          = collision_object:getAnisotropicFriction()
boolean             = collision_object:hasAnisotropicFriction()
value               = collision_object:getContactProcessingThreshold()
value               = collision_object:getRestitution()
value               = collision_object:getFriction()
value               = collision_object:getRollingFriction()
value               = collision_object:getSpinningFriction()
value               = collision_object:getContactStiffness()
value               = collision_object:getContactDamping()
value               = collision_object:getHitFraction()
value               = collision_object:getCcdSweptSphereRadius()
value               = collision_object:getCcdMotionThreshold()
value               = collision_object:getCcdSquareMotionThreshold()
boolean             = collision_object:canCollideWith()
RigidBody
local rbody = love.physics3d.newRigidBody(shape, mass, matrix)
rbody:setDamping(lin, ang)
rbody:applyForce(vec3LinDamping, vec3AngDamping)
rbody:setAngularFactor(vec3Factor)
rbody:setLinearFactor(vec3Factor)
rbody:setKinematic(boolean)
rbody:setLinearVelocity(x, y, z) -- need fix: change to parse vec3
xv, yv, zv          = rbody:getLinearVelocity()
GhostObject
love.physics3d.newGhostObject(shape)
Shapes
love.physics3d.newBoxShape(halfSizeX, halfSizeY, halfSizeZ)
love.physics3d.newCapsuleShape(radius, height)
love.physics3d.newTriangleMeshShape(vertices, indices)
CharacterController
local character_controller = love.physics.newCharacterController(ghost_object)
character_controller:jump(vec3)
character_controller:setWalkDirection(vec3)
character_controller:setGravity(vec3)
character_controller:setUp(vec3)
character_controller:setMaxJumpHeight(value)
character_controller:setMaxPenetrationDepth(value)
value               = character_controller:getMaxPenetrationDepth()
boolean             = character_controller:onGround()

Others:

ContactPoint
x, y, z             = point:getPositionA()
x, y, z             = point:getPositionB()
value               = point:getDistance()
RaycastHit
x, y, z             = hit:getPosition()
x, y, z             = hit:getNormal()
value               = hit:getDistance()
value               = hit:getHitFraction()
collision_body      = hit:getCollisionObject()