From a73b23575d2cd4ecccafcd7c584ece64d554560b Mon Sep 17 00:00:00 2001 From: Mark Hoekveen Date: Sat, 26 Oct 2019 17:14:35 +0200 Subject: [PATCH] WIP commit, creature infoscreen --- Creature.gd | 6 ++--- Creature.tscn | 67 +++++++++++++++++++++++++++++++++++++++++++-------- InfoScreen.gd | 32 ++++++++++++++++++++++++ Spatial.tscn | 2 ++ 4 files changed, 94 insertions(+), 13 deletions(-) create mode 100644 InfoScreen.gd diff --git a/Creature.gd b/Creature.gd index a7a5924..94d62a7 100644 --- a/Creature.gd +++ b/Creature.gd @@ -54,12 +54,12 @@ func describe(): print(strand) print(TIERS_STRING) print(TRAIT_STRING) + get_node("InfoScreen/Viewport/Control/Description").text = (strand) func _ready(): - print(naampje) initialize() - print(dna.size()) - + # print(dna.size()) + describe() #Register the selection event get_node("Area").connect('input_event', get_parent(), 'select_a_bitch', [get_index()]) pass \ No newline at end of file diff --git a/Creature.tscn b/Creature.tscn index 58a133d..63f708b 100644 --- a/Creature.tscn +++ b/Creature.tscn @@ -1,19 +1,32 @@ -[gd_scene load_steps=7 format=2] +[gd_scene load_steps=12 format=2] [ext_resource path="res://figure.gltf" type="PackedScene" id=1] [ext_resource path="res://Creature.gd" type="Script" id=2] -[ext_resource path="res://Creature.tres" type="Material" id=3] +[ext_resource path="res://InfoScreen.gd" type="Script" id=3] +[ext_resource path="res://Creature.tres" type="Material" id=4] -[sub_resource type="CylinderMesh" id=3] +[sub_resource type="CylinderMesh" id=1] top_radius = 0.5 bottom_radius = 0.5 height = 0.001 radial_segments = 8 rings = 2 -[sub_resource type="ShaderMaterial" id=4] +[sub_resource type="ShaderMaterial" id=2] -[sub_resource type="CylinderShape" id=1] +[sub_resource type="ViewportTexture" id=3] +viewport_path = NodePath("InfoScreen/Viewport") + +[sub_resource type="SpatialMaterial" id=4] +resource_local_to_scene = true +albedo_texture = SubResource( 3 ) + +[sub_resource type="QuadMesh" id=5] + +[sub_resource type="BoxShape" id=6] +extents = Vector3( 0.51038, 0.447592, 0.128839 ) + +[sub_resource type="CylinderShape" id=9] height = 1.21849 [node name="Creature" index="0" instance=ExtResource( 1 )] @@ -22,14 +35,48 @@ script = ExtResource( 2 ) [node name="SelectionIndicator" type="MeshInstance" parent="." index="0"] visible = false cast_shadow = 0 -mesh = SubResource( 3 ) -material/0 = SubResource( 4 ) +mesh = SubResource( 1 ) +material/0 = SubResource( 2 ) + +[node name="InfoScreen" type="StaticBody" parent="." index="1"] +script = ExtResource( 3 ) + +[node name="Screen" type="MeshInstance" parent="InfoScreen" index="0"] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.24649, 0 ) +material_override = SubResource( 4 ) +cast_shadow = 0 +mesh = SubResource( 5 ) +material/0 = null + +[node name="CollisionShape" type="CollisionShape" parent="InfoScreen" index="1"] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.23924, 0 ) +shape = SubResource( 6 ) + +[node name="Viewport" type="Viewport" parent="InfoScreen" index="2"] +size = Vector2( 500, 500 ) +hdr = false +disable_3d = true +usage = 0 +render_target_v_flip = true +gui_disable_input = true + +[node name="Control" type="Control" parent="InfoScreen/Viewport" index="0"] +margin_right = 522.0 +margin_bottom = 494.0 + +[node name="Description" type="RichTextLabel" parent="InfoScreen/Viewport/Control" index="0"] +margin_top = -1.0 +margin_right = 102.0 +margin_bottom = 101.0 +rect_scale = Vector2( 5, 5 ) +text = "Hallo ik ben een creature. +aangenaam ofzo" [node name="Mesh" parent="Node/Node 2/Armature" index="0"] -material/0 = ExtResource( 3 ) +material/0 = ExtResource( 4 ) -[node name="Area" type="Area" parent="." index="3"] +[node name="Area" type="Area" parent="." index="4"] [node name="CollisionShape" type="CollisionShape" parent="Area" index="0"] transform = Transform( 0.25, 0, 0, 0, 1, 0, 0, 0, 0.25, 0, 0.803572, 0 ) -shape = SubResource( 1 ) +shape = SubResource( 9 ) diff --git a/InfoScreen.gd b/InfoScreen.gd new file mode 100644 index 0000000..918e7b3 --- /dev/null +++ b/InfoScreen.gd @@ -0,0 +1,32 @@ +extends StaticBody + +# 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(): + #set_screen(get_node( + # Retrieve the captured Image using get_data(). + var img = get_viewport().get_texture().get_data() + # Flip on the y axis. + # You can also set "V Flip" to true if not on the Root Viewport. + img.flip_y() + # Convert Image to ImageTexture. + var tex = ImageTexture.new() + tex.create_from_image(img) +# Set Sprite Texture. + #$sprite.texture = tex + #set_screen(tex) + + pass # Replace with function body. + +func set_screen(img): + var surface = get_node('Screen') + surface.material_override = surface.material_override.duplicate() + if surface.material_override: + surface.material_override.albedo_texture = img + surface.material_override.emission_texture = img +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass diff --git a/Spatial.tscn b/Spatial.tscn index 755a90b..cf5e0c5 100644 --- a/Spatial.tscn +++ b/Spatial.tscn @@ -46,8 +46,10 @@ glow_bicubic_upscale = true [node name="Todd_Test" type="Spatial"] [node name="GUI" type="CanvasLayer" parent="."] +editor/display_folded = true [node name="Control" type="Control" parent="GUI"] +editor/display_folded = true material = SubResource( 1 ) [node name="Spawn" type="Button" parent="GUI/Control"]