Blank terrain plane mesh generated
This commit is contained in:
4
godot/ProceduralGeneration/Materials/terrain.tres
Normal file
4
godot/ProceduralGeneration/Materials/terrain.tres
Normal file
@ -0,0 +1,4 @@
|
||||
[gd_resource type="StandardMaterial3D" format=3 uid="uid://bvyxpk6nlcaol"]
|
||||
|
||||
[resource]
|
||||
albedo_color = Color(0.45098, 1, 0.25098, 1)
|
31
godot/ProceduralGeneration/TerrainGeneration.gd
Normal file
31
godot/ProceduralGeneration/TerrainGeneration.gd
Normal file
@ -0,0 +1,31 @@
|
||||
class_name TerrainGeneration
|
||||
extends Node
|
||||
|
||||
var mesh : MeshInstance3D
|
||||
var size_depth : int = 100
|
||||
var size_width : int = 100
|
||||
var mesh_res : int = 2
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
generate()
|
||||
|
||||
func generate():
|
||||
var plane_mesh = PlaneMesh.new()
|
||||
plane_mesh.size = Vector2(size_width, size_depth)
|
||||
plane_mesh.subdivide_depth = size_depth * mesh_res
|
||||
plane_mesh.subdivide_width = size_width * mesh_res
|
||||
plane_mesh.material = preload("res://ProceduralGeneration/Materials/terrain.tres")
|
||||
|
||||
var surface = SurfaceTool.new()
|
||||
|
||||
surface.create_from(plane_mesh, 0)
|
||||
|
||||
mesh = MeshInstance3D.new()
|
||||
mesh.mesh = surface.commit()
|
||||
mesh.create_trimesh_collision()
|
||||
mesh.cast_shadow = GeometryInstance3D.SHADOW_CASTING_SETTING_OFF
|
||||
|
||||
mesh.add_to_group("NavSource")
|
||||
add_child(mesh)
|
Reference in New Issue
Block a user