本文整理汇总了C++中WorldPtr类的典型用法代码示例。如果您正苦于以下问题:C++ WorldPtr类的具体用法?C++ WorldPtr怎么用?C++ WorldPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WorldPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
WorldPtr world = std::make_shared<World>();
world->addSkeleton(createGround());
world->addSkeleton(createWall());
MyWindow window(world, createBall(), createSoftBody(), createHybridBody(),
createRigidChain(), createRigidRing());
std::cout << "space bar: simulation on/off" << std::endl;
std::cout << "'1': toss a rigid ball" << std::endl;
std::cout << "'2': toss a soft body" << std::endl;
std::cout << "'3': toss a hybrid soft/rigid body" << std::endl;
std::cout << "'4': toss a rigid chain" << std::endl;
std::cout << "'5': toss a ring of rigid bodies" << std::endl;
std::cout << "\n'd': delete the oldest object" << std::endl;
std::cout << "'r': toggle randomness" << std::endl;
std::cout << "\nWarning: Let objects settle before tossing a new one, or the simulation could explode." << std::endl;
std::cout << " If the simulation freezes, you may need to force quit the application.\n" << std::endl;
glutInit(&argc, argv);
window.initWindow(640, 480, "Collisions");
glutMainLoop();
}
示例2: TEST
//==============================================================================
TEST(SKEL_PARSER, JointActuatorType)
{
WorldPtr world = SkelParser::readWorld(
DART_DATA_PATH"/skel/test/joint_actuator_type_test.skel");
EXPECT_TRUE(world != nullptr);
SkeletonPtr skel1 = world->getSkeleton("skeleton 1");
EXPECT_TRUE(skel1 != nullptr);
// Test for no actuator type attribute being specified
Joint* joint0 = skel1->getJoint("joint0");
EXPECT_EQ(joint0->getActuatorType(), Joint::DefaultActuatorType);
EXPECT_EQ(joint0->getActuatorType(), Joint::FORCE);
// Test for when actuator type attribute are specified
Joint* joint1 = skel1->getJoint("joint1");
EXPECT_EQ(joint1->getActuatorType(), Joint::FORCE);
// Test for only a dof name being changed
Joint* joint2 = skel1->getJoint("joint2");
EXPECT_EQ(joint2->getActuatorType(), Joint::PASSIVE);
joint2->setActuatorType(Joint::FORCE);
EXPECT_EQ(joint2->getActuatorType(), Joint::FORCE);
// Test for when actuator type attribute are specified
Joint* joint3 = skel1->getJoint("joint3");
EXPECT_EQ(joint3->getActuatorType(), Joint::ACCELERATION);
// Test for when actuator type attribute are specified
Joint* joint4 = skel1->getJoint("joint4");
EXPECT_EQ(joint4->getActuatorType(), Joint::VELOCITY);}
示例3: initRenderingContext
void AbstractGLDisplayHelper::initRenderingContext(WorldPtr world)
{
int height = world->getHeight();
int width = world->getWidth();
int depth = world->getDepth();
int pixelResolution = world->getPixelResolution();
_renderContext = std::make_shared<OpenGLRenderContext>(width, height, depth, pixelResolution);
}
示例4:
collision_detection::WorldDiff::WorldDiff(WorldDiff &other)
{
WorldPtr world = other.world_.lock();
if (world)
{
changes_ = other.changes_;
boost::weak_ptr<World>(world).swap(world_);
observer_handle_ = world->addObserver(boost::bind(&WorldDiff::notify, this, _1, _2));
}
}
示例5: loadBiped
// Load a biped model and enable joint limits and self-collision
SkeletonPtr loadBiped()
{
// Lesson 1
// Create the world with a skeleton
WorldPtr world = SkelParser::readWorld("dart://sample/skel/biped.skel");
assert(world != nullptr);
SkeletonPtr biped = world->getSkeleton("biped");
return biped;
}
示例6: modifyBipedWithSkateboard
// Load a skateboard model and connect it to the biped model via an Euler joint
// (Lesson 5 Answer)
void modifyBipedWithSkateboard(SkeletonPtr biped)
{
// Load the Skeleton from a file
WorldPtr world = SkelParser::readWorld("dart://sample/skel/skateboard.skel");
SkeletonPtr skateboard = world->getSkeleton(0);
EulerJoint::Properties properties = EulerJoint::Properties();
properties.mT_ChildBodyToJoint.translation() = Eigen::Vector3d(0, 0.1, 0);
skateboard->getRootBodyNode()->moveTo<EulerJoint>
(biped->getBodyNode("h_heel_left"), properties);
}
示例7: TEST
//==============================================================================
TEST(VskParser, EmptySkeleton)
{
WorldPtr world = World::create();
EXPECT_TRUE(world != nullptr);
SkeletonPtr skeleton
= VskParser::readSkeleton("dart://sample/vsk/test/empty.vsk");
EXPECT_TRUE(skeleton == nullptr);
world->addSkeleton(skeleton);
EXPECT_EQ(world->getNumSkeletons(), 0u);
world->step();
}
示例8: main
int main(int argc, char* argv[])
{
SkeletonPtr floor = createFloor();
// Lesson 1
SkeletonPtr biped = loadBiped();
// Lesson 2
setInitialPose(biped);
// Lesson 5
modifyBipedWithSkateboard(biped);
// Lesson 6
setVelocityAccuators(biped);
// Lesson 7
Eigen::VectorXd balancedPose = solveIK(biped);
biped->setPositions(balancedPose);
WorldPtr world = std::make_shared<World>();
world->setGravity(Eigen::Vector3d(0.0, -9.81, 0.0));
#if HAVE_BULLET_COLLISION
world->getConstraintSolver()->setCollisionDetector(
dart::collision::BulletCollisionDetector::create());
#endif
world->addSkeleton(floor);
world->addSkeleton(biped);
// Create a window for rendering the world and handling user input
MyWindow window(world);
// Print instructions
std::cout << "'.': forward push" << std::endl;
std::cout << "',': backward push" << std::endl;
std::cout << "'s': increase skateboard forward speed" << std::endl;
std::cout << "'a': increase skateboard backward speed" << std::endl;
std::cout << "space bar: simulation on/off" << std::endl;
std::cout << "'p': replay simulation" << std::endl;
std::cout << "'v': Turn contact force visualization on/off" << std::endl;
std::cout <<
"'[' and ']': replay one frame backward and forward" << std::endl;
// Initialize glut, initialize the window, and begin the glut event loop
glutInit(&argc, argv);
window.initWindow(640, 480, "Multi-Pendulum Tutorial");
glutMainLoop();
}
示例9: createWorld
static WorldPtr createWorld()
{
WorldPtr world = boost::make_shared<World>(500,500);
world->addObstacle( boost::make_shared<SquareObstacle>( 0, 50, 400, 50) );
world->addObstacle( boost::make_shared<SquareObstacle>( 0, 150, 200, 50) );
world->addObstacle( boost::make_shared<SquareObstacle>(300, 150, 200, 50) );
world->addObstacle( boost::make_shared<SquareObstacle>(100, 250, 400, 50) );
world->addObstacle( boost::make_shared<SquareObstacle>( 0, 350, 250, 50) );
world->addObstacle( boost::make_shared<SquareObstacle>(350, 350, 50, 50) );
world->addObstacle( boost::make_shared<SquareObstacle>(150, 450, 350, 50) );
return world;
}
示例10: loadBiped
// Load a biped model and enable joint limits and self-collision
// (Lesson 1 Answer)
SkeletonPtr loadBiped()
{
// Create the world with a skeleton
WorldPtr world = SkelParser::readWorld(DART_DATA_PATH"skel/biped.skel");
assert(world != nullptr);
SkeletonPtr biped = world->getSkeleton("biped");
// Set joint limits
for(size_t i = 0; i < biped->getNumJoints(); ++i)
biped->getJoint(i)->setPositionLimitEnforced(true);
// Enable self collision check but ignore adjacent bodies
biped->enableSelfCollision();
return biped;
}
示例11: getSkeletons
std::vector<SkeletonPtr> getSkeletons()
{
std::vector<std::string> fileList = getFileList();
std::vector<WorldPtr> worlds;
for(size_t i=0; i<fileList.size(); ++i)
worlds.push_back(utils::SkelParser::readWorld(fileList[i]));
std::vector<SkeletonPtr> skeletons;
for(size_t i=0; i<worlds.size(); ++i)
{
WorldPtr world = worlds[i];
for(size_t j=0; j<world->getNumSkeletons(); ++j)
skeletons.push_back(world->getSkeleton(j));
}
return skeletons;
}
示例12:
void GL2DDisplayHelper::paintSingleSolution(WorldPtr world, PartLocationListPtr parts)
{
for (tuple<PartOrientationPtr, Point>& partLocation : *parts)
{
PartOrientationPtr currentOrientation = std::get<0>(partLocation);
Point anchorPartPoint = std::get<1>(partLocation);
RGB_COLOR orientationColor = _colorManager->getColor(*currentOrientation);
float r = std::get<0>(orientationColor);
float g = std::get<1>(orientationColor);
float b = std::get<2>(orientationColor);
float a;
r /= 255.0;
g /= 255.0;
b /= 255.0;
a = 1.0f;
for (Point& relativePartCoordinate : *(currentOrientation->getPointList()))
{
Point point = anchorPartPoint + relativePartCoordinate;
// Paint a square for each unmasked pixel in the world
float v1x = point.getX();
float v1y = world->getHeight() - point.getY() - 1; // OpenGL Y axis is inverted
float v2x = v1x + SQUARE_SIZE;
float v2y = v1y;
float v3x = v1x;
float v3y = v1y + SQUARE_SIZE;
float v4x = v1x + SQUARE_SIZE;
float v4y = v1y + SQUARE_SIZE;
_renderContext->write2DTriangle(v1x, v1y, v2x, v2y, v3x, v3y, r, g, b, a);
_renderContext->write2DTriangle(v2x, v2y, v3x, v3y, v4x, v4y, r, g, b, a);
if (currentOrientation->isContainsPointAbovePoint(relativePartCoordinate))
_renderContext->writeLine(v1x, v1y, v2x, v2y);
else
_renderContext->writeBoldLine(v1x, v1y, v2x, v2y);
if (currentOrientation->isContainsPointRightOfPoint(relativePartCoordinate))
_renderContext->writeLine(v2x, v2y, v4x, v4y);
else
_renderContext->writeBoldLine(v2x, v2y, v4x, v4y);
if (currentOrientation->isContainsPointBelowPoint(relativePartCoordinate))
_renderContext->writeLine(v3x, v3y, v4x, v4y);
else
_renderContext->writeBoldLine(v3x, v3y, v4x, v4y);
if (currentOrientation->isContainsPointLeftPoint(relativePartCoordinate))
_renderContext->writeLine(v3x, v3y, v1x, v1y);
else
_renderContext->writeBoldLine(v3x, v3y, v1x, v1y);
}
}
}
示例13: SimulationWorld
SimulationWorld(WorldPtr world, const std::vector<Eigen::VectorXd>& trajectory)
: osgDart::WorldNode(world), mTrajectory(trajectory)
{
mHubo = world->getSkeleton("drchubo");
double height = mHubo->getPosition(5);
mHubo->setPositions(mTrajectory[0]);
mHubo->setPosition(5, height);
// index = 0;
}
示例14: HELIUM_ASSERT
/// Create a new World instance.
///
/// @param[in] pSceneDefinition The SceneDefinition from which to create the new World.
///
/// @return Newly created world instance.
Helium::World* WorldManager::CreateWorld( SceneDefinition* pSceneDefinition )
{
// Any scene that creates a world must define a world definition so that the world knows what components to init on itself
HELIUM_ASSERT(pSceneDefinition);
const WorldDefinition *pWorldDefinition = pSceneDefinition->GetWorldDefinition();
WorldPtr spWorld;
if (pWorldDefinition)
{
// Let the world definition provide the world
spWorld = pWorldDefinition->CreateWorld();
}
else
{
// Make a blank, default world.
// TODO: Consider having the concept of a "default" world definition. Generally, not loading a world from a definition
// is bad because pretty much any useful world should be initialized with world components
HELIUM_ASSERT( 0 );
spWorld = new World();
spWorld->Initialize();
}
HELIUM_ASSERT(spWorld.Get());
m_worlds.Push( spWorld );
if ( pSceneDefinition && spWorld )
{
Slice *pRootSlice = spWorld->GetRootSlice();
size_t entityDefinitionCount = pSceneDefinition->GetEntityDefinitionCount();
for ( size_t i = 0; i < entityDefinitionCount; ++i )
{
EntityDefinition *pEntityDefinition = pSceneDefinition->GetEntityDefinition( i );
HELIUM_ASSERT( pEntityDefinition );
Entity *pEntity = pRootSlice->CreateEntity(pEntityDefinition);
}
}
return spWorld;
}
示例15: clearChanges
void collision_detection::WorldDiff::reset(const WorldPtr& world)
{
clearChanges();
WorldPtr old_world = world_.lock();
if (old_world)
old_world->removeObserver(observer_handle_);
boost::weak_ptr<World>(world).swap(world_);
observer_handle_ = world->addObserver(boost::bind(&WorldDiff::notify, this, _1, _2));
}