Example #1
0
static int	add_room2(t_lem_env *env, char *s, int i)
{
	char	*t;
	char	*tmp;

	if ((t = ft_strstr(env->str, ft_strjoin(ft_strsub(s, 0, i), "\n")))
		!= NULL)
	{
		if (t != env->str && *(--t) == '\n')
			return (ft_error(env, 1));
	}
	tmp = ft_strjoin(env->str, ft_strsub(s, 0, i));
	tmp = ft_strjoin(tmp, "\n");
	free(env->str);
	env->str = tmp;
	env->nbroom += 1;
	coord(s, i, env);
	return (1);
}
/*private*/
void
OffsetCurveSetBuilder::addLineString(const LineString *line)
{
	if (distance <= 0.0 && ! curveBuilder.getBufferParameters().isSingleSided())
	{
		return;
	}

#if GEOS_DEBUG
	std::cerr<<__FUNCTION__<<": "<<line->toString()<<std::endl;
#endif
	std::auto_ptr<CoordinateSequence> coord(CoordinateSequence::removeRepeatedPoints(line->getCoordinatesRO()));
#if GEOS_DEBUG
	std::cerr<<" After coordinate removal: "<<coord->toString()<<std::endl;
#endif
	std::vector<CoordinateSequence*> lineList;
	curveBuilder.getLineCurve(coord.get(), distance, lineList);
	addCurves(lineList, Location::EXTERIOR, Location::INTERIOR);
}
Example #3
0
void Tet::dump_mesh(FILE *name){
  Coord X;
  X.x = dvector(0,QGmax*QGmax*QGmax-1);
  X.y = dvector(0,QGmax*QGmax*QGmax-1);
  X.z = dvector(0,QGmax*QGmax*QGmax-1);

  coord(&X);

  if(!option("NOHEADER"))
    fprintf(name,"VARIABLES = x y z u\n");
  fprintf(name,"ZONE T=\"Element %d\", I=%d, J=%d, K=%d,F=POINT\n",
    0,qa,qb,qc);

  for(int i=0;i<qtot;++i)
    fprintf(name,"%lf %lf %lf %lf\n", X.x[i], X.y[i], X.z[i], h_3d[0][0][i]);
  free(X.x);
  free(X.y);
  free(X.z);
}
Example #4
0
void ompl::geometric::ProjEST::addMotion(Motion *motion)
{
    Grid<MotionInfo>::Coord coord(projectionEvaluator_->getDimension());
    projectionEvaluator_->computeCoordinates(motion->state, coord);
    GridCell *cell = tree_.grid.getCell(coord);
    if (cell != nullptr)
    {
        cell->data.push_back(motion);
        pdf_.update(cell->data.elem_, 1.0 / cell->data.size());
    }
    else
    {
        cell = tree_.grid.createCell(coord);
        cell->data.push_back(motion);
        tree_.grid.add(cell);
        cell->data.elem_ = pdf_.add(cell, 1.0);
    }
    tree_.size++;
}
Example #5
0
DataNumMatrix& DataNumMatrix::operator=(const DataNumMatrix copy_Matrix){
	this->n  = copy_Matrix.n;
	this->m = copy_Matrix.m;
	this->env = copy_Matrix.env;

	this->Matrix = IloArray<IloNumArray> (this->env,this->n);
	for(int i = 0; i < this->n; i++){
		this->Matrix[i] = IloNumArray(this->env,this->m);
	}

	for(int i = 1; i <= this->n; i++){
		for(int j = 1; j <= this->m; j++){
			Coordinate coord(i,j);
			this->Matrix[i-1][j-1]= copy_Matrix.get(coord);
		}
	}

	return *this;
}
Example #6
0
// prime MCOORD -> MCOORD
void metptomet(int ii, int jj, FTYPE*ucon)
{
  int j,k;
  FTYPE r, th, X[NDIM];
  FTYPE dxdxp[NDIM][NDIM];
  FTYPE tmp[NDIM];

  coord(ii, jj, CENT, X);
  bl_coord(X, &r, &th);

  dxdxprim(X, r, th, dxdxp);

  /* transform ucon */
  // this is u^j = T^j_k u^k, as in above
  DLOOPA tmp[j] = 0.;
  DLOOP tmp[j] += dxdxp[j][k] * ucon[k];
  DLOOPA ucon[j] = tmp[j];

  /* done! */
}
Example #7
0
  LinearProblem prob(const Mesh& mesh) const
    {
      CellFilter left = domain().left();

      Expr u = new UnknownFunction(basis_, "u");
      Expr v = new TestFunction(basis_, "v");
      Expr dx = gradient(1);
      Expr x = coord(0);

      QuadratureFamily quad = new GaussianQuadrature(2*basis_.order());

      const double pi = 4.0*atan(1.0);
      Expr eqn = Integral(interior(), (dx*v)*(dx*u), quad)
        + Integral(interior(), -2.25*pi*pi*sin(3.0*pi*x/2.0)*v, quad);

      Expr bc = EssentialBC(left, v*u, quad);
      
      
      return LinearProblem(mesh, eqn, bc, v, u, vecType());
    }
Example #8
0
sf::Vector2i GameMap::getTileCoord(Tile* tile)
{
	sf::Vector2i coord(-1,-1);

	for (int a(0); a < mapSize.x; a++)
	{
		for (int b(0); b < mapSize.y; b++)
		{
			Tile* temp = getTileByXY(sf::Vector2i(a, b));
			if ( temp == tile)
			{
				coord.x = a;
				coord.y = b;
				return coord;
			}
		}
	}

	return coord;
}
Example #9
0
/**
* Convert the mouse cursor coordinate on the window (i.e. from (0,0) to (windowWidth, windowHeight))
* into normalised screen coordinate , i.e. (-1, -1) to (1, 1)
*/
glm::vec3 Arcball::toScreenCoord(double x, double y)
{
	glm::vec3 coord(0.0f);

	coord.x = (2.f * float(x) - m_windowWidth) / m_windowWidth;
	coord.y = -(2.f * float(y) - m_windowHeight) / m_windowHeight;

	/* Clamp cursor to border of the windows, comment these lines to allow rotation when cursor is outside the window */
	coord.x = glm::clamp(coord.x, -1.0f, 1.0f);
	coord.y = glm::clamp(coord.y, -1.0f, 1.0f);

	float length_squared = coord.x * coord.x + coord.y * coord.y;
	if (length_squared < 1.0) {
		coord.z = sqrt(1.f - length_squared);
	} else {
		coord = glm::normalize(coord);
	}

	return coord;
}
Example #10
0
int main()
{
	uint n, k;
	scanf("%u %u", &n, &k);

	heap<coord> h(k / 2 + 1);
	h.push(coord(n, n));
	uint64 last = +INF;

	for (uint i = 0; i < k; i++) {
		while (h.front().value() >= last) {
			repopulate(h);
		}
		
		last = repopulate(h);
		printf("%llu\n", last);
	}

	return 0;
}
Example #11
0
// Find the X and Y in hex coordinates of the hexagon next to this hexagon
// in the direction specified.
Coord Hexagon::neighborCoord(int dir) const
{
    static int evenx[] = { 0, -1, -1, 0, 1, 1 };
    static int eveny[] = { -1, -1, 0, 1, 0, -1 };
    static int oddx[] = { 0, -1, -1, 0, 1, 1 };
    static int oddy[] = { -1, 0, 1, 1, 1, 0 };

    Coord coord(m_x, m_y);
    if (xeven())
    {
        coord.m_x += evenx[dir];
        coord.m_y += eveny[dir];
    }
    else
    {
        coord.m_x += oddx[dir];
        coord.m_y += oddy[dir];
    }
    return coord;
}
Example #12
0
void KSegmentorBase::copyIntegralDuringPaste(int kFrom, int kTo)
{
    std::vector <unsigned int> coord(3);
    unsigned int element=0;
    for (int i=0;i<=this->dimx-1; i++)  {
        for (int j=0; j<=this->dimy-1; j++) {
            double val = this->U_Integral_image->GetScalarComponentAsDouble(i,j,kFrom,0);
            this->U_Integral_image->SetScalarComponentFromDouble(i,j,kTo,0,val);
            if(fabs(val)>0)
            {
                element=kTo*dimx*dimy +j*dimx+i;
                this->AddPointToUpdateVector(element);
                coord[0] = (i);
                coord[1] = (j);
                coord[2] = (kTo);
                this->AddPointToCoordinatesVector(coord);
            }
        }
    }
}
Example #13
0
void shell::paint( paint_param_t& paintParam, RECT const& rect ) {
	struct _{
		static void __( frame_ptr const& f, frame_coord const& coord, bool const cf, paint_param_t& pp, RECT r ) {
			HDC dc = pp.dcb.dc;
			RECT rt;
			int const rw = RECT_WIDTH( r );
			int const rh = RECT_HEIGHT( r );
			rt.left 	= r.left + coord.left.get_n() * rw / coord.left.get_d();
			rt.top 		= r.top + coord.top.get_n() * rh / coord.top.get_d();
			rt.right	= rt.left + rw / coord.width;
			rt.bottom	= rt.top + rh / coord.height;
			//
			//
			FrameRect( dc, &rt, ( cf )?( pp.borderActive ):( pp.borderInactive ) );
			InflateRect( &rt, -1, -1 );
			//
			SetBkMode( dc, TRANSPARENT );
			//
			atom::shared_gdiobj<HRGN> rgn = CreateRectRgn( rt.left, rt.top, rt.right, rt.bottom );
			SelectClipRgn( dc, rgn );
			{
				SelectObject( dc, pp.sysFont.font);
				SetTextColor( dc, pp.sysFont.color );
				atom::stringstream_t ss;
				ss << _T( " #" ) << f->get_index();
				DrawText( dc, ss.str().c_str(), -1, &rt, DT_RIGHT | DT_TOP | DT_SINGLELINE );
				//
				SelectObject( dc, pp.textFont.font );
				SetTextColor( dc, pp.textFont.color );
				f->paint( dc, rt, pp.textFont.height );
			}
			SelectClipRgn( dc, NULL );
		}
	};
	frame_coord coord( 0, 1, 0, 1, 1, 1 );
	if ( this->expandMode ) {
		_::__( this->currentFrame, coord, true, paintParam, rect );
	} else {
		this->headArea->draw( boost::bind( &_::__, _1, _2, _3, boost::ref( paintParam ), rect ), coord, this->currentFrame );
	}
}
// append local profile to MNI space profile
void appendpf_local2std(string coordfile_std2local) {
  ifstream coordstream(coordfile_std2local);
  floatVector coord(3);
  vector<floatVector> coord_map_std2local;
  for (int i=0; i<3; i++)
    coordstream >> coord[i];
  while(coordstream.good()) {
    coord_map_std2local.push_back(coord);
    for (int i=0; i<3; i++)
      coordstream >> coord[i];
  }

  assert(coord_map_std2local.size()==conn_profile().size());
  floatVector append;
  intVector start(3);
  floatVector coef(3);
  intVector tmpCoord(3);
  int dim_profile = (conn_profile().begin()->second).size();

  auto it = conn_profile().begin();
  for (int i=0; i<conn_profile().size(); i++, it++) {
    for (int k=0; k<3; k++) {
      start[k]=(int)coord_map_std2local[i][k];
      coef[k] = coord_map_std2local[i][k]-start[k];
    }
    for (int z=0; z<2; z++) { // Note: we assume that all points are within the interiors, therefore exactly 8 neighbors
      float fracZ = (1-coef[2])*(1-z)+coef[2]*z;
      for (int y=0; y<2; y++) {
	float fracZY=fracZ * ( (1-coef[1])*(1-y)+coef[1]*y );
	for (int x=0; x<2; x++) {
	  float fracZYX=fracZY * ( (1-coef[0])*(1-x)+coef[0]*x );
	  tmpCoord[0]=start[0]+x; tmpCoord[1]=start[1]+y; tmpCoord[2]=start[2]+z;
	  if (conn_profile_local().count(tmpCoord)) {
	    for (int k=0; k<dim_profile; k++)
	      (it->second)[k] += fracZYX * conn_profile_local()[tmpCoord][k];
	  }
	}
      }
    }
  }
}
Example #15
0
/*
====================
Flush
====================
*/
VOID BrushLozenge::Flush(const Map* map, const Vector3& pt)
{
	GUARD(BrushLozenge::Flush);

	// compute the view
	F32 radius = this->Radius();
	Vector4 rect(pt[0]-P2U(TILE_WIDTH/2), pt[1], pt[0]+P2U(TILE_WIDTH/2), pt[1]+P2U(TILE_HEIGHT));
	Rect src, dst, clip;
/*	
	src.left	= U2P(rect[0])/U2P(CHUNK_STRIDE);
	src.top		= U2P(rect[1])/U2P(CHUNK_STRIDE);
	src.right	= (U2P(rect[2])%U2P(CHUNK_STRIDE)) ? (U2P(rect[2])/U2P(CHUNK_STRIDE)+1) : U2P(rect[2])/U2P(CHUNK_STRIDE);
	src.bottom	= (U2P(rect[3])%U2P(CHUNK_STRIDE)) ? (U2P(rect[3])/U2P(CHUNK_STRIDE)+1) : U2P(rect[3])/U2P(CHUNK_STRIDE);
*/
	src.left	= (U2P(rect[0])%U2P(CHUNK_STRIDE)) ? (U2P(rect[0])/U2P(CHUNK_STRIDE)-1) : U2P(rect[0])/U2P(CHUNK_STRIDE);
	src.top		= (U2P(rect[1])%U2P(CHUNK_STRIDE)) ? (U2P(rect[1])/U2P(CHUNK_STRIDE)-1) : U2P(rect[1])/U2P(CHUNK_STRIDE);
	src.right	= (U2P(rect[2])%U2P(CHUNK_STRIDE)) ? (U2P(rect[2])/U2P(CHUNK_STRIDE)+1) : U2P(rect[2])/U2P(CHUNK_STRIDE);
	src.bottom	= (U2P(rect[3])%U2P(CHUNK_STRIDE)) ? (U2P(rect[3])/U2P(CHUNK_STRIDE)+1) : U2P(rect[3])/U2P(CHUNK_STRIDE);

	dst.left	= -map->mWidth/2;
	dst.top		= 0;
	dst.right	= map->mWidth/2;
	dst.bottom	= map->mHeight;	
	IntersectRect(&clip, &dst, &src);
	for(I32 j = clip.top; j < clip.bottom; j++)
	{
		for(I32 i = clip.left; i < clip.right; i++)
		{
			std::pair<I32,I32> coord(i,j);
			std::map< std::pair<I32,I32>, ChunkPtr >::const_iterator it = map->mChunks.find(coord);
			if(it == map->mChunks.end()) continue;
			EChunkPtr chunk =  dynamic_ptr_cast<EChunk>(it->second);
			Matrix world = Matrix::makeTranslate(i*CHUNK_STRIDE,j*CHUNK_STRIDE,0);
			Matrix world_inv; world_inv.invert(world);
			Vector3 point = pt * world_inv;
			this->Flush(chunk.Ptr(), point);
		}
	}

	UNGUARD;
}
Example #16
0
coord maze_router::check_nvals(int x, int y, int val, bool vert){

  int next = val-1;
  if (val == 1) {next = 9;}
  
  if(vert){
    if(grid[x][y+1].val == next){return coord(x, y+1);}
    if(grid[x][y-1].val == next){return coord(x, y-1);}
  }
  if(grid[x+1][y].val == next){return coord(x+1, y);}
  if(grid[x-1][y].val == next){return coord(x-1, y);}
  if(grid[x][y+1].val == next){return coord(x, y+1);}
  if(grid[x][y-1].val == next){return coord(x, y-1);}

}
Example #17
0
double PortraitCut::BVZ_ComputeSpatialOnly() { 
  
  double E=0;
  
  int i,j,index=0, k;
  Coord np;
  for (j=0; j<_h; j++)
    for (i=0; i<_w; i++, ++index) {
      Coord coord(i,j);
      for (k=0; k<(int)NEIGHBOR_NUM; k++){
	np = coord + NEIGHBORS[k];
	if (np>=Coord(0,0) && np<_size)
	  E += BVZ_interaction_penalty(coord,np,_labels[index], _labels[CINDEX(np)]);	
	
      }

    }

  //assert(_finite(E) && !_isnan(E));
  return E;
}
Example #18
0
/*****************************************************
**
**   BasicVedicChart   ---   paintOuterRectangle
**
******************************************************/
void BasicVedicChart::paintOuterRectangle()
{
	VedicChartConfig *vconf = getVChartConfig();
  if ( ! vconf->outerRectangle.show ) return;

  painter->setPen( vconf->outerRectangle.pen.IsOk() ? vconf->outerRectangle.pen : defaultPen  );

  if ( vconf->outerRectangle.brush.IsOk() ) painter->setBrush( vconf->outerRectangle.brush );
  else painter->setTransparentBrush();

  MRect coord( xcenter - xr, ycenter - yr, 2 * xr, 2 * yr );
  painter->drawRectangle( coord, .01 * Min( xmax, ymax ) * vconf->outerRectangle.cornerRadius );

	if ( vconf->outerRectangle.doubleOuterLine )
	{
		// distance of second frame: derive from rmax -> prevent scaling errors in pdf output
		const double delta = rmax / 100.0;
		painter->drawRectangle( MRect( coord.x - delta, coord.y - delta, coord.width + 2 * delta, coord.height + 2 * delta ));
	}
	painter->setPen( defaultPen );
}
Example #19
0
//
// -------------------------------------------------------------
//
int main()
{
  typedef float   NumericType;

  //doing nothing but instantiating a few types
  viennacl::scalar<NumericType>  s;
  viennacl::vector<NumericType>  v(10);
  viennacl::matrix<NumericType>  m(10, 10);
  viennacl::compressed_matrix<NumericType>  compr(10, 10);
  viennacl::coordinate_matrix<NumericType>  coord(10, 10);

  //this is the external linkage check:
  other_func();

   std::cout << std::endl;
   std::cout << "------- Test completed --------" << std::endl;
   std::cout << std::endl;


  return EXIT_SUCCESS;
}
Example #20
0
static void dumpG(graph_t * g)
{
    node_t *n;
    /* point  p; */
    edge_t *e;

    for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
	fprintf(stderr, " node %s \n", n->name);

	for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
	    fprintf(stderr, " %s - %s \n", e->tail->name, e->head->name);
	}
#ifdef OLD
	p = coord(n);
	fprintf(stderr, " %s pos (%f,%f) (%d,%d)\n",
		n->name, ND_pos(n)[0], ND_pos(n)[1], p.x, p.y);
	fprintf(stderr, "   width %f height %f xsize %d ysize %d\n",
		ND_width(n), ND_height(n), ND_xsize(n), ND_ysize(n));
#endif
    }
}
Example #21
0
	void ListCtrl::updateDropItems()
	{
		if (nullptr == mItemDrag)
		{
			// спрашиваем размер иконок
			IntCoord coord(0, 0, 50, 50);

			//requestCoordItem(this, coord, true);

			mPointDragOffset = coord.point();

			// создаем и запрашиваем детей
			mItemDrag = Gui::getInstance().createWidget<Widget>("Default", IntCoord(0, 0, coord.width, coord.height), Align::Default, mDragLayer);
			requestCreateWidgetItem(this, mItemDrag);
		}

		const IntPoint& point = InputManager::getInstance().getMousePositionByLayer();

		mItemDrag->setPosition(point.left - mClickInWidget.left + mPointDragOffset.left, point.top - mClickInWidget.top + mPointDragOffset.top);
		mItemDrag->setVisible(true);
	}
Example #22
0
 /**
  * Convert the mouse cursor coordinate on the window (i.e. from (0,0) to (windowWidth, windowHeight))
  * into normalized screen coordinate (i.e. (-1, -1) to (1, 1)
  */
 glm::vec3 Arcball::toScreenCoord( double x, double y ) {
     glm::vec3 coord(0.0f);
     
     if( xAxis )
         coord.x =  (2 * x - windowWidth ) / windowWidth;
     
     if( yAxis )
         coord.y = -(2 * y - windowHeight) / windowHeight;
     
     /* Clamp it to border of the windows, comment these codes to allow rotation when cursor is not over window */
     coord.x = glm::clamp( coord.x, -1.0f, 1.0f );
     coord.y = glm::clamp( coord.y, -1.0f, 1.0f );
     
     float length_squared = coord.x * coord.x + coord.y * coord.y;
     if( length_squared <= 1.0 )
         coord.z = sqrt( 1.0 - length_squared );
     else
         coord = glm::normalize( coord );
     
     return coord;
 }
