本文整理汇总了C++中Motion::setMode方法的典型用法代码示例。如果您正苦于以下问题:C++ Motion::setMode方法的具体用法?C++ Motion::setMode怎么用?C++ Motion::setMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Motion
的用法示例。
在下文中一共展示了Motion::setMode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
TypeNode type("test_type");
Entity tlve("0", 0), ent("1", 1), other("2", 2);
ent.m_location.m_loc = &tlve;
ent.m_location.m_pos = Point3D(1, 1, 0);
ent.m_location.m_velocity = Vector3D(1,0,0);
ent.setType(&type);
// Set up another entity to test collisions with.
other.m_location.m_loc = &tlve;
other.m_location.m_pos = Point3D(10, 0, 0);
other.setType(&type);
tlve.m_contains = new LocatedEntitySet;
tlve.m_contains->insert(&ent);
tlve.m_contains->insert(&other);
tlve.setType(&type);
tlve.incRef();
tlve.incRef();
Motion * motion = new Motion(ent);
std::string example_mode("walking");
motion->setMode(example_mode);
assert(motion->mode() == example_mode);
motion->adjustPostion();
motion->genUpdateOperation();
motion->genMoveOperation();
// No collisions yet
motion->checkCollisions();
assert(!motion->collision());
// Set up our moving entity with a bbox so collisions can be checked for.
ent.m_location.m_bBox = BBox(Point3D(-1,-1,-1), Point3D(1,1,1));
// No collision yet, as other still has no big box
motion->checkCollisions();
assert(!motion->collision());
// Set up the other entity with a bbox so collisions can be checked for.
other.m_location.m_bBox = BBox(Point3D(-1,-1,-1), Point3D(5,1,1));
// No collision yet, as other is still too far away
motion->checkCollisions();
assert(!motion->collision());
// Move it closer
other.m_location.m_pos = Point3D(3, 0, 0);
// Now it can collide
motion->checkCollisions();
assert(motion->collision());
motion->resolveCollision();
// Put the velocity back, as it was affected by the collision
ent.m_location.m_velocity = Vector3D(1,0,0);
// Set up the collision again
motion->checkCollisions();
assert(motion->collision());
// But this time break the hierarchy to hit the error message
other.m_location.m_loc = &ent;
motion->resolveCollision();
// Repair the hierarchy, and restore the velocity
other.m_location.m_loc = &tlve;
ent.m_location.m_velocity = Vector3D(1,0,0);
// Set up the collision again
motion->checkCollisions();
assert(motion->collision());
// Re-align the velocity so some is preserved by the collision normal
ent.m_location.m_velocity = Vector3D(1,1,0);
motion->resolveCollision();
// Put the velocity back, as it was affected by the collision
ent.m_location.m_velocity = Vector3D(1,0,0);
// Add another entity inside other
Entity inner("3", 3);
inner.m_location.m_loc = &other;
inner.m_location.m_pos = Point3D(0,0,0);
other.m_contains = new LocatedEntitySet;
other.m_contains->insert(&inner);
// Make other non-simple so that collision checks go inside
other.m_location.setSimple(false);
motion->checkCollisions();
//.........这里部分代码省略.........