Пример #1
0
Player::Player(std::string _name, osg::Vec3f _pos, float _colRad, int _hp, osg::ref_ptr<osg::MatrixTransform> _scene, int _bridgeModel)
{
	initTransform();
	rigidBodyRadius = _colRad;
	pos = _pos;
	setName(_name);
	setHP(_hp);
	setMaxHP(_hp);

	_scene->addChild(playerTransform);
	playerTransform->postMult(osg::Matrix::translate(pos));


	healthbarTransform->postMult(osg::Matrix::rotate(-PI / 8, 1.0f, 0.0f, 0.0f));

	bridgeTransform->postMult(osg::Matrix::rotate(PI + PI / 4.0, 1.0, 0.0, 0.0));
	//bridgeTransform->postMult(osg::Matrix::scale(0.1f, 0.1f, 0.1f));

	if (_bridgeModel == 1) {
		bridge = GameObject((std::string)("Kommandobryggan"), osg::Vec3f(0, 0, 0), 0, 100000, (std::string)("models/kurvbrygga_lasselagom.ive"), bridgeTransform, 100000);
		bridgeTransform->postMult(osg::Matrix::translate(0.0f, 3.5f, 0.0f));
	}
	if (_bridgeModel == 2) {
		bridge = GameObject((std::string)("Kommandobryggan"), osg::Vec3f(0, 0, 0), 0, 100000, (std::string)("models/kurvbrygga_lasselagom.ive"), bridgeTransform, 100000);
		bridgeTransform->postMult(osg::Matrix::translate(0.0f, 2.5f, 0.0f));
	}
	if (_bridgeModel == 3) {
		bridge = GameObject((std::string)("Kommandobryggan"), osg::Vec3f(0, 0, 0), 0, 100000, (std::string)("models/kurvbrygga_lassesmal.ive"), bridgeTransform, 100000);
		bridgeTransform->postMult(osg::Matrix::translate(0.0f, 3.5f, 0.0f));
	}
	if (_bridgeModel == 4) {
		bridge = GameObject((std::string)("Kommandobryggan"), osg::Vec3f(0, 0, 0), 0, 100000, (std::string)("models/kurvbrygga_lassesmal.ive"), bridgeTransform, 100000);
		bridgeTransform->postMult(osg::Matrix::translate(0.0f, 2.5f, 0.0f));
	}
}
Пример #2
0
static int transformops_data(bContext *C, wmOperator *op, const wmEvent *event)
{
	int retval = 1;
	if (op->customdata == NULL) {
		TransInfo *t = MEM_callocN(sizeof(TransInfo), "TransInfo data2");
		TransformModeItem *tmode;
		int mode = -1;

		for (tmode = transform_modes; tmode->idname; tmode++) {
			if (op->type->idname == tmode->idname) {
				mode = tmode->mode;
				break;
			}
		}

		if (mode == -1) {
			mode = RNA_enum_get(op->ptr, "mode");
		}

		retval = initTransform(C, t, op, event, mode);

		/* store data */
		if (retval) {
			G.moving = special_transform_moving(t);
			op->customdata = t;
		}
		else {
			MEM_freeN(t);
		}
	}

	return retval; /* return 0 on error */
}
Пример #3
0
GLBackend::GLBackend() :
    _input(),
    _transform(),
    _pipeline(),
    _output()
{
    initTransform();
}
Пример #4
0
// virtual
void SkeletonRagdoll::initPoints() {
    clearConstraintsAndPoints();
    _muscleConstraints.clear();

    initTransform();
    // one point for each joint
    int numStates = _model->getJointStates().size();
    _points.fill(VerletPoint(), numStates);
    slamPointPositions();
}
GameObject::GameObject(std::string _name, osg::Vec3f _pos, float _colRad, int _hp, std::string _model, osg::ref_ptr<osg::MatrixTransform> _scene, int _id)
{
    initTransform();
    setVel(0.0);
    setDir(osg::Vec3f(0.0f, 0.0f, 1.0f));
    setOrientation(osg::Quat(0.0f, 0.0f, 0.0f, 1.0f));
    rigidBodyRadius = _colRad;
    translate(_pos);
    setName(_name);
    setHP(_hp);
    setDescr((std::string)("hej"));
    _scene->addChild(getTrans());
    setID(_id);
    setModel(_model);
}
Пример #6
0
    void CPDNRigid<T, D>::initialization()
    {

        _paras._W = TMatrix::Zero(_M, D);

        T sigma_sum = _M*(_data.transpose()*_data).trace() + 
            _N*(_model.transpose()*_model).trace() - 
            2*(_data.colwise().sum())*(_model.colwise().sum()).transpose();
        _paras._sigma2 = sigma_sum / (D*_N*_M);

        initTransform();
        constructG();
        
        if (_lr)
            lr_approximate<T, D>(_G, _Q, _S, _K, _lr_maxitr);
    }
