pandemonium_engine/modules/procedural_tree_3d/procedural_tree_mesh.cpp

517 lines
19 KiB
C++
Raw Normal View History

2024-09-08 13:33:48 +02:00
#include "procedural_tree_mesh.h"
2024-09-08 13:35:37 +02:00
#include "core/object/class_db.h"
2024-09-08 13:28:45 +02:00
#include "core/object/object.h"
2024-09-08 13:28:45 +02:00
#include "servers/rendering_server.h"
2024-09-08 14:25:06 +02:00
// General
int ProceduralTreeMesh::get_seed() const {
return _seed;
}
void ProceduralTreeMesh::set_seed(const int p_value) {
_seed = p_value;
}
int ProceduralTreeMesh::get_branch_segments() const {
return _branch_segments;
}
void ProceduralTreeMesh::set_branch_segments(const int p_value) {
_branch_segments = p_value;
}
int ProceduralTreeMesh::get_branch_levels() const {
return _branch_levels;
}
void ProceduralTreeMesh::set_branch_levels(const int p_value) {
_branch_levels = p_value;
}
int ProceduralTreeMesh::get_trunk_forks() const {
return _trunk_forks;
}
void ProceduralTreeMesh::set_trunk_forks(const int p_value) {
_trunk_forks = p_value;
}
float ProceduralTreeMesh::get_texture_v_multiplier() const {
return _texture_v_multiplier;
}
void ProceduralTreeMesh::set_texture_v_multiplier(const float p_value) {
_texture_v_multiplier = p_value;
}
float ProceduralTreeMesh::get_twig_scale() const {
return _twig_scale;
}
void ProceduralTreeMesh::set_twig_scale(const float p_value) {
_twig_scale = p_value;
}
// Branching
2024-09-08 14:36:59 +02:00
float ProceduralTreeMesh::branching_get_initial_length() const {
return _branching_initial_length;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
void ProceduralTreeMesh::branching_set_initial_length(const float p_value) {
_branching_initial_length = p_value;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
float ProceduralTreeMesh::branching_get_length_falloff_rate() const {
return _branching_length_falloff_rate;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
void ProceduralTreeMesh::branching_set_length_falloff_rate(const float p_value) {
_branching_length_falloff_rate = p_value;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
float ProceduralTreeMesh::branching_get_length_falloff_power() const {
return _branching_length_falloff_power;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
void ProceduralTreeMesh::branching_set_length_falloff_power(const float p_value) {
_branching_length_falloff_power = p_value;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
float ProceduralTreeMesh::branching_get_max_clumping() const {
return _branching_max_clumping;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
void ProceduralTreeMesh::branching_set_max_clumping(const float p_value) {
_branching_max_clumping = p_value;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
float ProceduralTreeMesh::branching_get_min_clumping() const {
return _branching_min_clumping;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
void ProceduralTreeMesh::branching_set_min_clumping(const float p_value) {
_branching_min_clumping = p_value;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
float ProceduralTreeMesh::branching_get_symmetry() const {
return _branching_symmetry;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
void ProceduralTreeMesh::branching_set_symmetry(const float p_value) {
_branching_symmetry = p_value;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
float ProceduralTreeMesh::branching_get_droop() const {
return _branching_droop;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
void ProceduralTreeMesh::branching_set_droop(const float p_value) {
_branching_droop = p_value;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
float ProceduralTreeMesh::branching_get_growth() const {
return _branching_growth;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
void ProceduralTreeMesh::branching_set_growth(const float p_value) {
_branching_growth = p_value;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
float ProceduralTreeMesh::branching_get_sweep() const {
return _branching_sweep;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
void ProceduralTreeMesh::branching_set_sweep(const float p_value) {
_branching_sweep = p_value;
2024-09-08 14:25:06 +02:00
}
// Trunk
2024-09-08 14:36:59 +02:00
float ProceduralTreeMesh::trunk_get_radius() const {
2024-09-08 14:25:06 +02:00
return _trunk_radius;
}
2024-09-08 14:36:59 +02:00
void ProceduralTreeMesh::trunk_set_radius(const float p_value) {
2024-09-08 14:25:06 +02:00
_trunk_radius = p_value;
}
2024-09-08 14:36:59 +02:00
float ProceduralTreeMesh::trunk_get_radius_falloff() const {
return _trunk_radius_falloff;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
void ProceduralTreeMesh::trunk_set_radius_falloff(const float p_value) {
_trunk_radius_falloff = p_value;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
float ProceduralTreeMesh::trunk_get_climb_rate() const {
return _trunk_climb_rate;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
void ProceduralTreeMesh::trunk_set_climb_rate(const float p_value) {
_trunk_climb_rate = p_value;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
float ProceduralTreeMesh::trunk_get_kink() const {
return _trunk_kink;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
void ProceduralTreeMesh::trunk_set_kink(const float p_value) {
_trunk_kink = p_value;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
float ProceduralTreeMesh::trunk_get_taper_rate() const {
return _trunk_taper_rate;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
void ProceduralTreeMesh::trunk_set_taper_rate(const float p_value) {
_trunk_taper_rate = p_value;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
float ProceduralTreeMesh::trunk_get_twists() const {
return _trunk_twists;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
void ProceduralTreeMesh::trunk_set_twists(const float p_value) {
_trunk_twists = p_value;
2024-09-08 14:25:06 +02:00
}
2024-09-08 14:36:59 +02:00
float ProceduralTreeMesh::trunk_get_length() const {
2024-09-08 14:25:06 +02:00
return _trunk_length;
}
2024-09-08 14:36:59 +02:00
void ProceduralTreeMesh::trunk_set_length(const float p_value) {
2024-09-08 14:25:06 +02:00
_trunk_length = p_value;
}
void ProceduralTreeMesh::_update() const {
2024-09-08 13:28:45 +02:00
Array arr;
arr.resize(RS::ARRAY_MAX);
PoolVector<Vector3> points = arr[RS::ARRAY_VERTEX];
aabb = AABB();
int pc = points.size();
ERR_FAIL_COND(pc == 0);
{
PoolVector<Vector3>::Read r = points.read();
for (int i = 0; i < pc; i++) {
if (i == 0) {
aabb.position = r[i];
} else {
aabb.expand_to(r[i]);
}
}
}
RenderingServer::get_singleton()->mesh_clear(mesh);
// in with the new
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(mesh, RenderingServer::PRIMITIVE_TRIANGLES, arr);
RenderingServer::get_singleton()->mesh_add_surface_from_arrays(mesh, RenderingServer::PRIMITIVE_TRIANGLES, arr);
RenderingServer::get_singleton()->mesh_surface_set_material(mesh, TREE_SURFACE_TWIG, _surfaces[TREE_SURFACE_TWIG].material.is_null() ? RID() : _surfaces[TREE_SURFACE_TWIG].material->get_rid());
2024-09-08 14:25:06 +02:00
RenderingServer::get_singleton()->mesh_surface_set_material(mesh, TREE_SURFACE_TRUNK, _surfaces[TREE_SURFACE_TRUNK].material.is_null() ? RID() : _surfaces[TREE_SURFACE_TRUNK].material->get_rid());
2024-09-08 13:28:45 +02:00
pending_request = false;
clear_cache();
const_cast<ProceduralTreeMesh *>(this)->emit_changed();
2024-09-08 13:28:45 +02:00
}
void ProceduralTreeMesh::_request_update() {
2024-09-08 13:28:45 +02:00
if (pending_request) {
return;
}
_update();
}
int ProceduralTreeMesh::get_surface_count() const {
2024-09-08 13:28:45 +02:00
if (pending_request) {
_update();
}
return TREE_SURFACE_COUNT;
}
int ProceduralTreeMesh::surface_get_array_len(int p_idx) const {
2024-09-08 13:28:45 +02:00
ERR_FAIL_INDEX_V(p_idx, TREE_SURFACE_COUNT, -1);
if (pending_request) {
_update();
}
return RenderingServer::get_singleton()->mesh_surface_get_array_len(mesh, p_idx);
}
int ProceduralTreeMesh::surface_get_array_index_len(int p_idx) const {
2024-09-08 13:28:45 +02:00
ERR_FAIL_INDEX_V(p_idx, TREE_SURFACE_COUNT, -1);
if (pending_request) {
_update();
}
return RenderingServer::get_singleton()->mesh_surface_get_array_index_len(mesh, p_idx);
}
Array ProceduralTreeMesh::surface_get_arrays(int p_surface) const {
2024-09-08 13:28:45 +02:00
ERR_FAIL_INDEX_V(p_surface, TREE_SURFACE_COUNT, Array());
if (pending_request) {
_update();
}
return RenderingServer::get_singleton()->mesh_surface_get_arrays(mesh, p_surface);
}
Array ProceduralTreeMesh::surface_get_blend_shape_arrays(int p_surface) const {
2024-09-08 13:28:45 +02:00
ERR_FAIL_INDEX_V(p_surface, TREE_SURFACE_COUNT, Array());
if (pending_request) {
_update();
}
return Array();
}
uint32_t ProceduralTreeMesh::surface_get_format(int p_idx) const {
2024-09-08 13:28:45 +02:00
ERR_FAIL_INDEX_V(p_idx, TREE_SURFACE_COUNT, 0);
if (pending_request) {
_update();
}
return RenderingServer::get_singleton()->mesh_surface_get_format(mesh, p_idx);
}
Mesh::PrimitiveType ProceduralTreeMesh::surface_get_primitive_type(int p_idx) const {
2024-09-08 13:28:45 +02:00
return Mesh::PRIMITIVE_TRIANGLES;
}
void ProceduralTreeMesh::surface_set_material(int p_idx, const Ref<Material> &p_material) {
2024-09-08 13:28:45 +02:00
ERR_FAIL_INDEX(p_idx, TREE_SURFACE_COUNT);
switch (p_idx) {
case TREE_SURFACE_TWIG:
set_twig_material(p_material);
break;
2024-09-08 14:25:06 +02:00
case TREE_SURFACE_TRUNK:
set_trunk_material(p_material);
break;
2024-09-08 13:28:45 +02:00
case TREE_SURFACE_COUNT:
default:
break;
}
}
Ref<Material> ProceduralTreeMesh::surface_get_material(int p_idx) const {
2024-09-08 13:28:45 +02:00
ERR_FAIL_INDEX_V(p_idx, TREE_SURFACE_COUNT, nullptr);
return _surfaces[p_idx].material;
}
2024-09-08 13:28:45 +02:00
int ProceduralTreeMesh::get_blend_shape_count() const {
2024-09-08 13:28:45 +02:00
return 0;
}
StringName ProceduralTreeMesh::get_blend_shape_name(int p_index) const {
2024-09-08 13:28:45 +02:00
return StringName();
}
void ProceduralTreeMesh::set_blend_shape_name(int p_index, const StringName &p_name) {
2024-09-08 13:28:45 +02:00
}
AABB ProceduralTreeMesh::get_aabb() const {
2024-09-08 13:28:45 +02:00
if (pending_request) {
_update();
}
2024-09-08 13:28:45 +02:00
return aabb;
}
RID ProceduralTreeMesh::get_rid() const {
2024-09-08 13:28:45 +02:00
if (pending_request) {
_update();
}
return mesh;
}
2024-09-08 14:25:06 +02:00
void ProceduralTreeMesh::set_twig_material(const Ref<Material> &p_material) {
_surfaces[TREE_SURFACE_TWIG].material = p_material;
2024-09-08 13:28:45 +02:00
if (!pending_request) {
// just apply it, else it'll happen when _update is called.
2024-09-08 14:25:06 +02:00
RenderingServer::get_singleton()->mesh_surface_set_material(mesh, TREE_SURFACE_TWIG, _surfaces[TREE_SURFACE_TWIG].material.is_null() ? RID() : _surfaces[TREE_SURFACE_TWIG].material->get_rid());
2024-09-08 13:28:45 +02:00
_change_notify();
emit_changed();
};
}
2024-09-08 14:25:06 +02:00
Ref<Material> ProceduralTreeMesh::get_twig_material() const {
return _surfaces[TREE_SURFACE_TWIG].material;
2024-09-08 13:28:45 +02:00
}
2024-09-08 14:25:06 +02:00
void ProceduralTreeMesh::set_trunk_material(const Ref<Material> &p_material) {
_surfaces[TREE_SURFACE_TRUNK].material = p_material;
2024-09-08 13:28:45 +02:00
if (!pending_request) {
// just apply it, else it'll happen when _update is called.
2024-09-08 14:25:06 +02:00
RenderingServer::get_singleton()->mesh_surface_set_material(mesh, TREE_SURFACE_TRUNK, _surfaces[TREE_SURFACE_TRUNK].material.is_null() ? RID() : _surfaces[TREE_SURFACE_TRUNK].material->get_rid());
2024-09-08 13:28:45 +02:00
_change_notify();
emit_changed();
};
}
2024-09-08 14:25:06 +02:00
Ref<Material> ProceduralTreeMesh::get_trunk_material() const {
return _surfaces[TREE_SURFACE_TRUNK].material;
2024-09-08 13:28:45 +02:00
}
Array ProceduralTreeMesh::get_mesh_arrays() const {
2024-09-08 13:28:45 +02:00
Array arr;
for (int i = 0; i < TREE_SURFACE_COUNT; ++i) {
arr.push_back(surface_get_arrays(i));
}
return arr;
}
void ProceduralTreeMesh::set_custom_aabb(const AABB &p_custom) {
2024-09-08 13:28:45 +02:00
custom_aabb = p_custom;
RS::get_singleton()->mesh_set_custom_aabb(mesh, custom_aabb);
emit_changed();
}
AABB ProceduralTreeMesh::get_custom_aabb() const {
2024-09-08 13:28:45 +02:00
return custom_aabb;
}
ProceduralTreeMesh::ProceduralTreeMesh() {
2024-09-08 13:28:45 +02:00
// defaults
mesh = RID_PRIME(RenderingServer::get_singleton()->mesh_create());
// make sure we do an update after we've finished constructing our object
pending_request = true;
2024-09-08 14:25:06 +02:00
// General
_seed = 262;
_branch_segments = 6;
_branch_levels = 5;
_twig_scale = 0.39;
_trunk_forks = 5;
_texture_v_multiplier = 0.36;
// Branching
2024-09-08 14:36:59 +02:00
_branching_initial_length = 0.49;
_branching_length_falloff_rate = 0.85;
_branching_length_falloff_power = 0.99;
_branching_max_clumping = 0.454;
_branching_min_clumping = 0.404;
_branching_symmetry = 2.45;
_branching_droop = -0.1;
_branching_growth = 0.235;
_branching_sweep = 0.01;
2024-09-08 14:25:06 +02:00
// Trunk
_trunk_radius = 0.139;
2024-09-08 14:36:59 +02:00
_trunk_radius_falloff = 0.73;
_trunk_climb_rate = 0.371;
_trunk_kink = 0.093;
_trunk_taper_rate = 0.947;
_trunk_twists = 3.02;
2024-09-08 14:25:06 +02:00
_trunk_length = 2.4;
2024-09-08 13:28:45 +02:00
}
ProceduralTreeMesh::~ProceduralTreeMesh() {
2024-09-08 13:28:45 +02:00
RenderingServer::get_singleton()->free(mesh);
}
void ProceduralTreeMesh::_bind_methods() {
2024-09-08 14:25:06 +02:00
ADD_GROUP("General", "");
ClassDB::bind_method(D_METHOD("get_seed"), &ProceduralTreeMesh::get_seed);
ClassDB::bind_method(D_METHOD("set_seed", "value"), &ProceduralTreeMesh::set_seed);
ADD_PROPERTY(PropertyInfo(Variant::INT, "seed"), "set_seed", "get_seed");
2024-09-08 13:28:45 +02:00
2024-09-08 14:25:06 +02:00
ClassDB::bind_method(D_METHOD("get_branch_segments"), &ProceduralTreeMesh::get_branch_segments);
ClassDB::bind_method(D_METHOD("set_branch_segments", "value"), &ProceduralTreeMesh::set_branch_segments);
ADD_PROPERTY(PropertyInfo(Variant::INT, "branch_segments"), "set_branch_segments", "get_branch_segments");
ClassDB::bind_method(D_METHOD("get_branch_levels"), &ProceduralTreeMesh::get_branch_levels);
ClassDB::bind_method(D_METHOD("set_branch_levels", "value"), &ProceduralTreeMesh::set_branch_levels);
ADD_PROPERTY(PropertyInfo(Variant::INT, "branch_levels"), "set_branch_levels", "get_branch_levels");
ClassDB::bind_method(D_METHOD("get_trunk_forks"), &ProceduralTreeMesh::get_trunk_forks);
ClassDB::bind_method(D_METHOD("set_trunk_forks", "value"), &ProceduralTreeMesh::set_trunk_forks);
ADD_PROPERTY(PropertyInfo(Variant::INT, "trunk_forks"), "set_trunk_forks", "get_trunk_forks");
ClassDB::bind_method(D_METHOD("get_texture_v_multiplier"), &ProceduralTreeMesh::get_texture_v_multiplier);
ClassDB::bind_method(D_METHOD("set_texture_v_multiplier", "value"), &ProceduralTreeMesh::set_texture_v_multiplier);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "texture_v_multiplier"), "set_texture_v_multiplier", "get_texture_v_multiplier");
ClassDB::bind_method(D_METHOD("get_twig_scale"), &ProceduralTreeMesh::get_twig_scale);
ClassDB::bind_method(D_METHOD("set_twig_scale", "value"), &ProceduralTreeMesh::set_twig_scale);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "twig_scale"), "set_twig_scale", "get_twig_scale");
2024-09-08 14:36:59 +02:00
ADD_GROUP("Branching", "branching");
ClassDB::bind_method(D_METHOD("branching_get_initial_length"), &ProceduralTreeMesh::branching_get_initial_length);
ClassDB::bind_method(D_METHOD("branching_set_initial_length", "value"), &ProceduralTreeMesh::branching_set_initial_length);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "branching_initial_length"), "branching_set_initial_length", "branching_get_initial_length");
2024-09-08 14:25:06 +02:00
2024-09-08 14:36:59 +02:00
ClassDB::bind_method(D_METHOD("branching_get_length_falloff_rate"), &ProceduralTreeMesh::branching_get_length_falloff_rate);
ClassDB::bind_method(D_METHOD("branching_set_length_falloff_rate", "value"), &ProceduralTreeMesh::branching_set_length_falloff_rate);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "branching_length_falloff_rate"), "branching_set_length_falloff_rate", "branching_get_length_falloff_rate");
2024-09-08 14:25:06 +02:00
2024-09-08 14:36:59 +02:00
ClassDB::bind_method(D_METHOD("branching_get_length_falloff_power"), &ProceduralTreeMesh::branching_get_length_falloff_power);
ClassDB::bind_method(D_METHOD("branching_set_length_falloff_power", "value"), &ProceduralTreeMesh::branching_set_length_falloff_power);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "branching_length_falloff_power"), "branching_set_length_falloff_power", "branching_get_length_falloff_power");
2024-09-08 14:25:06 +02:00
2024-09-08 14:36:59 +02:00
ClassDB::bind_method(D_METHOD("branching_get_max_clumping"), &ProceduralTreeMesh::branching_get_max_clumping);
ClassDB::bind_method(D_METHOD("branching_set_max_clumping", "value"), &ProceduralTreeMesh::branching_set_max_clumping);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "branching_max_clumping"), "branching_set_max_clumping", "branching_get_max_clumping");
2024-09-08 14:25:06 +02:00
2024-09-08 14:36:59 +02:00
ClassDB::bind_method(D_METHOD("branching_get_min_clumping"), &ProceduralTreeMesh::branching_get_min_clumping);
ClassDB::bind_method(D_METHOD("branching_set_min_clumping", "value"), &ProceduralTreeMesh::branching_set_min_clumping);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "branching_min_clumping"), "branching_set_min_clumping", "branching_get_min_clumping");
2024-09-08 14:25:06 +02:00
2024-09-08 14:36:59 +02:00
ClassDB::bind_method(D_METHOD("branching_get_symmetry"), &ProceduralTreeMesh::branching_get_symmetry);
ClassDB::bind_method(D_METHOD("branching_set_symmetry", "value"), &ProceduralTreeMesh::branching_set_symmetry);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "branching_symmetry"), "branching_set_symmetry", "branching_get_symmetry");
2024-09-08 14:25:06 +02:00
2024-09-08 14:36:59 +02:00
ClassDB::bind_method(D_METHOD("branching_get_droop"), &ProceduralTreeMesh::branching_get_droop);
ClassDB::bind_method(D_METHOD("branching_set_droop", "value"), &ProceduralTreeMesh::branching_set_droop);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "branching_droop"), "branching_set_droop", "branching_get_droop");
2024-09-08 14:25:06 +02:00
2024-09-08 14:36:59 +02:00
ClassDB::bind_method(D_METHOD("branching_get_growth"), &ProceduralTreeMesh::branching_get_growth);
ClassDB::bind_method(D_METHOD("branching_set_growth", "value"), &ProceduralTreeMesh::branching_set_growth);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "branching_growth"), "branching_set_growth", "branching_get_growth");
2024-09-08 14:25:06 +02:00
2024-09-08 14:36:59 +02:00
ClassDB::bind_method(D_METHOD("branching_get_sweep"), &ProceduralTreeMesh::branching_get_sweep);
ClassDB::bind_method(D_METHOD("branching_set_sweep", "value"), &ProceduralTreeMesh::branching_set_sweep);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "branching_sweep"), "branching_set_sweep", "branching_get_sweep");
2024-09-08 14:25:06 +02:00
2024-09-08 14:36:59 +02:00
ADD_GROUP("Trunk", "trunk");
ClassDB::bind_method(D_METHOD("trunk_get_radius"), &ProceduralTreeMesh::trunk_get_radius);
ClassDB::bind_method(D_METHOD("trunk_set_radius", "value"), &ProceduralTreeMesh::trunk_set_radius);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "trunk_radius"), "trunk_set_radius", "trunk_get_radius");
2024-09-08 14:25:06 +02:00
2024-09-08 14:36:59 +02:00
ClassDB::bind_method(D_METHOD("trunk_get_radius_falloff"), &ProceduralTreeMesh::trunk_get_radius_falloff);
ClassDB::bind_method(D_METHOD("trunk_set_radius_falloff", "value"), &ProceduralTreeMesh::trunk_set_radius_falloff);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "trunk_radius_falloff"), "trunk_set_radius_falloff", "trunk_get_radius_falloff");
2024-09-08 14:25:06 +02:00
2024-09-08 14:36:59 +02:00
ClassDB::bind_method(D_METHOD("trunk_get_climb_rate"), &ProceduralTreeMesh::trunk_get_climb_rate);
ClassDB::bind_method(D_METHOD("trunk_set_climb_rate", "value"), &ProceduralTreeMesh::trunk_set_climb_rate);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "trunk_climb_rate"), "trunk_set_climb_rate", "trunk_get_climb_rate");
2024-09-08 14:25:06 +02:00
2024-09-08 14:36:59 +02:00
ClassDB::bind_method(D_METHOD("trunk_get_kink"), &ProceduralTreeMesh::trunk_get_kink);
ClassDB::bind_method(D_METHOD("trunk_set_kink", "value"), &ProceduralTreeMesh::trunk_set_kink);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "trunk_kink"), "trunk_set_kink", "trunk_get_kink");
2024-09-08 14:25:06 +02:00
2024-09-08 14:36:59 +02:00
ClassDB::bind_method(D_METHOD("trunk_get_taper_rate"), &ProceduralTreeMesh::trunk_get_taper_rate);
ClassDB::bind_method(D_METHOD("trunk_set_taper_rate", "value"), &ProceduralTreeMesh::trunk_set_taper_rate);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "trunk_taper_rate"), "trunk_set_taper_rate", "trunk_get_taper_rate");
2024-09-08 14:25:06 +02:00
2024-09-08 14:36:59 +02:00
ClassDB::bind_method(D_METHOD("trunk_get_twists"), &ProceduralTreeMesh::trunk_get_twists);
ClassDB::bind_method(D_METHOD("trunk_set_twists", "value"), &ProceduralTreeMesh::trunk_set_twists);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "trunk_twists"), "trunk_set_twists", "trunk_get_twists");
2024-09-08 14:25:06 +02:00
2024-09-08 14:36:59 +02:00
ClassDB::bind_method(D_METHOD("trunk_get_length"), &ProceduralTreeMesh::trunk_get_length);
ClassDB::bind_method(D_METHOD("trunk_set_length", "value"), &ProceduralTreeMesh::trunk_set_length);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "trunk_length"), "trunk_set_length", "trunk_get_length");
2024-09-08 14:25:06 +02:00
ADD_GROUP("Mesh", "");
ClassDB::bind_method(D_METHOD("_update"), &ProceduralTreeMesh::_update);
2024-09-08 13:28:45 +02:00
ClassDB::bind_method(D_METHOD("set_twig_material", "material"), &ProceduralTreeMesh::set_twig_material);
ClassDB::bind_method(D_METHOD("get_twig_material"), &ProceduralTreeMesh::get_twig_material);
2024-09-08 13:28:45 +02:00
2024-09-08 14:25:06 +02:00
ClassDB::bind_method(D_METHOD("set_trunk_material", "material"), &ProceduralTreeMesh::set_trunk_material);
ClassDB::bind_method(D_METHOD("get_trunk_material"), &ProceduralTreeMesh::get_trunk_material);
ClassDB::bind_method(D_METHOD("get_mesh_arrays"), &ProceduralTreeMesh::get_mesh_arrays);
ClassDB::bind_method(D_METHOD("set_custom_aabb", "aabb"), &ProceduralTreeMesh::set_custom_aabb);
ClassDB::bind_method(D_METHOD("get_custom_aabb"), &ProceduralTreeMesh::get_custom_aabb);
2024-09-08 13:28:45 +02:00
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "twig_material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_twig_material", "get_twig_material");
2024-09-08 14:25:06 +02:00
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "trunk_material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_trunk_material", "get_trunk_material");
2024-09-08 13:28:45 +02:00
ADD_PROPERTY(PropertyInfo(Variant::AABB, "custom_aabb", PROPERTY_HINT_NONE, ""), "set_custom_aabb", "get_custom_aabb");
2024-09-08 13:35:37 +02:00
BIND_ENUM_CONSTANT(TREE_SURFACE_TRUNK);
BIND_ENUM_CONSTANT(TREE_SURFACE_TWIG);
BIND_ENUM_CONSTANT(TREE_SURFACE_COUNT);
}