当前位置: 首页>>代码示例>>C++>>正文


C++ Body::addForce方法代码示例

本文整理汇总了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 );
		}
	}
}
开发者ID:brendan0powers,项目名称:Random-Projects,代码行数:29,代码来源:OgreOdeVehicle.cpp

示例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);
		}
	}
开发者ID:zeeshanabid94,项目名称:Barnes-Hut-N-Body-Simulation,代码行数:28,代码来源:threadedquadtree.cpp

示例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;
	}
开发者ID:zeeshanabid94,项目名称:Barnes-Hut-N-Body-Simulation,代码行数:27,代码来源:threadedquadtree.cpp


注:本文中的Body::addForce方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。