Improve chunks, optimization, replace placeholder and more
Co-authored-by: f.fabbrizi <f.fabbrizi@jmpgames.it> Co-committed-by: f.fabbrizi <f.fabbrizi@jmpgames.it>
This commit was merged in pull request #25.
This commit is contained in:
BIN
tgcc/chunk/prop/tree/bambù/Bambu.fbx
Normal file
BIN
tgcc/chunk/prop/tree/bambù/Bambu.fbx
Normal file
Binary file not shown.
@@ -4,12 +4,12 @@ importer="scene"
|
||||
importer_version=1
|
||||
type="PackedScene"
|
||||
uid="uid://cbdgxbaa5prt3"
|
||||
path="res://.godot/imported/Bambù.fbx-185461b004716dcd06053cac2ce96f9e.scn"
|
||||
path="res://.godot/imported/Bambu.fbx-679039988da372e4aaebb3e6c20dbfbc.scn"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://tgcc/chunk/prop/tree/bambù/Bambù.fbx"
|
||||
dest_files=["res://.godot/imported/Bambù.fbx-185461b004716dcd06053cac2ce96f9e.scn"]
|
||||
source_file="res://tgcc/chunk/prop/tree/bambù/Bambu.fbx"
|
||||
dest_files=["res://.godot/imported/Bambu.fbx-679039988da372e4aaebb3e6c20dbfbc.scn"]
|
||||
|
||||
[params]
|
||||
|
||||
@@ -37,7 +37,19 @@ import_script/path=""
|
||||
materials/extract=0
|
||||
materials/extract_format=0
|
||||
materials/extract_path=""
|
||||
_subresources={}
|
||||
_subresources={
|
||||
"meshes": {
|
||||
"Cylinder_032": {
|
||||
"generate/lightmap_uv": 0,
|
||||
"generate/lods": 0,
|
||||
"generate/shadow_meshes": 0,
|
||||
"lods/normal_merge_angle": 20.0,
|
||||
"save_to_file/enabled": true,
|
||||
"save_to_file/fallback_path": "res://tgcc/chunk/prop/tree/bambù/Bambu.res",
|
||||
"save_to_file/path": "uid://bg5rfu7tyl3p8"
|
||||
}
|
||||
}
|
||||
}
|
||||
fbx/importer=0
|
||||
fbx/allow_geometry_helper_nodes=false
|
||||
fbx/embedded_image_handling=1
|
||||
BIN
tgcc/chunk/prop/tree/bambù/Bambu.res
Normal file
BIN
tgcc/chunk/prop/tree/bambù/Bambu.res
Normal file
Binary file not shown.
Binary file not shown.
129
tgcc/chunk/prop/tree/bambù/bambu.gd
Normal file
129
tgcc/chunk/prop/tree/bambù/bambu.gd
Normal file
@@ -0,0 +1,129 @@
|
||||
@tool
|
||||
extends MultiMeshInstance3D
|
||||
|
||||
enum LayoutMode { FORESTA, IN_FILA }
|
||||
|
||||
@export_group("Impostazioni Layout")
|
||||
@export var modalità_layout: LayoutMode = LayoutMode.FORESTA:
|
||||
set(value):
|
||||
modalità_layout = value
|
||||
genera_bambù()
|
||||
|
||||
@export var rotazione_griglia_gradi: float = 0.0:
|
||||
set(value):
|
||||
rotazione_griglia_gradi = value
|
||||
genera_bambù()
|
||||
|
||||
@export_range(1, 500) var quantità_bambù: int = 50:
|
||||
set(value):
|
||||
quantità_bambù = value
|
||||
genera_bambù()
|
||||
|
||||
@export var area_dispersione: float = 10.0:
|
||||
set(value):
|
||||
area_dispersione = value
|
||||
genera_bambù()
|
||||
|
||||
@export var bambù_per_fila: int = 10:
|
||||
set(value):
|
||||
if value < 1: value = 1
|
||||
bambù_per_fila = value
|
||||
genera_bambù()
|
||||
|
||||
@export var spaziatura_x: float = 1.5:
|
||||
set(value):
|
||||
spaziatura_x = value
|
||||
genera_bambù()
|
||||
|
||||
@export var spaziatura_z: float = 1.5:
|
||||
set(value):
|
||||
spaziatura_z = value
|
||||
genera_bambù()
|
||||
|
||||
@export_group("Ottimizzazione FBX")
|
||||
@export var scala_correzione_xz: float = 1.0:
|
||||
set(value):
|
||||
scala_correzione_xz = value
|
||||
genera_bambù()
|
||||
|
||||
@export var scala_correzione_y: float = 1.0:
|
||||
set(value):
|
||||
scala_correzione_y = value
|
||||
genera_bambù()
|
||||
|
||||
@export var ruota_x_gradi: float = -90.0:
|
||||
set(value):
|
||||
ruota_x_gradi = value
|
||||
genera_bambù()
|
||||
|
||||
@export_group("Variazione Naturale")
|
||||
@export var altezza_minima: float = 0.8:
|
||||
set(value):
|
||||
altezza_minima = value
|
||||
genera_bambù()
|
||||
|
||||
@export var altezza_massima: float = 1.4:
|
||||
set(value):
|
||||
altezza_massima = value
|
||||
genera_bambù()
|
||||
|
||||
func _ready() -> void:
|
||||
genera_bambù()
|
||||
|
||||
func genera_bambù() -> void:
|
||||
if not multimesh:
|
||||
return
|
||||
|
||||
multimesh.instance_count = quantità_bambù
|
||||
seed(12345)
|
||||
|
||||
# Matrice di correzione fissa per l'FBX
|
||||
var fbx_correction = Transform3D()
|
||||
if ruota_x_gradi != 0.0:
|
||||
fbx_correction = fbx_correction.rotated(Vector3(1, 0, 0), deg_to_rad(ruota_x_gradi))
|
||||
|
||||
for i in range(quantità_bambù):
|
||||
var pos_x = 0.0
|
||||
var pos_z = 0.0
|
||||
var pos_y = 0.0
|
||||
|
||||
# 1. CALCOLO DELLE COORDINATE DELLA GRIGLIA
|
||||
if modalità_layout == LayoutMode.FORESTA:
|
||||
pos_x = randf_range(-area_dispersione, area_dispersione)
|
||||
pos_z = randf_range(-area_dispersione, area_dispersione)
|
||||
else:
|
||||
var colonna = i % bambù_per_fila
|
||||
@warning_ignore("integer_division")
|
||||
var fila = i / bambù_per_fila
|
||||
|
||||
var totale_colonne = min(quantità_bambù, bambù_per_fila)
|
||||
var totale_file = ceil(float(quantità_bambù) / bambù_per_fila)
|
||||
|
||||
pos_x = (colonna - (totale_colonne - 1) / 2.0) * spaziatura_x
|
||||
pos_z = (fila - (totale_file - 1) / 2.0) * spaziatura_z
|
||||
|
||||
# Ruotiamo i punti della griglia se richiesto
|
||||
if rotazione_griglia_gradi != 0.0:
|
||||
var pos_2d = Vector2(pos_x, pos_z).rotated(deg_to_rad(rotazione_griglia_gradi))
|
||||
pos_x = pos_2d.x
|
||||
pos_z = pos_2d.y
|
||||
|
||||
# 2. COSTRUZIONE DELLA TRASFORMAZIONE (Dall'origine verso il mondo)
|
||||
var world_xform = Transform3D()
|
||||
|
||||
# Fa girare il bambù su se stesso PRIMA di muoverlo (gira sul proprio perno)
|
||||
var rotazione_y = randf_range(0.0, TAU)
|
||||
world_xform = world_xform.rotated(Vector3.UP, rotazione_y)
|
||||
|
||||
# Applica la scala sul proprio asse localmente
|
||||
var scale_y = randf_range(altezza_minima, altezza_massima) * scala_correzione_y
|
||||
var scale_xz = randf_range(0.9, 1.1) * scala_correzione_xz
|
||||
world_xform = world_xform.scaled_local(Vector3(scale_xz, scale_y, scale_xz))
|
||||
|
||||
# SOLO ORA lo spostiamo nella sua posizione finale sulla griglia
|
||||
world_xform.origin = Vector3(pos_x, pos_y, pos_z)
|
||||
|
||||
# 3. FUSIONE CON LA CORREZIONE FBX
|
||||
var final_xform = world_xform * fbx_correction
|
||||
|
||||
multimesh.set_instance_transform(i, final_xform)
|
||||
1
tgcc/chunk/prop/tree/bambù/bambu.gd.uid
Normal file
1
tgcc/chunk/prop/tree/bambù/bambu.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cp1pb5dnuojg3
|
||||
@@ -1,8 +1,8 @@
|
||||
[gd_scene format=3 uid="uid://c7hdw2g6sbygr"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://cbdgxbaa5prt3" path="res://tgcc/chunk/prop/tree/bambù/Bambù.fbx" id="1_rrnp2"]
|
||||
[ext_resource type="Material" uid="uid://b2tlen8e88l70" path="res://tgcc/chunk/prop/tree/bambù/Bambù.tres" id="2_r5ebk"]
|
||||
[ext_resource type="Material" uid="uid://1bbbnb0w665f" path="res://tgcc/chunk/prop/tree/bambù/bambù.material" id="2_ul8mj"]
|
||||
[ext_resource type="PackedScene" uid="uid://cbdgxbaa5prt3" path="res://tgcc/chunk/prop/tree/bambù/Bambu.fbx" id="1_rrnp2"]
|
||||
[ext_resource type="Material" uid="uid://b2tlen8e88l70" path="res://tgcc/chunk/prop/tree/bambù/Bambu.tres" id="2_r5ebk"]
|
||||
[ext_resource type="Material" uid="uid://1bbbnb0w665f" path="res://tgcc/chunk/prop/tree/bambù/bambu.material" id="2_ul8mj"]
|
||||
|
||||
[node name="Bambù" unique_id=514636059 instance=ExtResource("1_rrnp2")]
|
||||
|
||||
Reference in New Issue
Block a user