本文整理汇总了C++中CTime::getRefTime方法的典型用法代码示例。如果您正苦于以下问题:C++ CTime::getRefTime方法的具体用法?C++ CTime::getRefTime怎么用?C++ CTime::getRefTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CTime
的用法示例。
在下文中一共展示了CTime::getRefTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleEvent
void IHPDriver::handleEvent(core::objectmodel::Event *event)
{
//std::cout<<"IHPDriver::handleEvent() called:"<<std::endl;//////////////////////////////////////////////////////
static double time_prev;
if (firstDevice && dynamic_cast<sofa::simulation::AnimateEndEvent *> (event))
{
// force the simulation to be "real-time"
CTime *timer;
timer = new CTime();
double time = 0.001*timer->getRefTime()* PaceMaker::time_scale; // in sec
// if the computation time is shorter than the Dt set in the simulation... it waits !
if ((time- time_prev) < getContext()->getDt() )
{
double wait_time = getContext()->getDt() - time + time_prev;
timer->sleep(wait_time);
}
time_prev=time;
}
if (dynamic_cast<sofa::simulation::AnimateBeginEvent *>(event))
{
//turnOn xitactVisu
if(!visuActif && xitactVisu.getValue() && initVisu)
{
simulation::Node *parent = dynamic_cast<simulation::Node *>(this->getContext());
parent->addChild(nodeXitactVisual);
nodeXitactVisual->updateContext();
visuActif = true;
}
//turnOff xitactVisu
else if(initVisu && visuActif && !xitactVisu.getValue())
{
simulation::Node *parent = dynamic_cast<simulation::Node *>(this->getContext());
parent->removeChild(nodeXitactVisual);
nodeXitactVisual->updateContext();
visuActif=false;
}
// calcul des angles à partir de la direction proposée par l'interface...
// cos(ThetaX) = cx sin(ThetaX) = sx cos(ThetaZ) = cz sin(ThetaZ) = sz .
// au repos (si cx=1 et cz=1) on a Axe y
// on commence par tourner autour de x puis autour de z
// [cz -sz 0] [1 0 0 ] [0] [ -sz*cx]
// [sz cz 0]*[0 cx -sx]*[1] = [ cx*cz ]
// [0 0 1] [0 sx cx] [0] [ sx ]
xiTrocarAcquire();
XiToolState state;
xiTrocarQueryStates();
xiTrocarGetState(indexTool.getValue(), &state);
// saving informations in class structure.
data.simuState = state;
Vector3 dir;
dir[0] = -(double)state.trocarDir[0];
dir[1] = (double)state.trocarDir[2];
dir[2] = -(double)state.trocarDir[1];
double pi = 3.1415926535;
double thetaY;
double thetaX;
thetaY = (atan2(dir[0],-sqrt(1-dir[0]*dir[0])));
thetaX = (pi-acos(dir[2]*sqrt(1-dir[0]*dir[0])/(dir[0]*dir[0]-1)));
//look if thetaX and thetaY are NaN
if(!(thetaX == thetaX))
{
cout<<"ratrapage X"<<endl;
thetaX=pi;
}
if(!(thetaY == thetaY))
{
cout<<"ratrapage Y"<<endl;
thetaY=pi;
}
if(dir[1]>=0)
thetaX*=-1;
while(thetaY<=0)
thetaY+=2*pi;
while(thetaX<=0)
thetaX+=2*pi;
while(thetaY>2*pi)
thetaY-=2*pi;
while(thetaX>2*pi)
thetaX-=2*pi;
if (showToolStates.getValue()) // print tool state
//.........这里部分代码省略.........