示例#1
0
void updateKeyboard()
{
  if (keyboard['w'] || keyboard['W'])
  { 
    if (ship->position->y < 20)
    {
     ship->position->y += 1;
     x_angle = fmax(-24, x_angle - 4);
    }   
  }
  if (keyboard['s'] || keyboard['S'])
  { 
    if (ship->position->y > -5)
    {
     ship->position->y -= 1;
     x_angle = fmin(24, x_angle + 4);
    }
  }
  if (keyboard['a'] || keyboard['A'])
  { 
    if (ship->position->x < 12)
    {
     ship->position->x +=1;
     z_angle = fmax(-35, z_angle - 5);
    }
  }
  if (keyboard['d'] || keyboard['D'])
  {
    if (ship->position->x > -12)
    {
     ship->position->x -= 1;
     z_angle = fmin(35, z_angle + 5);
    }
  }
  if (keyboard['e'] || keyboard['E']) {
     forceField = TRUE;
     beginFF = glutGet(GLUT_ELAPSED_TIME);
  }
  if (keyboard['u'] || keyboard['U'])
  {   if (shootAcc > 20)
      {
       shipShoot();
       shootAcc = 0.0;
      } else shootAcc += 10;
  }
  if (keyboard['q'] || keyboard['Q']) {
     freeCenario();
     exit(EXIT_SUCCESS);
  }
  if (!keyboard['w'] && !keyboard['W'] && !keyboard['s'] && !keyboard['S'])
    x_angle = closeToZero(x_angle, 4);
  if (!keyboard['a'] && !keyboard['A'] && !keyboard['d'] && !keyboard['D'])
    z_angle = closeToZero(z_angle, 5);

  ship->orientation->y = ship->position->y - tan(x_angle * PI/180) * 15;
  ship->orientation->x = ship->position->x;
}
示例#2
0
bool hasZeros (double minx, double miny, double maxx, double maxy, double normx, double normy) {
	pdal::Options readerOptions;
	readerOptions.add("connection", "host='localhost' dbname='lidar' user='******'");
	readerOptions.add("table", "lidar");
	readerOptions.add("column", "pa");
	readerOptions.add("srid", 3857);

	char buf [4096];
	snprintf(buf, sizeof(buf) - 1,
			"PC_Intersects(pa, ST_MakeEnvelope(%lf,%lf,%lf,%lf,3857))",
			minx, miny, maxx, maxy);
	buf[sizeof(buf) - 1] = 0;
	readerOptions.add("where", buf);


	boost::shared_ptr<pdal::drivers::pgpointcloud::Reader> pReader(new
			pdal::drivers::pgpointcloud::Reader(readerOptions));

	pReader->initialize();
	std::cout << "Query: " << buf << " ::: " << pReader->getNumPoints() << " points" << std::endl;

	pdal::PointBuffer pbuf(pReader->getSchema(), pReader->getNumPoints());
	pdal::StageSequentialIterator* iterator = pReader->createSequentialIterator(pbuf);
	iterator->read(pbuf);

	//std::cout << pbuf.getSchema() << std::endl;

	// read in points
	pdal::Dimension const& x = pbuf.getSchema().getDimension("X");
	pdal::Dimension const& y = pbuf.getSchema().getDimension("Y");
	pdal::Dimension const& z = pbuf.getSchema().getDimension("Z");

	size_t origin_points = 0;
	for (size_t i = 0, il = pReader->getNumPoints() ; i < il ; i ++) {
		float x_ = static_cast<float>(x.applyScaling(pbuf.getField<int>(x, i))) - normx,
			  y_ = static_cast<float>(y.applyScaling(pbuf.getField<int>(y, i))) - normy,
			  z_ = static_cast<float>(z.applyScaling(pbuf.getField<int>(z, i)));



		if (closeToZero(x_) &&
			closeToZero(y_)) {
				origin_points ++;
		}

	}
	std::cout << "Volume point stats: origin: " << origin_points << std::endl;
	return origin_points > 0;
}