47 #ifndef _MIRA_POLYGONOBJECT_H_ 48 #define _MIRA_POLYGONOBJECT_H_ 56 #include <OGRE/OgreSceneManager.h> 57 #include <OGRE/OgreSceneNode.h> 58 #include <OGRE/OgreManualObject.h> 59 #include <OGRE/OgreMaterialManager.h> 72 typedef boost::geometry::model::ring<Point2>
Polygon2;
73 typedef boost::geometry::model::ring<Point3>
Polygon3;
76 PolygonObject(Ogre::SceneManager* sceneManager, Ogre::SceneNode* parent = NULL);
80 virtual void setColor(
const Ogre::ColourValue& color);
85 virtual void setFillColor(
const Ogre::ColourValue& color);
90 void setPolygons(
const std::vector<Polygon2>& polygons);
91 void setPolygons(
const std::vector<Polygon3>& polygons);
106 template <
typename T>
109 mOutlineColor(
Ogre::ColourValue::
Black), mFillColor(0.f, 0.f, 0.f, 0.f)
122 template <
typename T>
125 mNode->detachObject(mOutlineObject);
126 mSceneManager->destroyManualObject(mOutlineObject);
127 mNode->detachObject(mAreaObject);
128 mSceneManager->destroyManualObject(mAreaObject);
131 template <
typename T>
134 setOutlineColor(color);
137 template <
typename T>
140 mOutlineColor = color;
144 template <
typename T>
151 template <
typename T>
155 boost::geometry::correct(p);
160 for (std::size_t i = 0; i < p.size(); ++i)
161 mPolygons.back().push_back(
Point3(p[i].x(), p[i].y(), 0));
166 template <
typename T>
174 mPolygons.push_back(p);
179 template <
typename T>
183 foreach(
const Polygon2& polygon, polygons)
186 boost::geometry::correct(p);
189 for (std::size_t i = 0; i < p.size(); ++i)
190 mPolygons.back().push_back(
Point3(p[i].x(), p[i].y(), 0));
196 template <
typename T>
199 mPolygons = polygons;
203 template <
typename T>
207 foreach(
const Polygon3& polygon, mPolygons)
208 count += polygon.size();
210 mOutlineObject->clear();
211 mOutlineObject->estimateVertexCount(count * 2);
213 mOutlineObject->begin(
"TransparentNoLight", Ogre::RenderOperation::OT_LINE_LIST);
215 foreach(
const Polygon3& polygon, mPolygons)
217 for (std::size_t i = 1; i < polygon.size(); ++i)
219 const Point3& a = polygon[i-1];
220 const Point3& b = polygon[i];
222 mOutlineObject->position(Ogre::Vector3(a.x(), a.y(), a.z()));
223 mOutlineObject->colour(mOutlineColor);
224 mOutlineObject->position(Ogre::Vector3(b.x(), b.y(), b.z()));
225 mOutlineObject->colour(mOutlineColor);
229 mOutlineObject->end();
231 mAreaObject->clear();
233 foreach(
const Polygon3& polygon, mPolygons)
235 mAreaObject->begin(
"TransparentNoLightTwoSided",
236 Ogre::RenderOperation::OT_TRIANGLE_FAN);
237 for (std::size_t i = 0; i < polygon.size(); ++i)
239 const Point3& p = polygon[i];
240 mAreaObject->position(Ogre::Vector3(p.x(), p.y(), p.z()));
241 mAreaObject->colour(mFillColor);
virtual void setColor(const Ogre::ColourValue &color)
Definition: PolygonObject.h:132
Ogre::ManualObject * mOutlineObject
Definition: PolygonObject.h:96
Ogre::ColourValue mOutlineColor
Definition: PolygonObject.h:98
void setupPolygons()
Definition: PolygonObject.h:204
Point< T, 3 > Point3
Definition: PolygonObject.h:71
Declaration of VisualizationObject.
Definition: PolygonObject.h:67
void setPolygon(const Polygon2 &polygon)
Definition: PolygonObject.h:152
Point< T, 2 > Point2
Definition: PolygonObject.h:70
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
std::vector< Polygon3 > mPolygons
Definition: PolygonObject.h:101
Definition: VisualizationObject.h:71
virtual ~PolygonObject()
Definition: PolygonObject.h:123
Specialization of Point for 2 dimensions with specialized constructors and converters.
Definition: Point.h:169
Specialization of Point for 3 dimensions with specialized constructors and converters.
Definition: Point.h:252
std::string toString(const T &value, int precision=-1)
Converts any data type to string (the data type must support the stream << operator).
Definition: ToString.h:256
const RGB Black(0.0f, 0.0f, 0.0f)
Ogre::SceneNode * mNode
Definition: VisualizationObject.h:99
void setPolygons(const std::vector< Polygon2 > &polygons)
Definition: PolygonObject.h:180
virtual void setOutlineColor(const Ogre::ColourValue &color)
Definition: PolygonObject.h:138
Ogre::SceneManager * mSceneManager
Definition: VisualizationObject.h:98
virtual void setFillColor(const Ogre::ColourValue &color)
Definition: PolygonObject.h:145
Simple Wrapper for Boost::geometry polygon.
boost::geometry::model::ring< Point3 > Polygon3
Definition: PolygonObject.h:73
Definition: ImageObject.h:60
PolygonObject(Ogre::SceneManager *sceneManager, Ogre::SceneNode *parent=NULL)
Definition: PolygonObject.h:107
Ogre::ManualObject * mAreaObject
Definition: PolygonObject.h:97
Non intrusive reflect for OGRE color class.
boost::geometry::model::ring< Point2 > Polygon2
Definition: PolygonObject.h:72
Ogre::ColourValue mFillColor
Definition: PolygonObject.h:99