ceiling ???
This commit is contained in:
parent
8908b51103
commit
ff2020af43
@ -10,6 +10,7 @@ class_name SpaceRegion
|
||||
@export var height: float = 100.0
|
||||
@export var wall_texture: Texture2D
|
||||
@export var floor_texture: Texture2D
|
||||
@export var ceiling_texture: Texture2D
|
||||
|
||||
|
||||
func generate_geometry(space: Space) -> Node3D:
|
||||
@ -43,6 +44,12 @@ func _generate_geometry(space: Space, looked_from_inside: bool) -> Node3D:
|
||||
floor_material.albedo_texture = floor_texture
|
||||
mesh.surface_set_material(1, floor_material)
|
||||
|
||||
mesh.add_surface_from_arrays(Mesh.PRIMITIVE_TRIANGLES, _generate_ceiling_arrays(space))
|
||||
var ceiling_material := StandardMaterial3D.new()
|
||||
ceiling_material.albedo_texture = ceiling_texture
|
||||
ceiling_material.cull_mode = BaseMaterial3D.CULL_FRONT # todo: Don't require state change
|
||||
mesh.surface_set_material(2, ceiling_material)
|
||||
|
||||
geometry.mesh = mesh
|
||||
|
||||
for child in get_children():
|
||||
@ -124,3 +131,27 @@ func _generate_floor_arrays(space: Space) -> Array:
|
||||
arrays[Mesh.ARRAY_TEX_UV] = uvs
|
||||
|
||||
return arrays
|
||||
|
||||
|
||||
# todo: Reuse triangulation with the floor
|
||||
func _generate_ceiling_arrays(space: Space) -> Array:
|
||||
var triangulation := Geometry2D.triangulate_polygon(self.polygon)
|
||||
var vertices := PackedVector3Array()
|
||||
var uvs := PackedVector2Array()
|
||||
vertices.resize(triangulation.size())
|
||||
uvs.resize(triangulation.size())
|
||||
|
||||
for i in range(triangulation.size()):
|
||||
vertices[i] = Vector3(
|
||||
self.polygon[triangulation[i]].x * space.unit_scale,
|
||||
(elevation + height) * space.unit_scale,
|
||||
self.polygon[triangulation[i]].y * space.unit_scale,
|
||||
)
|
||||
uvs[i] = self.polygon[triangulation[i]] * space.unit_scale
|
||||
|
||||
var arrays := Array()
|
||||
arrays.resize(Mesh.ARRAY_MAX)
|
||||
arrays[Mesh.ARRAY_VERTEX] = vertices
|
||||
arrays[Mesh.ARRAY_TEX_UV] = uvs
|
||||
|
||||
return arrays
|
||||
|
@ -20,6 +20,7 @@ uv = PackedVector2Array(1.88, 5.28, 0.6, 1.44, 5.24, 0.64, 5.24, 0.64, 9.94, 3.8
|
||||
script = ExtResource("2_s3h7s")
|
||||
wall_texture = ExtResource("3_ondo6")
|
||||
floor_texture = ExtResource("4_mnswr")
|
||||
ceiling_texture = ExtResource("4_mnswr")
|
||||
|
||||
[node name="Column" type="Polygon2D" parent="Room"]
|
||||
texture_repeat = 2
|
||||
|
Loading…
Reference in New Issue
Block a user