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