Adds missing data

This commit is contained in:
Michel 2025-02-03 19:17:20 +01:00
parent e6391d9fdd
commit 53cdcc3433
620 changed files with 47293 additions and 151 deletions

View file

@ -0,0 +1,92 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
extends Node3D
class_name GizmoBase
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
func intersect_part(ray_origin:Vector3, ray_dir:Vector3, viewport_camera:Camera3D, mesh_inst:MeshInstance3D)->MathUtil.IntersectTriangleResult:
var proj:Projection = viewport_camera.get_camera_projection()
#Calc modelview matrix
var view_inv_matrix:Transform3D = viewport_camera.global_transform.affine_inverse()
var mv:Projection = Projection(view_inv_matrix * mesh_inst.global_transform)
#Static size adjustment
if proj[3][3] != 0:
var h:float = abs(1 / (2 * proj[1][1]))
var sc = h * 2
mv[0] *= sc
mv[1] *= sc
mv[2] *= sc
else:
var sc:float = -mv[3].z
mv[0] *= sc
mv[1] *= sc
mv[2] *= sc
var model_mtx:Projection = Projection(viewport_camera.global_transform) * mv
var mesh:Mesh = mesh_inst.mesh
var tris:PackedVector3Array = mesh.get_faces()
for i in range(0, tris.size(), 3):
var p0:Vector3 = tris[i]
var p1:Vector3 = tris[i + 1]
var p2:Vector3 = tris[i + 2]
var p0_t:Vector3 = proj_mul_point(model_mtx, p0)
var p1_t:Vector3 = proj_mul_point(model_mtx, p1)
var p2_t:Vector3 = proj_mul_point(model_mtx, p2)
#print("tri world %s %s %s" % [p0_t, p1_t, p2_t])
var res = MathUtil.intersect_triangle(ray_origin, ray_dir, p0_t, p1_t, p2_t)
if res:
return res
return null
func proj_mul_point(m:Projection, p:Vector3)->Vector3:
var p4:Vector4 = Vector4(p.x, p.y, p.z, 1)
var p4_t = m * p4
p4_t /= p4_t.w
return Vector3(p4_t.x, p4_t.y, p4_t.z)
func proj_mul_vec(m:Projection, p:Vector3)->Vector3:
var p4:Vector4 = Vector4(p.x, p.y, p.z, 0)
var p4_t = m * p4
p4_t /= p4_t.w
return Vector3(p4_t.x, p4_t.y, p4_t.z)

View file

@ -0,0 +1,72 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
extends GizmoBase
class_name GizmoRotate
enum Part { NONE, PLANE_XY, PLANE_XZ, PLANE_YZ, VIEWPORT, TRACKBALL }
class IntersectResult:
var part:Part
var pos_world:Vector3
# Called when the node enters the scene tree for the first time.
func _ready():
$gizmo_rotate/rot_axis_viewport.visible = false
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
get_viewport()
pass
func intersect(ray_origin:Vector3, ray_dir:Vector3, viewport_camera:Camera3D)->IntersectResult:
var result:IntersectResult = IntersectResult.new()
result.part = Part.NONE
for child in $gizmo_rotate.get_children():
var part_res:MathUtil.IntersectTriangleResult = intersect_part(ray_origin, ray_dir, viewport_camera, child)
if part_res:
result.pos_world = part_res.position
match child.name:
"rot_axis_x":
result.part = Part.PLANE_YZ
"rot_axis_y":
result.part = Part.PLANE_XZ
"rot_axis_z":
result.part = Part.PLANE_XY
return result
# print("hit " + child.name)
# return
return null

View file

