Now the dungeon teleporters switch between 2 materials for hover / normal states. This way only the hovered one will light up, instead of all. Also reworked them to use mesh data resources.

This commit is contained in:
Relintai 2022-02-13 15:52:19 +01:00
parent 4a907a37c5
commit df071af39c
7 changed files with 60 additions and 41 deletions

View File

@ -0,0 +1,5 @@
[gd_resource type="MeshDataResource" format=2]
[resource]
array = [ PoolVector3Array( -0.5, -0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5, -0.5, -0.5, -0.5, -0.5, 0.5, 0.5, -0.5, 0.5, -0.5, 0.5, 0.5, -0.5, 0.5, 0.5, 0.5, -0.5, -0.5, 0.5, -0.5, -0.5, -0.5, 0.5, -0.5, -0.5, 0.5, -0.5, 0.5 ), PoolVector3Array( 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0, 0, -1, 0 ), null, null, PoolVector2Array( 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1 ), null, null, null, PoolIntArray( 0, 1, 2, 2, 3, 0, 4, 6, 5, 4, 7, 6, 8, 9, 10, 10, 11, 8, 12, 14, 13, 12, 15, 14, 16, 17, 18, 18, 19, 16, 20, 22, 21, 20, 23, 22 ) ]
aabb = AABB( -0.5, -0.5, -0.5, 1, 1, 1 )

View File

@ -1,25 +1,23 @@
[gd_scene load_steps=6 format=2] [gd_scene load_steps=7 format=2]
[ext_resource path="res://scripts/dungeons/teleporters/dung_back_teleporter.gd" type="Script" id=1] [ext_resource path="res://scripts/dungeons/teleporters/dung_back_teleporter.gd" type="Script" id=1]
[ext_resource path="res://textures/bricks/test_brick_albedo.png" type="Texture" id=2] [ext_resource path="res://textures/bricks/test_brick_albedo.png" type="Texture" id=2]
[ext_resource path="res://props/teleporters/dungeon/simple_dungeon_teleporter_material.tres" type="Material" id=3]
[sub_resource type="CubeMesh" id=1] [ext_resource path="res://props/teleporters/dungeon/simple_dungeon_teleporter_highlight_material.tres" type="Material" id=4]
size = Vector3( 1, 1, 1 ) [ext_resource path="res://models/teleporters/dungeon/simple_dungeon_teleporter.tres" type="MeshDataResource" id=5]
[sub_resource type="SpatialMaterial" id=2]
flags_vertex_lighting = true
albedo_color = Color( 0.494118, 0.494118, 0.494118, 1 )
albedo_texture = ExtResource( 2 )
[sub_resource type="BoxShape" id=3] [sub_resource type="BoxShape" id=3]
extents = Vector3( 0.5, 0.5, 0.5 ) extents = Vector3( 0.5, 0.5, 0.5 )
[node name="DungeonBackTeleporter" type="StaticBody"] [node name="DungeonBackTeleporter" type="StaticBody"]
script = ExtResource( 1 ) script = ExtResource( 1 )
default_material = ExtResource( 3 )
hover_material = ExtResource( 4 )
[node name="MeshInstance" type="MeshInstance" parent="."] [node name="MeshDataInstance" type="MeshDataInstance" parent="."]
mesh = SubResource( 1 ) mesh_data = ExtResource( 5 )
material/0 = SubResource( 2 ) texture = ExtResource( 2 )
material = ExtResource( 3 )
[node name="CollisionShape" type="CollisionShape" parent="."] [node name="CollisionShape" type="CollisionShape" parent="."]
shape = SubResource( 3 ) shape = SubResource( 3 )

View File

@ -1,28 +1,25 @@
[gd_scene load_steps=7 format=2] [gd_scene load_steps=8 format=2]
[ext_resource path="res://scripts/dungeons/teleporters/dung_teleporter.gd" type="Script" id=1] [ext_resource path="res://scripts/dungeons/teleporters/dung_teleporter.gd" type="Script" id=1]
[ext_resource path="res://props/teleporters/dungeon/simple_dungeon_back_teleporter.tscn" type="PackedScene" id=2] [ext_resource path="res://props/teleporters/dungeon/simple_dungeon_back_teleporter.tscn" type="PackedScene" id=2]
[ext_resource path="res://models/teleporters/dungeon/simple_dungeon_teleporter.tres" type="MeshDataResource" id=3]
[ext_resource path="res://textures/bricks/test_brick_albedo.png" type="Texture" id=4] [ext_resource path="res://textures/bricks/test_brick_albedo.png" type="Texture" id=4]
[ext_resource path="res://props/teleporters/dungeon/simple_dungeon_teleporter_material.tres" type="Material" id=5]
[sub_resource type="CubeMesh" id=1] [ext_resource path="res://props/teleporters/dungeon/simple_dungeon_teleporter_highlight_material.tres" type="Material" id=6]
size = Vector3( 1, 1, 1 )
[sub_resource type="SpatialMaterial" id=2]
flags_vertex_lighting = true
albedo_color = Color( 0.494118, 0.494118, 0.494118, 1 )
albedo_texture = ExtResource( 4 )
[sub_resource type="BoxShape" id=3] [sub_resource type="BoxShape" id=3]
extents = Vector3( 0.5, 0.5, 0.5 ) extents = Vector3( 0.5, 0.5, 0.5 )
[node name="DungeonTeleporter" type="StaticBody"] [node name="DungeonTeleporter" type="StaticBody"]
script = ExtResource( 1 ) script = ExtResource( 1 )
default_albedo = Color( 0.521569, 0.521569, 0.521569, 1 ) default_material = ExtResource( 5 )
hover_material = ExtResource( 6 )
dungeon_back_teleporter = ExtResource( 2 ) dungeon_back_teleporter = ExtResource( 2 )
[node name="MeshInstance" type="MeshInstance" parent="."] [node name="MeshDataInstance" type="MeshDataInstance" parent="."]
mesh = SubResource( 1 ) mesh_data = ExtResource( 3 )
material/0 = SubResource( 2 ) texture = ExtResource( 4 )
material = ExtResource( 5 )
[node name="CollisionShape" type="CollisionShape" parent="."] [node name="CollisionShape" type="CollisionShape" parent="."]
shape = SubResource( 3 ) shape = SubResource( 3 )

