Skip to content

Commit

Permalink
Revert "chore: removed test files from master branch"
Browse files Browse the repository at this point in the history
This reverts commit 01feecb.
  • Loading branch information
akorzunin committed Aug 5, 2024
1 parent 7f06638 commit 664ebd9
Show file tree
Hide file tree
Showing 5 changed files with 376 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/models/icosahedron/test/Material.face_index.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[gd_resource type="StandardMaterial3D" load_steps=4 format=3 uid="uid://b6aokpwbpsi2l"]

[ext_resource type="Texture2D" uid="uid://cf1aybqr46afw" path="res://src/models/icosahedron/test/UV_face_index.png" id="1_w4ekc"]
[ext_resource type="Shader" path="res://src/models/icosahedron/shaders/cutplane_effect_v3.gdshader" id="2_x1gid"]

[sub_resource type="ShaderMaterial" id="ShaderMaterial_2ft62"]
render_priority = 0
shader = ExtResource("2_x1gid")
shader_parameter/cutplane = Vector4(0.358, 0, 0.934, 0.794)
shader_parameter/color = Color(0, 1, 0, 1)
shader_parameter/enable = true
shader_parameter/outline_thickness = 0.0

[resource]
resource_name = "Material.002"
next_pass = SubResource("ShaderMaterial_2ft62")
albedo_texture = ExtResource("1_w4ekc")
roughness = 0.5
20 changes: 20 additions & 0 deletions src/models/icosahedron/test/PointerSphere.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@tool
extends MeshInstance3D
class_name PointerSphere

signal pointer_changed
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
set_notify_transform(true)
pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:

pass

func _notification(what: int) -> void:
match what:
NOTIFICATION_TRANSFORM_CHANGED:
pointer_changed.emit()
Binary file added src/models/icosahedron/test/UV_face_index.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
264 changes: 264 additions & 0 deletions src/models/icosahedron/test/cutplanes.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,264 @@
@tool
extends Node3D
class_name Cutplanes

const phi := 0.398
## fine analog of 1 for cutplane
const ico_a := 0.934
## fine analog of phi for cutplane
const ico_b := 0.358
## for diagonal vectors
const ico_c := 0.577


const w_2 := .849
const w_3 := 1.369
## correcn value in fine case for dst and dst
#const ico_dst := IcosahedronVarints.dst
const ico_dst := 0.794

#@onready var mesh_icosahedron: MeshIcosahedron = $MeshIcosahedron
@onready var pointer_sphere: MeshInstance3D = $PointerSphere
@onready var mesh_icosahedron: MeshInstance3D = $Solid

@export var enable_shader := true:
set(val):
enable_shader = val
var m = mesh_icosahedron.material_override
m.next_pass.set_shader_parameter("enable", val)

func set_shader_cutplane(_cutplane: Vector4):
if not mesh_icosahedron:
return
var m = mesh_icosahedron.material_override
m.next_pass.set_shader_parameter("cutplane", _cutplane)

@export var cutplane := Vector4(-0.577, -0.577, -0.577, IcosahedronVarints.dst):
set(val):
cutplane = val
set_shader_cutplane(val)

enum IcoAngle {ZERO_0, ONE_1, NEG_ONE_1, PHI, NEG_PHI, W_1, W_2, W_3}
@export var x := IcoAngle.ONE_1:
set(val):
x = val
if not set_silent:
cutplane.x = angle_to_float(val)
upd_cutplane()

@export var y := IcoAngle.ONE_1:
set(val):
y = val
if not set_silent:
cutplane.y = angle_to_float(val)
upd_cutplane()

@export var z := IcoAngle.ONE_1:
set(val):
z = val
if not set_silent:
cutplane.z = angle_to_float(val)
upd_cutplane()

@export var w := IcoAngle.W_3:
set(val):
w = val
if not set_silent:
cutplane.w = angle_to_float(val)
upd_cutplane()

var set_silent := false
@export var trans := TransformType.NONE:
set(val):
trans = val
cutplane = get_next_cutplane(cutplane, val)
set_silent = true
print_debug(cutplane)
x = float_to_angle(cutplane.x)
y = float_to_angle(cutplane.y)
z = float_to_angle(cutplane.z)
w = float_to_angle(cutplane.w)
set_silent = false
notify_property_list_changed()



func upd_cutplane():
set_shader_cutplane(cutplane)
notify_property_list_changed()


