mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-05 16:45:34 +00:00
Incorporate terrain height to labels and camera.
This commit is contained in:
parent
bfd10a03c0
commit
3e5027abbb
3 changed files with 33 additions and 19 deletions
|
@ -214,3 +214,11 @@ bool CSVRender::Cell::referenceAdded (const QModelIndex& parent, int start, int
|
||||||
|
|
||||||
return addObjects (start, end);
|
return addObjects (start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float CSVRender::Cell::getTerrainHeightAt(const Ogre::Vector3 &pos) const
|
||||||
|
{
|
||||||
|
if(mTerrain.get() != NULL)
|
||||||
|
return mTerrain->getHeightAt(pos);
|
||||||
|
else
|
||||||
|
return -std::numeric_limits<float>::max();
|
||||||
|
}
|
||||||
|
|
|
@ -70,6 +70,8 @@ namespace CSVRender
|
||||||
/// \return Did this call result in a modification of the visual representation of
|
/// \return Did this call result in a modification of the visual representation of
|
||||||
/// this cell?
|
/// this cell?
|
||||||
bool referenceAdded (const QModelIndex& parent, int start, int end);
|
bool referenceAdded (const QModelIndex& parent, int start, int end);
|
||||||
|
|
||||||
|
float getTerrainHeightAt(const Ogre::Vector3 &pos) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,7 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells()
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// check if name or region field has changed
|
// check if name or region field has changed
|
||||||
|
// FIXME: config setting
|
||||||
std::string name = cells.getRecord(index).get().mName;
|
std::string name = cells.getRecord(index).get().mName;
|
||||||
std::string region = cells.getRecord(index).get().mRegion;
|
std::string region = cells.getRecord(index).get().mRegion;
|
||||||
|
|
||||||
|
@ -113,26 +114,34 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells()
|
||||||
if (index > 0 && cells.getRecord (index).mState!=CSMWorld::RecordBase::State_Deleted &&
|
if (index > 0 && cells.getRecord (index).mState!=CSMWorld::RecordBase::State_Deleted &&
|
||||||
mCells.find (*iter)==mCells.end())
|
mCells.find (*iter)==mCells.end())
|
||||||
{
|
{
|
||||||
|
Cell *cell = new Cell (mDocument.getData(), getSceneManager(), iter->getId (mWorldspace));
|
||||||
|
mCells.insert (std::make_pair (*iter, cell));
|
||||||
|
|
||||||
|
float height = cell->getTerrainHeightAt(Ogre::Vector3(
|
||||||
|
ESM::Land::REAL_SIZE * iter->getX() + ESM::Land::REAL_SIZE/2,
|
||||||
|
ESM::Land::REAL_SIZE * iter->getY() + ESM::Land::REAL_SIZE/2,
|
||||||
|
0));
|
||||||
if (setCamera)
|
if (setCamera)
|
||||||
{
|
{
|
||||||
setCamera = false;
|
setCamera = false;
|
||||||
getCamera()->setPosition (ESM::Land::REAL_SIZE * iter->getX() + ESM::Land::REAL_SIZE/2,
|
getCamera()->setPosition (
|
||||||
ESM::Land::REAL_SIZE * iter->getY() + ESM::Land::REAL_SIZE/2, 0);
|
ESM::Land::REAL_SIZE * iter->getX() + ESM::Land::REAL_SIZE/2,
|
||||||
|
ESM::Land::REAL_SIZE * iter->getY() + ESM::Land::REAL_SIZE/2,
|
||||||
|
height);
|
||||||
|
// better camera position at the start
|
||||||
|
getCamera()->move(getCamera()->getDirection() * -6000); // FIXME: config setting
|
||||||
}
|
}
|
||||||
|
|
||||||
mCells.insert (std::make_pair (*iter,
|
Ogre::ManualObject* manual =
|
||||||
new Cell (mDocument.getData(), getSceneManager(), iter->getId (mWorldspace))));
|
getSceneManager()->createManualObject("manual" + iter->getId(mWorldspace));
|
||||||
|
|
||||||
Ogre::ManualObject* manual = getSceneManager()->createManualObject("manual" + iter->getId(mWorldspace));
|
|
||||||
|
|
||||||
manual->begin("BaseWhite", Ogre::RenderOperation::OT_LINE_LIST);
|
manual->begin("BaseWhite", Ogre::RenderOperation::OT_LINE_LIST);
|
||||||
|
|
||||||
// define start and end point (x, y, z)
|
// define start and end point (x, y, z)
|
||||||
// FIXME: need terrain height to get the correct starting point
|
|
||||||
manual-> position(ESM::Land::REAL_SIZE * iter->getX() + ESM::Land::REAL_SIZE/2,
|
manual-> position(ESM::Land::REAL_SIZE * iter->getX() + ESM::Land::REAL_SIZE/2,
|
||||||
ESM::Land::REAL_SIZE * iter->getY() + ESM::Land::REAL_SIZE/2, 0);
|
ESM::Land::REAL_SIZE * iter->getY() + ESM::Land::REAL_SIZE/2,
|
||||||
|
height);
|
||||||
manual-> position(ESM::Land::REAL_SIZE * iter->getX() + ESM::Land::REAL_SIZE/2,
|
manual-> position(ESM::Land::REAL_SIZE * iter->getX() + ESM::Land::REAL_SIZE/2,
|
||||||
ESM::Land::REAL_SIZE * iter->getY() + ESM::Land::REAL_SIZE/2, 2000);
|
ESM::Land::REAL_SIZE * iter->getY() + ESM::Land::REAL_SIZE/2,
|
||||||
|
height+2000); // FIXME: config setting
|
||||||
manual->end();
|
manual->end();
|
||||||
Ogre::MeshPtr meshPtr = manual->convertToMesh("vLine" + iter->getId(mWorldspace));
|
Ogre::MeshPtr meshPtr = manual->convertToMesh("vLine" + iter->getId(mWorldspace));
|
||||||
Ogre::Entity* entity = getSceneManager()->createEntity(meshPtr);
|
Ogre::Entity* entity = getSceneManager()->createEntity(meshPtr);
|
||||||
|
@ -142,12 +151,13 @@ bool CSVRender::PagedWorldspaceWidget::adjustCells()
|
||||||
// keep pointers so that they can be deleted later
|
// keep pointers so that they can be deleted later
|
||||||
mEntities.insert(std::make_pair(*iter, entity));
|
mEntities.insert(std::make_pair(*iter, entity));
|
||||||
|
|
||||||
CSVRender::TextOverlay *textDisp = new CSVRender::TextOverlay(entity, getCamera(), iter->getId(mWorldspace));
|
CSVRender::TextOverlay *textDisp =
|
||||||
|
new CSVRender::TextOverlay(entity, getCamera(), iter->getId(mWorldspace));
|
||||||
textDisp->enable(true);
|
textDisp->enable(true);
|
||||||
textDisp->setCaption(iter->getId(mWorldspace));
|
textDisp->setCaption(iter->getId(mWorldspace));
|
||||||
std::string desc = cells.getRecord(index).get().mName;
|
std::string desc = cells.getRecord(index).get().mName;
|
||||||
if(desc == "") desc = cells.getRecord(index).get().mRegion;
|
if(desc == "") desc = cells.getRecord(index).get().mRegion;
|
||||||
textDisp->setDesc(desc);
|
textDisp->setDesc(desc); // FIXME: config setting
|
||||||
textDisp->update();
|
textDisp->update();
|
||||||
mTextOverlays.insert(std::make_pair(*iter, textDisp));
|
mTextOverlays.insert(std::make_pair(*iter, textDisp));
|
||||||
|
|
||||||
|
@ -185,12 +195,6 @@ void CSVRender::PagedWorldspaceWidget::mouseDoubleClickEvent (QMouseEvent *event
|
||||||
|
|
||||||
void CSVRender::PagedWorldspaceWidget::updateOverlay()
|
void CSVRender::PagedWorldspaceWidget::updateOverlay()
|
||||||
{
|
{
|
||||||
// better camera position at the start
|
|
||||||
if(getCamera()->getViewport() && getCamera()->getPosition().z < 1)
|
|
||||||
{
|
|
||||||
getCamera()->move(getCamera()->getDirection() * -6000);
|
|
||||||
}
|
|
||||||
|
|
||||||
Ogre::OverlayManager &overlayMgr = Ogre::OverlayManager::getSingleton();
|
Ogre::OverlayManager &overlayMgr = Ogre::OverlayManager::getSingleton();
|
||||||
Ogre::Overlay* overlay = overlayMgr.getByName("CellIDPanel");
|
Ogre::Overlay* overlay = overlayMgr.getByName("CellIDPanel");
|
||||||
if(overlay && !mTextOverlays.empty())
|
if(overlay && !mTextOverlays.empty())
|
||||||
|
|
Loading…
Reference in a new issue