void SimpleDraw::DrawCircle( const Vec3d& center, double radius, const Vec4d& c, const Vec3d& n, float lineWidth ) { Vec3d startV(0,0,0); // Find orthogonal start vector if ((abs(n.y()) >= 0.9f * abs(n.x())) && abs(n.z()) >= 0.9f * abs(n.x())) startV = Vec3d(0.0f, -n.z(), n.y()); else if ( abs(n.x()) >= 0.9f * abs(n.y()) && abs(n.z()) >= 0.9f * abs(n.y()) ) startV = Vec3d(-n.z(), 0.0f, n.x()); else startV = Vec3d(-n.y(), n.x(), 0.0f); int segCount = 20; double theta = 2.0 * M_PI / segCount; glDisable(GL_LIGHTING); glLineWidth(lineWidth); glColor4dv(c); glBegin(GL_LINE_LOOP); for(int i = 0; i < segCount; i++){ glVertex3dv(center + startV * radius ); ROTATE_VEC(startV, theta, n); } glEnd(); glEnable(GL_LIGHTING); }
void TradeNet::calculatePos(const sf::Vector2f& topLeft, int dx, int h, int dy) { std::cout << "VertexLength: " << _vertex.size() << "\n"; assert(_vertex.empty()); int x, y; int width = _pBezirk->getWidth(); for( auto node : _tradeRouts ) { x = node.second.front().start % width; y = node.second.front().start / width; sf::Vertex startV(topLeft + sf::Vector2f(x * dx, y * 2.f * h + (x % 2 == 0 ? 0.f : dy)), _color ); for(auto e : node.second) { if(e.idStart >= e.idEnd) // only draw one direction continue; _vertex.push_back(startV); x = e.end % width; y = e.end / width; _vertex.push_back(sf::Vertex(topLeft + sf::Vector2f(x * dx, y * 2.f * h + (x % 2 == 0 ? 0.f : dy)), _color )); } } _change = false; }