enum TransformType {NONE, SOME, NEG_X, NEG_Y, NEG_Z, SWAP_X}
func get_next_cutplane(_cutplane: Vector4, transfrom: TransformType) -> Vector4:
var c = _cutplane.abs()
var diag_vec = is_equal_approx(c.x, c.y) \
and is_equal_approx(c.y, c.z)
match transfrom:
TransformType.NEG_X:
_cutplane.x = -_cutplane.x
return _cutplane
TransformType.NEG_Y:
_cutplane.y = -_cutplane.y
return _cutplane
TransformType.NEG_Z:
_cutplane.z = -_cutplane.z
return _cutplane
TransformType.SWAP_X:
if diag_vec:
_cutplane.x = ico_b * cutplane.x
_cutplane.y = 0.
_cutplane.w = w_2
else:
_cutplane = Vector4(
sign(max(_cutplane.x, 1.)),
sign(max(cutplane.y, 1.)),
sign(max(cutplane.z, 1.)),
w_3
)
var a = pointer_sphere.position - mesh_icosahedron.position
print_debug(a)
var b = get_closest(a)
print_debug("v: ", b)
return Vector4(b.x, b.y, b.z, w_3 if diag_vec else w_2)

func get_closest(v: Vector3) -> Vector3:
var a = v.clamp(Vector3(-1, -1, -1), Vector3(1,1,1))
var diag := false
if a.abs() > Vector3(ico_b,ico_b,ico_b):
print_debug("a")
#for i in 3:
#var s = sign(a[i])
#if abs(a[i]) < ico_b:
#a[i] = 0
#else:
#a[i] = ico_b * s
#print_debug(a[i])
return a

func angle_to_float(ia: IcoAngle) -> float:
match ia:
IcoAngle.ZERO_0:
return 0.
IcoAngle.ONE_1:
return ico_a
IcoAngle.NEG_ONE_1:
return -ico_a
IcoAngle.PHI:
return ico_b
IcoAngle.NEG_PHI:
return -ico_b
IcoAngle.W_1:
return ico_dst
IcoAngle.W_2:
return w_2
IcoAngle.W_3:
return w_3
return 1.

func float_to_angle(f: float) -> IcoAngle:
if is_equal_approx(f, 0.):
return IcoAngle.ZERO_0
elif is_equal_approx(f, ico_a):
return IcoAngle.ONE_1
elif is_equal_approx(f, -ico_a):
return IcoAngle.NEG_ONE_1
elif is_equal_approx(f, ico_b):
return IcoAngle.PHI
elif is_equal_approx(f, ico_b):
return IcoAngle.NEG_PHI
elif is_equal_approx(f, ico_dst):
return IcoAngle.W_1
elif is_equal_approx(f, w_2):
return IcoAngle.W_2
elif is_equal_approx(f, w_3):
return IcoAngle.W_3
return IcoAngle.ONE_1

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pointer_sphere.pointer_changed.connect(_aboba)
pass # Replace with function body.

func _aboba() -> void:
trans = TransformType.NONE

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass


## icosahedron faces index according to UV map
const faces: Array[Vector4] = [
Vector4(ico_c, ico_c, -ico_c, ico_dst), # 0
Vector4(0, ico_a, -ico_b, ico_dst), # 1
Vector4(0, ico_a, ico_b, ico_dst), # 2
Vector4(ico_c, ico_c, ico_c, ico_dst), # 3
Vector4(ico_a, ico_b, 0, ico_dst), # 4
Vector4(ico_a, -ico_b, 0, ico_dst), # 5
Vector4(-ico_c, ico_c, ico_c, ico_dst), # 6
Vector4(-ico_b, 0, ico_a, ico_dst), # 7
Vector4(ico_b, 0, ico_a, ico_dst), # 8
Vector4(ico_c, -ico_c, ico_c, ico_dst), # 9
Vector4(-ico_a, ico_b, 0, ico_dst), # 10
Vector4(-ico_a, -ico_b, 0, ico_dst), # 11
Vector4(-ico_c, -ico_c, ico_c, ico_dst), # 12
Vector4(-ico_c, ico_c, -ico_c, ico_dst), # 13
Vector4(-ico_b, 0, -ico_a, ico_dst), # 14
Vector4(-ico_c, -ico_c, -ico_c, ico_dst), # 15
Vector4(0, -ico_a, -ico_b, ico_dst), # 16
Vector4(0, -ico_a, ico_b, ico_dst), # 17
Vector4(ico_b, 0, -ico_a, ico_dst), # 18
Vector4(ico_c, -ico_c, -ico_c, ico_dst), # 19
]

