- Added an icon to the bug marker.

- Bug marker position now updates on every process frame.
- Updated licence document to include CC4 icons for bug reports.
This commit is contained in:
Jamie Greunbaum 2024-05-15 19:09:47 -04:00
parent de4bd6e3db
commit 8527572748
19 changed files with 96 additions and 33 deletions

View File

@ -1,9 +0,0 @@
MIT License
Copyright (c) 2024 BattyBovine
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.

26
LICENSE.md Normal file
View File

@ -0,0 +1,26 @@
All code within this repository is licenced under the MIT licence:
MIT License
Copyright (c) 2024 Jamie Greunbaum
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.
--------------------------------------------------------------------------------
Bug icon licenced from the [CoreUI](https://coreui.io/icons/) icon set under the [Creative Commons Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/) licence.

BIN
Materials/bug.dds Normal file

Binary file not shown.

View File

@ -0,0 +1,25 @@
// NOTE: Shader automatically converted from Godot Engine 4.2.2.stable's StandardMaterial3D.
shader_type spatial;
render_mode blend_mix,depth_test_disabled,cull_disabled,unshaded;
uniform vec3 colour : source_color = vec3(1.0f, 0.0f, 0.0f);
uniform sampler2D msdf_icon : filter_linear_mipmap,hint_default_black;
uniform float shape_thickness : hint_range(0.0f,1.0f,0.01) = 0.95f;
uniform vec3 line_colour : source_color = vec3(0.0f);
uniform float line_thickness : hint_range(0.0f,1.0f,0.01) = 0.0f;
uniform bool billboard = false;
void vertex() {
if (billboard) {
MODELVIEW_MATRIX = VIEW_MATRIX * mat4(INV_VIEW_MATRIX[0], INV_VIEW_MATRIX[1], INV_VIEW_MATRIX[2], MODEL_MATRIX[3]);
MODELVIEW_MATRIX = MODELVIEW_MATRIX * mat4(vec4(length(MODEL_MATRIX[0].xyz), 0.0, 0.0, 0.0), vec4(0.0, length(MODEL_MATRIX[1].xyz), 0.0, 0.0), vec4(0.0, 0.0, length(MODEL_MATRIX[2].xyz), 0.0), vec4(0.0, 0.0, 0.0, 1.0));
MODELVIEW_NORMAL_MATRIX = mat3(MODELVIEW_MATRIX);
}
}
void fragment() {
vec4 albedo_tex = texture(msdf_icon, UV);
if (step(shape_thickness, albedo_tex.r) > 0.5f) { discard; }
ALBEDO = (step(shape_thickness-line_thickness, albedo_tex.r) > 0.5f) ? pow(line_colour, vec3(0.4545454545)) : pow(colour.rgb, vec3(0.4545454545));
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,22 +1,20 @@
[gd_scene load_steps=4 format=3 uid="uid://crr6cjploetps"] [gd_scene load_steps=4 format=3 uid="uid://crr6cjploetps"]
[ext_resource type="ArrayMesh" uid="uid://dtvea38mlpfla" path="res://addons/Bugbot/Meshes/arrow.res" id="1_65xos"] [ext_resource type="ArrayMesh" uid="uid://dtvea38mlpfla" path="res://addons/Bugbot/Meshes/arrow.res" id="1_65xos"]
[ext_resource type="Material" uid="uid://dkaq0ok73o5d4" path="res://addons/Bugbot/Materials/bug_marker_icon.material" id="3_px2dp"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_v6jy1"]
shading_mode = 0
billboard_mode = 1
billboard_keep_scale = true
[sub_resource type="QuadMesh" id="QuadMesh_dd1nc"] [sub_resource type="QuadMesh" id="QuadMesh_dd1nc"]
material = SubResource("StandardMaterial3D_v6jy1") material = ExtResource("3_px2dp")
custom_aabb = AABB(-0.25, -0.25, -0.25, 0.5, 0.5, 0.5) custom_aabb = AABB(-0.25, -0.25, -0.25, 0.5, 0.5, 0.5)
size = Vector2(0.25, 0.25) size = Vector2(0.25, 0.25)
[node name="BugMarker" type="Node3D"] [node name="BugMarker" type="Node3D"]
[node name="Arrow" type="MeshInstance3D" parent="."] [node name="Arrow" type="MeshInstance3D" parent="."]
cast_shadow = 0
mesh = ExtResource("1_65xos") mesh = ExtResource("1_65xos")
[node name="Billboard" type="MeshInstance3D" parent="."] [node name="Billboard" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.4, 0) transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.4, 0)
cast_shadow = 0
mesh = SubResource("QuadMesh_dd1nc") mesh = SubResource("QuadMesh_dd1nc")

View File

@ -0,0 +1,21 @@
extends Node3D
enum BugStatus { UNRESOLVED, IN_PROGRESS, RESOLVED }
@export var marker_status : BugStatus
const UNRESOLVED_COLOUR = Color(0.1, 0.0, 0.0)
const IN_PROGRESS_COLOUR = Color(0.5, 0.5, 0.0)
const RESOLVED_COLOUR = Color(0.0, 0.1, 0.0)
@export var follow_node : Node3D
func _process(_delta:float) -> void:
if not visible:
position = Vector3(0.0, 0.0, 0.0)
elif follow_node:
global_position = follow_node.global_position
func set_rotation_to_normal(_normal:Vector3):
global_transform.basis.y = _normal
global_transform.basis.x = global_transform.basis.z.cross(_normal)
global_transform.basis = global_transform.basis.orthonormalized()

View File

@ -1,6 +1,12 @@
class_name Bugbot class_name Bugbot
extends CharacterBody3D extends CharacterBody3D
## A controllable bot that marks the location of a bug, and allows writing a bug
## report for it.
## Distance from camera to allow placing bug markers.
@export_range(0.0, 100.0, 0.01, "or_greater", "suffix:m") var ray_length : float = 10.0
@export_group("Inputs") @export_group("Inputs")
@export_subgroup("Keyboard") @export_subgroup("Keyboard")
@export var keyboard_move_forward : InputEventKey @export var keyboard_move_forward : InputEventKey
@ -60,8 +66,6 @@ var stored_mouse_mode : int = Input.MOUSE_MODE_CAPTURED
var stored_pause_status : bool = false var stored_pause_status : bool = false
var raycast_collision : Dictionary var raycast_collision : Dictionary
var _previous_bug_marker_position : Vector3
static func instantiate(tree:SceneTree) -> void: static func instantiate(tree:SceneTree) -> void:
tree.root.add_child(load("res://addons/Bugbot/Scenes/bugbot_player.tscn").instantiate() as CharacterBody3D) tree.root.add_child(load("res://addons/Bugbot/Scenes/bugbot_player.tscn").instantiate() as CharacterBody3D)
@ -262,7 +266,7 @@ func _on_exit_placement_timer_timeout() -> void:
func _raycast_to_world(): func _raycast_to_world():
var space : PhysicsDirectSpaceState3D = get_world_3d().direct_space_state var space : PhysicsDirectSpaceState3D = get_world_3d().direct_space_state
var query : PhysicsRayQueryParameters3D = PhysicsRayQueryParameters3D.create(global_position, global_position - global_transform.basis.z * 25.0) var query : PhysicsRayQueryParameters3D = PhysicsRayQueryParameters3D.create(global_position, global_position - global_transform.basis.z * ray_length)
query.collide_with_areas = false query.collide_with_areas = false
query.collide_with_bodies = true query.collide_with_bodies = true
query.exclude = [get_rid()] query.exclude = [get_rid()]
@ -278,13 +282,7 @@ func _raycast_to_world():
func _place_dummy_marker(): func _place_dummy_marker():
if raycast_collision: if raycast_collision:
var collision_point : Vector3 = raycast_collision["position"] bug_marker.set_rotation_to_normal(raycast_collision["normal"])
var collision_normal : Vector3 = raycast_collision["normal"]
bug_marker.global_position = collision_point
_previous_bug_marker_position = bug_marker.global_position
bug_marker.global_transform.basis.y = collision_normal
bug_marker.global_transform.basis.x = bug_marker.global_transform.basis.z.cross(collision_normal)
bug_marker.global_transform.basis = bug_marker.global_transform.basis.orthonormalized()
bug_marker.visible = true bug_marker.visible = true
else: else:
bug_marker.visible = false bug_marker.visible = false

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=40 format=3 uid="uid://dvgain3s4xa4r"] [gd_scene load_steps=41 format=3 uid="uid://dvgain3s4xa4r"]
[ext_resource type="Script" path="res://addons/Bugbot/Scenes/bugbot_player.gd" id="1_kdrpa"] [ext_resource type="Script" path="res://addons/Bugbot/Scenes/bugbot_player.gd" id="1_kdrpa"]
[ext_resource type="InputEventKey" uid="uid://di5q6d4wt12et" path="res://addons/Bugbot/Inputs/Keyboard/move_forward.res" id="2_jfhdw"] [ext_resource type="InputEventKey" uid="uid://di5q6d4wt12et" path="res://addons/Bugbot/Inputs/Keyboard/move_forward.res" id="2_jfhdw"]
@ -33,26 +33,28 @@
[ext_resource type="InputEventJoypadButton" uid="uid://biuae513qxxf2" path="res://addons/Bugbot/Inputs/Joystick/speed_down.res" id="31_t01c7"] [ext_resource type="InputEventJoypadButton" uid="uid://biuae513qxxf2" path="res://addons/Bugbot/Inputs/Joystick/speed_down.res" id="31_t01c7"]
[ext_resource type="InputEventJoypadButton" uid="uid://bc2q8kry856bq" path="res://addons/Bugbot/Inputs/Joystick/place_marker.res" id="32_q7vmk"] [ext_resource type="InputEventJoypadButton" uid="uid://bc2q8kry856bq" path="res://addons/Bugbot/Inputs/Joystick/place_marker.res" id="32_q7vmk"]
[ext_resource type="InputEventJoypadButton" uid="uid://8tu5a8nlxgsj" path="res://addons/Bugbot/Inputs/Joystick/exit_placement.res" id="33_lwr38"] [ext_resource type="InputEventJoypadButton" uid="uid://8tu5a8nlxgsj" path="res://addons/Bugbot/Inputs/Joystick/exit_placement.res" id="33_lwr38"]
[ext_resource type="Material" uid="uid://c8b630nfapp8l" path="res://addons/Bugbot/Textures/laser_glow.material" id="34_18wde"]
[ext_resource type="PackedScene" uid="uid://crr6cjploetps" path="res://addons/Bugbot/Scenes/bug_marker.tscn" id="34_jyjbc"] [ext_resource type="PackedScene" uid="uid://crr6cjploetps" path="res://addons/Bugbot/Scenes/bug_marker.tscn" id="34_jyjbc"]
[ext_resource type="Material" uid="uid://dewbda2gd8bgv" path="res://addons/Bugbot/Textures/laser_glare.material" id="35_f65w0"] [ext_resource type="Script" path="res://addons/Bugbot/Scenes/bug_marker_dummy.gd" id="35_ibing"]
[ext_resource type="Material" uid="uid://c8b630nfapp8l" path="res://addons/Bugbot/Materials/laser_glow.material" id="35_xqv41"]
[ext_resource type="Material" uid="uid://dewbda2gd8bgv" path="res://addons/Bugbot/Materials/laser_glare.material" id="36_e4bro"]
[sub_resource type="CylinderMesh" id="CylinderMesh_ts4fq"] [sub_resource type="CylinderMesh" id="CylinderMesh_ts4fq"]
material = ExtResource("34_18wde") material = ExtResource("35_xqv41")
top_radius = 0.005 top_radius = 0.005
bottom_radius = 0.005 bottom_radius = 0.005
height = 1.0 height = 1.0
[sub_resource type="QuadMesh" id="QuadMesh_kvipo"] [sub_resource type="QuadMesh" id="QuadMesh_kvipo"]
material = ExtResource("35_f65w0") material = ExtResource("36_e4bro")
size = Vector2(0.25, 0.25) size = Vector2(0.25, 0.25)
[sub_resource type="SphereShape3D" id="SphereShape3D_6gwao"] [sub_resource type="SphereShape3D" id="SphereShape3D_6gwao"]
radius = 0.25
[node name="BugbotPlayer" type="CharacterBody3D"] [node name="BugbotPlayer" type="CharacterBody3D"]
process_mode = 3 process_mode = 3
collision_layer = 4294967295 collision_layer = 0
collision_mask = 0 collision_mask = 4294967295
input_ray_pickable = false input_ray_pickable = false
motion_mode = 1 motion_mode = 1
platform_on_leave = 2 platform_on_leave = 2
@ -91,7 +93,9 @@ joypad_movement_speed_down = ExtResource("31_t01c7")
joypad_place_marker = ExtResource("32_q7vmk") joypad_place_marker = ExtResource("32_q7vmk")
joypad_exit_placement = ExtResource("33_lwr38") joypad_exit_placement = ExtResource("33_lwr38")
[node name="BugMarker" parent="." instance=ExtResource("34_jyjbc")] [node name="BugMarker" parent="." node_paths=PackedStringArray("follow_node") instance=ExtResource("34_jyjbc")]
script = ExtResource("35_ibing")
follow_node = NodePath("../LaserBeamRoot/LaserGlare")
[node name="LaserBeamRoot" type="Node3D" parent="."] [node name="LaserBeamRoot" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.5, -0.5, 0) transform = Transform3D(1, 0, 0, 0, -4.37114e-08, 1, 0, -1, -4.37114e-08, -0.5, -0.5, 0)

Binary file not shown.