Added initial experimental stage.

This commit is contained in:
Mono 2021-11-18 17:23:37 +01:00
parent ac4ff4a8ba
commit 0b3c07d11f
43 changed files with 2776 additions and 0 deletions

16
Bullshit/Main.gd Normal file

@ -0,0 +1,16 @@
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
return
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

16
Bullshit/NewTexutre.gd Normal file

@ -0,0 +1,16 @@
extends ViewportTexture
class_name PremiumTexture
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# 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

15
Bullshit/OhItGetsWorse.gd Normal file

@ -0,0 +1,15 @@
extends OH
class_name VeryWorse
export(int) var ButItIsWhatItIs = 33
# 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

@ -0,0 +1,16 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://icon.png" type="Texture" id=1]
[node name="PolyTest" type="Node"]
[node name="Polygon2D" type="Polygon2D" parent="."]
scale = Vector2( 50, 50 )
polygon = PoolVector2Array( 0.42, 0.4, 2.34, 0.04, 1.98, 2.06, 0.58, 1.96 )
[node name="Camera2D" type="Camera2D" parent="."]
current = true
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( -95, 98 )
texture = ExtResource( 1 )

@ -0,0 +1,17 @@
extends ScriptEditor
class_name ScriptEditorTest
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# 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

14
Bullshit/TestResource.gd Normal file

@ -0,0 +1,14 @@
extends ConvexPolygonShape
class_name ConvexYoMama
export(int) var YoFatMama = 23
# 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

15
Bullshit/YoArOphanHaha.gd Normal file

@ -0,0 +1,15 @@
extends Resource
class_name OH
export(int) var IDidntMeanTo = 6
# 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

8
Bullshit/aahhh.tres Normal file

@ -0,0 +1,8 @@
[gd_resource type="ConvexPolygonShape" load_steps=2 format=2]
[ext_resource path="res://Bullshit/convexDad.gd" type="Script" id=1]
[resource]
script = ExtResource( 1 )
YoFatMama = 23
moan = "Ahhh >///<"

15
Bullshit/convexDad.gd Normal file

@ -0,0 +1,15 @@
extends ConvexYoMama
class_name ConvexDaddyAahhh
export(String) var moan = "Ahhh >///<"
# 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

7
Bullshit/ieeeee.tres Normal file

@ -0,0 +1,7 @@
[gd_resource type="ConvexPolygonShape" load_steps=2 format=2]
[ext_resource path="res://Bullshit/TestResource.gd" type="Script" id=1]
[resource]
script = ExtResource( 1 )
YoFatMama = 23

@ -0,0 +1,4 @@
[gd_resource type="ConvexPolygonShape" format=2]
[resource]
points = PoolVector3Array( 1, 0, 0, 0, 1, 0, 1, 1, 0, 0, 0, 1 )

7
Bullshit/oh.tres Normal file

@ -0,0 +1,7 @@
[gd_resource type="Resource" load_steps=2 format=2]
[ext_resource path="res://Bullshit/YoArOphanHaha.gd" type="Script" id=1]
[resource]
script = ExtResource( 1 )
IDidntMeanTo = 6

7
Bullshit/scene_073.tres Normal file

@ -0,0 +1,7 @@
[gd_resource type="Resource" load_steps=2 format=2]
[ext_resource path="res://addons/summer_day/data_structure/scene/scene.gd" type="Script" id=1]
[resource]
script = ExtResource( 1 )
aspect_ratio = Vector2( 16, 9 )

87
CSGCylinder.gd Normal file

@ -0,0 +1,87 @@
extends CSGCylinder
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
var orig01 = Vector3(-1, -1, 1)
var orig02 = Vector3(1, -1, 1)
var orig03 = Vector3(-1, 1, 1)
var orig04 = Vector3(2, -5, 1)
var dest01 = Vector3(-3, -7, 1)
var dest02 = Vector3(7, -3, 1)
var dest03 = Vector3(-7, 7, 1)
var dest04 = Vector3(4, 8, 1)
print(str(dest01) + "\n" + str(dest02) + "\n" + str(dest03) + "\n" + str(dest04) + "\n")
var a_ = Basis( Vector3(orig01.x, orig02.x, orig03.x),
Vector3(orig01.y, orig02.y, orig03.y),
Vector3.ONE )
var a_inverse = a_.inverse()
var a_coeff = a_inverse.xform(orig04)
print(orig04)
print(a_coeff)
print(str(a_.xform(a_coeff)) + "\n")
var A = Basis( Vector3(orig01.x * a_coeff.x, orig02.x * a_coeff.y, orig03.x * a_coeff.z),
Vector3(orig01.y * a_coeff.x, orig02.y * a_coeff.y, orig03.y * a_coeff.z),
a_coeff )
print(str(A) + "\n")
var A_inverse = A.inverse()
print(str(A_inverse))
print(str(A * A_inverse) + "\n")
var b_ = Basis( Vector3(dest01.x, dest02.x, dest03.x),
Vector3(dest01.y, dest02.y, dest03.y),
Vector3(dest01.z, dest02.z, dest03.z) )
var b_inverse = b_.inverse()
var b_coeff = b_inverse.xform(dest04)
var B = Basis( Vector3(dest01.x * b_coeff.x, dest02.x * b_coeff.y, dest03.x * b_coeff.z),
Vector3(dest01.y * b_coeff.x, dest02.y * b_coeff.y, dest03.y * b_coeff.z),
b_coeff )
var C = A_inverse * B
print(str(B))
print(str(b_coeff) + "\n")
print(str(C) + "\n")
var proof01 = C.xform(orig01)
var proof02 = C.xform(orig02)
var proof03 = C.xform(orig03)
var proof04 = C.xform(orig04)
print(str(proof01) + "\n" + str(proof02) + "\n" + str(proof03) + "\n" + str(proof04))
func adj(m: Basis):
return Basis(
Vector3(
m[1][1] * m[2][2] - m[1][2] * m[2][1],
m[0][2] * m[2][1] - m[0][1] * m[2][2],
m[0][1] * m[1][2] - m[0][2] * m[1][1]
),
Vector3(
m[1][2] * m[2][0] - m[1][0] * m[2][2],
m[0][0] * m[2][2] - m[0][2] * m[2][0],
m[0][2] * m[1][0] - m[0][0] * m[1][2]
),
Vector3(
m[1][0] * m[2][1] - m[1][1] * m[2][0],
m[0][1] * m[2][0] - m[0][0] * m[2][1],
m[0][0] * m[1][1] - m[0][1] * m[1][0]
)
)

