Fix washed-out look (inverted terrain normals via winding), tune lighting/fog, add tree+rock collision
This commit is contained in:
@@ -36,6 +36,17 @@ func _make_tree(pos: Vector3, rng: RandomNumberGenerator) -> void:
|
||||
trunk.material_override = _mat(Color(0.33, 0.24, 0.16))
|
||||
root.add_child(trunk)
|
||||
|
||||
# Collision: a capsule around the trunk so you can't walk through the tree.
|
||||
var body := StaticBody3D.new()
|
||||
root.add_child(body)
|
||||
var col := CollisionShape3D.new()
|
||||
var cap := CapsuleShape3D.new()
|
||||
cap.radius = 0.35
|
||||
cap.height = 4.0
|
||||
col.shape = cap
|
||||
col.position = Vector3(0, 2.0, 0)
|
||||
body.add_child(col)
|
||||
|
||||
# Low-poly conifer canopy: stacked cones.
|
||||
var h := 3.0
|
||||
for j in range(3):
|
||||
@@ -57,13 +68,25 @@ func _make_tree(pos: Vector3, rng: RandomNumberGenerator) -> void:
|
||||
func _make_rock(pos: Vector3, rng: RandomNumberGenerator) -> void:
|
||||
var rock := MeshInstance3D.new()
|
||||
var bm := BoxMesh.new()
|
||||
bm.size = Vector3(rng.randf_range(0.8, 1.8), rng.randf_range(0.6, 1.2), rng.randf_range(0.8, 1.8))
|
||||
var box_size := Vector3(rng.randf_range(0.8, 1.8), rng.randf_range(0.6, 1.2), rng.randf_range(0.8, 1.8))
|
||||
bm.size = box_size
|
||||
rock.mesh = bm
|
||||
rock.position = pos + Vector3(0, 0.3, 0)
|
||||
rock.rotation = Vector3(rng.randf_range(-0.2, 0.2), rng.randf_range(0, TAU), rng.randf_range(-0.2, 0.2))
|
||||
rock.material_override = _mat(Color(0.42, 0.42, 0.45))
|
||||
add_child(rock)
|
||||
|
||||
# Collision: a box matching the rock mesh.
|
||||
var body := StaticBody3D.new()
|
||||
body.position = rock.position
|
||||
body.rotation = rock.rotation
|
||||
add_child(body)
|
||||
var col := CollisionShape3D.new()
|
||||
var box := BoxShape3D.new()
|
||||
box.size = box_size
|
||||
col.shape = box
|
||||
body.add_child(col)
|
||||
|
||||
func _mat(c: Color) -> StandardMaterial3D:
|
||||
var m := StandardMaterial3D.new()
|
||||
m.albedo_color = c
|
||||
|
||||
Reference in New Issue
Block a user