Esempio n. 1
0
void
ScenarioHelper::createTopology(std::initializer_list<std::initializer_list<std::string>/*node clique*/> topology)
{
  if (m_isTopologyInitialized) {
    throw std::logic_error("Topology cannot be created twice");
  }

  PointToPointHelper p2p;
  p2p.SetQueue ("ns3::ndn::NdnDropTailQueue");

  for (auto&& clique : topology) {
    for (auto i = clique.begin(); i != clique.end(); ++i) {
      auto node1 = getOrCreateNode(*i);
      for (auto j = i + 1; j != clique.end(); ++j) {
        auto node2 = getOrCreateNode(*j);

        auto link = p2p.Install(node1, node2);
        links[*i][*j] = link.Get(0);
        links[*j][*i] = link.Get(1);
      }
    }
  }

  ndnHelper.InstallAll();
  m_isTopologyInitialized = true;
}
Esempio n. 2
0
ATOM_OctreeNode *ATOM_OctreeNodeChunk::getOrCreateNodeChain (ATOM_OctreeNode::NodeIndex index) 
{
  ATOM_OctreeNode *node = getOrCreateNode (index);
  if (getPrev ())
  {
    getPrev()->getOrCreateNodeChain (getParentIndex (index));
  }
  return node;
}
  RandomListNode *copyRandomList(RandomListNode *head) {
    RandomListNode *dup = NULL, *tail = NULL;
    RandomListNode *p = head;
    while (p != NULL) {
      RandomListNode *node = getOrCreateNode(p);
      RandomListNode *random = getOrCreateNode(p->random);
      node->random = random;

      if (dup == NULL) {
        dup = tail = node;
      } else {
        tail->next = node;
        tail = tail->next;
      }
      p = p->next;
    }

    return dup;
  }
void OssiaImpulse::setNode(QString node)
{
    if(!publisher_singleton)
        return;

    if (m_node == node)
        return;

    m_node = node;

    if(m_ossia_node)
    {
        auto par = m_ossia_node->getParent();
        auto& cld = par->children();
        auto it = std::find(cld.begin(), cld.end(), m_ossia_node);
        if(it != cld.end())
            par->erase(it);
    }

    m_ossia_node = getOrCreateNode(
                publisher_singleton->_localDevice,
                node.split('/'));

    if(auto addr = m_ossia_node->getAddress())
    {
        m_address = addr;
    }
    else
    {
        m_address = m_ossia_node->createAddress(OSSIA::Value::Type::IMPULSE);
        m_address->addCallback([=] (const OSSIA::Value* val) {
            emit impulse();
        });
    }

    emit nodeChanged(node);
}
Esempio n. 5
0
int main_phys_viewer( int argc, char** argv )
{
    osg::ArgumentParser arguments( &argc, argv );
    const bool debugDisplay( arguments.find( "--debug" ) > 0 );

    btDiscreteDynamicsWorld* bw = initPhysics();
    osg::Group* root = new osg::Group;

    osg::Group* launchHandlerAttachPoint = new osg::Group;
    root->addChild( launchHandlerAttachPoint );
    
    std::string         model_name = "eisk";
    
    auto obj = avCore::createObject(model_name, 10);
    osg::ref_ptr< osg::Node > rootModel( obj->getOrCreateNode() );
    if( !rootModel.valid() )
    {
        osg::notify( osg::FATAL ) << "mesh: Can't create mesh." << std::endl;
        return( 1 );
    }
    
    btCompoundShape*        cs_;
    bool loaded = phys::loadBulletFile(cfg().path.data + "/areas/" + model_name + "/" + model_name + ".bullet",  cs_);
    if(loaded)
    {
        const btTransform ct0 = cs_->getChildTransform(0);
        // cs.offset_ = from_bullet_vector3(ct0.getOrigin()); 
        cs_->setLocalScaling( btVector3(0.013,0.013,0.013));
        addRigidBody( bw, cs_ );
    }

    root->addChild( rootModel.get() );
    
    DynamicCharacterController* m_character = new DynamicCharacterController ();
    m_character->setup();
    bw->addAction(m_character);

#if 0
    // Add ground
    const osg::Vec4 plane( 0., 0., 1., -100. );
    root->addChild( osgbDynamics::generateGroundPlane( plane, bw ) );
#endif


    osgbCollision::GLDebugDrawer* dbgDraw( NULL );
    if( /*debugDisplay*/ true)
    {
        dbgDraw = new osgbCollision::GLDebugDrawer();
        dbgDraw->setDebugMode( ~btIDebugDraw::DBG_DrawText );
        bw->setDebugDrawer( dbgDraw );
        root->addChild( dbgDraw->getSceneGraph() );
    }

    osgViewer::Viewer viewer( arguments );
	viewer.apply(new osgViewer::SingleScreen(1));
    viewer.addEventHandler( new osgViewer::StatsHandler() );
    //viewer.setUpViewInWindow( 30, 30, 768, 480 );
    viewer.setSceneData( root );

    osgGA::TrackballManipulator* tb = new osgGA::TrackballManipulator;
    // tb->setHomePosition( osg::Vec3( 0., -16., 6. ), osg::Vec3( 0., 0., 5. ), osg::Vec3( 0., 0., 1. ) ); 
    viewer.setCameraManipulator( tb );
    viewer.getCamera()->setClearColor( osg::Vec4( .5, .5, .5, 1. ) );
    viewer.realize();


    double prevSimTime = 0.;
    while( !viewer.done() )
    {
        if( dbgDraw != NULL )
            dbgDraw->BeginDraw();

        const double currSimTime = viewer.getFrameStamp()->getSimulationTime();
        bw->stepSimulation( currSimTime - prevSimTime/*0.0*//*0.1*/ );
        prevSimTime = currSimTime;

        if( dbgDraw != NULL )
        {
            bw->debugDrawWorld();
            dbgDraw->EndDraw();
        }

        // worldInfo.m_sparsesdf.GarbageCollect();

        viewer.frame();
    }

    return( 0 );
}