Ejemplo n.º 1
0
void TopologyDialog::test()
{

    info->setPos(91.122236, 29.642912);
    info->setPos(102.742145, 24.998378);
    info->setPos(113.328695, 23.131285);
    info->setPos(108.979783, 34.257154);

    addToGraph("10.0.0.2", "10.0.0.4");
    addToGraph("10.0.0.3", "10.0.0.4");
    addToGraph("10.0.0.4", "10.0.0.5");

    refreshMap();
}
Ejemplo n.º 2
0
Character::Character(Ogre::String _name, Ogre::SceneManager* _sceneMgr, Ogre::Real _height, std::string _objName) : GameObject(_name)
{
  height = _height;
  speed = 0.02f;
  mesh = _objName;
  obj = _objName;
  finished = false;
  deathTimer = 0;
  givenExp = false;
  level = 1;
  experience = 0;
  healthChange = 0;
  gold = 0;
  changes = 255;

  if (_sceneMgr)
    addToGraph(_sceneMgr);

  // set up Bullet properties
  btTransform* transform = new btTransform(btMatrix3x3::getIdentity());
  MotionState *motionState = new MotionState(node, *transform);

  btCollisionShape *shape = new btBoxShape(btVector3(height/2, height/2, height/2));
  //btCollisionShape *shape = GenerateShape(obj, 1.f);

  btScalar mass(1.f);
  btVector3 localInertia(0,0,0);
  btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, motionState, shape, localInertia);
  body = new btRigidBody(rbInfo);
  body->setLinearFactor(btVector3(1.f,0.f,1.f));
  body->forceActivationState(DISABLE_DEACTIVATION);
  body->setRestitution(1.f);
  body->setFriction(0.f);
  body->setUserPointer((void *)this);
}
Ejemplo n.º 3
0
BoxChunk::BoxChunk(Ogre::SceneManager* _sceneMgr, Character* _character) : GameObject(nextName)
{
  height = _character->getHeight()*0.2f;
  speed = _character->getHeight()*0.03f; // ((float)(rand() % 5))/10.f; 
  direction = Ogre::Vector3(rand() % 3 - 1, 2.f, rand() % 3 -1);
  direction.normalise();

  if (_sceneMgr) {
    sceneMgr = _sceneMgr;
    addToGraph(sceneMgr);
    //node->translate(Ogre::Vector3(0, height/2.f, 0));
  }

  // set up Bullet properties
  btTransform* transform = new btTransform(btMatrix3x3::getIdentity());
  MotionState *motionState = new MotionState(node, *transform);

  btCollisionShape *shape = new btBoxShape(btVector3(height/2, height/2, height/2));

  btScalar mass(1.f);
  btVector3 localInertia(0,0,0);
  btRigidBody::btRigidBodyConstructionInfo rbInfo(mass, motionState, shape, localInertia);
  body = new btRigidBody(rbInfo);
  body->setLinearFactor(btVector3(1.f,0.f,1.f));
  body->forceActivationState(DISABLE_DEACTIVATION);
  body->setRestitution(1.f);
  body->setFriction(0.f);
  body->setUserPointer((void *)this);
  body->translate(btVector3(0, height/2.f, 0));

  translate(_character->getPosition());
  std::stringstream ss;
  ss << "bc" << nextNum++;
  nextName = ss.str();
}
Ejemplo n.º 4
0
// FREE OPERATORS
void NxNSceneGraph::preTick()
{
    updateGraph();

    for( int i=0; i<d_addColliders.getLastIndex(); i++ )
    {
      addToGraph( d_addColliders[i] );
    }

    d_addColliders = sgdc::DynamicArray<ICollider*>();
}
Ejemplo n.º 5
0
void TopologyDialog::getEdgeInfo()
{
    qDebug() << "get edge info";
    QByteArray datagram;
    QHostAddress address;

    QDataStream in(&datagram, QIODevice::ReadOnly);
    char msgRecv[256];
    char dstIp[256];
    char nextHop[256];
    int nread = 0;
    int count;

    do {
        datagram.resize(udpSocket->pendingDatagramSize());
        udpSocket->readDatagram(datagram.data(), datagram.size(), &address);

    } while(udpSocket->hasPendingDatagrams());
    nread = in.readRawData(msgRecv, 256);
    if (nread > 0) {
        msgRecv[nread ] = '\0';
        qDebug() << QString(msgRecv) << address.toString();
        count = getEdgeCount(msgRecv);
        for (int i = 0; i < count; i++) {
            sscanf(msgRecv + i*16, "%8s%8s", dstIp, nextHop);
            convertIp(dstIp);
            convertIp(nextHop);
            qDebug() << "dstIp:" << dstIp << "nextHop:" << nextHop;
            if (QString(nextHop) == "0.0.0.0") {
                addToGraph(address.toString(), dstIp);
            } else {
                addToGraph(address.toString(), nextHop);
            }

        }
    }
}
Ejemplo n.º 6
0
void map(void)
{
    int i, j, c;
    uint16_t f1, f2;
    bool cycle;
    uint8_t *keys;

    c = 0;

    do {
        initGraph();
        cycle = false;

        // Randomly generate T1 and T2
        for (i = 0; i < SetSize * EntryLen; i++) {
            T1base[i] = rand() % NumVert;
            T2base[i] = rand() % NumVert;
        }

        for (i = 0; i < NumEntry; i++) {
            f1 = 0;
            f2 = 0;
            getKey(i, &keys);
            for (j = 0; j < EntryLen; j++) {
                T1 = T1base + j * SetSize;
                T2 = T2base + j * SetSize;
                f1 += T1[keys[j] - SetMin];
                f2 += T2[keys[j] - SetMin];
            }
            f1 %= (uint16_t)NumVert;
            f2 %= (uint16_t)NumVert;
            if (f1 == f2) { // A self loop. Reject!
                printf("Self loop on vertex %d!\n", f1);
                cycle = true;
                break;
            }
            addToGraph(numEdges++, f1, f2);
        }

        if (cycle || (cycle = isCycle())) // OK - is there a cycle?
            printf("Iteration %d\n", ++c);
        else
            break;

    } while (/* there is a cycle */ 1);
}
Ejemplo n.º 7
0
void NxNSceneGraph::updateGraph()
{
    for( int i=0; i<d_divisions; i++ )
    {
      for( int j=0; j<d_divisions; j++ )
      {
        for( int k=0; k<d_colliders[i][j].getLastIndex(); k++ )
        {
          d_colliders[i][j].pop();
        }
      }
    }

    for( int i=0; i<d_updateColliders.getLastIndex(); i++ )
    {
      addToGraph( d_updateColliders[i] );
    }
}