本文整理汇总了C++中Body::addForce方法的典型用法代码示例。如果您正苦于以下问题:C++ Body::addForce方法的具体用法?C++ Body::addForce怎么用?C++ Body::addForce使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Body
的用法示例。
在下文中一共展示了Body::addForce方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyAntiSwayBarForces
//------------------------------------------------------------------------------------------------
void Vehicle::applyAntiSwayBarForces ( )
{
Real amt;
Body * wheelBody;
for( int i = 0; i < 4; i++)
{
SuspensionJoint * const wheelJoint = static_cast<SuspensionJoint*>( _wheels.at( i )->getBody()->getJoint(0) );
const Ogre::Vector3 anchor2 (wheelJoint->getAdditionalAnchor());
const Ogre::Vector3 anchor1 (wheelJoint->getAnchor());
const Ogre::Vector3 axis (wheelJoint->getAxis());
const Ogre::Real displacement = ( anchor1 - anchor2 ).dotProduct( axis );
if( displacement > 0 )
{
amt = displacement * _swayForce;
if( amt > _swayForceLimit )
amt = _swayForceLimit;
// force down
wheelBody = _wheels.at( i )->getBody();
wheelBody->addForce( -axis * amt );
// force up
wheelBody = _wheels.at( i^1 )->getBody();
wheelBody->addForce( axis * amt );
}
}
}
示例2: getBodies
void getBodies(Body &body, double error) {
double s = _box.getSize();
double d = (getCenterOfMass() - body.getPos()).getMagnitude();
double SbyD = s/d;
// cout << "S/D: " << SbyD << endl;
if (!isExternal()) {
if (SbyD < error) {
Body overallBody(_mass, 0, 0, getCenterOfMass().getX(), getCenterOfMass().getY());
body.addForce(body.calculateForceFromBody(overallBody));
return;
} else {
if (_NW != NULL)
_NW->getBodies(body, error);
if (_NE != NULL)
_NE->getBodies(body, error);
if (_SW != NULL)
_SW->getBodies(body, error);
if (_SE != NULL)
_SE->getBodies(body, error);
}
} else {
Body overallBody(_mass, 0, 0, getCenterOfMass().getX(), getCenterOfMass().getY());
body.addForce(body.calculateForceFromBody(overallBody));
// forceBodies.push_back(*_body);
}
}
示例3: current
vector<Body> calculateForcesOnBodies(vector<Body> &oldBodies, double error) {
vector<Body> newBodies;
for (int i = 0; i < oldBodies.size(); i++) {
Body current (oldBodies[i]);
Job* _force0 = new ForceCalculation(_root0, current, error);
Job* _force1 = new ForceCalculation(_root1, current, error);
Job* _force2 = new ForceCalculation(_root2, current, error);
Job* _force3 = new ForceCalculation(_root3, current, error);
thread0->setJob(_force0);
thread1->setJob(_force1);
thread2->setJob(_force2);
thread3->setJob(_force3);
thread0->WakeUpThread();
thread1->WakeUpThread();
thread2->WakeUpThread();
thread3->WakeUpThread();
while (!isIdle());
current.addForce(((ForceCalculation*)_force0)->getResult() +
((ForceCalculation*)_force1)->getResult() +
((ForceCalculation*)_force2)->getResult() +
((ForceCalculation*)_force3)->getResult());
newBodies.push_back(current);
delete _force0, _force1, _force2, _force3;
}
return newBodies;
}