I don't know what, but I'm sure something has changed.
This commit is contained in:
parent
65a11991fc
commit
e2ada93a08
25
Buctton.gd
25
Buctton.gd
@ -3,14 +3,17 @@ extends Button
|
||||
|
||||
|
||||
func _on_Button_pressed():
|
||||
SummerDay.z_space_manager.z_ranges.clear()
|
||||
var a = SummerDayZRange.new()
|
||||
a.index = 0
|
||||
var b = SummerDayZRange.new()
|
||||
var c = SummerDayZRange.new()
|
||||
b.index = 1
|
||||
a.index = 1
|
||||
c.index = 2
|
||||
c.index = 0
|
||||
b.index = 0
|
||||
print(str(a.index) + ", " + str(b.index) + ", " + str(c.index))
|
||||
var quad = SummerDayQuad.new()
|
||||
quad.guess_normal()
|
||||
|
||||
# SummerDay.z_space_manager.z_ranges.clear()
|
||||
# var a = SummerDayZRange.new()
|
||||
# a.index = 0
|
||||
# var b = SummerDayZRange.new()
|
||||
# var c = SummerDayZRange.new()
|
||||
# b.index = 1
|
||||
# a.index = 1
|
||||
# c.index = 2
|
||||
# c.index = 0
|
||||
# b.index = 0
|
||||
# print(str(a.index) + ", " + str(b.index) + ", " + str(c.index))
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
[sub_resource type="Image" id=1]
|
||||
data = {
|
||||
"data": PoolByteArray( 65, 239, 176, 190, 71, 61, 75, 189, 0, 0, 0, 0, 62, 8, 104, 62, 225, 23, 108, 188, 79, 178, 95, 190, 0, 0, 0, 0, 235, 85, 150, 61, 238, 130, 247, 61, 4, 190, 218, 62, 0, 0, 0, 0, 0, 0, 128, 63, 238, 130, 247, 61, 4, 190, 218, 62, 0, 0, 0, 0, 0, 0, 128, 63, 149, 180, 151, 190, 43, 243, 217, 188, 0, 0, 0, 0, 194, 193, 28, 190, 74, 160, 139, 188, 18, 181, 131, 190, 0, 0, 0, 0, 105, 78, 11, 190, 170, 140, 27, 62, 130, 27, 96, 62, 0, 0, 0, 0, 0, 0, 128, 191, 170, 140, 27, 190, 130, 27, 96, 190, 0, 0, 0, 0, 0, 0, 128, 63 ),
|
||||
"data": PoolByteArray( 66, 239, 176, 190, 85, 61, 75, 189, 0, 0, 0, 0, 60, 8, 104, 62, 211, 23, 108, 188, 79, 178, 95, 190, 0, 0, 0, 0, 239, 85, 150, 61, 245, 130, 247, 61, 1, 190, 218, 62, 0, 0, 0, 0, 0, 0, 128, 63, 245, 130, 247, 61, 1, 190, 218, 62, 0, 0, 0, 0, 0, 0, 128, 63, 119, 234, 78, 190, 46, 210, 79, 61, 0, 0, 0, 0, 68, 26, 14, 190, 108, 59, 114, 61, 150, 204, 59, 190, 0, 0, 0, 0, 200, 146, 21, 190, 139, 5, 64, 62, 164, 242, 51, 62, 0, 0, 0, 0, 0, 0, 128, 191, 139, 5, 64, 190, 164, 242, 51, 190, 0, 0, 0, 0, 0, 0, 128, 63 ),
|
||||
"format": "RGBAFloat",
|
||||
"height": 1,
|
||||
"mipmaps": false,
|
||||
|
@ -1,6 +1,12 @@
|
||||
extends Resource
|
||||
class_name SummerDayQuad
|
||||
|
||||
export(PoolVector3Array) var original_vertices = PoolVector3Array([
|
||||
Vector3(-1.0, -1.0, 0.0),
|
||||
Vector3(1.0, -1.0, 0.0),
|
||||
Vector3(1.0, 1.0, 0.0),
|
||||
Vector3(-1.0, 1.0, 0.0),
|
||||
])
|
||||
|
||||
export(PoolVector2Array) var vertices = PoolVector2Array([
|
||||
Vector2(-0.4, -0.4),
|
||||
@ -10,11 +16,70 @@ export(PoolVector2Array) var vertices = PoolVector2Array([
|
||||
])
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass # Replace with function body.
|
||||
func guess_normal() -> Vector3:
|
||||
var original_angles = get_quad_angles(original_vertices)
|
||||
|
||||
var angles = get_quad_angles(vertices)
|
||||
|
||||
var angle_changes = [
|
||||
range_lerp(angles[0], original_angles[0], PI, 0.0, 1.0),
|
||||
range_lerp(angles[1], original_angles[1], PI, 0.0, 1.0),
|
||||
range_lerp(angles[2], original_angles[2], PI, 0.0, 1.0),
|
||||
range_lerp(angles[3], original_angles[3], PI, 0.0, 1.0),
|
||||
]
|
||||
|
||||
var FRONT_VECTOR = Vector3(0.0, 0.0, -1.0)
|
||||
|
||||
# Going \.
|
||||
var s_slope_vector_dest
|
||||
var s_slope_vector_weight
|
||||
if angle_changes[0] > angle_changes[2]:
|
||||
s_slope_vector_dest = Vector3(-1.0, -1.0, 0.0)
|
||||
s_slope_vector_weight = angle_changes[0]
|
||||
elif angle_changes[0] < angle_changes[2]:
|
||||
s_slope_vector_dest = Vector3(1.0, 1.0, 0.0)
|
||||
s_slope_vector_weight = angle_changes[2]
|
||||
else:
|
||||
s_slope_vector_dest = FRONT_VECTOR
|
||||
s_slope_vector_weight = 0.0
|
||||
|
||||
# Going /.
|
||||
var z_slope_vector_dest
|
||||
var z_slope_vector_weight
|
||||
if angle_changes[1] > angle_changes[3]:
|
||||
z_slope_vector_dest = Vector3(1.0, -1.0, 0.0)
|
||||
z_slope_vector_weight = angle_changes[1]
|
||||
elif angle_changes[1] < angle_changes[3]:
|
||||
z_slope_vector_dest = Vector3(-1.0, 1.0, 0.0)
|
||||
z_slope_vector_weight = angle_changes[3]
|
||||
else:
|
||||
z_slope_vector_dest = FRONT_VECTOR
|
||||
z_slope_vector_weight = 0.0
|
||||
|
||||
var s_slope_vector = FRONT_VECTOR.slerp(
|
||||
s_slope_vector_dest, s_slope_vector_weight
|
||||
)
|
||||
|
||||
var z_slope_vector = FRONT_VECTOR.slerp(
|
||||
z_slope_vector_dest, z_slope_vector_weight
|
||||
)
|
||||
|
||||
var total_weight = s_slope_vector_weight + z_slope_vector_weight
|
||||
if total_weight != 0.0:
|
||||
return s_slope_vector.slerp(
|
||||
z_slope_vector, s_slope_vector_weight / total_weight
|
||||
)
|
||||
else:
|
||||
return FRONT_VECTOR
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
# pass
|
||||
func get_quad_angles(verts) -> Array:
|
||||
var angles = []
|
||||
for i in range(4):
|
||||
var next_i = wrapi(i + 1, 0, 4)
|
||||
var prev_i = wrapi(i - 1, 0, 4)
|
||||
var to_next = verts[next_i] - verts[i]
|
||||
var to_prev = verts[prev_i] - verts[i]
|
||||
var angle = to_next.angle_to(to_prev)
|
||||
angles.append(angle)
|
||||
return angles
|
||||
|
@ -14,6 +14,13 @@ export(PoolVector2Array) var vertices = PoolVector2Array([
|
||||
Vector2(-0.1, 0.4),
|
||||
])
|
||||
|
||||
|
||||
### DEBUG ###
|
||||
var test_quad = SummerDayQuad.new()
|
||||
var normal = Vector2(0.0, 0.0)
|
||||
|
||||
|
||||
|
||||
var picked_point = -1
|
||||
|
||||
|
||||
@ -42,6 +49,15 @@ func _interact(event: InputEvent) -> bool: # Virtual.
|
||||
|
||||
vertices[picked_point] = event.position
|
||||
_update_table()
|
||||
|
||||
|
||||
### DEBUG ###
|
||||
for i in range(0, 4):
|
||||
test_quad.vertices[i] = vertices[i]
|
||||
var normal_3d = test_quad.guess_normal()
|
||||
normal = Vector2(normal_3d.x, normal_3d.y) * 0.2
|
||||
|
||||
|
||||
update_interaction_hint()
|
||||
return true
|
||||
|
||||
@ -90,6 +106,16 @@ func _draw_interaction_hint():
|
||||
_with_z(vertices[wrapi(i + 1, 0, 4)], 0.0),
|
||||
Color.cornflower
|
||||
)
|
||||
|
||||
|
||||
### DEBUG ###
|
||||
draw_line(
|
||||
_with_z(vertices[i], 0.0),
|
||||
_with_z(vertices[i] + normal, 0.0),
|
||||
Color.mintcream
|
||||
)
|
||||
|
||||
|
||||
for i in range(4):
|
||||
draw_line(
|
||||
_with_z(vertices[i], 0.0),
|
||||
|
@ -28,3 +28,10 @@ func _set_index(value: int):
|
||||
|
||||
func _get_index():
|
||||
return _index
|
||||
|
||||
|
||||
# Only returns the z row of rotation Transform. + Translation, right?
|
||||
func _get_rotation(rotation: Quat) -> Vector3:
|
||||
var basis = Basis(rotation)
|
||||
var z_row = basis.z
|
||||
return Vector3.ZERO
|
||||
|
@ -51,7 +51,7 @@ void fragment() {
|
||||
[sub_resource type="ShaderMaterial" id=7]
|
||||
render_priority = 1
|
||||
shader = SubResource( 6 )
|
||||
shader_param/canvas_transform = Basis( 0.999548, 0, -0.339853, 0, -1.22596, 0.160758, 0, 0, 1 )
|
||||
shader_param/canvas_transform = Basis( 0.00240964, 0, -1, 0, -0.00326797, 1, 0, 0, 1 )
|
||||
|
||||
[node name="Canvas" type="PanelContainer"]
|
||||
anchor_right = 1.0
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
[sub_resource type="Image" id=1]
|
||||
data = {
|
||||
"data": PoolByteArray( 65, 239, 176, 190, 71, 61, 75, 189, 0, 0, 0, 0, 62, 8, 104, 62, 225, 23, 108, 188, 79, 178, 95, 190, 0, 0, 0, 0, 235, 85, 150, 61, 238, 130, 247, 61, 4, 190, 218, 62, 0, 0, 0, 0, 0, 0, 128, 63, 238, 130, 247, 61, 4, 190, 218, 62, 0, 0, 0, 0, 0, 0, 128, 63, 149, 180, 151, 190, 43, 243, 217, 188, 0, 0, 0, 0, 194, 193, 28, 190, 74, 160, 139, 188, 18, 181, 131, 190, 0, 0, 0, 0, 105, 78, 11, 190, 170, 140, 27, 62, 130, 27, 96, 62, 0, 0, 0, 0, 0, 0, 128, 191, 170, 140, 27, 190, 130, 27, 96, 190, 0, 0, 0, 0, 0, 0, 128, 63 ),
|
||||
"data": PoolByteArray( 66, 239, 176, 190, 85, 61, 75, 189, 0, 0, 0, 0, 60, 8, 104, 62, 211, 23, 108, 188, 79, 178, 95, 190, 0, 0, 0, 0, 239, 85, 150, 61, 245, 130, 247, 61, 1, 190, 218, 62, 0, 0, 0, 0, 0, 0, 128, 63, 245, 130, 247, 61, 1, 190, 218, 62, 0, 0, 0, 0, 0, 0, 128, 63, 89, 93, 111, 190, 155, 15, 186, 60, 0, 0, 0, 0, 240, 213, 20, 190, 166, 49, 220, 60, 22, 11, 89, 190, 0, 0, 0, 0, 106, 51, 15, 190, 248, 151, 214, 61, 9, 93, 243, 61, 0, 0, 0, 0, 0, 0, 128, 191, 248, 151, 214, 189, 9, 93, 243, 189, 0, 0, 0, 0, 0, 0, 128, 63 ),
|
||||
"format": "RGBAFloat",
|
||||
"height": 1,
|
||||
"mipmaps": false,
|
||||
@ -26,7 +26,7 @@ image = SubResource( 1 )
|
||||
[sub_resource type="Resource" id=3]
|
||||
script = ExtResource( 6 )
|
||||
table = SubResource( 2 )
|
||||
vertices = PoolVector2Array( -0.756447, -0.652097, 0.124979, -0.403235, 0.123889, 0.100852, -0.396248, 0.0976196, -0.108909, -0.103003, 0.4, -0.1, 1.3759, 0.677717, -0.1, 0.4 )
|
||||
vertices = PoolVector2Array( -0.459035, -0.418504, 0.112703, -0.384075, 0.0536891, 0.0369665, -0.396248, 0.0976196, -0.108909, -0.103003, 0.4, -0.1, 1.3759, 0.677717, -0.1, 0.4 )
|
||||
|
||||
[sub_resource type="Resource" id=4]
|
||||
script = ExtResource( 2 )
|
||||
|
@ -57,5 +57,5 @@ void fragment() {
|
||||
|
||||
[resource]
|
||||
shader = SubResource( 1 )
|
||||
shader_param/canvas_transform = Basis( 0.553425, 0, -0.374799, 0, -0.678787, 0.280612, 0, 0, 1 )
|
||||
shader_param/canvas_transform = Basis( 0.622756, 0.051744, -0.187155, 0.0954389, -1.14864, 0.015115, 0, 0, 1 )
|
||||
shader_param/table = ExtResource( 1 )
|
||||
|
Loading…
Reference in New Issue
Block a user