Example #23
0
my::ConicMesh::ConicMesh(const float & height, const float & aperture, const int & nbSlices, const int & nbStacks)
    :ParametricMesh("ConicMesh", nbStacks+2, 2*nbSlices),
      _height(height),
      _aperture(aperture),
      _nbSlices(nbSlices),
      _nbStacks(nbStacks)
{
    _preConicMesh(_height, _aperture, _nbSlices, _nbStacks);

    my::Conic coord(Point(0,-1,0), _aperture);

    parametricVertexInsertion(imax()-1, jmax(), coord);
    this->addVertex(0,-1,0);

    parametricTriangleInsertion(imax()-1, jmax());

    flipTriangles();

    computeNormalsT();
    computeNormalsV();
}
// Визуальные образы - билборды.
void RealtimePhysicsPort::pushDroneBillboard( const uid_t& fromThrone ) {

    // Т.к. метод вызывается в потоке, позаботимся о безопасности
    waitFreeSetLock();

    // Находим запрашиваемого трона
    auto throne = search( fromThrone );
    assert( throne && "Сущность по заданному UID не найдена." );

    // Определяем координаты трона
    const coord2d_t coordThrone = coord( throne->body );

    // "Выстреливаем" дронов
    const size_t N = 100;
    const size_t M = 5;
    for (size_t m = 0; m < M; ++m ) {
        for (size_t n = 0; n < N; ++n ) {
            FlatInitEntity ie( InitEntity::FORM_SPHERE );
            const auto a = Ogre::StringConverter::toString( n + 1 );
            const auto b = Ogre::StringConverter::toString( GetTickCount() );
            ie.uid = "D" + a + "-" + b;
            //std::cout << "RealtimePhysicsPort::pushDroneBillboard() UID " << ie.uid << std::endl;
            ie.boundingRadius = 1.0f * 100.0f;
            ie.mass = 1.0f;
            //const float rx = ((float)n * 0.1f - 0.0f) * 100.0f;
            //const float rz = ((float)n * 2.0f + 5.0f) * 100.0f;
            const float rx = (((float)n - (float)N / 2.0f) * 2.0f) * 100.0f;
            const float rz = (((float)m - (float)M / 2.0f) * 2.0f + (float)M * 5.0f) * 100.0f;
            ie.coord = coordThrone + coord2d_t( rx, rz );
            ie.model = "sphere.png";
            ie.force = vector2d_t( 0.0f, 10000.0f );
            set( &ie );
        }
    }

    // Дальше всё сделает физический движок

    // Освобождаем порт
    unlock();
}
void afficherGrille(Grille grille){
    cout << endl << endl << "Affichage grille" << endl << endl;

	for (int i=0;i<grille.getTailleGrille().getLongueur();i++){
        cout << "|";
        if(i/10 == 0)
            cout << " ";
        else
            cout << i/10;

    }
    cout << "|" << endl;

	for (int i=0;i<grille.getTailleGrille().getLongueur();i++)
        cout << "|" << i%10;
    cout << "|" << endl;

	for (int i=0;i<grille.getTailleGrille().getLongueur();i++)
        cout << "--";
    cout << "-" << endl;

	for (int i=0;i<grille.getTailleGrille().getHauteur();i++){
		for (int j=0;j<grille.getTailleGrille().getLongueur();j++){
			Coordonnees coord(j,i);
			cout << "|";
			if(grille.getCaseElt(coord).getBateau()!=nullptr){
				if(grille.getCaseElt(coord).getTouche()==false)
					cout << "o";
				else cout << "x";
			}
			else {
				if(grille.getCaseElt(coord).getTouche()==false)
					cout << " ";
				else cout << "-";
			}
		}
		cout << "|"  << i << endl;
	}
	cout<< endl << endl;
}
Example #26
0
void buildPolygon(const Polygon& polygon,
    double height,
    std::vector<PolygonVertex>& outVertices,
    std::vector<unsigned int>& outIndices,
    const std::unique_ptr<HeightData>& elevation,
    float centroidHeight,
    float inverseTileScale)
{
    mapbox::Earcut<float, unsigned int> earcut;

    earcut(polygon);

    unsigned int vertexDataOffset = outVertices.size();

    if (earcut.indices.size() == 0) {
        return;
    }

    if (vertexDataOffset == 0) {
        outIndices = std::move(earcut.indices);
    } else {
        outIndices.reserve(outIndices.size() + earcut.indices.size());

        for (auto i : earcut.indices) {
            outIndices.push_back(vertexDataOffset + i);
        }
    }

    static glm::vec3 normal(0.0, 0.0, 1.0);

    outVertices.reserve(outVertices.size() + earcut.vertices.size());

    centroidHeight *= inverseTileScale;

    for (auto& p : earcut.vertices) {
        glm::vec2 position(p[0], p[1]);
        glm::vec3 coord(position.x, position.y, height + centroidHeight);
        outVertices.push_back({coord, normal});
    }
}
Example #27
0
    std::vector< std::pair<std::string, Ogre::Vector3> > PhysicsSystem::doPhysicsFixed (
        const std::vector<std::pair<std::string, Ogre::Vector3> >& actors)
    {
        Pmove(playerphysics);

        std::vector< std::pair<std::string, Ogre::Vector3> > response;
        for(std::map<std::string,OEngine::Physic::PhysicActor*>::iterator it = mEngine->PhysicActorMap.begin(); it != mEngine->PhysicActorMap.end();it++)
        {
            btVector3 newPos = it->second->getPosition();

            Ogre::Vector3 coord(newPos.x(), newPos.y(), newPos.z());
            if(it->first == "player"){

                coord = playerphysics->ps.origin;
            }


            response.push_back(std::pair<std::string, Ogre::Vector3>(it->first, coord));
        }

        return response;
    }
