Beispiel #1
0
/**
 * This method is used for activating or deactivating
 * the Joint. If the Joint was inactive and should be
 * activated the fixed ODE-joint is removed and the
 * virtual attachJoint-method is called.
 * If the Joint was active and should be deactivated
 * the virtual detachJoint-method is called and then
 * a fixed ODE-joint is created and attached to the bodies.
 * @param isActive             0 .. not active
 *				   anything else .. active
 **/
void Joint::setActive(int isActive)
{
	dBodyID body1, body2;
	if (!active && isActive && joint)
	{
		dJointDestroy(joint);
		body1 = jointInteraction->getBodyWithID(entityID1);
		body2 = jointInteraction->getBodyWithID(entityID2);
		attachJoint(body1, body2);
	} // if
	else if (active && !isActive && joint)
	{
// first detach joint e.g. for saving axis angles
		detachJoint();
		dJointDestroy(joint);
		body1 = jointInteraction->getBodyWithID(entityID1);
		body2 = jointInteraction->getBodyWithID(entityID2);
		joint = dJointCreateFixed(world, 0);
		dJointAttach(joint, body1, body2);
		dJointSetFixed(joint);
	} // else if

	if (isActive)
		this->active = true;
	else
		this->active = false;
} // setActive
Beispiel #2
0
/**
 * This method is called if the Joint should be detached.
 * It first calls the virtual method detachJoint, so that
 * each type of Joint can store relevant information (e.g axis-angles)
 * before the joint is deleted.
 **/
void Joint::detach()
{
	detachJoint();
	if (joint)
	{
		dJointDestroy(joint);
		joint = NULL;
	} // if
	alreadyAttached = false;
} // detach
Beispiel #3
0
void CSkeleton::deleteJoint(Joint_handle hJoint, bool deleteChildren/* = true*/)
{
	detachJoint(hJoint);
	if(deleteChildren && children[hJoint].size() > 0)
	{
		Joint_handle_iterator jh_it, jh_end = children[hJoint].end();
		for(jh_it = children[hJoint].begin(); jh_it != jh_end; ++jh_it)
			deleteJoint(*jh_it, true);
	}
	else
	{
		joints.erase(joints.begin() + hJoint);
		globals.erase(globals.begin() + hJoint);
		children.erase(children.begin() + hJoint);
		parents.erase(parents.begin() + hJoint);
	}
}