Пример #7
0
    void CPDRigid<T, D>::initialization()
    {
        // determine data number
        _M = _model.rows();
        _N = _data.rows();

        // initialization
        _paras._R = TMatrix::Identity(D, D);
        _paras._t = TVector::Zero(D, 1);
        _paras._s = 1;

        T sigma_sum = _M*(_data.transpose()*_data).trace() + 
            _N*(_model.transpose()*_model).trace() - 
            2*(_data.colwise().sum())*(_model.colwise().sum()).transpose();
        _paras._sigma2 = sigma_sum / (D*_N*_M);

        initTransform();
    }
EnemyShip::EnemyShip(std::string _name, osg::Vec3f _pos, float _colRad, std::string _model, osg::ref_ptr<osg::MatrixTransform> _scene, int _hp, int _id)
{
	initTransform();
	setVel(0.0);
	setDir(osg::Vec3f(0.0f, 0.0f, 1.0f));	//Not used
	setOrientation(osg::Quat(0.0f, 0.0f, 1.0f, 0.0f));
	setColRad(_colRad);
	setHP(_hp);
	translate(_pos);
	setName(_name);
	setDescr((std::string)("hej"));
	_scene->addChild(getTrans());
	setID(_id);
	setModel(_model);

	attackCooldown = 10;
	homingMissileAttackCooldown = 40;
}
Пример #9
0
void ParticleCreatorLatticeBCC::createParticles()
{    
  //RandomNumberGenerator m_rng;
  point_t box_size, spacing, offset;
  //    cuboid_t box;
  // offset due to wall particles
  //    point_t offset = ((Boundary*) m_parent) -> offset();
  double density;
  //    gsl_rng *rng;

//   size_t seed;

  /* We need the manager to check which group a particle has. */
  ManagerCell *manager = M_PHASE->manager();

  box_size = M_BOUNDARY->boundingBox().size();
  MSG_DEBUG("ParticleCreatorLatticeBCC::createParticles", "box_size=" << box_size);
  
  if (m_nlattice_points[0] == -1 &&
      m_nlattice_points[1] == -1 &&
      m_nlattice_points[2] == -1) 
  { 
    for (int i = 0; i < SPACE_DIMS; i++) {
      int n = (int) (box_size[i] / m_distance + 0.5);
      if (n < 1)
        n = 1;
      m_nlattice_points[i] = n;
    }
  }

  offset = M_BOUNDARY->boundingBox().corner1;

  initTransform();

//   if (m_randomize) {
//     seed = 2*getpid() + 1;
//   } else {
//     seed = 1;
//     MSG_INFO("ParticleCreatorLatticeBCC::randomizeVels", "randomize = no --> Numbers won't be random.");
//   }

  //    rng = gsl_rng_alloc(gsl_rng_default);

  //    gsl_rng_set(rng, seed);

  /*    MSG_DEBUG("ParticleCreatorLatticeBCC::createParticles", "Box size for particles: (" <<
  ((Boundary*) m_parent)->wallBound().x << ", " <<
  ((Boundary*) m_parent)->wallBound().y << ", " <<
  ((Boundary*) m_parent)->wallBound().z << ")");*/

  density = 1;
  for (int i = 0; i < SPACE_DIMS; i++) {/*all this SPECIFIC*/
    
 //     bool dd_is_defined = adjustBoxSize(point_t &size, bool_point_t& frameRCfront,  bool_point_t& frameRCend):dd_defined;
//    spacing[i] = box_size[i]/(m_nlattice_points[i]-1);
    if(m_dd_defined){ /*all this SPECIFIC*/
      spacing[i] = 2*m_distance/(sqrt(3.));
      offset[i] += spacing[i]/4;
      density *= spacing[i];
    }
    else{      /*all this SPECIFIC*/
      // FIXME: the setting of m_distance in this case is a little bit of rubbish and could produce bugs, because m_distance is no array, but spacing is
      int n = m_nlattice_points[i];
      spacing[i] = (double) ((box_size[i] / n ));
      
      m_distance = spacing[i]*sqrt(3.)/2;
      offset[i] += spacing[i]/4;
      density *= spacing[i];
    }
  
  }
    
  MSG_DEBUG("ParticleCreatorLatticeBCC::createParticles", "spacing = " << spacing);

  /* The density that is generated may differ from the density wished in the configuration
  file because the particle are equally spaced in space and have the same distance from
  the boundaries (of the cube, of course). That means the REAL density can still differ
  from this value */
  
  /*SPECIFIC*/
  density = 2/density;

  MSG_DEBUG("ParticleCreatorLatticeBCC::createParticles", "density = " << density);

  MSG_DEBUG("ParticleCreatorLatticeBCC::createParticles", "lattice = " << m_nlattice_points);

  /* All particles sit in a surrounding box of identical size. This is of course assuming the
  Boundary is exactly as big as returnMaxBoxSize proposes. */

  // create the function list for m_properties.unknown()
  // fList will be deleted at the end of this function	
  list<FunctionFixed> fl;
  fList(fl);
  
  // creation of FREE particles
  MSG_DEBUG("ParticleCreatorLatticeBCC::createParticles", "Creating free particles." << ", spacing = " << spacing << ", offset = " << offset << ", m_nlattice_points = " << m_nlattice_points);
                
  for (int i = 0; i < m_nlattice_points[0]; i++)
    for (int j = 0; j < m_nlattice_points[1]; j++)
      for (int k = 0; k < m_nlattice_points[2]; k++)
        for (int l = 0; l < 2; l++) {
    point_t pos = { { {  /*SPECIFIC*/
      i*spacing[0]+offset[0]+l*spacing[0]/2.,
      j*spacing[1]+offset[1]+l*spacing[1]/2.,
      k*spacing[2]+offset[2]+l*spacing[2]/2.
    } } };
    Cell *c;
    Particle p;
	
    p.r = pos;
    p.setColour(m_colour);

    transformPos(p);

    c = manager->findCell(p.r);

    if (c) {
      if (M_BOUNDARY->isInside(p.r)) {
        p.g = c->group();

        for (int w = 0; w < SPACE_DIMS; w++)
          p.v[w] = m_rng.uniform() - 0.5;
        
        // compute all from m_properties.unknown()
        computeUnknown(fl.begin(), p);

        m_particles[p.g].newEntry() = p;
      }
//       else MSG_DEBUG("ParticleCreatorLatticeBCC::createParticles", "NOT INSIDE: " << p.r << ", i = " << i << ", j = " << j << ", k = " << k << ", l = " << l);
    }
//     else MSG_DEBUG("ParticleCreatorLatticeBCC::createParticles", "NO CELL: " << p.r << ", i = " << i << ", j = " << j << ", k = " << k << ", l = " << l);
    
      }
      scaleVels();

  // next will call the one in ParticleCreatorFree and then ParticleCreatorFreeF::transformVel
      flushParticles();
}