Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
RichTeaMan committed Dec 29, 2023
1 parent 0366e7d commit 03a96dc
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 15 deletions.
9 changes: 8 additions & 1 deletion assets/cube.glb.import
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
import_script/path=""
_subresources={}
_subresources={
"nodes": {
"PATH:Cube": {
"generate/navmesh": 1,
"generate/physics": true
}
}
}
gltf/naming_version=1
gltf/embedded_image_handling=1
53 changes: 39 additions & 14 deletions editor/editor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ var zoom_constant = 0.2
var prev_mouse_position
var next_mouse_position

var SELECTED_GRP = "selected"

@onready
var highlighted_shader = preload("res://shaders/highlighted.gdshader")

Expand Down Expand Up @@ -43,13 +45,15 @@ func _on_button_combine_pressed():
%container.add_child(instance)
instance.set_process(false)
instance.set_physics_process(false)
add_selection_listener(%container)

func _on_button_cube_pressed():
var scene = load("res://vehicles/cube.tscn")
var instance = scene.instantiate()
%container.add_child(instance)
instance.set_process(false)
instance.set_physics_process(false)
add_selection_listener(%container)

func override_material(container: Node3D):
for c in container.get_children(true):
Expand All @@ -64,23 +68,44 @@ func override_material(container: Node3D):

mesh_instance.material_overlay = shader

if c is CollisionObject3D:
var collision: CollisionObject3D = c
collision.input_event.connect(_model_clicked)

print("xxxx")
override_material(c)

func add_selection_listener(container: Node3D):
for c in container.get_children(true):
if c is CollisionObject3D:
var collision: CollisionObject3D = c
if !collision.input_event.is_connected(_model_clicked):
collision.input_event.connect(_model_clicked)
add_selection_listener(c)

func _on_color_picker_color_changed(color):
override_material(%container)

func dir(class_instance):
var output = {}
var methods = []
for method in class_instance.get_method_list():
methods.append(method.name)

output["METHODS"] = methods

var properties = []
for prop in class_instance.get_property_list():
if prop.type == 3:
properties.append(prop.name)
output["PROPERTIES"] = properties
func _model_clicked(_camera: Node, event: InputEvent, _position: Vector3, _normal: Vector3, shape_idx: int):

var shape_owner_id: int = shape_find_owner(shape_idx)
var shape_owner: Object = shape_owner_get_owner(shape_owner_id)

var collision_object := shape_owner as CollisionObject2D

print("Model clicked")
print(event.as_text())


if event is InputEventMouseMotion:
print("motion")
pass

return output
if event is InputEventMouseButton:
var button_event: InputEventMouseButton = event
if button_event.button_index == MOUSE_BUTTON_LEFT && button_event.is_released():
print("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! selected")

#if event.is_action_released():
# print("model selected???")
pass

0 comments on commit 03a96dc

Please sign in to comment.