Various fixes as per feedback comments.

pull/300/head
cc9cii 10 years ago
parent 809b8c6d5b
commit 758ce0ed98

@ -272,7 +272,8 @@ endif ()
endif(OGRE_STATIC)
include_directories("."
${OGRE_INCLUDE_DIR} ${OGRE_INCLUDE_DIR}/Ogre ${OGRE_INCLUDE_DIR}/OGRE ${OGRE_INCLUDE_DIRS} ${OGRE_PLUGIN_INCLUDE_DIRS} ${OGRE_INCLUDE_DIR}/Overlay
${OGRE_INCLUDE_DIR} ${OGRE_INCLUDE_DIR}/Ogre ${OGRE_INCLUDE_DIR}/OGRE ${OGRE_INCLUDE_DIRS} ${OGRE_PLUGIN_INCLUDE_DIRS}
${OGRE_INCLUDE_DIR}/Ogre/Overlay ${OGRE_INCLUDE_DIR}/OGRE/Overlay ${OGRE_Overlay_INCLUDE_DIRS}
${SDL2_INCLUDE_DIR}
${Boost_INCLUDE_DIR}
${PLATFORM_INCLUDE_DIR}

@ -8,13 +8,13 @@
#include <OgreCamera.h>
#include <OgreSceneManager.h>
#include <OgreManualObject.h>
#include <OGRE/Overlay/OgreOverlayContainer.h>
#include <OGRE/Overlay/OgreOverlayManager.h>
#include <OgreOverlayContainer.h>
#include <OgreOverlayManager.h>
#include <OgreRoot.h>
#include <OgreSceneQuery.h>
#include <OgreEntity.h>
#include "../../../../components/esm/loadland.hpp"
#include <components/esm/loadland.hpp>
#include "textoverlay.hpp"
#include "../../model/world/tablemimedata.hpp"
@ -194,25 +194,14 @@ void CSVRender::PagedWorldspaceWidget::mouseDoubleClickEvent (QMouseEvent *event
}
void CSVRender::PagedWorldspaceWidget::updateOverlay()
{
Ogre::OverlayManager &overlayMgr = Ogre::OverlayManager::getSingleton();
Ogre::Overlay* overlay = overlayMgr.getByName("CellIDPanel");
if(overlay && !mTextOverlays.empty())
{
if(getCamera()->getViewport())
{
if((uint32_t)getCamera()->getViewport()->getVisibilityMask()
& (uint32_t)CSVRender::Element_CellMarker)
{
mDisplayCellCoord = true;
overlay->show();
}
else
{
mDisplayCellCoord = false;
overlay->hide();
}
}
}
if(!mTextOverlays.empty())
@ -220,6 +209,7 @@ void CSVRender::PagedWorldspaceWidget::updateOverlay()
std::map<CSMWorld::CellCoordinates, TextOverlay *>::iterator it = mTextOverlays.begin();
for(; it != mTextOverlays.end(); ++it)
{
it->second->enable(mDisplayCellCoord);
it->second->update();
}
}
@ -324,13 +314,20 @@ CSVRender::PagedWorldspaceWidget::~PagedWorldspaceWidget()
{
delete iter->second;
std::map<CSMWorld::CellCoordinates, Ogre::Entity *>::iterator it = mEntities.find(iter->first);
if(it != mEntities.end())
getSceneManager()->destroyManualObject("manual"+iter->first.getId(mWorldspace));
}
for (std::map<CSMWorld::CellCoordinates, Ogre::Entity *>::iterator iter (mEntities.begin());
iter != mEntities.end(); ++iter)
{
getSceneManager()->destroyEntity(it->second);
mEntities.erase(it);
getSceneManager()->destroyEntity(iter->second);
mEntities.erase(iter);
}
getSceneManager()->destroyManualObject("manual"+iter->first.getId(mWorldspace));
for (std::map<CSMWorld::CellCoordinates, TextOverlay *>::iterator iter (mTextOverlays.begin());
iter != mTextOverlays.end(); ++iter)
{
delete iter->second;
}
}