202
Main.tscn Normal file

@ -0,0 +1,202 @@
[gd_scene load_steps=17 format=2]
[ext_resource path="res://TryingOutSomethingNew.gd" type="Script" id=1]
[ext_resource path="res://Node2D.gd" type="Script" id=2]
[ext_resource path="res://icon.png" type="Texture" id=3]
[ext_resource path="res://addons/summer_day/interface/display.gd" type="Script" id=4]
[ext_resource path="res://Bullshit/Main.gd" type="Script" id=5]
[sub_resource type="Shader" id=1]
code = "shader_type spatial;
render_mode blend_mix,depth_draw_opaque,cull_disabled,skip_vertex_transform;
uniform vec4 albedo : hint_color;
uniform sampler2D texture_albedo : hint_albedo;
uniform mat4 ha;
void vertex() {
vec4 row0 = vec4(0.25, 0.0, 0.0, -0.5);
vec4 row1 = vec4(0.0, 0.25, 0.0, 0.0);
vec4 row2 = vec4(0.0, 0.0, 0.25, -3.0);
vec4 row3 = vec4(0.0, 0.0, 0.00, 3.5);
mat4 crank_matrix = mat4(row0, row1, row2, row3);
vec4 pre = vec4(VERTEX, 1.0) * crank_matrix;
POSITION = pre;
}
void fragment() {
vec2 base_uv = UV;
vec4 albedo_tex = texture(texture_albedo,base_uv);
ALBEDO = albedo.rgb;
}"
[sub_resource type="ShaderMaterial" id=2]
shader = SubResource( 1 )
shader_param/albedo = Color( 0.768627, 0.231373, 0.231373, 1 )
shader_param/ha = null
[sub_resource type="Image" id=17]
data = {
"data": PoolByteArray( 0, 0, 128, 62, 0, 0, 0, 0, 0, 0, 0, 0, 154, 153, 25, 62, 0, 0, 0, 0, 0, 0, 128, 62, 0, 0, 0, 0, 154, 153, 25, 62, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 63, 0, 0, 128, 62, 0, 0, 0, 0, 0, 0, 0, 0, 154, 153, 25, 190, 0, 0, 0, 0, 0, 0, 128, 62, 0, 0, 0, 0, 154, 153, 25, 190, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 63 ),
"format": "RGBAFloat",
"height": 1,
"mipmaps": false,
"width": 8
}
[sub_resource type="ImageTexture" id=16]
flags = 0
flags = 0
image = SubResource( 17 )
size = Vector2( 8, 1 )
[sub_resource type="CapsuleMesh" id=5]
radius = 0.9
mid_height = 2.0
radial_segments = 16
rings = 2
[sub_resource type="Shader" id=6]
code = "shader_type spatial;
render_mode blend_mix,depth_draw_opaque,cull_disabled,skip_vertex_transform;
uniform sampler2D table : hint_albedo;
vec4 indx(int i) {
//return vec4(1.0, 1.0, 0.0, 1.0);
return texture(table, vec2(float(i) * 0.125 + 0.0625), 0.5);
}
void vertex() {
vec4 row0;
vec4 row1;
vec4 row2;
vec4 row3;
if (VERTEX.z >= 0.0) {
row0 = vec4(indx(0).x, indx(0).y, indx(0).z, indx(0).w);
row1 = vec4(indx(1).x, indx(1).y, indx(1).z, indx(1).w);
row2 = vec4(indx(2).x, indx(2).y, indx(2).z, indx(2).w);
row3 = vec4(indx(3).x, indx(3).y, indx(3).z, indx(3).w);
// row0 = vec4(0.1, 0.0, 0.0, 0.0);
// row1 = vec4(0.0, 0.1, 0.0, 0.0);
// row2 = vec4(0.0, 0.0, 0.1, 0.0);
// row3 = vec4(0.0, 0.0, 0.0, 1.0);
}
else {
row0 = vec4(indx(4).x, indx(4).y, indx(4).z, indx(4).w);
row1 = vec4(indx(5).x, indx(5).y, indx(5).z, indx(5).w);
row2 = vec4(indx(6).x, indx(6).y, indx(6).z, indx(6).w);
row3 = vec4(indx(7).x, indx(7).y, indx(7).z, indx(7).w);
// row0 = vec4(0.1, 0.0, 0.0, 0.0);
// row1 = vec4(0.0, 0.1, 0.0, 0.0);
// row2 = vec4(0.0, 0.0, 0.1, 0.0);
// row3 = vec4(0.0, 0.0, 0.0, 1.0);
}
mat4 crank_matrix = mat4(row0, row1, row2, row3);
vec4 pre = vec4(VERTEX, 1.0) * crank_matrix;
POSITION = pre;
VERTEX = (pre / pre.w).xyz;
}
void fragment() {
ALBEDO = texture(table, UV).rgb;
}"
[sub_resource type="ShaderMaterial" id=7]
shader = SubResource( 6 )
shader_param/table = SubResource( 16 )
[sub_resource type="QuadMesh" id=8]
[sub_resource type="Shader" id=9]
code = "shader_type spatial;
render_mode blend_mix,depth_draw_opaque,cull_disabled,unshaded;
void vertex() {
vec4 row0;
vec4 row1;
vec4 row2;
vec4 row3;
row0 = vec4(0.2, 0.2, 0.0, 0.0);
row1 = vec4(-0.2, 0.2, 0.0, 0.0);
row2 = vec4(0.0, 0.0, 1.0, 0.0);
row3 = vec4(0.0, 0.0, 0.0, 1.0);
mat4 crank_matrix = mat4(row0, row1, row2, row3);
vec4 pre = vec4(VERTEX, 1.0) * crank_matrix;
POSITION = pre;
VERTEX = VERTEX;
}
void fragment() {
ALBEDO = vec3(0.0, 1.0, 0.0);
}"
[sub_resource type="ShaderMaterial" id=10]
shader = SubResource( 9 )
[sub_resource type="Animation" id=14]
length = 725.63
loop = true
[node name="Main" type="Node"]
script = ExtResource( 5 )
[node name="CSGCylinder" type="CSGCylinder" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 3.03888, -0.0140027, -0.205594 )
height = 3.586
material = SubResource( 2 )
script = ExtResource( 1 )
[node name="CSGCylinder2" type="CSGCylinder" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -25.8122, 0, 0 )
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 32.985 )
projection = 1
current = true
size = 2.0
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 619.786, 73.103 )
texture = SubResource( 16 )
centered = false
[node name="Sprite3D" type="Sprite3D" parent="."]
visible = false
opacity = 0.15
texture = ExtResource( 3 )
[node name="CSGBox" type="CSGMesh" parent="."]
mesh = SubResource( 5 )
material = SubResource( 7 )
[node name="Node2D" type="Node2D" parent="."]
script = ExtResource( 2 )
[node name="CSGBox2" type="CSGBox" parent="."]
visible = false
[node name="CSGMesh" type="CSGMesh" parent="."]
visible = false
mesh = SubResource( 8 )
material = SubResource( 10 )
[node name="DirectionalLight" type="DirectionalLight" parent="."]
transform = Transform( 0.398693, -0.714769, -0.574586, 0.450925, 0.698355, -0.555848, 0.798568, -0.0374829, 0.600737, -4.26558, 5.43131, 5.80283 )
[node name="SDDisplay" type="Control" parent="."]
margin_right = 40.0
margin_bottom = 40.0
script = ExtResource( 4 )
__meta__ = {
"_edit_use_anchors_": false
}
scene = SubResource( 14 )

162
Node2D.gd Normal file

@ -0,0 +1,162 @@
tool
extends Node2D
var image := Image.new()
var table := ImageTexture.new()
onready var Util = preload("res://Util.gd")
var corners = [
Vector2(-0.4, -0.4),
Vector2(0.1, -0.4),
Vector2(0.1, 0.1),
Vector2(-0.4, 0.1),
Vector2(-0.1, -0.1),
Vector2(0.4, -0.1),
Vector2(0.4, 0.4),
Vector2(-0.1, 0.4),
]
var picked_point = -1
var rear_matrix := []
var front_matrix := []
var canvas_inv : Transform2D
var canvas_trans : Transform2D
# Called when the node enters the scene tree for the first time.
func _ready():
update_canvas_inv()
image.create(8, 1, false, Image.FORMAT_RGBAF)
table.create_from_image(image, 0)
#table.create(8, 1, Image.FORMAT_RGBAF, 0)
#image = table.get_data()
image.lock()
for i in range(8):
image.set_pixel(i, 0,
Color(1.0, 0.0, 0.0))
image.unlock()
table.set_data(image)
$"../Sprite".texture = table
$"../CSGBox".material.set_shader_param("table", table)
_update_matrix()
func update_canvas_inv():
while true:
var viewport_size = get_viewport_rect().size
canvas_inv = Transform2D(
Vector2(2.0 / viewport_size.x, 0.0),
Vector2(0.0, -2.0 / viewport_size.y),
Vector2(-1.0, 1.0)
)
canvas_trans = canvas_inv.affine_inverse()
update()
yield(get_viewport(), "size_changed")
func _input(event):
#print(canvas_inv.xform(get_local_mouse_position()))
#print(event.as_text())
var mouse_position = get_viewport().get_mouse_position()
if event is InputEventMouseButton:
if event.button_index == BUTTON_LEFT:
if event.pressed:
_pick_point(canvas_inv.xform(mouse_position))
else:
picked_point = -1
if event is InputEventMouseMotion:
if picked_point != -1:
corners[picked_point] = canvas_inv.xform(mouse_position)
_update_matrix()
update()
func _draw():
for i in range(4):
draw_line(
canvas_trans.xform(corners[i]),
canvas_trans.xform(corners[wrapi(i + 1, 0, 4)]),
Color.maroon)
for i in range(4):
draw_circle(canvas_trans.xform(corners[i]), 10.0, Color.maroon)
for i in range(4):
draw_line(
canvas_trans.xform(corners[i]),
canvas_trans.xform(corners[i + 4]),
Color.yellow)
for i in range(4):
draw_line(
canvas_trans.xform(corners[i + 4]),
canvas_trans.xform(corners[wrapi(i + 5, 4, 8)]),
Color.purple)
for i in range(4):
draw_circle(canvas_trans.xform(corners[i + 4]), 10.0, Color.purple)
draw_texture_rect(table, Rect2(
Vector2(750.0, 50.0), Vector2(256.0, 32.0)
), false)
func _pick_point(mouse_pos):
var picked_point_so_far = -1
var nearest_distance = 20.0
for i in corners.size():
var distance = corners[i].distance_to(mouse_pos)
if distance < nearest_distance:
nearest_distance = distance
picked_point_so_far = i
picked_point = picked_point_so_far
func _update_matrix():
rear_matrix = Util.plane_3d_to_xy(
Vector3(-1.0, -1.0, 1.0),
Vector3(1.0, -1.0, 1.0),
Vector3(1.0, 1.0, 1.0),
Vector3(-1.0, 1.0, 1.0),
corners[0], corners[1], corners[2], corners[3]
)
front_matrix = Util.plane_3d_to_xy(
Vector3(-1.0, -1.0, -1.0),
Vector3(1.0, -1.0, -1.0),
Vector3(1.0, 1.0, -1.0),
Vector3(-1.0, 1.0, -1.0),
corners[4], corners[5], corners[6], corners[7]
)
# rear_matrix = [
# 0.5, 0.0, 0.0, 0.0,
# 0.0, 0.5, 0.0, 0.0,
# 0.0, 0.0, 0.5, 0.0,
# 0.0, 0.0, 0.0, 8.5,
# ]
#
# front_matrix = [
# 0.5, 0.0, 0.0, 0.0,
# 0.0, 0.5, 0.0, 20.0,
# 0.0, 0.0, 0.5, 0.0,
# 0.0, 0.0, 0.0, 8.5,
# ]
image.lock()
for i in range(4):
image.set_pixel(i, 0,
Color(front_matrix[i * 4], front_matrix[i * 4 + 1],
front_matrix[i * 4 + 2], front_matrix[i * 4 + 3]))
for i in range(4):
image.set_pixel(i + 4, 0,
Color(rear_matrix[i * 4], rear_matrix[i * 4 + 1],
rear_matrix[i * 4 + 2], rear_matrix[i * 4 + 3]))
image.unlock()
table.set_data(image)

148
PerspectiveTransform.gd Normal file

@ -0,0 +1,148 @@
extends CSGCylinder
# Called when the node enters the scene tree for the first time.
func _ready():
g2dp_as_basis_test()
#--- UNIT TESTS ---
func g2dp_as_basis_test():
# Origin.
var o1 = Vector2(-1.0, -1.0)
var o2 = Vector2(1.0, -1.0)
var o3 = Vector2(-1.0, 1.0)
var o4 = Vector2(1.0, 1.0)
# Destination.
var d1 = Vector2(-1.0, -1.0)
var d2 = Vector2(1.0, -2.0)
var d3 = Vector2(-1.0, 1.0)
var d4 = Vector2(1.0, 1.0)
print(str(d1) + "\n" + str(d2) + "\n" + str(d3) + "\n" + str(d4) + "\n")
var m = g2dp_as_basis(o1, o2, o3, o4, d1, d2, d3, d4)
print(str(m) + "\n")
var p1 = multiply_basis_vector2(m, o1)
var p2 = multiply_basis_vector2(m, o2)
var p3 = multiply_basis_vector2(m, o3)
var p4 = multiply_basis_vector2(m, o4)
print(str(p1) + "\n" + str(p2) + "\n" + str(p3) + "\n" + str(p4) + "\n")
func multmm_test():
var m = Basis(
Vector3(5, 3, 1) ,
Vector3(0, -4, -2) ,
Vector3(0, 0, 1)
)
var mi = m.inverse()
var ma = [
m[0][0], m[0][1], m[0][2],
m[1][0], m[1][1], m[1][2],
m[2][0], m[2][1], m[2][2]
]
var mia = [
mi[0][0], mi[0][1], mi[0][2],
mi[1][0], mi[1][1], mi[1][2],
mi[2][0], mi[2][1], mi[2][2]
]
var res = multmm(ma, mia)
print(res)
#--- HELPER FUNCTIONS ---
func adj(m):
var adj = [
m[4]*m[8]-m[5]*m[7], m[2]*m[7]-m[1]*m[8], m[1]*m[5]-m[2]*m[4],
m[5]*m[6]-m[3]*m[8], m[0]*m[8]-m[2]*m[6], m[2]*m[3]-m[0]*m[5],
m[3]*m[7]-m[4]*m[6], m[1]*m[6]-m[0]*m[7], m[0]*m[4]-m[1]*m[3]
]
print("\n" + "adjunctive: " + str(adj) + "\n")
return adj
func multmm(a, b): # Multiply two matrices.
var c = range(9)
for i in range(3):
for j in range(3):
var cij = 0
for k in range(3):
cij += a[3*i + k] * b[3*k + j]
c[3*i + j] = cij
return c
func multmv(m, v): # Multiply matrix and vector.
return [
m[0]*v[0] + m[1]*v[1] + m[2]*v[2],
m[3]*v[0] + m[4]*v[1] + m[5]*v[2],
m[6]*v[0] + m[7]*v[1] + m[8]*v[2]
]
func basis_to_points(x1, y1, x2, y2, x3, y3, x4, y4):
var m = [
x1, x2, x3,
y1, y2, y3,
1.0, 1.0, 1.0
]
var v = multmv(adj(m), [x4, y4, 1.0]);
print("coeffs: " + str(v))
var b = multmm(m, [
v[0], 0.0, 0.0,
0.0, v[1], 0.0,
0.0, 0.0, v[2]
])
print("matrix: " + str(b))
return b
func general_2d_projection(
x1s, y1s, x1d, y1d,
x2s, y2s, x2d, y2d,
x3s, y3s, x3d, y3d,
x4s, y4s, x4d, y4d
):
var s = basis_to_points(x1s, y1s, x2s, y2s, x3s, y3s, x4s, y4s)
var d = basis_to_points(x1d, y1d, x2d, y2d, x3d, y3d, x4d, y4d)
var m = multmm(d, adj(s))
for i in range(9):
m[i] /= m[8]
return m
func g2dp_as_basis(
s1, s2, s3, s4,
d1, d2, d3, d4
):
var m = general_2d_projection(
s1.x, s1.y, d1.x, d1.y,
s2.x, s2.y, d2.x, d2.y,
s3.x, s3.y, d3.x, d3.y,
s4.x, s4.y, d4.x, d4.y
)
return Basis(
Vector3(m[0], m[1], m[2]),
Vector3(m[3], m[4], m[5]),
Vector3(m[6], m[7], m[8])
)
func multiply_basis_vector2(b, v):
var h = b.xform(Vector3(v.x, v.y, 1.0))
return Vector2(h.x / h.z, h.y / h.z)

