本文整理汇总了C++中RootEntity::modifyVelocity方法的典型用法代码示例。如果您正苦于以下问题:C++ RootEntity::modifyVelocity方法的具体用法?C++ RootEntity::modifyVelocity怎么用?C++ RootEntity::modifyVelocity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RootEntity
的用法示例。
在下文中一共展示了RootEntity::modifyVelocity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test
void test()
{
const double x1 = 3.5;
const double y1 = -4.6;
const double z1 = 2.0;
const double x2 = 42.0;
const double y2 = 7.0;
std::vector<RootEntity> ent_vec(10);
for(int i=0; i<10; i++) {
DEBUG_PRINT(std::cout<<std::endl<<"round:"<<i<<std::endl);
RootEntity human;
//check for empty default:
DEBUG_PRINT(std::cout<<"empty ok?"<<std::endl);
Atlas::Message::ListType empty = human->getVelocityAsList();
if(i==0) check_float_list3(empty, 0.0, 0.0, 0.0);
else check_float_list3(empty, 0.0, y2, 0.0);
//check after setting it
DEBUG_PRINT(std::cout<<"setting ok?"<<std::endl);
Atlas::Message::ListType velocity;
velocity.push_back(x1);
velocity.push_back(y1);
velocity.push_back(z1);
check_float_list3(velocity, x1, y1, z1);
human->setVelocityAsList(velocity);
Atlas::Message::ListType foo = human->getVelocityAsList();
check_float_list3(foo, x1, y1, z1);
DEBUG_PRINT(std::cout<<"changing it?"<<std::endl);
std::vector<double> &foo2 = human->modifyVelocity();
*foo2.begin() = x2;
check_float_list3(human->getVelocityAsList(), x2, y1, z1);
DEBUG_PRINT(std::cout<<"check change result?"<<std::endl);
foo = human->getVelocityAsList();
check_float_list3(foo, x2, y1, z1);
DEBUG_PRINT(std::cout<<"std::vector of entities?"<<std::endl);
const Atlas::Message::ListType &ent_velocity = ent_vec[i]->getVelocityAsList();
if(i==0) check_float_list3(ent_velocity, 0.0, 0.0, 0.0);
else check_float_list3(ent_velocity, 0.0, y2, 0.0);
DEBUG_PRINT(std::cout<<"base?"<<std::endl);
RootEntity base_entity = Atlas::Objects::Entity::RootEntityData::allocator.getDefaultObjectInstance();
std::vector<double> &base = base_entity->modifyVelocity();
base[1] = y2;
check_float_list3(base_entity->getVelocityAsList(), 0.0, y2, 0.0);
RootOperation move_op;
std::vector<Root> move_args(1);
move_args[0] = human;
move_op->setArgs(move_args);
RootOperation sight_op;
//sight_op->setFrom(humanent.asObjectPtr());
std::vector<Root> sight_args(1);
sight_args[0] = move_op;
sight_op->setArgs(sight_args);
//test
DEBUG_PRINT(std::cout<<"get move_op?"<<std::endl);
const std::vector<Root>& test_args = sight_op->getArgs();
assert(test_args.size() == 1);
RootOperation test_op =
(RootOperation&)test_args[0];
DEBUG_PRINT(std::cout<<"get human_ent?"<<std::endl);
const std::vector<Root>& test_args2 = test_op->getArgs();
assert(test_args2.size() == 1);
RootEntity test_ent =
(RootEntity&)test_args2[0];
Atlas::Message::ListType foo3 = test_ent->getVelocityAsList();
check_float_list3(foo3, x2, y1, z1);
std::vector<double> coords(3, 0.0);
human->setPos(coords);
human->setVelocity(coords);
human->modifyVelocity()[0] = 1.0;
check_float_list3(human->getPosAsList(), 0.0, 0.0, 0.0);
check_float_list3(human->getVelocityAsList(), 1.0, 0.0, 0.0);
}
}