2012-07-13 12:23:58 +00:00
|
|
|
#ifndef _PAYSAGES_QT_WIDGETHEIGHTMAP_H_
|
|
|
|
#define _PAYSAGES_QT_WIDGETHEIGHTMAP_H_
|
|
|
|
|
|
|
|
#include <QGLWidget>
|
2012-07-24 14:59:06 +00:00
|
|
|
#include <QDateTime>
|
2013-01-19 22:42:50 +00:00
|
|
|
#include "../lib_paysages/tools/euclid.h"
|
2013-01-10 15:41:14 +00:00
|
|
|
#include "../lib_paysages/renderer.h"
|
2012-12-10 22:05:53 +00:00
|
|
|
#include "../lib_paysages/terrain/public.h"
|
2012-07-13 12:23:58 +00:00
|
|
|
|
2012-07-15 14:42:50 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
Vector3 point;
|
|
|
|
Vector3 normal;
|
|
|
|
} _VertexInfo;
|
|
|
|
|
2012-07-16 15:48:05 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
HEIGHTMAP_BRUSH_RAISE = 0,
|
|
|
|
HEIGHTMAP_BRUSH_SMOOTH = 1
|
|
|
|
} HeightMapBrushMode;
|
|
|
|
|
2012-07-13 12:23:58 +00:00
|
|
|
class WidgetHeightMap : public QGLWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2012-12-10 22:05:53 +00:00
|
|
|
WidgetHeightMap(QWidget* parent, TerrainDefinition* terrain);
|
2012-07-13 12:23:58 +00:00
|
|
|
~WidgetHeightMap();
|
2012-12-10 22:05:53 +00:00
|
|
|
|
2012-07-13 21:24:19 +00:00
|
|
|
void setHorizontalViewAngle(double angle_h);
|
|
|
|
void setVerticalViewAngle(double angle_v);
|
2012-07-16 15:48:05 +00:00
|
|
|
void setBrushMode(HeightMapBrushMode mode);
|
2012-07-15 14:42:50 +00:00
|
|
|
void setBrushSize(double size);
|
|
|
|
void setBrushSmoothing(double smoothing);
|
2012-07-16 20:34:01 +00:00
|
|
|
void setBrushStrength(double smoothing);
|
2012-12-10 22:05:53 +00:00
|
|
|
|
2012-07-13 21:24:19 +00:00
|
|
|
public slots:
|
2012-07-16 20:34:01 +00:00
|
|
|
void revert();
|
2012-07-13 12:23:58 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void mousePressEvent(QMouseEvent* event);
|
2012-07-16 20:34:01 +00:00
|
|
|
void mouseReleaseEvent(QMouseEvent* event);
|
2012-07-13 12:23:58 +00:00
|
|
|
void mouseMoveEvent(QMouseEvent* event);
|
2012-12-10 22:05:53 +00:00
|
|
|
|
2012-07-16 20:34:01 +00:00
|
|
|
void timerEvent(QTimerEvent* event);
|
2012-07-13 12:23:58 +00:00
|
|
|
|
|
|
|
void initializeGL();
|
|
|
|
void resizeGL(int w, int h);
|
|
|
|
void paintGL();
|
2012-12-10 22:05:53 +00:00
|
|
|
|
2012-07-15 14:42:50 +00:00
|
|
|
private:
|
|
|
|
void updateVertexInfo();
|
|
|
|
|
2012-07-13 12:23:58 +00:00
|
|
|
private:
|
2012-12-10 22:05:53 +00:00
|
|
|
TerrainDefinition* _terrain;
|
2013-01-20 15:07:45 +00:00
|
|
|
Renderer* _renderer;
|
2012-08-08 13:30:40 +00:00
|
|
|
_VertexInfo* _vertices;
|
2012-12-10 22:05:53 +00:00
|
|
|
|
2012-07-15 14:42:50 +00:00
|
|
|
bool _dirty;
|
2012-12-10 22:05:53 +00:00
|
|
|
|
2012-07-13 12:23:58 +00:00
|
|
|
double _average_frame_time;
|
2012-12-10 22:05:53 +00:00
|
|
|
|
2012-07-16 20:34:01 +00:00
|
|
|
int _last_brush_action;
|
2012-07-13 12:23:58 +00:00
|
|
|
int _last_mouse_x;
|
|
|
|
int _last_mouse_y;
|
2012-07-24 14:59:06 +00:00
|
|
|
QDateTime _last_time;
|
2012-07-23 09:58:06 +00:00
|
|
|
bool _mouse_moved;
|
2012-12-10 22:05:53 +00:00
|
|
|
|
2013-01-14 13:28:42 +00:00
|
|
|
int _position_x;
|
|
|
|
int _position_z;
|
2012-07-13 21:24:19 +00:00
|
|
|
double _angle_h;
|
|
|
|
double _angle_v;
|
2012-12-10 22:05:53 +00:00
|
|
|
|
2012-07-15 14:42:50 +00:00
|
|
|
double _brush_x;
|
|
|
|
double _brush_z;
|
2012-07-16 15:48:05 +00:00
|
|
|
HeightMapBrushMode _brush_mode;
|
2012-07-15 14:42:50 +00:00
|
|
|
double _brush_size;
|
|
|
|
double _brush_smoothing;
|
2012-07-16 20:34:01 +00:00
|
|
|
double _brush_strength;
|
2012-07-24 14:59:06 +00:00
|
|
|
NoiseGenerator* _brush_noise;
|
2012-07-13 12:23:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|