17
Something.gd Normal file

@ -0,0 +1,17 @@
extends MeshInstance
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
#mesh.material.set_shader_param("my_matrix", Transform())
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

16
TryingOutSomethingNew.gd Normal file

@ -0,0 +1,16 @@
extends CSGCylinder
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# 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

219
Util.gd Normal file

@ -0,0 +1,219 @@
extends Node
static func matrix_to_points(
p01: Vector2, p02: Vector2, p03: Vector2, p04: Vector2
) -> Array:
var j = p01.x - p02.x - p03.x + p04.x
if j == 0.0:
j = 0.00000001
var k = -p01.x - p02.x + p03.x + p04.x
var l = -p01.x + p02.x - p03.x + p04.x
var m = p01.y - p02.y - p03.y + p04.y
var n = -p01.y - p02.y + p03.y + p04.y
var o = -p01.y + p02.y - p03.y + p04.y
var i = 1;
var q = m * k - j * n
if q == 0.0:
q = 0.00000001
var h = (j * o - m * l) * i / q
var g = (k * h + l * i) / j
var f = (p01.y * (g + h + i) + p03.y * (-g - h + i)) / 2
var e = (p01.y * (g + h + i) - p02.y * (g - h + i)) / 2
var d = p01.y * (g + h + i) - f - e
var c = (p01.x * (g + h + i) + p03.x * (-g - h + i)) / 2
var b = (p01.x * (g + h + i) - p02.x * (g - h + i)) / 2
var a = p01.x * (g + h + i) - c - b
return [
a, d, g,
b, e, h,
c, f, i
]
static func basis_from_to_points(
s01: Vector2, s02: Vector2, s03: Vector2, s04: Vector2,
d01: Vector2, d02: Vector2, d03: Vector2, d04: Vector2
):
var matrix_to_source = matrix_to_points(s01, s02, s03, s04)
var basis_to_source = array_to_basis(matrix_to_source)
var basis_from_source = basis_to_source.inverse()
var matrix_to_dest = matrix_to_points(d01, d02, d03, d04)
var basis_to_dest = array_to_basis(matrix_to_dest)
var from_source_to_dest = basis_to_dest * basis_from_source
return from_source_to_dest
static func array_to_basis(arr: Array) -> Basis:
return Basis(
Vector3(arr[0], arr[1], arr[2]),
Vector3(arr[3], arr[4], arr[5]),
Vector3(arr[6], arr[7], arr[8])
)
static func basis_to_array(basis: Basis) -> Array:
return [
basis.x.x, basis.x.y, basis.x.z,
basis.y.x, basis.y.y, basis.y.z,
basis.z.x, basis.z.y, basis.z.z
]
static func mult_4x4_matrices(left: Array, right: Array) -> Array:
var result = []
for y in range(4):
for x in range(4):
var sum = 0.0
for i in range(4):
sum += left[_c2i(x, i)] * right[_c2i(i, y)]
result.append(sum)
return result
# Coordinates on a 4x4 field to index.
static func _c2i(x: int, y: int) -> int:
return y * 4 + x
# This just calculates a rotation-matrix that flattens the z-coordinates of
# the given Quad. You could also say that it makes the normal of the Quad
# point directly to the camera. (-z)
static func plane_to_xy_basis(
p01: Vector3, p02: Vector3, p03: Vector3, p04: Vector3
) -> Basis:
var sample_normal_01 = (p02 - p01).cross(p04 - p02).normalized()
var sample_normal_02 = (p03 - p02).cross(p04 - p03).normalized()
if sample_normal_01.dot(sample_normal_02) <= 0.99999:
push_error("The given form is not a plane and can" +
"therefore not be transformed correctly")
var normal = sample_normal_01.linear_interpolate(sample_normal_02, 0.5)
normal = normal.normalized()
var dest_normal = Vector3.BACK
if normal.dot(dest_normal) >= 0.99999:
return Basis()
var rot_axis = normal.cross(dest_normal).normalized()
var rot_angle = normal.dot(dest_normal)
var quad = Quat(-rot_axis, acos(rot_angle))
var basis = Basis(quad)
return basis.inverse()
# This basically takes four Vector3 that form a Quad somewhere in the
# space and a second (this time two-dimensional) Quad to calculate
# the transformation-matrix that is required to get from the former
# to the latter. Returned is said transformation-matrix.
static func plane_3d_to_xy(
p3d_01: Vector3, p3d_02: Vector3, p3d_03: Vector3, p3d_04: Vector3,
d_01: Vector2, d_02: Vector2, d_03: Vector2, d_04: Vector2):
var rotation_matrix = plane_to_xy_basis(
p3d_01, p3d_02,
p3d_03, p3d_04
)
var to_plane_transform = Transform(
rotation_matrix, Vector3(0.0, 0.0,
-rotation_matrix.xform(p3d_01).z
)
)
var plane_points = [
to_plane_transform.xform(p3d_01),
to_plane_transform.xform(p3d_02),
to_plane_transform.xform(p3d_03),
to_plane_transform.xform(p3d_04)
]
var xy_points = [
Vector2(plane_points[0].x, plane_points[0].y),
Vector2(plane_points[1].x, plane_points[1].y),
Vector2(plane_points[2].x, plane_points[2].y),
Vector2(plane_points[3].x, plane_points[3].y),
]
var basis_2d = basis_from_to_points(
xy_points[0], xy_points[1], xy_points[2], xy_points[3],
d_01, d_02, d_03, d_04)
# print(basis_2d)
#
# for i in range(4):
# var flat_coord = xy_points[i]
# var ext_coord = Vector3(flat_coord.x, flat_coord.y, 1.0)
# var trans_coord = basis_2d.xform(ext_coord)
# var cut_coord = Vector2(trans_coord.x, trans_coord.y)
# print(cut_coord)
# print("")
var transform_2d = Transform(
Vector3(basis_2d.x.x, basis_2d.y.x, 0.0),
Vector3(basis_2d.x.y, basis_2d.y.y, 0.0),
Vector3.ZERO,
Vector3(basis_2d.x.z, basis_2d.y.z, 0.0)
)
# var transform_2d = Transform(
# Vector3(basis_2d.x.x, basis_2d.x.y, basis_2d.x.z),
# Vector3(basis_2d.y.x, basis_2d.y.y, basis_2d.y.z),
# Vector3.ZERO,
# Vector3(0.0, 0.0, 0.0)
# )
var transform = transform_2d * to_plane_transform
# return [
# transform.basis.x.x, transform.basis.x.y, transform.basis.x.z,
# transform.origin.x,
# transform.basis.y.x, transform.basis.y.y, transform.basis.y.z,
# transform.origin.y,
# transform.basis.z.x, transform.basis.z.y, transform.basis.z.z,
# transform.origin.z,
# basis_2d.z.x, basis_2d.z.y, 0.0, 1.0
# ]
var cool = mult_4x4_matrices(
# [
# basis_2d.x.x, basis_2d.x.y, 0.0, basis_2d.x.z,
# basis_2d.y.x, basis_2d.y.y, 0.0, basis_2d.y.z,
# 0.0, 0.0, 0.0, 0.0,
# basis_2d.z.x, basis_2d.z.y, 0.0, basis_2d.z.z,
# ],
[
basis_2d.x.x, basis_2d.y.x, 0.0, basis_2d.z.x,
basis_2d.x.y, basis_2d.y.y, 0.0, basis_2d.z.y,
0.0, 0.0, 0.0, 0.0,
basis_2d.x.z, basis_2d.y.z, 0.0, basis_2d.z.z,
],
[
to_plane_transform.basis.x.x, to_plane_transform.basis.x.y,
to_plane_transform.basis.x.z, to_plane_transform.origin.x,
to_plane_transform.basis.y.x, to_plane_transform.basis.y.y,
to_plane_transform.basis.y.z, to_plane_transform.origin.y,
to_plane_transform.basis.z.x, to_plane_transform.basis.z.y,
to_plane_transform.basis.z.z, to_plane_transform.origin.z,
0.0, 0.0, 0.0, 1.0
]
)
# cool = [
# cool[0], cool[4], cool[8], cool[12],
# cool[1], cool[5], cool[9], cool[13],
# cool[2], cool[6], cool[10], cool[14],
# cool[3], cool[7], cool[11], cool[15],
# ]
return cool

