Next: , Previous: PrimitiveData, Up: Functions



12.8 Physics

The physics system used in fluxus is based on the ode library, which allows you to add physical properties to objects and set them in motion. Since ODE is designed for rigid-body simulations, structures are described in terms of objects, joints and forces. A much more comprehensive explanation of these concepts can be found in the ODE documentation, which you have probably downloaded if you have compiled fluxus, or can be found at http://ode.org/ode-docs.html To help with debugging joints, try calling (render-physics) every frame, which will render locators showing you positions and axes of joints that have positional information.

Example
     

12.8.1 (collisions on/off-number)

Returns

void

Description

Enables or disables collision detection. Defaults to off.

Example
      (collisions 1)
     

12.8.2 (ground-plane plane-vector offset-number)

Returns

void

Description

Create an infinite passive plane for use as the 'ground'

Example
      (ground-plane (vector 0 1 0) 0)
     

12.8.3 (active-box primitiveid-number)

Returns

void

Description

Enable the object to be acted upon by the physics system, using a box as the bounding volume. As an active object, it will be transformed by ode. Note: rotations only work correctly if you specify your transforms scale first, then rotate (translate doesn't matter) basically, ode can't deal with shearing transforms.

Example
      (define mycube (build-cube))
      (active-box mycube)
     

12.8.4 (active-cylinder primitiveid-number)

Returns

void

Description

Enable the object to be acted upon by the physics system, using a cylinder as the bounding volume. As an active object, it will be transformed by ode. Note: rotations only work correctly if you specify your transforms scale first, then rotate (translate doesn't matter) basically, ode can't deal with shearing transforms.

Example
      (define mycube (build-cube))
      (active-cylinder mycube)
     

12.8.5 (active-sphere primitiveid-number)

Returns

void

Description

Enable the object to be acted upon by the physics system, using a sphere as the bounding volume. As an active object, it will be transformed by ode. Note: rotations only work correctly if you specify your transforms scale first, then rotate (translate doesn't matter) basically, ode can't deal with shearing transforms.

Example
      (define mycube (build-cube))
      (active-sphere mycube)
     

12.8.6 (passive-box primitiveid-number)

Returns

void

Description

Enable the object to be acted upon by the physics system, using a sphere as the bounding volume. As a passive object, active objects will collide with it, but it will not be transformed. Note: rotations only work correctly if you specify your transforms scale first, then rotate (translate doesn't matter) basically, ode can't deal with shearing transforms.

Example
      (define mycube (build-cube))
      (passive-box mycube)
     

12.8.7 (passive-cylinder primitiveid-number)

Returns

void

Description

Enable the object to be acted upon by the physics system, using a cylinder as the bounding volume. As a passive object, active objects will collide with it, but it will not be transformed. Note: rotations only work correctly if you specify your transforms scale first, then rotate (translate doesn't matter) basically, ode can't deal with shearing transforms.

Example
      (define mycube (build-cube))
      (passive-cylinder mycube)
     

12.8.8 (passive-sphere primitiveid-number)

Returns

void

Description

Enable the object to be acted upon by the physics system, using a sphere as the bounding volume. As a passive object, active objects will collide with it, but it will not be transformed. Note: rotations only work correctly if you specify your transforms scale first, then rotate (translate doesn't matter) basically, ode can't deal with shearing transforms.

Example
      (define mycube (build-cube))
      (passive-sphere mycube)
     

12.8.9 (surface-params slip1-number slip2-number softerp-number softcfm-number)

Returns

void

Description

Sets some global surface attributes that affect friction and bouncyness. see section 7.3.7 of the ODE docs for an explanation of these parameters

Example
      (surface-params 0.1 0.1 0.1 0.1)
     

12.8.10 (build-balljoint primitiveid-number primitiveid-number axis-vector)

Returns

void

Description

Creates a balljoint to connect two objects (see the ode docs for a detailed description of the differences between the joint types). ODE considers joints to be a constraint that is enforced between two objects. When creating a joint, it is important to have the two primitives being joined in the desired positions before creating the joint. Joints can be created, modified and indexed in a similar way to other primitives.

Example
      (build-balljoint shape1 shape2 (vector 0 1 0))
     

12.8.11 (build-fixedjoint primitiveid-number)

Returns

void

Description

Creates a joint to connect an object to the global environment. This locks the object in place.

Example
      (build-fixedjoint shape)
     

12.8.12 (build-hingejoint primitiveid1-number primitiveid2-number anchor-vector axis-vector)

Returns

hingeid-number

Description

Creates a ball joint to connect two objects (see the ode docs for a detailed description of the differences between the joint types). ODE considers joints to be a constraint that is enforced between two objects. When creating a joint, it is important to have the two primitives being joined in the desired positions before creating the joint. Joints can be created, modified and indexed in a similar way to other primitives.

Example
      (build-hingejoint shape1 shape2 (vector 0 1 0) (vector 0 1 0))
     

12.8.13 (build-sliderjoint primitiveid1-number primitiveid2-number axis-vector)

Returns

hingeid-number

Description

Creates a slider joint to connect two objects (see the ode docs for a detailed description of the differences between the joint types). ODE considers joints to be a constraint that is enforced between two objects. When creating a joint, it is important to have the two primitives being joined in the desired positions before creating the joint. Joints can be created, modified and indexed in a similar way to other primitives.

Example
      (build-sliderjoint shape1 shape2 (vector 0 1 0))
     

12.8.14 (build-hinge2joint primitiveid1-number primitiveid2-number anchor-vector axis1-vector axis2-vector)

Returns

hingeid-number

Description

Creates a hinge2 joint to connect two objects (see the ode docs for a detailed description of the differences between the joint types). ODE considers joints to be a constraint that is enforced between two objects. When creating a joint, it is important to have the two primitives being joined in the desired positions before creating the joint. Joints can be created, modified and indexed in a similar way to other primitives.

Example
      (build-hinge2joint shape1 shape2 (vector 0 100 0) (vector 0 1 0) (vector 0 1 0))
     

12.8.15 (build-amotorjoint primitiveid1-number primitiveid2-number axis-vector)

Returns

hingeid-number

Description

Creates a angular motor joint to connect two objects (see the ode docs for a detailed description of the differences between the joint types). ODE considers joints to be a constraint that is enforced between two objects. When creating a joint, it is important to have the two primitives being joined in the desired positions before creating the joint. Joints can be created, modified and indexed in a similar way to other primitives.

Example
      (build-amotorjoint shape1 shape2 (vector 0 1 0))
     

12.8.16 (joint-param jointid-number param-string value-number)

Returns

hingeid-number

Description

Sets the joint parameter for a joint where param is one of the following: "HiStop", "Vel", "FMax", "FudgeFactor", "Bounce", "CFM", "StopERP", "StopCFM","SuspensionERP", "SuspensionCFM", "Vel2", "FMax2". see section 7.5.1 of the ODE docs for an explanation of each of these parameters, and which joint types they apply to.

Example
      (joint-param joint "Vel" 0.1)
     

12.8.17 (joint-angle jointid-number param-string value-number)

Returns

void

Description

Set a new angle for this joint, with a given velocity taken to get there

Example
      (joint-angle joint "Vel" 0.1)
     

12.8.18 (set-max-physical max-number)

Returns

void

Description

Sets the maximum number of objects the physics system can deal with. When the max level has been reached the oldest objects are automatically destroyed.

Example
      (set-max-physical 100)
     

12.8.19 (set-mass primitiveid-number mass-number)

Returns

void

Description

Sets the mass of an active object

Example
      (set-mass myshape 100)
     

12.8.20 (gravity gravity-vector)

Returns

void

Description

Sets the strength and direction of gravity.

Example
      (gravity (vector 0 -1 0))
     

12.8.21 (kick primitiveid-number kick-vector)

Returns

void

Description

Applies translation force to the object

Example
      (kick myshape (vector 0 1 0))
     

12.8.22 (twist primitiveid-number spin-vector)

Returns

void

Description

Applies rotational force to the object

Example
      (kick myshape (vector 2 0 0))
     

12.8.23 (has-collided primitiveid-number)

Returns

void

Description

Returns true if the grabbed object collided in the last frame

Example
      (if (has-collided myshape) (display "bang!"))