示例#1
0
Board2::Board2() : Board()
{
  setSize(5.0, 20.0);
  
  //player 0 bas
  Matrix4d pt;
  pt.setTranslation(Point3d(0.0, -9.5, 0.0));
  mPlayerTransformations.push_back(pt);
  //player 1 haut
  pt = getRotationMatrix(180 * kDegreeToRadian,
    Vector3d(0.0, 0.0, 1.0));
  pt.setTranslation(Point3d(0.0, 9.5, 0.0));
  mPlayerTransformations.push_back(pt);

  //net 0 bas
  Matrix4d nt;
  nt.setTranslation(Point3d(0.0, -10.0, 0.0));
  mNetTransformations.push_back(nt);
  //net 1 haut
  nt = getRotationMatrix(180 * kDegreeToRadian,
    Vector3d(0.0, 0.0, 1.0));
  nt.setTranslation(Point3d(0.0, 10.0, 0.0));
  mNetTransformations.push_back(nt);
}
示例#2
0
Board4::Board4() : Board()
{
  setSize(10.0, 10.0);
  
  //player 0 bas
  Matrix4d pt;
  pt.setTranslation(Point3d(0.0, -4.5, 0.0));
  mPlayerTransformations.push_back(pt);
  //player 1 haut
  pt = getRotationMatrix(180 * kDegreeToRadian,
    Vector3d(0.0, 0.0, 1.0));
  pt.setTranslation(Point3d(0.0, 4.5, 0.0));
  mPlayerTransformations.push_back(pt);
  //player 2 gauche
  pt = getRotationMatrix(-90 * kDegreeToRadian,
    Vector3d(0.0, 0.0, 1.0));
  pt.setTranslation(Point3d(-4.5, 0.0, 0.0));
  mPlayerTransformations.push_back(pt);
  //player 3 droite
  pt = getRotationMatrix(90 * kDegreeToRadian,
    Vector3d(0.0, 0.0, 1.0));
  pt.setTranslation(Point3d(4.5, 0.0, 0.0));
  mPlayerTransformations.push_back(pt);

  //net 0 bas
  Matrix4d nt;
  nt.setTranslation(Point3d(0.0, -5.0, 0.0));
  mNetTransformations.push_back(nt);
  //net 1 haut
  nt = getRotationMatrix(180 * kDegreeToRadian,
    Vector3d(0.0, 0.0, 1.0));
  nt.setTranslation(Point3d(0.0, 5.0, 0.0));
  mNetTransformations.push_back(nt);
  //net 2 gauche
  nt = getRotationMatrix(-90 * kDegreeToRadian,
    Vector3d(0.0, 0.0, 1.0));
  nt.setTranslation(Point3d(-5.0, 0.0, 0.0));
  mNetTransformations.push_back(nt);
  //net 3 droite
  nt = getRotationMatrix(90 * kDegreeToRadian,
    Vector3d(0.0, 0.0, 1.0));
  nt.setTranslation(Point3d(5.0, 0.0, 0.0));
  mNetTransformations.push_back(nt);
}
示例#3
0
void GameWindow::addCollision(const Vector3d& p, const Vector3d& n)
{
  Collision* c = 0;
  for(unsigned int i = 0; i < cMaxCollisions; ++i)
    if(mCollisions[i]->isDone())
    { c = mCollisions[i]; break; }

  if(c)
  {
    Matrix4d m;
    m.setTranslation(toPoint(p));
    c->setTransformationToGlobal(m);
    double a = atan2(n.getY(), n.getX());
    c->setAngle(a);
    c->setNormal(n);
    c->animate();
  }
}
示例#4
0
void GameWindow::startGame() 
{
  //initialize collision object
  for(unsigned int i = 0; i < cMaxCollisions; ++i)
  {
    mCollisions[i] = new Collision();
    mCollisions[i]->setTexture(mGameAssets, QRect(264, 168, 72, 960));
  }
  
  //add balls
  mBalls.push_back(new Ball());
  //load textured object
  for(unsigned int i = 0; i < mBalls.size(); ++i)
    mBalls[i]->setTexture(mGameAssets, QRect(12, 12, 48, 48));
    
  //create the static board game
  mpBoard = new Board2();
  
  //init player position and orientation, define the local player.
  for(unsigned int i = 0; i < mPlayers.size(); ++i)
  {
    mPlayers[i]->setTransformationToGlobal(mpBoard->getPlayerTransformation(i));
    mNets[i]->setTransformationToGlobal(mpBoard->getNetTransformation(i));
  }
  
  mpLocalPlayer = mPlayers[0];
  mpLocalPlayer->setType(Player::tHuman);
  Camera c = getCamera();
  Matrix4d cm = mpLocalPlayer->getTransformationToGlobal();
  cm.setTranslation(Point3d(0.0));
  c.setTransformationToGlobal(cm);
  setCamera(c);
  
  //init chipMunk and physics
  cpInitChipmunk();
  mpPhysics = new Physics(this, *mpBoard, mBalls, mNets, mPlayers);
  resumeGame();
}
示例#5
0
  void spin_value_changed (int axis)
  {
    Shape *shape;
    TreeObject *object;

    if (m_inhibit_update)
      return;
    if (!m_view->get_selected_stl(object, shape))
      return;
    if (!object && !shape)
      return;

    double val = m_xyz[axis]->get_value();
    Matrix4d *mat;
    if (!shape)
        mat = &object->transform3D.transform;
    else
        mat = &shape->transform3D.transform;
    Vector3d trans = mat->getTranslation();
    trans.xyz[axis] = val;
    mat->setTranslation (trans);
    m_view->get_model()->CalcBoundingBoxAndCenter();
  }