|
|
@ -66,108 +66,83 @@ namespace MWRender
|
|
|
|
loadingListener->setProgressRange((mMaxX-mMinX+1) * (mMaxY-mMinY+1));
|
|
|
|
loadingListener->setProgressRange((mMaxX-mMinX+1) * (mMaxY-mMinY+1));
|
|
|
|
loadingListener->setProgress(0);
|
|
|
|
loadingListener->setProgress(0);
|
|
|
|
|
|
|
|
|
|
|
|
const Ogre::ColourValue waterShallowColour(0.15, 0.2, 0.19);
|
|
|
|
std::vector<Ogre::uchar> data (mWidth * mHeight * 3);
|
|
|
|
const Ogre::ColourValue waterDeepColour(0.1, 0.14, 0.13);
|
|
|
|
|
|
|
|
const Ogre::ColourValue groundColour(0.254, 0.19, 0.13);
|
|
|
|
|
|
|
|
const Ogre::ColourValue mountainColour(0.05, 0.05, 0.05);
|
|
|
|
|
|
|
|
const Ogre::ColourValue hillColour(0.16, 0.12, 0.08);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if (!boost::filesystem::exists(mCacheDir + "/GlobalMap.png"))
|
|
|
|
|
|
|
|
if (1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::vector<Ogre::uchar> data (mWidth * mHeight * 3);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int x = mMinX; x <= mMaxX; ++x)
|
|
|
|
for (int x = mMinX; x <= mMaxX; ++x)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for (int y = mMinY; y <= mMaxY; ++y)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (int y = mMinY; y <= mMaxY; ++y)
|
|
|
|
ESM::Land* land = esmStore.get<ESM::Land>().search (x,y);
|
|
|
|
{
|
|
|
|
|
|
|
|
ESM::Land* land = esmStore.get<ESM::Land>().search (x,y);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (land)
|
|
|
|
if (land)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int mask = ESM::Land::DATA_VHGT | ESM::Land::DATA_VNML | ESM::Land::DATA_VCLR | ESM::Land::DATA_VTEX;
|
|
|
|
int mask = ESM::Land::DATA_WNAM;
|
|
|
|
if (!land->isDataLoaded(mask))
|
|
|
|
if (!land->isDataLoaded(mask))
|
|
|
|
land->loadData(mask);
|
|
|
|
land->loadData(mask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (int cellY=0; cellY<mCellSize; ++cellY)
|
|
|
|
for (int cellY=0; cellY<mCellSize; ++cellY)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
for (int cellX=0; cellX<mCellSize; ++cellX)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (int cellX=0; cellX<mCellSize; ++cellX)
|
|
|
|
int vertexX = float(cellX)/float(mCellSize) * 9;
|
|
|
|
{
|
|
|
|
int vertexY = float(cellY)/float(mCellSize) * 9;
|
|
|
|
int vertexX = float(cellX)/float(mCellSize) * ESM::Land::LAND_SIZE;
|
|
|
|
|
|
|
|
int vertexY = float(cellY)/float(mCellSize) * ESM::Land::LAND_SIZE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int texelX = (x-mMinX) * mCellSize + cellX;
|
|
|
|
int texelX = (x-mMinX) * mCellSize + cellX;
|
|
|
|
int texelY = (mHeight-1) - ((y-mMinY) * mCellSize + cellY);
|
|
|
|
int texelY = (mHeight-1) - ((y-mMinY) * mCellSize + cellY);
|
|
|
|
|
|
|
|
|
|
|
|
unsigned char r,g,b;
|
|
|
|
unsigned char r,g,b;
|
|
|
|
|
|
|
|
|
|
|
|
if (land)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const float landHeight = land->mLandData->mHeights[vertexY * ESM::Land::LAND_SIZE + vertexX];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (landHeight >= 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const float hillHeight = 2500.f;
|
|
|
|
|
|
|
|
if (landHeight >= hillHeight)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const float mountainHeight = 15000.f;
|
|
|
|
|
|
|
|
float factor = std::min(1.f, float(landHeight-hillHeight)/mountainHeight);
|
|
|
|
|
|
|
|
r = (hillColour.r * (1-factor) + mountainColour.r * factor) * 255;
|
|
|
|
|
|
|
|
g = (hillColour.g * (1-factor) + mountainColour.g * factor) * 255;
|
|
|
|
|
|
|
|
b = (hillColour.b * (1-factor) + mountainColour.b * factor) * 255;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
float factor = std::min(1.f, float(landHeight)/hillHeight);
|
|
|
|
|
|
|
|
r = (groundColour.r * (1-factor) + hillColour.r * factor) * 255;
|
|
|
|
|
|
|
|
g = (groundColour.g * (1-factor) + hillColour.g * factor) * 255;
|
|
|
|
|
|
|
|
b = (groundColour.b * (1-factor) + hillColour.b * factor) * 255;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (landHeight >= -100)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
float factor = std::min(1.f, -1*landHeight/100.f);
|
|
|
|
|
|
|
|
r = (((waterShallowColour+groundColour)/2).r * (1-factor) + waterShallowColour.r * factor) * 255;
|
|
|
|
|
|
|
|
g = (((waterShallowColour+groundColour)/2).g * (1-factor) + waterShallowColour.g * factor) * 255;
|
|
|
|
|
|
|
|
b = (((waterShallowColour+groundColour)/2).b * (1-factor) + waterShallowColour.b * factor) * 255;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
float factor = std::min(1.f, -1*(landHeight-100)/1000.f);
|
|
|
|
|
|
|
|
r = (waterShallowColour.r * (1-factor) + waterDeepColour.r * factor) * 255;
|
|
|
|
|
|
|
|
g = (waterShallowColour.g * (1-factor) + waterDeepColour.g * factor) * 255;
|
|
|
|
|
|
|
|
b = (waterShallowColour.b * (1-factor) + waterDeepColour.b * factor) * 255;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
float y = 0;
|
|
|
|
|
|
|
|
if (land && land->mDataTypes & ESM::Land::DATA_WNAM)
|
|
|
|
|
|
|
|
y = (land->mLandData->mWnam[vertexY * 9 + vertexX] << 4) / 2048.f;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
y = (SCHAR_MIN << 4) / 2048.f;
|
|
|
|
|
|
|
|
if (y < 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
r = (14 * y + 38);
|
|
|
|
|
|
|
|
g = 20 * y + 56;
|
|
|
|
|
|
|
|
b = 18 * y + 51;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (y < 0.3f)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (y < 0.1f)
|
|
|
|
|
|
|
|
y *= 8.f;
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
r = waterDeepColour.r * 255;
|
|
|
|
y -= 0.1;
|
|
|
|
g = waterDeepColour.g * 255;
|
|
|
|
y += 0.8;
|
|
|
|
b = waterDeepColour.b * 255;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
r = 66 - 32 * y;
|
|
|
|
data[texelY * mWidth * 3 + texelX * 3] = r;
|
|
|
|
g = 48 - 23 * y;
|
|
|
|
data[texelY * mWidth * 3 + texelX * 3+1] = g;
|
|
|
|
b = 33 - 16 * y;
|
|
|
|
data[texelY * mWidth * 3 + texelX * 3+2] = b;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
y -= 0.3f;
|
|
|
|
|
|
|
|
y *= 1.428f;
|
|
|
|
|
|
|
|
r = 34 - 29 * y;
|
|
|
|
|
|
|
|
g = 25 - 20 * y;
|
|
|
|
|
|
|
|
b = 17 - 12 * y;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data[texelY * mWidth * 3 + texelX * 3] = r;
|
|
|
|
|
|
|
|
data[texelY * mWidth * 3 + texelX * 3+1] = g;
|
|
|
|
|
|
|
|
data[texelY * mWidth * 3 + texelX * 3+2] = b;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
loadingListener->increaseProgress();
|
|
|
|
|
|
|
|
if (land)
|
|
|
|
|
|
|
|
land->unloadData();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Ogre::DataStreamPtr stream(new Ogre::MemoryDataStream(&data[0], data.size()));
|
|
|
|
Ogre::DataStreamPtr stream(new Ogre::MemoryDataStream(&data[0], data.size()));
|
|
|
|
|
|
|
|
|
|
|
|
tex = Ogre::TextureManager::getSingleton ().createManual ("GlobalMap.png", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
|
|
|
tex = Ogre::TextureManager::getSingleton ().createManual ("GlobalMap.png", Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME,
|
|
|
|
Ogre::TEX_TYPE_2D, mWidth, mHeight, 0, Ogre::PF_B8G8R8, Ogre::TU_STATIC);
|
|
|
|
Ogre::TEX_TYPE_2D, mWidth, mHeight, 0, Ogre::PF_B8G8R8, Ogre::TU_STATIC);
|
|
|
|
tex->loadRawData(stream, mWidth, mHeight, Ogre::PF_B8G8R8);
|
|
|
|
tex->loadRawData(stream, mWidth, mHeight, Ogre::PF_B8G8R8);
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
tex = Ogre::TextureManager::getSingleton ().getByName ("GlobalMap.png");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tex->load();
|
|
|
|
tex->load();
|
|
|
|
|
|
|
|
|
|
|
@ -267,9 +242,9 @@ namespace MWRender
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const ESM::GlobalMap::Bounds& bounds = map.mBounds;
|
|
|
|
const ESM::GlobalMap::Bounds& bounds = map.mBounds;
|
|
|
|
|
|
|
|
|
|
|
|
if (bounds.mMaxX-bounds.mMinX <= 0)
|
|
|
|
if (bounds.mMaxX-bounds.mMinX < 0)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
if (bounds.mMaxY-bounds.mMinY <= 0)
|
|
|
|
if (bounds.mMaxY-bounds.mMinY < 0)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (bounds.mMinX > bounds.mMaxX
|
|
|
|
if (bounds.mMinX > bounds.mMaxX
|
|
|
|