Lua API  0.4.0
Game Engine
 All Files Functions
Physics.lua File Reference

Functions

 setGravity (vec3)
 Sets the current gravity. More...
 
 getGravity ()
 Returns the gravity in the current scene. More...
 
 getLinearDamping (object)
 Returns the linear damping from the given object. More...
 
 setLinearDamping (object, damping)
 Sets the linear damping of the given object. More...
 
 getAngularDamping (object)
 Returns the angular damping from the given object. More...
 
 setAngularDamping (object, damping)
 Sets the angular damping of the given object. More...
 
 getLinearFactor (object)
 Returns the linear factor from the given object. More...
 
 setLinearFactor (object, factor)
 Sets the linear factor of the given object. More...
 
 getAngularFactor (object)
 Returns the angular factor from the given object. More...
 
 setAngularFactor (object, factor)
 Sets the angular factor of the given object. More...
 
 getMass (object)
 Returns the mass of the given object. More...
 
 setMass (object, mass)
 Sets the mass of the given object. More...
 
 getFriction (object)
 Returns the friction constant of the given object. More...
 
 setFriction (object, friction)
 Sets the friction constant of the given object. More...
 
 getRestitution (object)
 Returns the physical restitution of the given object. More...
 
 setRestitution (object, restitution)
 Sets the restitution of the given object. More...
 
 clearForces (object)
 Removes all active forces from the given object. More...
 
 addCentralForce (object, force, mode)
 Applies a new central force to the given object. More...
 
 addTorque (object, torque, mode)
 Applies a new torque to the given object. More...
 
 getCentralForce (object)
 Returns the force applied to the given object. More...
 
 getTorque (object)
 Returns the torque applied to the given object. More...
 
 isCollisionTest (object)
 Checks if the object is colliding at all. More...
 
 isCollisionBetween (object1, object2)
 Checks if the two given objects are colliding. More...
 
 getNumCollisions (object)
 Returns the total number of collisions the given object currently has. More...
 
 rayHit (start, end)
 

Function Documentation

addCentralForce ( object  ,
force  ,
mode   
)

Applies a new central force to the given object.

The new force will be added to the currently existing central force of the object. The mode parameter is optional and allows you to apply forces relative to the objects current rotation.

Parameters
objectThe physically active object.
forceA vec3 containing the force to apply.
modeA string containing "local". Can be left out.
addTorque ( object  ,
torque  ,
mode   
)

Applies a new torque to the given object.

The new torque will be added to the currently existing torque of the object. The mode parameter is optional and allows you to apply a torque relative to the objects current rotation.

Parameters
objectThe physically active object.
torqueA vec3 containing the torque to apply.
modeA string containing "local". Can be left out.
clearForces ( object  )

Removes all active forces from the given object.

Parameters
objectThe physically activated object.
getAngularDamping ( object  )

Returns the angular damping from the given object.

Parameters
objectThe physically active object
Returns
A number containing the angular damping.
getAngularFactor ( object  )

Returns the angular factor from the given object.

Returns
A number containing the linear factor.
getCentralForce ( object  )

Returns the force applied to the given object.

Parameters
objectThe physically active object.
Returns
A vec3.
getFriction ( object  )

Returns the friction constant of the given object.

Parameters
objectThe physically active object.
Returns
A number.
getGravity ( )

Returns the gravity in the current scene.

Returns
A vec3 containing the gravitational pull.
getLinearDamping ( object  )

Returns the linear damping from the given object.

Parameters
objectThe physically active object
Returns
A number containing the linear damping.
getLinearFactor ( object  )

Returns the linear factor from the given object.

Parameters
objectThe physically active object
Returns
A vec3 containing the linear factor.
getMass ( object  )

Returns the mass of the given object.

Parameters
objectThe physically active object.
Returns
A number.
getNumCollisions ( object  )

Returns the total number of collisions the given object currently has.

Parameters
objectThe physically active object.
Returns
A number.
getRestitution ( object  )

Returns the physical restitution of the given object.

Parameters
objectThe physically active object.
Returns
A number.
getTorque ( object  )

Returns the torque applied to the given object.

Parameters
objectThe physically active object.
Returns
A vec3.
isCollisionBetween ( object1  ,
object2   
)

Checks if the two given objects are colliding.

Parameters
object1The physically active object.
object2The physically active object.
Returns
A boolean.
isCollisionTest ( object  )

Checks if the object is colliding at all.

Parameters
objectThe physically active object.
Returns
A boolean.
rayHit ( start  ,
end   
)
setAngularDamping ( object  ,
damping   
)

Sets the angular damping of the given object.

Parameters
objectThe physically active object
dampingA number containing the angular damping.
setAngularFactor ( object  ,
factor   
)

Sets the angular factor of the given object.

Parameters
objectThe physically active object
factorA number containing the angular factor.
setFriction ( object  ,
friction   
)

Sets the friction constant of the given object.

Parameters
objectThe physically active object.
frictionThe new friction.
setGravity ( vec3  )

Sets the current gravity.

Example:

setGravity({0,0,-0.5})
Parameters
vec3A vec3 containing the new gravitational pull.
setLinearDamping ( object  ,
damping   
)

Sets the linear damping of the given object.

Parameters
objectThe physically active object
dampingA number containing the linear damping.
setLinearFactor ( object  ,
factor   
)

Sets the linear factor of the given object.

Parameters
objectThe physically active object
factorA vec3 containing the linear factor.
setMass ( object  ,
mass   
)

Sets the mass of the given object.

Parameters
objectThe physically active object.
massThe new mass.
setRestitution ( object  ,
restitution   
)

Sets the restitution of the given object.

Parameters
objectThe physically active object.
restitutionThe new restitution.