@export_range(0, 19) var fi: int:
set(val):
fi = val
var v = faces[fi]
cutplane = Vector4(v.x, v.y, v.z, ico_dst)

@export_category("Debug transform effects")
@export_enum("f_circle", "f_roatate_edge", ) var transfrom_list: String
@export var test_effect: bool:
set(value):
call(transfrom_list)

func f_none():
pass

func f_call(_f: Callable):
var res = _f.call(cutplane, fi)
cutplane = res.cutplane
fi = res.cur_id
notify_property_list_changed()

func f_circle():
f_call(roatate_circle)

static func roatate_circle(cutplane: Vector4, cur_id: int):
cur_id += 1
if cur_id > 19:
cur_id = 0
return {
cutplane = faces[cur_id],
cur_id = cur_id,
}

func f_roatate_edge():
f_call(roatate_edge)

static func roatate_edge(cutplane: Vector4, cur_id: int):
match cur_id:
0,1,2,3,4:
cur_id += 1
if cur_id > 4:
cur_id = 0
return {
cutplane = faces[cur_id],
cur_id = cur_id,
}
_:
return {
cutplane = faces[0],
cur_id = 0,
}
74 changes: 74 additions & 0 deletions src/models/icosahedron/test/cutplanes.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
[gd_scene load_steps=8 format=3 uid="uid://dr612yxxuqkob"]

[ext_resource type="ArrayMesh" uid="uid://dh3qpoqqgdct5" path="res://src/models/icosahedron/assets/icosahedron_Solid.res" id="1_26764"]
[ext_resource type="Script" path="res://src/models/icosahedron/test/cutplanes.gd" id="1_gtl60"]
[ext_resource type="Script" path="res://src/models/icosahedron/components/MeshIcosahedron.gd" id="2_32806"]
[ext_resource type="Material" uid="uid://b6aokpwbpsi2l" path="res://src/models/icosahedron/test/Material.face_index.tres" id="2_tiql4"]
[ext_resource type="Script" path="res://src/models/icosahedron/test/PointerSphere.gd" id="4_a7juu"]

