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


C++ Human::init方法代码示例

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


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

示例1: throwError

void CartWheel3D::addHuman(const string& name, const std::string& characterFile, const std::string& controllerFile, const std::string& actionFile,
        const Math::Point3d& pos, double heading) {
    bool foundMatch = (_humans.find(name) != _humans.end());
    if (foundMatch) {
        ostringstream osError;
        osError << name << " already exists!";
        throwError(osError.str().c_str());
    }

    string sFile = _path + characterFile;
    _world->loadRBsFromFile(sFile.c_str(), _path.c_str(), name.c_str());
    Character* ch = new Character(_world->getAF(_world->getAFCount() - 1));
//    printf("AF: %s\n", _world->getAF(_world->getAFCount() - 1)->getName());
    ArticulatedRigidBody* body = ch->getArticulatedRigidBody(4);
    printf("Trying to get a Body\n");
    if (body==NULL)
        printf("Body not found\n");
    else {
        printf("Body found!!!\n");
////        body->addMeshObj("data/models/bipv3/head.obj", Vector3d(0,0,0), Vector3d(0.5,2,0.5));
//        body->replaceMeshObj("data/models/box3.obj");
//        body->getMesh(0)->scale(Vector3d(0.06,0.06,0.06));
//        body->getMesh(0)->computeNormals();
//        body->setColour(1,0,0,1);
//        body->setMass(-10);
    }

    CompositeController* con = new CompositeController(ch, _oracle, controllerFile.c_str());
    ActionCollectionPolicy* policy = new ActionCollectionPolicy(con);
    policy->loadActionsFromFile(actionFile.c_str());

    // Create a new human
    Human* human = new Human(name, ch, con, policy);
    // Initialize
    human->init();

    human->setHeading(heading);
    human->setPosition(pos);

    ch->setHeading(heading);

    _humans[name] = human;
    ch->getState(&_hStates[name]);
//    doBehavior("Standing", name, NULL);
    setController(name, 0);
    
    
//    printf("\n\nJoints:\n");
//    for(int i=0; i<ch->getJointCount(); i++) {
//        Point3d p1 = ch->getJoint(i)->getChildJointPosition();
//        Point3d p2 = ch->getJoint(i)->getParentJointPosition();
//        printf("Joint: %s, Parent-Joint: %s, Pos: (%f, %f, %f)\n", ch->getJoint(i)->getName(), ch->getJoint(i)->getParent()->getName(), p2.x, p2.y, p2.z);
//        printf("Joint: %s, Child-Joint: %s, Pos: (%f, %f, %f)\n\n", ch->getJoint(i)->getName(), ch->getJoint(i)->getChild()->getName(), p1.x, p1.y, p1.z);
//    }
    printf("\n\n\nArticulated Rigid Bodies:\n");
    for(int i=0; i<ch->getArticulatedRigidBodyCount(); i++) {
        Vector3d p = ch->getArticulatedRigidBody(i)->getCMPosition();
        printf("ARB: %s, Pos: (%f, %f, %f)\n", ch->getArticulatedRigidBody(i)->getName(), p.x, p.y, p.z);
    }
}
开发者ID:ninod2014,项目名称:ua-cartwheel,代码行数:60,代码来源:CartWheel3D.cpp


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