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


C++ Time::AsInt方法代码示例

本文整理汇总了C++中Time::AsInt方法的典型用法代码示例。如果您正苦于以下问题:C++ Time::AsInt方法的具体用法?C++ Time::AsInt怎么用?C++ Time::AsInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Time的用法示例。


在下文中一共展示了Time::AsInt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Handle

void Airplane::Handle(ProcessEventArg arg) {    
    Time t = timer.GetElapsedTimeAndReset();
    float dt = t.AsInt()/1000.0;

    Matrix<3,3,float> rotM = box->GetRotationMatrix();

    box->AddForce(rotM *  Vector<3,float>(0,0,1*dt*trottle));

    for (vector<Point*>::iterator itr = points.begin();
         itr != points.end();
         itr++) {
        Point* p = *itr;
        Vector<3,float> speedVec = box->GetSpeed();

        float speed = speedVec.GetLength();
        Vector<3,float> dragVec;


        if (speed > 0.1) 
            dragVec = -speedVec/speed;


        Vector<3,float> normal = Vector<3,float>(0,1,0);
        Vector<3,float> liftVector = (dragVec % normal) % dragVec;

        if (liftVector.IsZero())
            return;

        float liftLen = liftVector.GetLength();
        liftVector.Normalize();

        float dotP = dragVec * normal;
        dotP = fmin(fmax(dotP, -1),1);

        float attackAngel = asin(dotP);
        float rho = 1.2f;    
        float area = 5*5;
        float force = 0.5f * rho * speed * speed * area;
    
        Vector<3,float> forceVec = 
            (liftVector * LiftCoefficient(attackAngel,0) +
             dragVec * DragCoefficient(attackAngel,0)) * force;

        //logger.info << forceVec << logger.end;


        box->AddForce(rotM * forceVec, p->forceIdx );

    }
    


    //box->AddForce(Vector<3,float>(0,lift,0));


    return;

    // Matrix<3,3,float> rotM = box->GetRotationMatrix();

    // //logger.info << speed << logger.end;
    // //speed = rotM*speed;

    // Quaternion<float> q = Quaternion<float>(rotM);

    // Vector<3,float> angles = q.GetEulerAngles();

    // float pitch = -angles[0];

    // //logger.info << "pitch " << pitch << logger.end;

    // float cl = 1;
    
    // float lift = speedVec[2]*cl;

    

    //logger.info << "cl " << cl << logger.end;
    //logger.info << "lift " << lift << logger.end;

    
    // Vector<3,float> old_pos;
    // Quaternion<float> old_rot;    
    // node->GetAccumulatedTransformations(&old_pos, &old_rot);
    
    // node->Move(0,0,0.01*dt*trottle);
            
    // // calc lift
    
    // Vector<3,float> angles = old_rot.GetEulerAngles();
    
    // float pitch = -angles[0];
    
    // float cl = pitch*0.08+0.5;
    // float lift = speed.GetLengthSquared()*cl*.5*2000.0;
    
    // node->Move(0,(lift-9.82)*dt,0);
    // //logger.info << lift << logger.end;
    
    // logger.info << "speed: " << speed.GetLengthSquared()  <<
    // " cl: " << cl << 
//.........这里部分代码省略.........
开发者ID:OpenEngineDK,项目名称:projects-FirstFlight,代码行数:101,代码来源:Airplane.cpp


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