mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-05 10:45:35 +00:00
transparent overlay
This commit is contained in:
parent
a04df37f83
commit
38828acac9
8 changed files with 68 additions and 2 deletions
|
@ -266,13 +266,17 @@ MapWindow::MapWindow(MWBase::WindowManager& parWindowManager, const std::string&
|
|||
mGlobalMapRender = new MWRender::GlobalMap(cacheDir);
|
||||
mGlobalMapRender->render();
|
||||
|
||||
mGlobalMapRender->exploreCell(0,0);
|
||||
|
||||
getWidget(mLocalMap, "LocalMap");
|
||||
getWidget(mGlobalMap, "GlobalMap");
|
||||
getWidget(mGlobalMapImage, "GlobalMapImage");
|
||||
getWidget(mGlobalMapOverlay, "GlobalMapOverlay");
|
||||
getWidget(mPlayerArrowLocal, "CompassLocal");
|
||||
getWidget(mPlayerArrowGlobal, "CompassGlobal");
|
||||
|
||||
mGlobalMapImage->setImageTexture("GlobalMap.png");
|
||||
mGlobalMapOverlay->setImageTexture("GlobalMapOverlay");
|
||||
|
||||
mGlobalMap->setVisible (false);
|
||||
|
||||
|
@ -328,6 +332,11 @@ void MapWindow::addVisitedLocation(const std::string& name, int x, int y)
|
|||
markerWidget->setUserString("Caption_Text", name);
|
||||
}
|
||||
|
||||
void MapWindow::cellExplored(int x, int y)
|
||||
{
|
||||
mGlobalMapRender->exploreCell(x,y);
|
||||
}
|
||||
|
||||
void MapWindow::onDragStart(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
|
||||
{
|
||||
if (_id!=MyGUI::MouseButton::Left) return;
|
||||
|
|
|
@ -70,6 +70,7 @@ namespace MWGui
|
|||
void setCellName(const std::string& cellName);
|
||||
|
||||
void addVisitedLocation(const std::string& name, int x, int y); // adds the marker to the global map
|
||||
void cellExplored(int x, int y);
|
||||
|
||||
virtual void open();
|
||||
|
||||
|
@ -82,6 +83,7 @@ namespace MWGui
|
|||
|
||||
MyGUI::ScrollView* mGlobalMap;
|
||||
MyGUI::ImageBox* mGlobalMapImage;
|
||||
MyGUI::ImageBox* mGlobalMapOverlay;
|
||||
MyGUI::ImageBox* mPlayerArrowLocal;
|
||||
MyGUI::ImageBox* mPlayerArrowGlobal;
|
||||
MyGUI::Button* mButton;
|
||||
|
|
|
@ -621,6 +621,8 @@ void WindowManager::changeCell(MWWorld::Ptr::CellStore* cell)
|
|||
name = getGameSettingString("sDefaultCellname", "Wilderness");
|
||||
}
|
||||
|
||||
mMap->cellExplored(cell->cell->getGridX(), cell->cell->getGridY());
|
||||
|
||||
mMap->setCellName( name );
|
||||
mHud->setCellName( name );
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <OgreColourValue.h>
|
||||
#include <OgreHardwareVertexBuffer.h>
|
||||
#include <OgreRoot.h>
|
||||
#include <OgreHardwarePixelBuffer.h>
|
||||
|
||||
#include "../mwbase/environment.hpp"
|
||||
#include "../mwbase/world.hpp"
|
||||
|
@ -47,6 +48,7 @@ namespace MWRender
|
|||
mWidth = cellSize*(mMaxX-mMinX+1);
|
||||
mHeight = cellSize*(mMaxY-mMinY+1);
|
||||
|
||||
mExploredBuffer.resize((mMaxX-mMinX+1) * (mMaxY-mMinY+1) * 4);
|
||||
|
||||
//if (!boost::filesystem::exists(mCacheDir + "/GlobalMap.png"))
|
||||
if (1)
|
||||
|
@ -179,5 +181,46 @@ namespace MWRender
|
|||
imageY = 1.f-float(y - mMinY + 1) / (mMaxY - mMinY + 1);
|
||||
}
|
||||
|
||||
void GlobalMap::exploreCell(int cellX, int cellY)
|
||||
{
|
||||
mExploredCells.push_back(std::make_pair(cellX, cellY));
|
||||
int width = mMaxX-mMinX+1;
|
||||
int height = mMaxY-mMinY+1;
|
||||
|
||||
if (mOverlayTexture.isNull())
|
||||
{
|
||||
mOverlayTexture = Ogre::TextureManager::getSingleton().createManual("GlobalMapOverlay", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
||||
Ogre::TEX_TYPE_2D, width, height, 0, Ogre::PF_A8B8G8R8, Ogre::TU_DYNAMIC_WRITE_ONLY);
|
||||
}
|
||||
|
||||
for (int x = mMinX; x <= mMaxX; ++x)
|
||||
{
|
||||
for (int y = mMinY; y <= mMaxY; ++y)
|
||||
{
|
||||
unsigned char r,g,b,a;
|
||||
r = 0;
|
||||
g = 0;
|
||||
b = 0;
|
||||
if (std::find(mExploredCells.begin(), mExploredCells.end(), std::make_pair(x, y)) != mExploredCells.end())
|
||||
a = 0;
|
||||
else
|
||||
a = 128;
|
||||
int texelX = (x-mMinX);
|
||||
int texelY = (height-1) - (y-mMinY);
|
||||
|
||||
assert( static_cast<unsigned int>(texelY * width * 4 + texelX * 4+3) < mExploredBuffer.size());
|
||||
mExploredBuffer[texelY * width * 4 + texelX * 4] = r;
|
||||
mExploredBuffer[texelY * width * 4 + texelX * 4+1] = g;
|
||||
mExploredBuffer[texelY * width * 4 + texelX * 4+2] = b;
|
||||
mExploredBuffer[texelY * width * 4 + texelX * 4+3] = a;
|
||||
}
|
||||
}
|
||||
|
||||
Ogre::Image image;
|
||||
image.loadDynamicImage(&mExploredBuffer[0], width, height, Ogre::PF_A8B8G8R8);
|
||||
|
||||
memcpy(mOverlayTexture->getBuffer()->lock(Ogre::HardwareBuffer::HBL_DISCARD),
|
||||
&mExploredBuffer[0], width*height*4);
|
||||
mOverlayTexture->getBuffer()->unlock();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include <string>
|
||||
|
||||
#include <OgreTexture.h>
|
||||
|
||||
namespace MWRender
|
||||
{
|
||||
|
||||
|
@ -22,9 +24,16 @@ namespace MWRender
|
|||
|
||||
void cellTopLeftCornerToImageSpace(int x, int y, float& imageX, float& imageY);
|
||||
|
||||
void exploreCell (int cellX, int cellY);
|
||||
|
||||
private:
|
||||
std::string mCacheDir;
|
||||
|
||||
std::vector< std::pair<int,int> > mExploredCells;
|
||||
|
||||
Ogre::TexturePtr mOverlayTexture;
|
||||
std::vector<Ogre::uchar> mExploredBuffer;
|
||||
|
||||
int mWidth;
|
||||
int mHeight;
|
||||
|
||||
|
|
|
@ -58,7 +58,6 @@ namespace MWRender
|
|||
*/
|
||||
void saveFogOfWar(MWWorld::CellStore* cell);
|
||||
|
||||
|
||||
/**
|
||||
* Get the interior map texture index and normalized position
|
||||
* on this texture, given a world position (in ogre coordinates)
|
||||
|
|
|
@ -23,7 +23,8 @@ namespace MWRender
|
|||
mFreeLook(true),
|
||||
mHeight(128.f),
|
||||
mCameraDistance(300.f),
|
||||
mDistanceAdjusted(false)
|
||||
mDistanceAdjusted(false),
|
||||
mAnimation(NULL)
|
||||
{
|
||||
mVanity.enabled = false;
|
||||
mVanity.allowed = true;
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
<Property key="CanvasSize" value="1536 1536"/>
|
||||
|
||||
<Widget type="ImageBox" skin="ImageBox" position_real="0 0 1 1" align="Stretch" name="GlobalMapImage">
|
||||
<Widget type="ImageBox" skin="ImageBox" position_real="0 0 1 1" align="Stretch" name="GlobalMapOverlay"/>
|
||||
</Widget>
|
||||
|
||||
<Widget type="ImageBox" skin="RotatingSkin" position="0 0 32 32" align="ALIGN_TOP ALIGN_LEFT" name="CompassGlobal">
|
||||
|
|
Loading…
Reference in a new issue