[sub_resource type="ArrayMesh" id="ArrayMesh_f5xtf"]
resource_name = "icosahedron_Solid"
_surfaces = [{
"aabb": AABB(-0.850651, -0.850651, -0.850651, 1.70131, 1.7013, 1.7013),
"attribute_data": PackedByteArray(137, 83, 248, 255, 137, 83, 248, 255, 83, 232, 114, 156, 83, 232, 114, 156, 83, 232, 114, 156, 247, 39, 66, 170, 247, 39, 66, 170, 247, 39, 66, 170, 247, 39, 66, 170, 247, 39, 66, 170, 136, 208, 96, 201, 136, 208, 96, 201, 136, 208, 96, 201, 136, 208, 96, 201, 136, 208, 96, 201, 228, 59, 225, 121, 228, 59, 225, 121, 228, 59, 225, 121, 6, 128, 247, 243, 6, 128, 247, 243, 188, 179, 245, 170, 188, 179, 245, 170, 188, 179, 245, 170, 188, 179, 245, 170, 188, 179, 245, 170, 248, 127, 3, 203, 248, 127, 3, 203, 248, 127, 3, 203, 248, 255, 103, 221, 248, 255, 103, 221, 6, 0, 114, 156, 6, 0, 114, 156, 6, 128, 214, 174, 6, 128, 214, 174, 6, 128, 214, 174, 37, 89, 127, 163, 37, 89, 127, 163, 37, 89, 127, 163, 37, 89, 127, 163, 37, 89, 127, 163, 171, 23, 103, 221, 171, 23, 103, 221, 117, 172, 225, 121, 171, 23, 103, 221, 117, 172, 225, 121, 75, 166, 223, 213, 75, 166, 223, 213, 75, 166, 223, 213, 75, 166, 223, 213, 75, 166, 223, 213, 201, 73, 89, 204, 201, 73, 89, 204, 201, 73, 89, 204, 201, 73, 89, 204, 201, 73, 89, 204, 248, 127, 226, 133, 26, 196, 248, 255, 248, 127, 226, 133, 26, 196, 248, 255, 26, 196, 248, 255),
"format": 34896613399,
"index_count": 60,
"index_data": PackedByteArray(2, 0, 22, 0, 44, 0, 1, 0, 54, 0, 27, 0, 12, 0, 49, 0, 23, 0, 11, 0, 28, 0, 59, 0, 8, 0, 40, 0, 31, 0, 7, 0, 36, 0, 50, 0, 18, 0, 32, 0, 45, 0, 17, 0, 55, 0, 37, 0, 0, 0, 43, 0, 53, 0, 9, 0, 51, 0, 41, 0, 10, 0, 58, 0, 48, 0, 19, 0, 46, 0, 56, 0, 24, 0, 4, 0, 14, 0, 29, 0, 13, 0, 3, 0, 30, 0, 16, 0, 6, 0, 35, 0, 5, 0, 15, 0, 42, 0, 20, 0, 33, 0, 47, 0, 34, 0, 21, 0, 52, 0, 38, 0, 25, 0, 57, 0, 26, 0, 39, 0),
"name": "Material.002",
"primitive": 3,
"uv_scale": Vector4(0, 0, 0, 0),
"vertex_count": 60,
"vertex_data": PackedByteArray(254, 255, 255, 127, 228, 48, 99, 247, 254, 255, 255, 127, 228, 48, 219, 238, 254, 255, 255, 127, 228, 48, 253, 217, 254, 255, 255, 127, 228, 48, 99, 203, 254, 255, 255, 127, 228, 48, 133, 201, 0, 0, 255, 127, 228, 48, 95, 198, 0, 0, 255, 127, 228, 48, 206, 228, 0, 0, 255, 127, 228, 48, 125, 217, 0, 0, 255, 127, 228, 48, 216, 249, 0, 0, 255, 127, 228, 48, 104, 247, 254, 255, 255, 127, 26, 207, 153, 161, 254, 255, 255, 127, 26, 207, 210, 192, 254, 255, 255, 127, 26, 207, 61, 175, 254, 255, 255, 127, 26, 207, 99, 203, 254, 255, 255, 127, 26, 207, 133, 201, 0, 0, 255, 127, 26, 207, 95, 198, 0, 0, 255, 127, 26, 207, 206, 228, 0, 0, 255, 127, 26, 207, 44, 167, 0, 0, 255, 127, 26, 207, 249, 166, 0, 0, 255, 127, 26, 207, 212, 145, 26, 207, 255, 255, 255, 127, 228, 206, 26, 207, 255, 255, 255, 127, 59, 177, 26, 207, 255, 255, 255, 127, 253, 217, 26, 207, 255, 255, 255, 127, 61, 175, 26, 207, 255, 255, 255, 127, 133, 201, 26, 207, 0, 0, 255, 127, 201, 213, 26, 207, 0, 0, 255, 127, 74, 182, 26, 207, 0, 0, 255, 127, 219, 238, 26, 207, 0, 0, 255, 127, 210, 192, 26, 207, 0, 0, 255, 127, 99, 203, 227, 48, 255, 255, 255, 127, 206, 228, 227, 48, 255, 255, 255, 127, 216, 249, 227, 48, 255, 255, 255, 127, 249, 166, 227, 48, 255, 255, 255, 127, 228, 206, 227, 48, 255, 255, 255, 127, 59, 177, 227, 48, 0, 0, 255, 127, 95, 198, 227, 48, 0, 0, 255, 127, 125, 217, 227, 48, 0, 0, 255, 127, 44, 167, 227, 48, 0, 0, 255, 127, 201, 213, 227, 48, 0, 0, 255, 127, 74, 182, 255, 127, 26, 207, 0, 0, 216, 249, 255, 127, 26, 207, 0, 0, 104, 247, 255, 127, 26, 207, 0, 0, 228, 206, 255, 127, 26, 207, 0, 0, 99, 247, 255, 127, 26, 207, 0, 0, 253, 217, 255, 127, 26, 207, 255, 255, 249, 166, 255, 127, 26, 207, 255, 255, 212, 145, 255, 127, 26, 207, 255, 255, 59, 177, 255, 127, 26, 207, 255, 255, 153, 161, 255, 127, 26, 207, 255, 255, 61, 175, 255, 127, 228, 48, 0, 0, 125, 217, 255, 127, 228, 48, 0, 0, 104, 247, 255, 127, 228, 48, 0, 0, 201, 213, 255, 127, 228, 48, 0, 0, 99, 247, 255, 127, 228, 48, 0, 0, 219, 238, 255, 127, 228, 48, 255, 255, 44, 167, 255, 127, 228, 48, 255, 255, 212, 145, 255, 127, 228, 48, 255, 255, 74, 182, 255, 127, 228, 48, 255, 255, 153, 161, 255, 127, 228, 48, 255, 255, 210, 192, 104, 195, 216, 79, 247, 22, 66, 185, 252, 199, 55, 81, 34, 142, 207, 53, 155, 179, 49, 84, 179, 78, 195, 178, 21, 91, 183, 169, 137, 58, 57, 180, 240, 88, 163, 182, 126, 60, 10, 176, 62, 142, 121, 91, 55, 121, 217, 72, 98, 186, 71, 100, 34, 142, 207, 53, 155, 179, 49, 84, 179, 78, 195, 178, 21, 91, 183, 169, 59, 65, 7, 184, 53, 188, 105, 191, 59, 119, 185, 199, 67, 249, 252, 131, 83, 244, 193, 132, 252, 199, 55, 81, 98, 186, 71, 100, 155, 179, 49, 84, 201, 36, 28, 190, 166, 22, 141, 183, 247, 22, 66, 185, 55, 121, 217, 72, 34, 142, 207, 53, 21, 91, 183, 169, 240, 88, 163, 182, 53, 188, 105, 191, 67, 249, 252, 131, 83, 244, 193, 132, 179, 78, 195, 178, 137, 58, 57, 180, 59, 65, 7, 184, 201, 36, 28, 190, 166, 22, 141, 183, 240, 88, 163, 182, 126, 60, 10, 176, 67, 249, 252, 131, 104, 195, 216, 79, 252, 199, 55, 81, 53, 188, 105, 191, 59, 119, 185, 199, 83, 244, 193, 132, 62, 142, 121, 91, 98, 186, 71, 100, 137, 58, 57, 180, 126, 60, 10, 176, 201, 36, 28, 190, 104, 195, 216, 79, 247, 22, 66, 185, 59, 65, 7, 184, 59, 119, 185, 199, 166, 22, 141, 183, 62, 142, 121, 91, 55, 121, 217, 72)
}]
blend_shape_mode = 0

