Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00025
00028
00029 #ifndef THOR_CONCAVESHAPE_HPP
00030 #define THOR_CONCAVESHAPE_HPP
00031
00032 #include <Thor/Config.hpp>
00033
00034 #include <SFML/Graphics/Color.hpp>
00035 #include <SFML/Graphics/ConvexShape.hpp>
00036 #include <SFML/Graphics/Drawable.hpp>
00037 #include <SFML/Graphics/Transformable.hpp>
00038 #include <SFML/Graphics/VertexArray.hpp>
00039
00040 #include <vector>
00041
00042
00043 namespace thor
00044 {
00045
00048
00052 class THOR_API ConcaveShape : public sf::Drawable, public sf::Transformable
00053 {
00054
00055
00056 public:
00059 ConcaveShape();
00060
00063 ConcaveShape(const sf::Shape& shape);
00064
00067 void setPointCount(std::size_t count);
00068
00071 std::size_t getPointCount() const;
00072
00076 void setPoint(std::size_t index, sf::Vector2f position);
00077
00080 sf::Vector2f getPoint(std::size_t index) const;
00081
00084 void setFillColor(const sf::Color& fillColor);
00085
00088 void setOutlineColor(const sf::Color& outlineColor);
00089
00092 sf::Color getFillColor() const;
00093
00096 sf::Color getOutlineColor() const;
00097
00100 void setOutlineThickness(float outlineThickness);
00101
00104 float getOutlineThickness() const;
00105
00108 sf::FloatRect getLocalBounds() const;
00109
00114 sf::FloatRect getGlobalBounds() const;
00115
00116
00117
00118
00119 private:
00120 struct TriangleGenerator;
00121
00122
00123
00124
00125 private:
00126
00127 virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const;
00128
00129
00130 void ensureDecomposed() const;
00131
00132
00133 void ensureOutlineUpdated() const;
00134
00135
00136
00137
00138 private:
00139 std::vector<sf::Vector2f> mPoints;
00140 sf::Color mFillColor;
00141 sf::Color mOutlineColor;
00142 float mOutlineThickness;
00143
00144 mutable sf::VertexArray mTriangleVertices;
00145 mutable std::vector<sf::ConvexShape> mOutlineShapes;
00146 mutable sf::FloatRect mLocalBounds;
00147 mutable bool mNeedsDecomposition;
00148 mutable bool mNeedsOutlineUpdate;
00149 };
00150
00152
00153 }
00154
00155 #endif // THOR_CONCAVESHAPE_HPP