@ -0,0 +1,18 @@
[general]
singleton=true
load_once=true
symbol_prefix="godot_"
reloadable=false
[entry]
OSX.64="res://addons/godot-git-plugin/osx/release/libgitapi.dylib"
Windows.64="res://addons/godot-git-plugin/win64/release/libgitapi.dll"
X11.64="res://addons/godot-git-plugin/x11/release/libgitapi.so"
[dependencies]
OSX.64=[ ]
Windows.64=[ ]
X11.64=[ ]

@ -0,0 +1,9 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://addons/godot-git-plugin/git_api.gdnlib" type="GDNativeLibrary" id=1]
[resource]
resource_name = "GitAPI"
class_name = "GitAPI"
library = ExtResource( 1 )
script_class_name = "GitAPI"

Binary file not shown.

@ -0,0 +1,7 @@
[plugin]
name="Godot Git Plugin"
description="This plugin lets you interact with Git without leaving the Godot editor. More information can be found at https://github.com/godotengine/godot-git-plugin/wiki"
author="ChronicallySerious"
version="v1.2.2"
script="git_api.gdns"

Binary file not shown.

Binary file not shown.

@ -0,0 +1,3 @@
[gd_resource type="ConvexPolygonShape" format=2]
[resource]

@ -0,0 +1,15 @@
extends Control
class_name SDDisplay
export(Animation) var scene = null
# 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

