123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- #if defined(TARGET_HAS_ThirdPartyOgre3D)
-
- #include "ovassvepCBasicPainter.h"
- #include "ovassvepCApplication.h"
-
- #if (OGRE_VERSION_MAJOR > 1) || ((OGRE_VERSION_MAJOR == 1) && (OGRE_VERSION_MINOR >= 9))
- #include "Overlay/OgreOverlayManager.h"
- #include "Overlay/OgreOverlaySystem.h"
- #endif
-
- namespace OpenViBE {
- namespace SSVEP {
-
- //---------------------------------------------------------------------------------------------------
- CBasicPainter::CBasicPainter(CApplication* application)
- : m_application(application), m_sceneManager(application->getSceneManager())
- {
- m_aabInf.setInfinite();
-
- #if (OGRE_VERSION_MAJOR > 1) || ((OGRE_VERSION_MAJOR == 1) && (OGRE_VERSION_MINOR >= 9))
- // on Ogre 1.9, overlay system needs to be manually created
- Ogre::OverlaySystem* pOverlaySystem = OGRE_NEW Ogre::OverlaySystem();
- m_sceneManager->addRenderQueueListener(pOverlaySystem);
- #endif
-
- m_overlayManager = Ogre::OverlayManager::getSingletonPtr();
-
- (m_application->getLogManager()) << Kernel::LogLevel_Debug << " + Creating OverlayManager\n";
- Ogre::Overlay* overlay = m_overlayManager->create("TextOverlay");
-
-
- m_overlayContainer = dynamic_cast<Ogre::OverlayContainer*>(m_overlayManager->createOverlayElement("Panel", "TextContainer"));
- m_overlayContainer->setDimensions(1, 1);
- m_overlayContainer->setPosition(0, 0);
-
- overlay->add2D(m_overlayContainer);
- overlay->show();
- }
-
-
- //---------------------------------------------------------------------------------------------------
- Ogre::ManualObject* CBasicPainter::paintRectangle(const Ogre::RealRect& oRectangle, const Ogre::ColourValue color, const int plane) const
- {
- Ogre::ManualObject* object = m_sceneManager->createManualObject();
- object->begin("BasicSurface/Diffuse", Ogre::RenderOperation::OT_TRIANGLE_FAN);
- object->setUseIdentityProjection(true);
- object->setUseIdentityView(true);
-
- object->position(oRectangle.right, oRectangle.top, 0.0);
- object->colour(color);
- object->index(0);
-
- object->position(oRectangle.left, oRectangle.top, 0.0);
- object->colour(color);
- object->index(1);
-
- object->position(oRectangle.left, oRectangle.bottom, 0.0);
- object->colour(color);
- object->index(2);
-
- object->position(oRectangle.right, oRectangle.bottom, 0.0);
- object->colour(color);
- object->index(3);
-
- object->index(0);
-
- object->end();
-
- object->setBoundingBox(m_aabInf);
- object->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY - plane);
-
- object->setVisible(true);
-
- return object;
- }
-
-
- //---------------------------------------------------------------------------------------------------
- Ogre::ManualObject* CBasicPainter::paintTriangle(const Point p1, const Point p2, const Point p3, const Ogre::ColourValue color, const int plane) const
- {
- Ogre::ManualObject* object = m_sceneManager->createManualObject();
- object->begin("BasicSurface/Diffuse", Ogre::RenderOperation::OT_TRIANGLE_FAN);
- object->setUseIdentityProjection(true);
- object->setUseIdentityView(true);
-
- object->position(p1.m_X, p1.m_Y, 0.0);
- object->colour(color);
- object->index(0);
-
- object->position(p2.m_X, p2.m_Y, 0.0);
- object->colour(color);
- object->index(1);
-
- object->position(p3.m_X, p3.m_Y, 0.0);
- object->colour(color);
- object->index(2);
-
- object->index(0);
-
- object->end();
-
- object->setBoundingBox(m_aabInf);
- object->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY - plane);
-
- object->setVisible(true);
-
- return object;
- }
-
- //---------------------------------------------------------------------------------------------------
- Ogre::ManualObject* CBasicPainter::paintCircle(const Ogre::Real rX, const Ogre::Real rY, const Ogre::Real rR, const Ogre::ColourValue color,
- const bool bFilled, const int plane) const
- {
- Ogre::ManualObject* object = m_sceneManager->createManualObject();
-
- if (bFilled) { object->begin("BasicSurface/Diffuse", Ogre::RenderOperation::OT_TRIANGLE_FAN); }
- else { object->begin("BasicSurface/Diffuse", Ogre::RenderOperation::OT_LINE_STRIP); }
-
- object->setUseIdentityProjection(true);
- object->setUseIdentityView(true);
-
- float const fAccuracy = 16;
- unsigned uiIndex = 0;
-
- for (float theta = 0; theta <= 2 * Ogre::Math::PI; theta += Ogre::Math::PI / fAccuracy)
- {
- object->position(rX + rR * cos(theta), rY + rR * sin(theta), 0);
- object->colour(color);
- object->index(uiIndex++);
- }
-
- object->index(0);
-
- object->end();
-
- object->setBoundingBox(m_aabInf);
- object->setRenderQueueGroup(Ogre::RENDER_QUEUE_OVERLAY - plane);
-
- object->setVisible(true);
-
- return object;
- }
-
- //---------------------------------------------------------------------------------------------------
- void CBasicPainter::paintText(const std::string& sID, const std::string& sText, const Ogre::Real rX, const Ogre::Real rY,
- const Ogre::Real rWidth, const Ogre::Real rHeight, const Ogre::ColourValue& color) const
- {
- Ogre::OverlayElement* text = m_overlayManager->createOverlayElement("TextArea", sID);
- text->setDimensions(rWidth, rHeight);
- text->setMetricsMode(Ogre::GMM_PIXELS);
- text->setPosition(rX, rY);
- text->setParameter("font_name", "DejaVu");
- text->setColour(color);
- text->setCaption(sText);
- m_overlayContainer->addChild(text);
- }
-
-
- #endif
-
- } // namespace SSVEP
- } // namespace OpenViBE
|