View File

@ -0,0 +1,9 @@
[gd_resource type="ShaderMaterial" load_steps=3 format=2]
[ext_resource path="res://shaders/5_standard_shader_nouv2.tres" type="Shader" id=1]
[ext_resource path="res://textures/bricks/test_brick_albedo.png" type="Texture" id=2]
[resource]
shader = ExtResource( 1 )
shader_param/albedo = Color( 0.65098, 0.65098, 0.65098, 1 )
shader_param/texture_albedo = ExtResource( 2 )

View File

@ -0,0 +1,9 @@
[gd_resource type="ShaderMaterial" load_steps=3 format=2]
[ext_resource path="res://shaders/5_standard_shader_nouv2.tres" type="Shader" id=1]
[ext_resource path="res://textures/bricks/test_brick_albedo.png" type="Texture" id=2]
[resource]
shader = ExtResource( 1 )
shader_param/albedo = Color( 0.521569, 0.521569, 0.521569, 1 )
shader_param/texture_albedo = ExtResource( 2 )

View File

@ -1,7 +1,7 @@
extends StaticBody extends StaticBody
export(Color) var default_albedo : Color = Color(0.494118, 0.494118, 0.494118) export(Material) var default_material : Material = null
export(Color) var hover_albedo : Color = Color(0.65098, 0.65098, 0.65098) export(Material) var hover_material : Material = null
export(float) var use_range : float = 5 export(float) var use_range : float = 5
var _dungeon : Spatial = null var _dungeon : Spatial = null
@ -17,20 +17,20 @@ func _ready():
connect("mouse_entered", self, "on_mouse_entered") connect("mouse_entered", self, "on_mouse_entered")
connect("mouse_exited", self, "on_mouse_exited") connect("mouse_exited", self, "on_mouse_exited")
var mat = $MeshInstance.get_surface_material(0) if default_material:
mat.albedo_color = default_albedo $MeshDataInstance.material = default_material
func on_mouse_entered(): func on_mouse_entered():
var mat = $MeshInstance.get_surface_material(0) if hover_material:
mat.albedo_color = hover_albedo $MeshDataInstance.material = hover_material
Input.set_default_cursor_shape(Input.CURSOR_POINTING_HAND) Input.set_default_cursor_shape(Input.CURSOR_POINTING_HAND)
_mouse_hover = true _mouse_hover = true
func on_mouse_exited(): func on_mouse_exited():
var mat = $MeshInstance.get_surface_material(0) if default_material:
mat.albedo_color = default_albedo $MeshDataInstance.material = default_material
Input.set_default_cursor_shape(Input.CURSOR_ARROW) Input.set_default_cursor_shape(Input.CURSOR_ARROW)

View File

@ -1,7 +1,8 @@
extends StaticBody extends StaticBody
export(Color) var default_albedo : Color = Color(0.494118, 0.494118, 0.494118) export(Material) var default_material : Material = null
export(Color) var hover_albedo : Color = Color(0.65098, 0.65098, 0.65098) export(Material) var hover_material : Material = null
export(float) var use_range : float = 5 export(float) var use_range : float = 5
export(PackedScene) var dungeon : PackedScene export(PackedScene) var dungeon : PackedScene
@ -29,20 +30,20 @@ func _ready():
connect("mouse_entered", self, "on_mouse_entered") connect("mouse_entered", self, "on_mouse_entered")
connect("mouse_exited", self, "on_mouse_exited") connect("mouse_exited", self, "on_mouse_exited")
var mat = $MeshInstance.get_surface_material(0) if default_material:
mat.albedo_color = default_albedo $MeshDataInstance.material = default_material
func on_mouse_entered(): func on_mouse_entered():
var mat = $MeshInstance.get_surface_material(0) if hover_material:
mat.albedo_color = hover_albedo $MeshDataInstance.material = hover_material
Input.set_default_cursor_shape(Input.CURSOR_POINTING_HAND) Input.set_default_cursor_shape(Input.CURSOR_POINTING_HAND)
_mouse_hover = true _mouse_hover = true
func on_mouse_exited(): func on_mouse_exited():
var mat = $MeshInstance.get_surface_material(0) if default_material:
mat.albedo_color = default_albedo $MeshDataInstance.material = default_material
Input.set_default_cursor_shape(Input.CURSOR_ARROW) Input.set_default_cursor_shape(Input.CURSOR_ARROW)