@ -0,0 +1,2 @@
extends Control
class_name SummerDayMainScreen

@ -0,0 +1,21 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://addons/summer_day/tool/canvas/canvas.tscn" type="PackedScene" id=1]
[ext_resource path="res://addons/summer_day/main_screen.gd" type="Script" id=2]
[node name="MainScreen" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
size_flags_vertical = 3
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Canvas" parent="." instance=ExtResource( 1 )]
margin_left = 12.0
margin_top = 12.0
margin_right = -12.0
margin_bottom = -12.0
[connection signal="resized" from="Canvas" to="Canvas" method="_on_Canvas_resized"]

@ -0,0 +1,7 @@
[plugin]
name="SummerDay"
description="This plugin was designed for internal animation production."
author="Leon Rauschenberg"
version="0.1.0"
script="summer_day.gd"

@ -0,0 +1,71 @@
tool
extends EditorPlugin
signal sd_scene_changed(new_scene)
const MainScreen = preload("res://addons/summer_day/main_screen.tscn")
const Timeline = preload("res://addons/summer_day/tool/timeline/timeline.tscn")
var main_screen_instance: SummerDayMainScreen
var timeline_instance: SummerDayTimeline
func _enter_tree():
main_screen_instance = MainScreen.instance()
self.connect("sd_scene_changed",
main_screen_instance.get_node("Canvas"), "_on_SummerDay_scene_changed"
)
# Add the main panel to the editor's main viewport.
get_editor_interface().get_editor_viewport().add_child(main_screen_instance)
# Hide the main panel. Very much required.
make_visible(false)
timeline_instance = Timeline.instance()
add_control_to_bottom_panel(timeline_instance, "SummerDay Timeline")
add_custom_type("SummerDayScene", "Resource",
load("res://addons/summer_day/data_structure/scene/scene.gd"),
get_editor_interface().get_base_control().get_icon("Animation", "EditorIcons"))
add_custom_type("SummerDayDisplay", "Control",
load("res://addons/summer_day/interface/display.gd"),
get_editor_interface().get_base_control().get_icon("TextureRect", "EditorIcons"))
func _exit_tree():
if main_screen_instance:
main_screen_instance.queue_free()
remove_custom_type("SummerDayScene")
remove_custom_type("SummerDayDisplay")
remove_control_from_bottom_panel(timeline_instance)
func has_main_screen():
return true
func make_visible(visible):
if main_screen_instance:
main_screen_instance.visible = visible
# if visible:
# make_bottom_panel_item_visible(timeline_instance)
# else:
# hide_bottom_panel()
func handles(object):
if object is SummerDayScene:
return true
func edit(scene):
emit_signal("sd_scene_changed", scene)
func get_plugin_name():
return "SummerDay"
func get_plugin_icon():
return get_editor_interface().get_base_control().get_icon("AnimationPlayer", "EditorIcons")

@ -0,0 +1,66 @@
tool
extends Control
class_name SummerDayCanvas
signal fill_transform_changed(fill_transform)
signal canvas_transform_changed(canvas_transform)
signal view_transform_changed(view_transform)
var scene: SummerDayScene
var fill_transform := Transform2D.IDENTITY
var canvas_transform := Transform2D.IDENTITY
var view_transform := Transform2D.IDENTITY # fill_transform * canvas_transform
func _ready():
#connect("resized", self, "_size_changed")
pass
func _gui_input(event):
if event is InputEventMagnifyGesture:
print(event.factor)
if event is InputEventMouseButton:
print(event.pressed)
func _on_SummerDay_scene_changed(new_scene):
scene = new_scene
_update_fill_transform()
$Label.text = str(scene) + "\n" + str(scene.aspect_ratio)
func _on_Canvas_resized():
_update_fill_transform()
range(-1, 1, 2)
func _update_fill_transform():
if scene == null:
fill_transform = Transform2D.IDENTITY
else:
var aspect_ratio = scene.aspect_ratio.x / scene.aspect_ratio.y
var size_ratio = rect_size.x / rect_size.y
var scale
var translation = Vector2.ZERO
if aspect_ratio <= size_ratio:
scale = rect_size.y
translation.x = rect_size.x * 0.5 - aspect_ratio * scale * 0.5
else:
scale = rect_size.x / aspect_ratio
translation.y = rect_size.y * 0.5 - scale * 0.5
fill_transform = Transform2D.IDENTITY.scaled(Vector2(scale, scale))
fill_transform = fill_transform.translated(translation)
print(fill_transform)
emit_signal("fill_transform_changed", fill_transform)
func _update_view_transformation(transform):
view_transform = fill_transform * canvas_transform
emit_signal("view_transform_changed", view_transform)

@ -0,0 +1,100 @@
[gd_scene load_steps=7 format=2]
[ext_resource path="res://addons/summer_day/tool/canvas/canvas.gd" type="Script" id=1]
[ext_resource path="res://Main.tscn" type="PackedScene" id=2]
[sub_resource type="GDScript" id=4]
script/source = "tool
extends Polygon2D
# Declare member variables here. Examples:
# var a = 2
# var b = \"text\"
# 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
"
[sub_resource type="Environment" id=1]
ambient_light_color = Color( 1, 1, 1, 1 )
[sub_resource type="World" id=2]
environment = SubResource( 1 )
[sub_resource type="GDScript" id=3]
script/source = "tool
extends Control
# Declare member variables here. Examples:
# var a = 2
# var b = \"text\"
# Called when the node enters the scene tree for the first time.
func _ready():
update()
"
[node name="Canvas" type="ViewportContainer"]
anchor_right = 1.0
anchor_bottom = 1.0
stretch = true
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="BackgroundLayer" type="Viewport" parent="."]
size = Vector2( 1024, 600 )
size_override_stretch = true
transparent_bg = true
handle_input_locally = false
usage = 0
render_target_update_mode = 3
[node name="CanvasLayer" type="Polygon2D" parent="BackgroundLayer"]
scale = Vector2( 55, 55 )
polygon = PoolVector2Array( -0.8, -0.8, 0.8, -0.8, 0.8, 0.8, -0.8, 0.8 )
script = SubResource( 4 )
[node name="RenderLayer" type="Viewport" parent="."]
size = Vector2( 1024, 600 )
world = SubResource( 2 )
transparent_bg = true
handle_input_locally = false
render_target_update_mode = 3
[node name="Main" parent="RenderLayer" instance=ExtResource( 2 )]
[node name="ForegroundLayer" type="Viewport" parent="."]
size = Vector2( 1024, 600 )
transparent_bg = true
handle_input_locally = false
usage = 0
render_target_update_mode = 3
[node name="Control" type="Control" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 12.0
margin_top = 12.0
margin_right = -12.0
margin_bottom = -12.0
script = SubResource( 3 )
[node name="Label" type="Label" parent="."]
margin_right = 40.0
margin_bottom = 14.0
[connection signal="canvas_transform_changed" from="." to="." method="_update_view_transformation"]
[connection signal="fill_transform_changed" from="." to="." method="_update_view_transformation"]
[connection signal="resized" from="." to="." method="_on_Canvas_resized"]

@ -0,0 +1,10 @@
tool
extends Control
class_name SummerDayTimeline
func _ready():
pass
func _gui_input(event):
pass

@ -0,0 +1,28 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://addons/summer_day/tool/timeline/timeline.gd" type="Script" id=1]
[node name="Timeline" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
rect_min_size = Vector2( 0, 200 )
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Hello" type="Label" parent="."]
margin_right = 40.0
margin_bottom = 14.0
text = "Hello!"
[node name="Panel" type="Panel" parent="."]
margin_right = 691.0
margin_bottom = 167.0
[node name="Tree" type="Tree" parent="Panel"]
margin_left = 11.0
margin_top = 9.0
margin_right = 681.0
margin_bottom = 288.0
columns = 10

142
cylinder.dae Normal file

File diff suppressed because one or more lines are too long

1064
cylinder.dae.import Normal file

File diff suppressed because it is too large Load Diff

7
default_env.tres Normal file

@ -0,0 +1,7 @@
[gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1]
[resource]
background_mode = 2
background_sky = SubResource( 1 )

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

35