@ -0,0 +1,37 @@
[gd_scene load_steps=7 format=3 uid="uid://cyi4s4loi2i15"]
[ext_resource type="PackedScene" uid="uid://p26cj0m5amq0" path="res://addons/cyclops_level_builder/art/gizmos/gizmo_rotate.glb" id="1_knqem"]
[ext_resource type="Script" path="res://addons/cyclops_level_builder/tools/gizmos/gizmo_rotate.gd" id="1_vhpbh"]
[ext_resource type="Material" uid="uid://bv4k8o22vl6ub" path="res://addons/cyclops_level_builder/materials/gizmo_axis_y_material.tres" id="2_538x0"]
[ext_resource type="Material" uid="uid://drodm0wf41vin" path="res://addons/cyclops_level_builder/materials/gizmo_axis_x_material.tres" id="3_7q6t6"]
[ext_resource type="Material" uid="uid://divsg4lq712rw" path="res://addons/cyclops_level_builder/materials/gizmo_axis_z_material.tres" id="4_eibo1"]
[ext_resource type="Material" uid="uid://cqvh1j2n71fej" path="res://addons/cyclops_level_builder/materials/gizmo_axis_special_material.tres" id="5_ib271"]
[node name="GizmoRotate" type="Node3D"]
script = ExtResource("1_vhpbh")
[node name="gizmo_rotate" parent="." instance=ExtResource("1_knqem")]
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, 0, 0)
[node name="rot_axis_y" parent="gizmo_rotate" index="0"]
lod_bias = 128.0
ignore_occlusion_culling = true
surface_material_override/0 = ExtResource("2_538x0")
[node name="rot_axis_x" parent="gizmo_rotate" index="1"]
lod_bias = 128.0
ignore_occlusion_culling = true
surface_material_override/0 = ExtResource("3_7q6t6")
[node name="rot_axis_z" parent="gizmo_rotate" index="2"]
lod_bias = 128.0
ignore_occlusion_culling = true
surface_material_override/0 = ExtResource("4_eibo1")
[node name="rot_axis_viewport" parent="gizmo_rotate" index="3"]
visible = false
lod_bias = 128.0
ignore_occlusion_culling = true
surface_material_override/0 = ExtResource("5_ib271")
[editable path="gizmo_rotate"]

View file

@ -0,0 +1,23 @@
extends Node3D
func _input(event):
if event is InputEventMouseButton:
var e:InputEventMouseButton = event
if e.is_pressed():
var cam:Camera3D = %Camera3D
var ray_norm:Vector3 = cam.project_ray_normal(e.position)
var ray_orig:Vector3 = cam.project_ray_origin(e.position)
%gizmo_translate.intersect(ray_orig, ray_norm, cam)
pass
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass

View file

@ -0,0 +1,37 @@
[gd_scene load_steps=4 format=3 uid="uid://bykffnaq3h1ar"]
[ext_resource type="Script" path="res://addons/cyclops_level_builder/tools/gizmos/gizmo_test.gd" id="1_0e45b"]
[ext_resource type="PackedScene" uid="uid://2pi622xycrd6" path="res://addons/cyclops_level_builder/tools/gizmos/gizmo_translate.tscn" id="2_2n1ok"]
[sub_resource type="SphereMesh" id="SphereMesh_off5f"]
radius = 0.02
height = 0.04
[node name="gizmo_test" type="Node3D"]
script = ExtResource("1_0e45b")
[node name="gizmo_translate" parent="." instance=ExtResource("2_2n1ok")]
unique_name_in_owner = true
[node name="Camera3D" type="Camera3D" parent="."]
unique_name_in_owner = true
transform = Transform3D(0.930759, 0.202432, -0.30448, -0.0272565, 0.868848, 0.494329, 0.364615, -0.451802, 0.814206, -0.279477, 1.02398, 1.38375)
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.126, 0, 0.266)
mesh = SubResource("SphereMesh_off5f")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.266, 0, 0.126)
mesh = SubResource("SphereMesh_off5f")
[node name="MeshInstance3D3" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.266, 0, 0.266)
mesh = SubResource("SphereMesh_off5f")
[node name="MeshInstance3D4" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.126, 0, 0.126)
mesh = SubResource("SphereMesh_off5f")
[editable path="gizmo_translate"]
[editable path="gizmo_translate/gizmo_translate"]

