本文整理汇总了C++中SimObj::addForce方法的典型用法代码示例。如果您正苦于以下问题:C++ SimObj::addForce方法的具体用法?C++ SimObj::addForce怎么用?C++ SimObj::addForce使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimObj
的用法示例。
在下文中一共展示了SimObj::addForce方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onInit
void MyController::onInit(InitEvent &evt) {
// handle of target and tool
SimObj *toolName = getObj("TShapeTool_7");
SimObj *target = getObj("box_7");
toolName->setMass(10.0); // mass of all the tools should be set uniformly
target->getPosition(initTargetPos); // initial target position
target->getRotation(initTargetRotation); // initial target rotation in quaternion
toolName->getPosition(initToolPos); // initial tool position
toolName->getRotation(initToolRotation); // initial tool rotation in quaternion
isTargetAtRest = true; // target and tool both are at rest initially.
isToolAtRest = true;
insideTimer = true;
f_x = 0 ;
f_z = 0 ;
int xForceVariance = 4000;
int zForceVariance = 4000;
flag = true;
Colli = false;
counterOfCollision = 0;
counterOfAction = 0;
// Reset the forces applied
double r;
r = ((double) rand() / (RAND_MAX)) ;
f_x = r * int(xForceVariance);
f_z = r * int(zForceVariance);
forceOnTool_z = 8000 + f_z;
forceOnTool_x = 0;
forceOnTool.set(forceOnTool_x, 0 , forceOnTool_z);
toolName->addForce(forceOnTool.x(), forceOnTool.y(), forceOnTool.z());
toolName->getVelocity(appliedToolVel);
myfile.flush(); // I have uncommented the file, because I want to overwrite the file.
}