Example #28
0
void MapItem::drawMap() {
  for (int y = 0; y < map->getSizeY(); ++y) {
    for (int x = 0; x < map->getSizeX(); ++x) {
      Coordinate coord(x, y);
      switch (map->getCellType(coord)) {
      case CellType::PATH:
        if (map->isEntrance(coord)) {
          grid[y][x]->setBrush(entranceBrush);
          entrance = coord;
        } else if (map->isExit(coord)) {
          grid[y][x]->setBrush(exitBrush);
          exit = coord;
        } else
          grid[y][x]->setBrush(pathBrush);
        break;
      case CellType::SCENERY:
        grid[y][x]->setBrush(sceneryBrush);
        break;
      }
    }
  }
}
Example #29
0
void Fov::runPlayerFov(const bool obstructions[MAP_X_CELLS][MAP_Y_CELLS], const coord& origin) {
  int checkX, checkY;

  allUnseen(eng->map->playerVision);

  eng->map->playerVision[origin.x][origin.y] = true;

  const int checkX_end = origin.x + FOV_STANDARD_RADI_INT;
  const int checkY_end = origin.y + FOV_STANDARD_RADI_INT;

  checkX = origin.x - FOV_STANDARD_RADI_INT;

  while(checkX <= checkX_end) {
    checkY = origin.y - FOV_STANDARD_RADI_INT;

    while(checkY <= checkY_end) {
      performCheck(obstructions, coord(checkX, checkY), origin, eng->map->playerVision, true);
      checkY++;
    }
    checkX++;
  }
}
Example #30
0
/* set up all grid functions */
void init_geometry()
{
	int i, j;
	double X[NDIM];

	for (i = 0; i < N1; i++) {
		for (j = 0; j < N2; j++) {

			/* zone-centered */
			coord(i, j, X);

			gcov_func(X, geom[i][j].gcov);

			geom[i][j].g = gdet_func(geom[i][j].gcov);

			gcon_func(X, geom[i][j].gcon);

		}
	}

	/* done! */
}