Started terrain base noise edition dialog
This commit is contained in:
parent
6707998a76
commit
b15ea439d2
9 changed files with 142 additions and 4 deletions
|
@ -71,7 +71,8 @@ HEADERS += \
|
||||||
common/widgetsliderdecimal.h \
|
common/widgetsliderdecimal.h \
|
||||||
common/previewrenderer.h \
|
common/previewrenderer.h \
|
||||||
terrain/widgetterrainbasenoisepreview.h \
|
terrain/widgetterrainbasenoisepreview.h \
|
||||||
common/mainwindow.h
|
common/mainwindow.h \
|
||||||
|
terrain/dialogbaseterrainnoise.h
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
terrain/widgetheightmap.cpp \
|
terrain/widgetheightmap.cpp \
|
||||||
|
@ -121,13 +122,15 @@ SOURCES += \
|
||||||
common/widgetsliderdecimal.cpp \
|
common/widgetsliderdecimal.cpp \
|
||||||
common/previewrenderer.cpp \
|
common/previewrenderer.cpp \
|
||||||
terrain/widgetterrainbasenoisepreview.cpp \
|
terrain/widgetterrainbasenoisepreview.cpp \
|
||||||
common/mainwindow.cpp
|
common/mainwindow.cpp \
|
||||||
|
terrain/dialogbaseterrainnoise.cpp
|
||||||
|
|
||||||
FORMS += \
|
FORMS += \
|
||||||
terrain/dialogterrainpainting.ui \
|
terrain/dialogterrainpainting.ui \
|
||||||
common/widgetglobalformbuttons.ui \
|
common/widgetglobalformbuttons.ui \
|
||||||
terrain/mainterrainform.ui \
|
terrain/mainterrainform.ui \
|
||||||
common/mainwindow.ui
|
common/mainwindow.ui \
|
||||||
|
terrain/dialogbaseterrainnoise.ui
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
../../data/ui_pictures.qrc
|
../../data/ui_pictures.qrc
|
||||||
|
|
31
src/editing/terrain/dialogbaseterrainnoise.cpp
Normal file
31
src/editing/terrain/dialogbaseterrainnoise.cpp
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#include "dialogbaseterrainnoise.h"
|
||||||
|
#include "ui_dialogbaseterrainnoise.h"
|
||||||
|
|
||||||
|
DialogBaseTerrainNoise::DialogBaseTerrainNoise(QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::DialogBaseTerrainNoise)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
_original = 0;
|
||||||
|
_modified = noiseCreateGenerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
DialogBaseTerrainNoise::~DialogBaseTerrainNoise()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
noiseDeleteGenerator(_modified);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DialogBaseTerrainNoise::setNoise(NoiseGenerator* noise)
|
||||||
|
{
|
||||||
|
_original = noise;
|
||||||
|
noiseCopy(noise, _modified);
|
||||||
|
}
|
||||||
|
|
||||||
|
int DialogBaseTerrainNoise::editNoise(QWidget* parent, NoiseGenerator* noise)
|
||||||
|
{
|
||||||
|
DialogBaseTerrainNoise dialog(parent);
|
||||||
|
dialog.setNoise(noise);
|
||||||
|
return dialog.exec();
|
||||||
|
}
|
29
src/editing/terrain/dialogbaseterrainnoise.h
Normal file
29
src/editing/terrain/dialogbaseterrainnoise.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#ifndef DIALOGBASETERRAINNOISE_H
|
||||||
|
#define DIALOGBASETERRAINNOISE_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include "rendering/noise.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class DialogBaseTerrainNoise;
|
||||||
|
}
|
||||||
|
|
||||||
|
class DialogBaseTerrainNoise : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DialogBaseTerrainNoise(QWidget *parent = 0);
|
||||||
|
~DialogBaseTerrainNoise();
|
||||||
|
|
||||||
|
void setNoise(NoiseGenerator* noise);
|
||||||
|
|
||||||
|
static int editNoise(QWidget* parent, NoiseGenerator* noise);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::DialogBaseTerrainNoise *ui;
|
||||||
|
NoiseGenerator* _original;
|
||||||
|
NoiseGenerator* _modified;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DIALOGBASETERRAINNOISE_H
|
43
src/editing/terrain/dialogbaseterrainnoise.ui
Normal file
43
src/editing/terrain/dialogbaseterrainnoise.ui
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>DialogBaseTerrainNoise</class>
|
||||||
|
<widget class="QDialog" name="DialogBaseTerrainNoise">
|
||||||
|
<property name="windowModality">
|
||||||
|
<enum>Qt::ApplicationModal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Paysages 3D - Base terrain noise</string>
|
||||||
|
</property>
|
||||||
|
<property name="modal">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="WidgetGlobalFormButtons" name="widget" native="true"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>WidgetGlobalFormButtons</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>common/widgetglobalformbuttons.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
<slots>
|
||||||
|
<signal>okClicked()</signal>
|
||||||
|
<signal>revertClicked()</signal>
|
||||||
|
<signal>cancelClicked()</signal>
|
||||||
|
</slots>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -1,6 +1,8 @@
|
||||||
#include "mainterrainform.h"
|
#include "mainterrainform.h"
|
||||||
#include "ui_mainterrainform.h"
|
#include "ui_mainterrainform.h"
|
||||||
|
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include "dialogbaseterrainnoise.h"
|
||||||
#include "dialogterrainpainting.h"
|
#include "dialogterrainpainting.h"
|
||||||
#include "previewterrainshape.h"
|
#include "previewterrainshape.h"
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
|
@ -29,6 +31,7 @@ MainTerrainForm::MainTerrainForm(QWidget *parent) :
|
||||||
_form_helper->setExploreButton(ui->button_explore);
|
_form_helper->setExploreButton(ui->button_explore);
|
||||||
_form_helper->setRenderButton(ui->button_render);
|
_form_helper->setRenderButton(ui->button_render);
|
||||||
|
|
||||||
|
connect(ui->button_dialog_basenoise, SIGNAL(clicked()), this, SLOT(buttonBaseNoisePressed()));
|
||||||
connect(ui->button_dialog_painting, SIGNAL(clicked()), this, SLOT(buttonPaintingPressed()));
|
connect(ui->button_dialog_painting, SIGNAL(clicked()), this, SLOT(buttonPaintingPressed()));
|
||||||
connect(ui->button_goto_textures, SIGNAL(clicked()), this, SLOT(buttonTexturesPressed()));
|
connect(ui->button_goto_textures, SIGNAL(clicked()), this, SLOT(buttonTexturesPressed()));
|
||||||
|
|
||||||
|
@ -79,6 +82,27 @@ void MainTerrainForm::alterRenderer(Renderer* renderer)
|
||||||
TerrainRendererClass.bind(renderer, _terrain);
|
TerrainRendererClass.bind(renderer, _terrain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainTerrainForm::buttonBaseNoisePressed()
|
||||||
|
{
|
||||||
|
int erase;
|
||||||
|
if (terrainGetMemoryStats(_terrain) > 0)
|
||||||
|
{
|
||||||
|
erase = QMessageBox::question(this, tr("Paysages 3D - Base noise edition"), tr("You have manual modifications on this terrain, regenerating base noise may produce weird results."), tr("Keep my changes anyway"), tr("Erase my changes"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
erase = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (DialogBaseTerrainNoise::editNoise(this, _terrain->_height_noise))
|
||||||
|
{
|
||||||
|
if (erase)
|
||||||
|
{
|
||||||
|
terrainClearPainting(_terrain->height_map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainTerrainForm::buttonPaintingPressed()
|
void MainTerrainForm::buttonPaintingPressed()
|
||||||
{
|
{
|
||||||
DialogTerrainPainting dialog(this, _terrain);
|
DialogTerrainPainting dialog(this, _terrain);
|
||||||
|
|
|
@ -26,6 +26,7 @@ public slots:
|
||||||
void commitLocalDataToScenery();
|
void commitLocalDataToScenery();
|
||||||
void alterRenderer(Renderer* renderer);
|
void alterRenderer(Renderer* renderer);
|
||||||
|
|
||||||
|
void buttonBaseNoisePressed();
|
||||||
void buttonPaintingPressed();
|
void buttonPaintingPressed();
|
||||||
void buttonTexturesPressed();
|
void buttonTexturesPressed();
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pushButton">
|
<widget class="QPushButton" name="button_dialog_basenoise">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Generate base noise</string>
|
<string>Generate base noise</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
|
@ -81,6 +81,7 @@ typedef struct
|
||||||
|
|
||||||
/* Heightmap manipulation */
|
/* Heightmap manipulation */
|
||||||
int terrainIsPainted(TerrainHeightMap* heightmap, int x, int z);
|
int terrainIsPainted(TerrainHeightMap* heightmap, int x, int z);
|
||||||
|
void terrainClearPainting(TerrainHeightMap* heightmap);
|
||||||
void terrainBrushElevation(TerrainHeightMap* heightmap, TerrainBrush* brush, double value);
|
void terrainBrushElevation(TerrainHeightMap* heightmap, TerrainBrush* brush, double value);
|
||||||
void terrainBrushSmooth(TerrainHeightMap* heightmap, TerrainBrush* brush, double value);
|
void terrainBrushSmooth(TerrainHeightMap* heightmap, TerrainBrush* brush, double value);
|
||||||
void terrainBrushAddNoise(TerrainHeightMap* heightmap, TerrainBrush* brush, NoiseGenerator* generator, double value);
|
void terrainBrushAddNoise(TerrainHeightMap* heightmap, TerrainBrush* brush, NoiseGenerator* generator, double value);
|
||||||
|
|
|
@ -454,6 +454,12 @@ int terrainIsPainted(TerrainHeightMap* heightmap, int x, int z)
|
||||||
return _getDataPointer(&heightmap->brush_data, x, z, NULL, NULL, 0) || _getDataPointer(&heightmap->merged_data, x, z, NULL, NULL, 0);
|
return _getDataPointer(&heightmap->brush_data, x, z, NULL, NULL, 0) || _getDataPointer(&heightmap->merged_data, x, z, NULL, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void terrainClearPainting(TerrainHeightMap* heightmap)
|
||||||
|
{
|
||||||
|
_clearData(&heightmap->merged_data);
|
||||||
|
_clearData(&heightmap->brush_data);
|
||||||
|
}
|
||||||
|
|
||||||
typedef double (*BrushCallback)(TerrainHeightMap* heightmap, TerrainBrush* brush, double x, double z, double basevalue, double influence, double force, void* data);
|
typedef double (*BrushCallback)(TerrainHeightMap* heightmap, TerrainBrush* brush, double x, double z, double basevalue, double influence, double force, void* data);
|
||||||
|
|
||||||
static inline void _applyBrush(TerrainHeightMap* heightmap, TerrainBrush* brush, double force, void* data, BrushCallback callback)
|
static inline void _applyBrush(TerrainHeightMap* heightmap, TerrainBrush* brush, double force, void* data, BrushCallback callback)
|
||||||
|
|
Loading…
Reference in a new issue