[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

6.7.3 Forces

There are many types of forces that can be used. More are easy to add as well. The three main types are environmental forces, N-body forces, and simple forces.

Environmental forces are added to a `ctWorld' and act on all bodies in that world, for example gravity, air resistance, etc.

 
ctGravityF* gf = new ctGravityF(9.81 / M_PER_WORLDUNIT);
phyz_world.add_enviro_force(gf);

N-body forces are forces that act between multiple bodies, for example springs and planetary gravity.

 
ctVector3 spring_attachment_point1(0, 1, 0);
ctSpringF* sf = new ctSpringF(
    rb1, spring_attachment_point1,
    rb2, spring_attachment_point2);
sf->set_magnitude(200.0 / M_PER_WORLDUNIT);
// Need to add force to each body it affects.
rb1->add_force(sf);
rb2->add_force(sf);

Specify the second body as `NULL' to indicate that end is attached to the world and is therefore immovable.

Simple forces would be something like a rocket engine or other kind of force that only acts on one body.



This document was generated using texi2html