feat: implemented terrain editor plumbing
This commit is contained in:
parent
76dd9fbc62
commit
81ac67c623
10 changed files with 647 additions and 0 deletions
42
modules/terrain_editor/terrain_mesh_generator.h
Normal file
42
modules/terrain_editor/terrain_mesh_generator.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#pragma once
|
||||
|
||||
#include "core/math/color.h"
|
||||
#include "core/object/object.h"
|
||||
#include "core/variant/callable.h"
|
||||
#include "scene/main/node.h"
|
||||
#include "scene/resources/gradient.h"
|
||||
#include "scene/resources/mesh.h"
|
||||
#include "scene/resources/surface_tool.h"
|
||||
#include "terrain_editor/terrain_primitive.h"
|
||||
|
||||
class TerrainMeshGenerator : public Node {
|
||||
GDCLASS(TerrainMeshGenerator, Node);
|
||||
static void _bind_methods();
|
||||
void on_configuration_changed();
|
||||
|
||||
public:
|
||||
Color color_at_height(float height) const;
|
||||
float evaluate_point(Vector2 at) const;
|
||||
void generate_grid(Rect2 area, Ref<ArrayMesh> mesh, size_t side_points);
|
||||
void set_primitives(Array array);
|
||||
Array get_primitives() const;
|
||||
void set_vertex_color_gradient(Ref<Gradient> gradient);
|
||||
Ref<Gradient> get_vertex_color_gradient() const;
|
||||
void set_color_gradient_start_height(float value);
|
||||
float get_color_gradient_start_height() const;
|
||||
void set_color_gradient_end_height(float value);
|
||||
float get_color_gradient_end_height() const;
|
||||
|
||||
private:
|
||||
Vector<Ref<TerrainPrimitive>> primitives{};
|
||||
Ref<SurfaceTool> surface{ memnew(SurfaceTool) };
|
||||
Ref<Gradient> vertex_color_gradient{};
|
||||
float color_gradient_start_height{ 0.f };
|
||||
float color_gradient_end_height{ 10.f };
|
||||
|
||||
private:
|
||||
Callable generation_changed{ callable_mp(this, &self_type::on_configuration_changed) };
|
||||
|
||||
public:
|
||||
static String const sig_primitives_changed;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue