[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
An articulated body is a rigid body that can have one or more other rigid bodies connected to it by joints. Such as a chain or a human figure. Currently revolute (like a hinge) joints and prismatic (like an air pump) joints are implemented. Also the articulated body can not at present have any closed loops in it. Articulated bodies can have one end fixed immovably to the world reference frame, be free floating, or be attached to an entity whose movement is specified by the user.
// Use new_ctRigidBody makes sure the rb will have // a suitable reference frame. rb = ctRigidBody::new_ctRigidBody(); // Create an articulated body with a rigid body. ab_parent = new ctArticulatedBody(rb); // Only have to add the root; no need to add // children to world. phyz_world.add_add_articulatedbodybase(ab_parent); ab_child = new ctArticulatedBody(rb2); ctVector3 joint_offset_parent_to_child(0, -0.1, 0); // Line of action for this joint. ctVector3 joint_action(0, 0, 1); // Link the child to the parent with a revolute joint. ab_parent->link_revolute( ab_child, joint_offset_parent_to_child, joint_offset_ctop, joint_action); |
Now when evolved the articulated body will move in a dynamically correct manner in response to any external and internal forces (if the Featherstone solver is used).
It is possible to define your own joints from `ctJoint'. You can then
overload the get_actuator_magnitude()
method to implement a joint with
a motor that will exert whatever force you like at that joint. There is such
a joint implemented that enforces angle constraints on the joint,
`ctConstrainedRevoluteJoint'. Add this joint using:
parent_ab->link_joint(new_constrained_joint, child_ab); |
You can set the angles that joint is constrained to using:
set_constraint(max_angle, min_angle); |
Test out your joint and modify the spring and damping constants to get the proper behavior. For instance, if your joint bounces back too much at the constraint, your spring constant is too high.
You can attach the root of an articulated body to some object from your own side of the code. The attached articulated body's root will move however you specify and the correct physical behavior will result for the rest of the artibulated body.
Do this by subclassing `ctKinematicEntity' and implementing all its
methods. (Minimally, you need to implement get_a()
.) These methods
tell the physics module how your object moves. You can use this to attach
hair, or a chain, or whatever you like to your game characters. After you
create your subclass, you attach your articulated body root to it with:
abroot->attach_to_entity(&your_kinematic_entity); |
Make sure you have grounded your root first with
abroot->make_grounded()
. Now if you want to detach that chain you
should just be able to call abroot->make_ungrounded()
.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |