47 #ifndef _MIRA_POLYGONOBJECT_H_ 48 #define _MIRA_POLYGONOBJECT_H_ 53 #include <boost/geometry/algorithms/correct.hpp> 58 #include <OGRE/OgreSceneManager.h> 59 #include <OGRE/OgreSceneNode.h> 60 #include <OGRE/OgreManualObject.h> 61 #include <OGRE/OgreMaterialManager.h> 74 typedef boost::geometry::model::ring<Point2>
Polygon2;
75 typedef boost::geometry::model::ring<Point3>
Polygon3;
78 PolygonObject(Ogre::SceneManager* sceneManager, Ogre::SceneNode* parent = NULL);
82 virtual void setColor(
const Ogre::ColourValue& color);
87 virtual void setFillColor(
const Ogre::ColourValue& color);
92 void setPolygons(
const std::vector<Polygon2>& polygons);
93 void setPolygons(
const std::vector<Polygon3>& polygons);
108 template <
typename T>
111 mOutlineColor(
Ogre::ColourValue::
Black), mFillColor(0.f, 0.f, 0.f, 0.f)
124 template <
typename T>
127 mNode->detachObject(mOutlineObject);
128 mSceneManager->destroyManualObject(mOutlineObject);
129 mNode->detachObject(mAreaObject);
130 mSceneManager->destroyManualObject(mAreaObject);
133 template <
typename T>
136 setOutlineColor(color);
139 template <
typename T>
142 mOutlineColor = color;
146 template <
typename T>
153 template <
typename T>
157 boost::geometry::correct(p);
162 for (std::size_t i = 0; i < p.size(); ++i)
163 mPolygons.back().push_back(
Point3(p[i].x(), p[i].y(), 0));
168 template <
typename T>
176 mPolygons.push_back(p);
181 template <
typename T>
185 foreach(
const Polygon2& polygon, polygons)
188 boost::geometry::correct(p);
191 for (std::size_t i = 0; i < p.size(); ++i)
192 mPolygons.back().push_back(
Point3(p[i].x(), p[i].y(), 0));
198 template <
typename T>
201 mPolygons = polygons;
205 template <
typename T>
209 foreach(
const Polygon3& polygon, mPolygons)
210 count += polygon.size();
212 mOutlineObject->clear();
213 mOutlineObject->estimateVertexCount(count * 2);
215 mOutlineObject->begin(
"TransparentNoLight", Ogre::RenderOperation::OT_LINE_LIST);
217 foreach(
const Polygon3& polygon, mPolygons)
219 for (std::size_t i = 1; i < polygon.size(); ++i)
221 const Point3& a = polygon[i-1];
222 const Point3& b = polygon[i];
224 mOutlineObject->position(Ogre::Vector3(a.x(), a.y(), a.z()));
225 mOutlineObject->colour(mOutlineColor);
226 mOutlineObject->position(Ogre::Vector3(b.x(), b.y(), b.z()));
227 mOutlineObject->colour(mOutlineColor);
231 mOutlineObject->end();
233 mAreaObject->clear();
235 foreach(
const Polygon3& polygon, mPolygons)
237 mAreaObject->begin(
"TransparentNoLightTwoSided",
238 Ogre::RenderOperation::OT_TRIANGLE_FAN);
239 for (std::size_t i = 0; i < polygon.size(); ++i)
241 const Point3& p = polygon[i];
242 mAreaObject->position(Ogre::Vector3(p.x(), p.y(), p.z()));
243 mAreaObject->colour(mFillColor);
virtual void setColor(const Ogre::ColourValue &color)
Definition: PolygonObject.h:134
Ogre::ManualObject * mOutlineObject
Definition: PolygonObject.h:98
Ogre::ColourValue mOutlineColor
Definition: PolygonObject.h:100
void setupPolygons()
Definition: PolygonObject.h:206
Point< T, 3 > Point3
Definition: PolygonObject.h:73
Declaration of VisualizationObject.
Definition: PolygonObject.h:69
void setPolygon(const Polygon2 &polygon)
Definition: PolygonObject.h:154
Point< T, 2 > Point2
Definition: PolygonObject.h:72
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
std::vector< Polygon3 > mPolygons
Definition: PolygonObject.h:103
Definition: VisualizationObject.h:70
virtual ~PolygonObject()
Definition: PolygonObject.h:125
Specialization of Point for 2 dimensions with specialized constructors and converters.
Definition: Point.h:174
Specialization of Point for 3 dimensions with specialized constructors and converters.
Definition: Point.h:257
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:252
const RGB Black(0.0f, 0.0f, 0.0f)
Ogre::SceneNode * mNode
Definition: VisualizationObject.h:98
void setPolygons(const std::vector< Polygon2 > &polygons)
Definition: PolygonObject.h:182
virtual void setOutlineColor(const Ogre::ColourValue &color)
Definition: PolygonObject.h:140
Ogre::SceneManager * mSceneManager
Definition: VisualizationObject.h:97
virtual void setFillColor(const Ogre::ColourValue &color)
Definition: PolygonObject.h:147
Simple Wrapper for Boost::geometry polygon.
boost::geometry::model::ring< Point3 > Polygon3
Definition: PolygonObject.h:75
Definition: ImageObject.h:60
PolygonObject(Ogre::SceneManager *sceneManager, Ogre::SceneNode *parent=NULL)
Definition: PolygonObject.h:109
Ogre::ManualObject * mAreaObject
Definition: PolygonObject.h:99
Non intrusive reflect for OGRE color class.
boost::geometry::model::ring< Point2 > Polygon2
Definition: PolygonObject.h:74
Ogre::ColourValue mFillColor
Definition: PolygonObject.h:101