View file

@ -0,0 +1,73 @@
# MIT License
#
# Copyright (c) 2023 Mark McKay
# https://github.com/blackears/cyclopsLevelBuilder
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
@tool
extends GizmoBase
class_name GizmoTranslate
enum Part { NONE, AXIS_X, AXIS_Y, AXIS_Z, PLANE_XY, PLANE_XZ, PLANE_YZ }
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
pass
class IntersectResult:
var part:Part
var pos_world:Vector3
func intersect(ray_origin:Vector3, ray_dir:Vector3, viewport_camera:Camera3D)->IntersectResult:
var result:IntersectResult = IntersectResult.new()
result.part = Part.NONE
# if intersect_part(ray_origin, ray_dir, viewport_camera, $gizmo_translate/axis_y):
for child in $gizmo_translate.get_children():
var part_res:MathUtil.IntersectTriangleResult = intersect_part(ray_origin, ray_dir, viewport_camera, child)
if part_res:
result.pos_world = part_res.position
match child.name:
"axis_x":
result.part = Part.AXIS_X
"axis_y":
result.part = Part.AXIS_Y
"axis_z":
result.part = Part.AXIS_Z
"plane_xy":
result.part = Part.PLANE_XY
"plane_xz":
result.part = Part.PLANE_XZ
"plane_yz":
result.part = Part.PLANE_YZ
return result
# print("hit " + child.name)
# return
return null

View file

@ -0,0 +1,45 @@
[gd_scene load_steps=6 format=3 uid="uid://2pi622xycrd6"]
[ext_resource type="Script" path="res://addons/cyclops_level_builder/tools/gizmos/gizmo_translate.gd" id="1_fyqe0"]
[ext_resource type="PackedScene" uid="uid://ujq3kes2sdfu" path="res://addons/cyclops_level_builder/art/gizmos/gizmo_translate.glb" id="1_ljs46"]
[ext_resource type="Material" uid="uid://bv4k8o22vl6ub" path="res://addons/cyclops_level_builder/materials/gizmo_axis_y_material.tres" id="3_tsii4"]
[ext_resource type="Material" uid="uid://divsg4lq712rw" path="res://addons/cyclops_level_builder/materials/gizmo_axis_z_material.tres" id="4_0qd8v"]
[ext_resource type="Material" uid="uid://drodm0wf41vin" path="res://addons/cyclops_level_builder/materials/gizmo_axis_x_material.tres" id="5_xvd3e"]
[node name="gizmo_translate" type="Node3D"]
script = ExtResource("1_fyqe0")
[node name="gizmo_translate" parent="." instance=ExtResource("1_ljs46")]
transform = Transform3D(0.2, 0, 0, 0, 0.2, 0, 0, 0, 0.2, 0, 0, 0)
[node name="axis_y" parent="gizmo_translate" index="0"]
lod_bias = 128.0
ignore_occlusion_culling = true
surface_material_override/0 = ExtResource("3_tsii4")
[node name="axis_z" parent="gizmo_translate" index="1"]
lod_bias = 128.0
ignore_occlusion_culling = true
surface_material_override/0 = ExtResource("4_0qd8v")
[node name="axis_x" parent="gizmo_translate" index="2"]
lod_bias = 128.0
ignore_occlusion_culling = true
surface_material_override/0 = ExtResource("5_xvd3e")
[node name="plane_xz" parent="gizmo_translate" index="3"]
lod_bias = 128.0
ignore_occlusion_culling = true
surface_material_override/0 = ExtResource("3_tsii4")
[node name="plane_yz" parent="gizmo_translate" index="4"]
lod_bias = 128.0
ignore_occlusion_culling = true
surface_material_override/0 = ExtResource("5_xvd3e")
[node name="plane_xy" parent="gizmo_translate" index="5"]
lod_bias = 128.0
ignore_occlusion_culling = true
surface_material_override/0 = ExtResource("4_0qd8v")
[editable path="gizmo_translate"]