示例#1
0
void
Slic3rPolygons_to_ClipperPolygons(const Slic3r::Polygons &input, ClipperLib::Polygons &output)
{
    output.clear();
    for (Slic3r::Polygons::const_iterator it = input.begin(); it != input.end(); ++it) {
        ClipperLib::Polygon p;
        Slic3rPolygon_to_ClipperPolygon(*it, p);
        output.push_back(p);
    }
}
示例#2
0
void NavMeshEditorApp::_processEvent(const sf::Event& event)
{
	_polygonUserController.processUserEvent(event);

	switch(event.type)
	{
		case sf::Event::KeyPressed:
		{
			switch(event.key.code)
			{
				case sf::Keyboard::A:
				{
					_changeEditorState(EditorState::EditingWalkableRegion);

					std::cerr<<"State: EditingWalkableRegion"<<std::endl;
				}
					break;

				case sf::Keyboard::S:
				{
					_changeEditorState(EditorState::EditingObstacleRegion);

					std::cerr<<"State: EditingObstacleRegion"<<std::endl;
				}
					break;

				case sf::Keyboard::Q:
				{
					// walkableRegions
					ClipperLib::Polygons walkableRegions;
					for(unsigned int i=0; i < _walkableCuadrilaterals.size() ; ++i)
					{
						ClipperLib::Polygons p = (ClipperLib::Polygons)*_walkableCuadrilaterals[i];
						for(unsigned int j=0; j < p.size() ; ++j)
							walkableRegions.push_back(p[j]);
					}

					std::cerr<<"Process Walkable Polygons"<<std::endl;

					// obstaclesRegions
					ClipperLib::Polygons obstacleRegions;
					for(unsigned int i=0; i < _obstacleCuadrilaterals.size() ; ++i)
					{
						ClipperLib::Polygons p = (ClipperLib::Polygons)*_obstacleCuadrilaterals[i];
						for(unsigned int j=0; j < p.size() ; ++j)
							obstacleRegions.push_back(p[j]);
					}

					std::cerr<<"Process Obstacles Polygons"<<std::endl;

					_pNavMesh->processNavigationMesh( walkableRegions, obstacleRegions );

					walkableRegions.clear();
					obstacleRegions.clear();

					_changeEditorState(EditorState::ViewingNavMeshResult);
				}
					break;

				case sf::Keyboard::Escape:
					_App.close();
					break;
			}
		}
			break;
				
		case sf::Event::Closed://Si se cierra la ventana
			_App.close();
			break;
	}
}