@ -11,7 +11,7 @@
#include <OgreCamera.h>
#include <OgreSceneNode.h>
#include <OgreViewport.h>
#include <OGRE/Overlay/OgreOverlaySystem.h>
#include <OgreOverlaySystem.h>
#include "../widget/scenetoolmode.hpp"
#include "../../model/settings/usersettings.hpp"
@ -21,6 +21,8 @@
namespace CSVRender
{
Ogre::OverlaySystem *SceneWidget::mOverlaySystem = NULL;
SceneWidget::SceneWidget(QWidget *parent)
: QWidget(parent)
, mCamera(NULL)
@ -60,7 +62,8 @@ namespace CSVRender
setLighting (&mLightingDay);
Ogre::OverlaySystem *mOverlaySystem = new Ogre::OverlaySystem();
if(!mOverlaySystem)
mOverlaySystem = new Ogre::OverlaySystem();
mSceneMgr->addRenderQueueListener(mOverlaySystem);
QTimer *timer = new QTimer (this);
@ -164,11 +167,8 @@ namespace CSVRender
if (mWindow)
Ogre::Root::getSingleton().destroyRenderTarget (mWindow);
if (mOverlaySystem)
{
if (mSceneMgr)
mSceneMgr->removeRenderQueueListener (mOverlaySystem);
}
if (mSceneMgr)
Ogre::Root::getSingleton().destroySceneManager (mSceneMgr);

@ -90,7 +90,7 @@ namespace CSVRender
Ogre::SceneManager* mSceneMgr;
Ogre::RenderWindow* mWindow;
Ogre::Viewport *mViewport;
Ogre::OverlaySystem *mOverlaySystem;
static Ogre::OverlaySystem *mOverlaySystem;
Navigation *mNavigation;
Lighting *mLighting;

@ -4,10 +4,10 @@
#include <OgreMaterialManager.h>
#include <OgreTechnique.h>
#include <OGRE/Overlay/OgreOverlayManager.h>
#include <OGRE/Overlay/OgreOverlayContainer.h>
#include <OGRE/Overlay/OgreFontManager.h>
#include <OGRE/Overlay/OgreTextAreaOverlayElement.h>
#include <OgreOverlayManager.h>
#include <OgreOverlayContainer.h>
#include <OgreFontManager.h>
#include <OgreTextAreaOverlayElement.h>
#include <OgreEntity.h>
#include <OgreViewport.h>
#include <OgreRoot.h>
@ -27,18 +27,19 @@ namespace CSVRender
// http://www.ogre3d.org/tikiwiki/Creating+dynamic+textures
// http://www.ogre3d.org/tikiwiki/ManualObject
TextOverlay::TextOverlay(const Ogre::MovableObject* obj, const Ogre::Camera* camera, const Ogre::String& id)
: mOverlay(0), mCaption(""), mDesc(""), mEnabled(true), mCamera(camera), mObj(obj), mId(id), mOnScreen(false)
, mFontHeight(16) // FIXME: make font height configurable
: mOverlay(0), mCaption(""), mDesc(""), mEnabled(true), mCamera(camera), mObj(obj), mId(id)
, mOnScreen(false) , mInstance(0), mFontHeight(16) // FIXME: make font height configurable
{
if(id == "" || !camera || !obj)
throw std::runtime_error("TextOverlay could not be created.");
// setup font
if (Ogre::FontManager::getSingleton().resourceExists("DejaVuLGC"))
mFont = Ogre::FontManager::getSingleton().getByName("DejaVuLGC","General");
Ogre::FontManager &fontMgr = Ogre::FontManager::getSingleton();
if (fontMgr.resourceExists("DejaVuLGC"))
mFont = fontMgr.getByName("DejaVuLGC","General");
else
{
mFont = Ogre::FontManager::getSingleton().create("DejaVuLGC","General");
mFont = fontMgr.create("DejaVuLGC","General");
mFont->setType(Ogre::FT_TRUETYPE);
mFont->setSource("DejaVuLGCSansMono.ttf");
mFont->setTrueTypeSize(mFontHeight);
@ -51,9 +52,13 @@ TextOverlay::TextOverlay(const Ogre::MovableObject* obj, const Ogre::Camera* cam
// setup overlay
Ogre::OverlayManager &overlayMgr = Ogre::OverlayManager::getSingleton();
mOverlay = overlayMgr.getByName("CellIDPanel");
if(!mOverlay)
mOverlay = overlayMgr.create("CellIDPanel");
mOverlay = overlayMgr.getByName("CellIDPanel"+mId+Ogre::StringConverter::toString(mInstance));
while(mOverlay != NULL)
{
mInstance++;
mOverlay = overlayMgr.getByName("CellIDPanel"+mId+Ogre::StringConverter::toString(mInstance));
}
mOverlay = overlayMgr.create("CellIDPanel"+mId+Ogre::StringConverter::toString(mInstance));
// create texture
Ogre::TexturePtr texture = Ogre::TextureManager::getSingleton().getByName("DynamicTransBlue");
@ -93,7 +98,12 @@ TextOverlay::TextOverlay(const Ogre::MovableObject* obj, const Ogre::Camera* cam
}
// setup material for containers
Ogre::MaterialPtr mQuadMaterial = Ogre::MaterialManager::getSingleton().create("TransOverlayMaterial",
Ogre::MaterialPtr mQuadMaterial = Ogre::MaterialManager::getSingleton().getByName(
"TransOverlayMaterial");
if(mQuadMaterial.isNull())
{
Ogre::MaterialPtr mQuadMaterial = Ogre::MaterialManager::getSingleton().create(
"TransOverlayMaterial",
Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, true );
Ogre::Pass *pass = mQuadMaterial->getTechnique( 0 )->getPass( 0 );
pass->setLightingEnabled( false );
@ -104,13 +114,16 @@ TextOverlay::TextOverlay(const Ogre::MovableObject* obj, const Ogre::Camera* cam
tex->setTextureName("DynamicTransBlue");
tex->setTextureFiltering( Ogre::TFO_ANISOTROPIC );
mQuadMaterial->load();
}
mContainer = static_cast<Ogre::OverlayContainer*>(overlayMgr.createOverlayElement("Panel", "container"+mId));
mContainer = static_cast<Ogre::OverlayContainer*>(overlayMgr.createOverlayElement(
"Panel", "container"+mId +"#"+Ogre::StringConverter::toString(mInstance)));
mContainer->setMaterialName("TransOverlayMaterial");
mOverlay->add2D(mContainer);
// setup text area overlay element
mElement = static_cast<Ogre::TextAreaOverlayElement*>(overlayMgr.createOverlayElement("TextArea", "text"+mId));
mElement = static_cast<Ogre::TextAreaOverlayElement*>(overlayMgr.createOverlayElement(
"TextArea", "text"+mId +"#"+Ogre::StringConverter::toString(mInstance)));
mElement->setMetricsMode(Ogre::GMM_RELATIVE);
mElement->setDimensions(1.0, 1.0);
mElement->setMetricsMode(Ogre::GMM_PIXELS);
@ -197,10 +210,8 @@ TextOverlay::~TextOverlay()
mOverlay->hide();
Ogre::OverlayManager *overlayMgr = Ogre::OverlayManager::getSingletonPtr();
mContainer->removeChild("text"+mId);
mContainer->removeChild("text"+mId+"#"+Ogre::StringConverter::toString(mInstance));
mOverlay->remove2D(mContainer);
overlayMgr->destroyOverlayElement(mElement);
overlayMgr->destroyOverlayElement(mContainer);
if(!iter.hasMoreElements())
overlayMgr->destroy(mOverlay);
@ -208,14 +219,14 @@ TextOverlay::~TextOverlay()
void TextOverlay::enable(bool enable)
{
if(enable == mContainer->isVisible())
if(enable == mOverlay->isVisible())
return;
mEnabled = enable;
if (enable)
mContainer->show();
mOverlay->show();
else
mContainer->hide();
mOverlay->hide();
}
bool TextOverlay::isEnabled()
@ -282,7 +293,6 @@ void TextOverlay::update()
{
mOnScreen = false;
mContainer->hide();
Ogre::Root::getSingleton().renderOneFrame();
return;
}
@ -306,8 +316,6 @@ void TextOverlay::update()
mContainer->setDimensions(relTextWidth, relTextHeight);
mPos = QRect(posX*viewportWidth, posY*viewportHeight, width, height);
Ogre::Root::getSingleton().renderOneFrame();
}
QRect TextOverlay::container()

@ -4,7 +4,7 @@
#include <QRect>
#include <OgreString.h>
#include <OGRE/Overlay/OgreFont.h>
#include <OgreFont.h>
namespace Ogre
{
@ -36,6 +36,7 @@ namespace CSVRender
bool mEnabled;
bool mOnScreen; // not used
int mInstance;
Ogre::FontPtr getFont();
int textWidth();

@ -364,6 +364,9 @@ macro(ogre_find_component COMPONENT HEADER)
make_library_set(OGRE_${COMPONENT}_LIBRARY)
findpkg_finish(OGRE_${COMPONENT})
if (OGRE_${COMPONENT}_FOUND)
if (OGRE_${COMPONENT}_INCLUDE_DIR)
set(OGRE_${COMPONENT}_INCLUDE_DIRS ${OGRE_${COMPONENT}_INCLUDE_DIR})
endif()
# find binaries
if (NOT OGRE_STATIC)
if (WIN32)

Loading…
Cancel
Save