[sub_resource type="SphereMesh" id="SphereMesh_4esic"]

[node name="Cutplanes" type="Node3D"]
script = ExtResource("1_gtl60")
cutplane = Vector4(-0.934, 0.358, 0, 0.794)
x = 0
y = 2
z = 0
w = 5
trans = 2
fi = 10
transfrom_list = "f_circle"
metadata/_edit_pinned_properties_ = [&"fi"]

[node name="Solid" type="MeshInstance3D" parent="."]
material_override = ExtResource("2_tiql4")
transparency = 0.15
cast_shadow = 0
mesh = SubResource("ArrayMesh_f5xtf")
skeleton = NodePath("")

[node name="MeshIcosahedron" type="MeshInstance3D" parent="."]
visible = false
material_override = ExtResource("2_tiql4")
transparency = 0.71
mesh = ExtResource("1_26764")
script = ExtResource("2_32806")

[node name="PointerSphere" type="MeshInstance3D" parent="."]
transform = Transform3D(0.35, 0, 0, 0, 0.35, 0, 0, 0, 0.35, 1.32146, 1.46401, 1.37105)
mesh = SubResource("SphereMesh_4esic")
script = ExtResource("4_a7juu")

[node name="icosahedron" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -3.94164, 0, -0.260351)
visible = false

[node name="Light" type="OmniLight3D" parent="icosahedron"]
transform = Transform3D(-0.290865, -0.771101, 0.566393, -0.055189, 0.604525, 0.794672, -0.955171, 0.199883, -0.218391, 4.07625, 5.90386, -1.00545)
visible = false
light_energy = 54351.4
omni_range = 4096.0

[node name="Camera" type="Camera3D" parent="icosahedron"]
transform = Transform3D(0.685921, -0.324013, 0.651558, -1.49012e-08, 0.895396, 0.445271, -0.727676, -0.305421, 0.61417, 7.35889, 4.95831, 6.92579)
visible = false
current = true
fov = 22.8952
near = 0.1
far = 100.0

0 comments on commit 664ebd9

Please sign in to comment.