applied heightmap addition to map editor -> thanks muwum
This commit is contained in:
parent
a9a0a94550
commit
bd4e2c8724
|
@ -46,7 +46,7 @@ string getGameReadWritePath(string lookupKey) {
|
|||
|
||||
namespace MapEditor {
|
||||
|
||||
const string mapeditorVersionString = "v1.6.0";
|
||||
const string mapeditorVersionString = "v1.6.1";
|
||||
const string MainWindow::winHeader = "MegaGlest Map Editor " + mapeditorVersionString;
|
||||
|
||||
// ===============================================
|
||||
|
@ -193,6 +193,8 @@ void MainWindow::init(string fname) {
|
|||
menuView = new wxMenu();
|
||||
menuView->Append(miViewResetZoomAndPos, wxT("&Reset zoom and pos"));
|
||||
menuView->AppendCheckItem(miViewGrid, wxT("&Grid"));
|
||||
menuView->AppendCheckItem(miViewHeightMap, wxT("H&eightMap"));
|
||||
menuView->AppendCheckItem(miHideWater, wxT("Hide&Water"));
|
||||
menuView->AppendSeparator();
|
||||
menuView->Append(miViewHelp, wxT("&Help..."));
|
||||
menuView->Append(miViewAbout, wxT("&About..."));
|
||||
|
@ -528,7 +530,7 @@ void MainWindow::setExtension() {
|
|||
if (extnsn == "gbm" || extnsn == "mgm") {
|
||||
currentFile = cutLastExt(currentFile);
|
||||
}
|
||||
if (Program::getMap()->getMaxFactions() <= 4) {
|
||||
if (Program::getMap()->getMaxFactions() <= 4 || Program::getMap()->getCliffLevel() == 0) {
|
||||
SetStatusText(wxT(".gbm"), siFILE_TYPE);
|
||||
currentFile += ".gbm";
|
||||
}
|
||||
|
@ -1071,6 +1073,24 @@ void MainWindow::onMenuViewGrid(wxCommandEvent &event) {
|
|||
}
|
||||
|
||||
|
||||
void MainWindow::onMenuViewHeightMap(wxCommandEvent &event) {
|
||||
if(program == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
menuView->Check(miViewHeightMap, program->setHeightMapOnOff()); // miViewGrid event.GetId()
|
||||
wxPaintEvent e;
|
||||
onPaint(e);
|
||||
}
|
||||
void MainWindow::onMenuHideWater(wxCommandEvent &event) {
|
||||
if(program == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
menuView->Check(miHideWater, program->setHideWaterOnOff()); // miViewGrid event.GetId()
|
||||
wxPaintEvent e;
|
||||
onPaint(e);
|
||||
}
|
||||
void MainWindow::onMenuViewAbout(wxCommandEvent &event) {
|
||||
MsgDialog(
|
||||
this,
|
||||
|
@ -1373,6 +1393,8 @@ BEGIN_EVENT_TABLE(MainWindow, wxFrame)
|
|||
|
||||
EVT_MENU(miViewResetZoomAndPos, MainWindow::onMenuViewResetZoomAndPos)
|
||||
EVT_MENU(miViewGrid, MainWindow::onMenuViewGrid)
|
||||
EVT_MENU(miViewHeightMap, MainWindow::onMenuViewHeightMap)
|
||||
EVT_MENU(miHideWater, MainWindow::onMenuHideWater)
|
||||
EVT_MENU(miViewAbout, MainWindow::onMenuViewAbout)
|
||||
EVT_MENU(miViewHelp, MainWindow::onMenuViewHelp)
|
||||
|
||||
|
|
|
@ -143,6 +143,8 @@ private:
|
|||
|
||||
miViewResetZoomAndPos,
|
||||
miViewGrid,
|
||||
miViewHeightMap,
|
||||
miHideWater,
|
||||
miViewAbout,
|
||||
miViewHelp,
|
||||
|
||||
|
@ -252,6 +254,8 @@ public:
|
|||
|
||||
void onMenuViewResetZoomAndPos(wxCommandEvent &event);
|
||||
void onMenuViewGrid(wxCommandEvent &event);
|
||||
void onMenuViewHeightMap(wxCommandEvent &event);
|
||||
void onMenuHideWater(wxCommandEvent &event);
|
||||
void onMenuViewAbout(wxCommandEvent &event);
|
||||
void onMenuViewHelp(wxCommandEvent &event);
|
||||
|
||||
|
|
|
@ -147,6 +147,8 @@ MapPreview *Program::map = NULL;
|
|||
Program::Program(int w, int h) {
|
||||
cellSize = 6;
|
||||
grid=false;
|
||||
heightmap=false;
|
||||
hideWater=false;
|
||||
ofsetX = 0;
|
||||
ofsetY = 0;
|
||||
map = new MapPreview();
|
||||
|
@ -158,6 +160,8 @@ void Program::init() {
|
|||
redoStack = ChangeStack();
|
||||
cellSize = 6;
|
||||
grid=false;
|
||||
heightmap=false;
|
||||
hideWater=false;
|
||||
ofsetX = 0;
|
||||
ofsetY = 0;
|
||||
map = NULL;
|
||||
|
@ -250,7 +254,7 @@ bool Program::redo() {
|
|||
}
|
||||
|
||||
void Program::renderMap(int w, int h) {
|
||||
if(map) renderer.renderMap(map, ofsetX, ofsetY, w, h, cellSize, grid);
|
||||
if(map) renderer.renderMap(map, ofsetX, ofsetY, w, h, cellSize, grid,heightmap,hideWater);
|
||||
}
|
||||
|
||||
void Program::setRefAlt(int x, int y) {
|
||||
|
@ -629,6 +633,14 @@ bool Program::setGridOnOff() {
|
|||
grid=!grid;
|
||||
return grid;
|
||||
}
|
||||
bool Program::setHeightMapOnOff() {
|
||||
heightmap=!heightmap;
|
||||
return heightmap;
|
||||
}
|
||||
bool Program::setHideWaterOnOff() {
|
||||
hideWater=!hideWater;
|
||||
return hideWater;
|
||||
}
|
||||
|
||||
void Program::setMapAdvanced(int altFactor, int waterLevel, int cliffLevel , int cameraHeight) {
|
||||
if(map) map->setAdvanced(altFactor, waterLevel, cliffLevel, cameraHeight);
|
||||
|
|
|
@ -98,6 +98,8 @@ private:
|
|||
int ofsetX, ofsetY;
|
||||
int cellSize;
|
||||
bool grid; // show grid option
|
||||
bool heightmap;
|
||||
bool hideWater;
|
||||
//static Map *map;
|
||||
static MapPreview *map;
|
||||
friend class UndoPoint;
|
||||
|
@ -168,6 +170,8 @@ public:
|
|||
void incCellSize(int i);
|
||||
void resetOfset();
|
||||
bool setGridOnOff();
|
||||
bool setHeightMapOnOff();
|
||||
bool setHideWaterOnOff();
|
||||
|
||||
int getObject(int x, int y);
|
||||
int getResource(int x, int y);
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
virtual ~BaseRenderer() { }
|
||||
|
||||
virtual void initMapSurface(int clientW, int clientH);
|
||||
virtual void renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize, bool grid=false);
|
||||
virtual void renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize, bool grid=false, bool heightMap=false, bool hideWater=false);
|
||||
};
|
||||
|
||||
}} // end namespace
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
class RendererMapInterface {
|
||||
public:
|
||||
virtual void initMapSurface(int clientW, int clientH) = 0;
|
||||
virtual void renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize, bool grid) = 0;
|
||||
virtual void renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize, bool grid, bool heightMap, bool hideWater) = 0;
|
||||
|
||||
virtual ~RendererMapInterface() {}
|
||||
};
|
||||
|
|
|
@ -36,7 +36,7 @@ void BaseRenderer::initMapSurface(int clientW, int clientH) {
|
|||
}
|
||||
|
||||
void BaseRenderer::renderMap(MapPreview *map, int x, int y,
|
||||
int clientW, int clientH, int cellSize, bool grid) {
|
||||
int clientW, int clientH, int cellSize, bool grid, bool heightMap, bool hideWater) {
|
||||
float alt=0;
|
||||
float showWater=0;
|
||||
|
||||
|
@ -66,6 +66,9 @@ void BaseRenderer::renderMap(MapPreview *map, int x, int y,
|
|||
alt = map->getHeight(i, j) / 20.f;
|
||||
showWater = map->getWaterLevel()/ 20.f - alt;
|
||||
showWater = (showWater > 0)? showWater:0;
|
||||
if(hideWater){
|
||||
showWater = 0;
|
||||
}
|
||||
Vec3f surfColor;
|
||||
switch (map->getSurface(i, j)) {
|
||||
case st_Grass: surfColor = Vec3f(0.0, 0.8f * alt, 0.f + showWater); break;
|
||||
|
@ -74,6 +77,9 @@ void BaseRenderer::renderMap(MapPreview *map, int x, int y,
|
|||
case st_Stone: surfColor = Vec3f(0.7f * alt, 0.7f * alt, 0.7f * alt + showWater); break;
|
||||
case st_Ground: surfColor = Vec3f(0.7f * alt, 0.5f * alt, 0.3f * alt + showWater); break;
|
||||
}
|
||||
if(heightMap){
|
||||
surfColor = Vec3f(1.f * alt, 1.f * alt, 1.f * alt + showWater);
|
||||
}
|
||||
if(map->getCliffLevel()>0)
|
||||
{// we maybe need to render cliff surfColor
|
||||
if(map->isCliff(i, j)){
|
||||
|
@ -89,7 +95,7 @@ void BaseRenderer::renderMap(MapPreview *map, int x, int y,
|
|||
glVertex2i(i * cellSize + cellSize, clientH - j * cellSize - cellSize);
|
||||
glVertex2i(i * cellSize + cellSize, clientH - j * cellSize);
|
||||
glEnd();
|
||||
|
||||
if(!heightMap){
|
||||
//objects
|
||||
switch (map->getObject(i, j)) {
|
||||
case 0: glColor3f(0.f, 0.f, 0.f); break;
|
||||
|
@ -116,6 +122,7 @@ void BaseRenderer::renderMap(MapPreview *map, int x, int y,
|
|||
|
||||
//height lines
|
||||
// if (!found) {
|
||||
|
||||
glColor3fv((surfColor*0.5f).ptr());
|
||||
//left
|
||||
if (grid || (i > 0 && map->getHeight(i - 1, j) > map->getHeight(i, j))) {
|
||||
|
@ -147,7 +154,6 @@ void BaseRenderer::renderMap(MapPreview *map, int x, int y,
|
|||
glEnd();
|
||||
}
|
||||
// }
|
||||
|
||||
//resources
|
||||
switch (map->getResource(i, j)) {
|
||||
case 1: glColor3f(1.f, 1.f, 0.f); break;
|
||||
|
@ -165,6 +171,8 @@ void BaseRenderer::renderMap(MapPreview *map, int x, int y,
|
|||
glVertex2i(i * cellSize + cellSize, clientH - j * cellSize - cellSize);
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue