Still trying to make model loading work.

This commit is contained in:
mono 2021-12-21 21:40:04 +01:00
parent 45a3f6018d
commit 1cb8a639f3
11 changed files with 89 additions and 12 deletions

View File

@ -4,7 +4,7 @@ class_name SummerDayEditableTube
func _check_for_selection(event: InputEvent): # Virtual.
print(event.position)
pass
func _interact(event: InputEvent): # Virtual.

View File

@ -3,6 +3,10 @@ extends Resource
class_name SummerDayDocument
signal track_added(track)
signal track_deleted(track)
export(Resource) var scene = _scene_generation()
export(Array, Resource) var tracks
@ -12,6 +16,7 @@ func add_track(blueprint: SummerDayBlueprint):
track.blueprint = blueprint
track.add_cell(0)
tracks.append(track)
emit_signal("track_added", track)
func _scene_generation() -> SummerDayScene:

View File

@ -12,6 +12,10 @@ func _init():
priority = 1
func _handle_global_input(event: InputEvent):
pass
func _check_for_use(event: InputEvent, tool_context: SummerDayToolContext):
if event is InputEventScreenTouch:
if event.pressed:

View File

@ -1,4 +1,4 @@
extends Reference
extends Object
class_name SummerDayTool
var priority = 0

View File

@ -2,6 +2,8 @@ tool
extends PanelContainer
class_name SummerDayCanvas
onready var MeshContainer := $Render/RenderLayer/Container
var document: SummerDayDocument
var scene: SummerDayScene
var canvas_state := SummerDayCanvasState.new()
@ -47,6 +49,8 @@ func drop_data(position, data):
func _on_SummerDay_document_changed(new_doc):
if new_doc != document:
document = new_doc
new_doc.connect("track_added",
MeshContainer, "_on_Document_add_track")
func _on_SummerDay_scene_changed(new_scene):

View File

@ -1,7 +1,7 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://addons/summer_day/user_interface/canvas/canvas.gd" type="Script" id=1]
[ext_resource path="res://Main.tscn" type="PackedScene" id=2]
[ext_resource path="res://addons/summer_day/user_interface/canvas/mesh_container.gd" type="Script" id=2]
[sub_resource type="StyleBoxFlat" id=3]
bg_color = Color( 0.180392, 0.172549, 0.203922, 1 )
@ -70,7 +70,12 @@ handle_input_locally = false
render_target_update_mode = 3
gui_disable_input = true
[node name="Main" parent="Render/RenderLayer" instance=ExtResource( 2 )]
[node name="Container" type="Spatial" parent="Render/RenderLayer"]
script = ExtResource( 2 )
[node name="Camera" type="Camera" parent="Render/RenderLayer"]
projection = 1
current = true
[node name="BorderShadow" type="Polygon2D" parent="Render/RenderLayer" groups=["SummerDayCanvasPolygon"]]
material = SubResource( 5 )

View File

@ -0,0 +1,11 @@
tool
extends Spatial
func _on_Document_add_track(track: SummerDayTrack):
var packed_scene = track.blueprint._create_model()
print("I'm winning it")
var instance = packed_scene.instance()
add_child(instance, true)
#instance.name = "THE_BIG"
print("pain")

View File

@ -1,9 +1,31 @@
[gd_resource type="Resource" load_steps=3 format=2]
[gd_resource type="Resource" load_steps=12 format=2]
[ext_resource path="res://addons/summer_day/data/document/document.gd" type="Script" id=1]
[ext_resource path="res://production/test/scene_001.tres" type="Resource" id=2]
[ext_resource path="res://addons/summer_day/data/document/cell.gd" type="Script" id=3]
[ext_resource path="res://addons/summer_day/data/document/track.gd" type="Script" id=4]
[ext_resource path="res://addons/summer_day/data/blueprint/template_editables/tube.gd" type="Script" id=5]
[ext_resource path="res://production/blueprints/mannequin/mannequin.tres" type="Resource" id=6]
[sub_resource type="Resource" id=1]
script = ExtResource( 5 )
[sub_resource type="Resource" id=2]
script = ExtResource( 5 )
[sub_resource type="Resource" id=3]
script = ExtResource( 5 )
[sub_resource type="Resource" id=4]
script = ExtResource( 3 )
editable_list = [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ) ]
[sub_resource type="Resource" id=5]
script = ExtResource( 4 )
blueprint = ExtResource( 6 )
cells = [ SubResource( 4 ) ]
[resource]
script = ExtResource( 1 )
scene = ExtResource( 2 )
tracks = [ ]
tracks = [ SubResource( 5 ) ]

View File

@ -17,11 +17,11 @@ func _create_model():
var caps = CapsuleMesh.new()
var arr_mesh := ArrayMesh.new()
arr_mesh.add_surface_from_arrays(
Mesh.PRIMITIVE_TRIANGLES, caps.get_mesh_arrays
Mesh.PRIMITIVE_TRIANGLES, caps.get_mesh_arrays()
)
var m = MeshInstance.new()
m.material = custom_material
m.material_override = custom_material
m.add_to_group(\"SummerDaySpatialTransform\")
m.mesh = arr_mesh
@ -31,7 +31,7 @@ func _create_model():
var texture = ImageTexture.new()
#
texture.create_from_image(table, 0)
m.material.set_shader_param(\"table\", table)
m.material_override.set_shader_param(\"table\", texture)
model = PackedScene.new()
@ -43,7 +43,8 @@ func _create_cell():
var cell = SummerDayCell.new()
var cylinder = SummerDayEditableTube.new()
cell.editable_list.append(cylinder)
return cell"
return cell
"
[resource]
script = SubResource( 1 )

View File

@ -1,4 +1,4 @@
[gd_resource type="ShaderMaterial" load_steps=2 format=2]
[gd_resource type="ShaderMaterial" load_steps=4 format=2]
[sub_resource type="Shader" id=1]
code = "shader_type spatial;
@ -40,12 +40,33 @@ void vertex() {
vec4 post = vec4(transformed_xy.x, transformed_xy.y, pre.z, pre.w);
POSITION = post;
VERTEX = (post / post.w).xyz;
// vec3 tran = vec3(VERTEX.xy, 1.0) * transpose(canvas_transform);
// vec4 pos_t = vec4(tran.x, tran.y, VERTEX.z, 1.0);
// POSITION = pos_t;
// VERTEX = (pos_t / pos_t.w).xyz;
}
void fragment() {
ALBEDO = vec3(0.33, 0.81, 0.95);
}"
[sub_resource type="Image" id=4]
data = {
"data": PoolByteArray( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ),
"format": "RGBAFloat",
"height": 1,
"mipmaps": false,
"width": 8
}
[sub_resource type="ImageTexture" id=3]
flags = 0
flags = 0
image = SubResource( 4 )
size = Vector2( 8, 1 )
[resource]
shader = SubResource( 1 )
shader_param/canvas_transform = null
shader_param/table = SubResource( 3 )

View File

@ -134,7 +134,7 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://addons/summer_day/user_interface/timeline/timeline.gd"
}, {
"base": "Reference",
"base": "Object",
"class": "SummerDayTool",
"language": "GDScript",
"path": "res://addons/summer_day/tools/tool_system/base_tool.gd"
@ -214,6 +214,10 @@ config/icon="res://icon.png"
Util="res://addons/summer_day/utilities/math_helper.gd"
[editor_plugins]
enabled=PoolStringArray( "res://addons/summer_day/plugin.cfg" )
[gdnative]
singletons=[ "res://addons/godot-git-plugin/git_api.gdnlib" ]