61 lines
1.9 KiB
C++
61 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include "core/math/color.h"
|
|
#include "core/object/object.h"
|
|
#include "core/os/semaphore.h"
|
|
#include "core/os/thread.h"
|
|
#include "core/templates/hash_map.h"
|
|
#include "core/variant/callable.h"
|
|
#include "scene/main/node.h"
|
|
#include "scene/resources/gradient.h"
|
|
#include "scene/resources/material.h"
|
|
#include "scene/resources/mesh.h"
|
|
#include "scene/resources/surface_tool.h"
|
|
#include "terrain_editor/terrain_chunk.h"
|
|
#include "terrain_editor/terrain_primitive.h"
|
|
|
|
class TerrainMeshGenerator : public Node {
|
|
GDCLASS(TerrainMeshGenerator, Node);
|
|
static void _bind_methods();
|
|
void ready();
|
|
void on_configuration_changed();
|
|
|
|
protected:
|
|
void _notification(int what);
|
|
void rebuild_chunks();
|
|
|
|
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;
|
|
void set_chunk_count(int num);
|
|
int get_chunk_count() const;
|
|
void set_chunk_scene(Ref<PackedScene> scene);
|
|
Ref<PackedScene> get_chunk_scene() 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 };
|
|
int chunks_per_side{ 10 };
|
|
Ref<PackedScene> chunk_scene{};
|
|
Vector<TerrainChunk *> chunks{};
|
|
|
|
private:
|
|
Callable generation_changed{ callable_mp(this, &self_type::on_configuration_changed) };
|
|
|
|
public:
|
|
static String const sig_primitives_changed;
|
|
static String const sig_primitive_list_changed;
|
|
};
|