Hi, i tried to implement a Custom Shape:
class Hexagon : public sf::Shape {
private:
static std::vector<sf::Vector2f> m_Coordinates;
protected:
virtual unsigned int getPointCount() const {
return 6;
}
virtual sf::Vector2f getPoint(unsigned int index) const {
return m_Coordinates[index];
}
};
//In the Constructor
if(m_Coordinates.empty()) {
//More Details in image /Misc/hex_geometry.jpg
const float s = 1.f;
const float h = 0.5f; //sin(30°)
const float r = 0.86602540f; //cos(30°)
m_Coordinates.reserve(6);
m_Coordinates.push_back(sf::Vector2f(0.f, -s)); //Top
m_Coordinates.push_back(sf::Vector2f( +r, -h)); //Top-Right
m_Coordinates.push_back(sf::Vector2f( +r, +h)); //Bottom-Right
m_Coordinates.push_back(sf::Vector2f(0.f, +s)); //Bottom
m_Coordinates.push_back(sf::Vector2f( -r, +h)); //Bottom-Left
m_Coordinates.push_back(sf::Vector2f( -r, -h)); //Top-Left
Shape::scale(1000.f, 1000.f);
Shape::setFillColor(sf::Color(255.f, 0.f, 0.f));
Shape::setPosition(sf::Vector2f(200.f, 200.f));
}
but it won't appear if i use
Hexagon myShape;
App.draw(myShape);
i scaled it to 1000.f to be sure i can see it...