Wands stuff. didn't really work out
This commit is contained in:
parent
ffdc97583a
commit
7ed06d2a74
10 changed files with 115 additions and 16 deletions
|
@ -35,6 +35,8 @@ class CopiedCollision extends RefCounted:
|
||||||
var collision_shape : CollisionShape3D
|
var collision_shape : CollisionShape3D
|
||||||
var org_transform : Transform3D
|
var org_transform : Transform3D
|
||||||
|
|
||||||
|
@export var position_node : Node3D
|
||||||
|
|
||||||
## Pickup enabled property
|
## Pickup enabled property
|
||||||
@export var enabled : bool = true
|
@export var enabled : bool = true
|
||||||
|
|
||||||
|
@ -169,7 +171,8 @@ func _process(delta):
|
||||||
|
|
||||||
#Apply the public values to trick the movement script
|
#Apply the public values to trick the movement script
|
||||||
grip_value_public = _controller.get_float(pickup_axis_action)
|
grip_value_public = _controller.get_float(pickup_axis_action)
|
||||||
|
_grab_area.global_position = position_node.global_position
|
||||||
|
_ranged_area.global_position = position_node.global_position
|
||||||
# Handle our grip
|
# Handle our grip
|
||||||
#var grip_value = grip_value_public
|
#var grip_value = grip_value_public
|
||||||
var grip_value = _controller.get_float(pickup_axis_action_trigger)
|
var grip_value = _controller.get_float(pickup_axis_action_trigger)
|
||||||
|
@ -430,7 +433,8 @@ func _pick_up_object(target: Node3D) -> void:
|
||||||
# Pick up our target. Note, target may do instant drop_and_free
|
# Pick up our target. Note, target may do instant drop_and_free
|
||||||
picked_up_ranged = not _object_in_grab_area.has(target)
|
picked_up_ranged = not _object_in_grab_area.has(target)
|
||||||
picked_up_object = target
|
picked_up_object = target
|
||||||
target.pick_up(self)
|
target.pick_up(self,position_node)
|
||||||
|
#target.pick_up()
|
||||||
|
|
||||||
# If object picked up then emit signal
|
# If object picked up then emit signal
|
||||||
if is_instance_valid(picked_up_object):
|
if is_instance_valid(picked_up_object):
|
||||||
|
|
|
@ -17,6 +17,8 @@ extends Node3D
|
||||||
## Signal emitted when the hand scale changes
|
## Signal emitted when the hand scale changes
|
||||||
signal hand_scale_changed(scale)
|
signal hand_scale_changed(scale)
|
||||||
|
|
||||||
|
##Wand mesh for it blendshapes
|
||||||
|
@export var wand_mesh : MeshInstance3D
|
||||||
|
|
||||||
## Blend tree to use
|
## Blend tree to use
|
||||||
@export var hand_blend_tree : AnimationNodeBlendTree: set = set_hand_blend_tree
|
@export var hand_blend_tree : AnimationNodeBlendTree: set = set_hand_blend_tree
|
||||||
|
@ -158,6 +160,8 @@ func _physics_process(_delta: float) -> void:
|
||||||
var grip : float = _controller.get_float(grip_action)
|
var grip : float = _controller.get_float(grip_action)
|
||||||
var trigger : float = _controller.get_float(trigger_action)
|
var trigger : float = _controller.get_float(trigger_action)
|
||||||
|
|
||||||
|
#Animate wand opening
|
||||||
|
wand_mesh.set("blend_shapes/Key 1", 1-trigger)
|
||||||
# Allow overriding of grip and trigger
|
# Allow overriding of grip and trigger
|
||||||
if _force_grip >= 0.0: grip = _force_grip
|
if _force_grip >= 0.0: grip = _force_grip
|
||||||
if _force_trigger >= 0.0: trigger = _force_trigger
|
if _force_trigger >= 0.0: trigger = _force_trigger
|
||||||
|
|
|
@ -186,10 +186,11 @@ static func create_lerp(
|
||||||
# Create the driver to instantly snap to the primary grab-point.
|
# Create the driver to instantly snap to the primary grab-point.
|
||||||
static func create_snap(
|
static func create_snap(
|
||||||
p_target : Node3D,
|
p_target : Node3D,
|
||||||
p_grab : Grab) -> XRToolsGrabDriver:
|
p_grab : Grab,
|
||||||
|
p_pos : Node3D) -> XRToolsGrabDriver:
|
||||||
|
|
||||||
print_verbose("%s> snapping to %s" % [p_target.name, p_grab.by.name])
|
print_verbose("%s> snapping to %s" % [p_target.name, p_grab.by.name])
|
||||||
|
print("%s> snapping to %s" % [p_target.name, p_grab.by.name])
|
||||||
# Construct the driver snapped to the held position
|
# Construct the driver snapped to the held position
|
||||||
var driver := XRToolsGrabDriver.new()
|
var driver := XRToolsGrabDriver.new()
|
||||||
driver.name = p_target.name + "_driver"
|
driver.name = p_target.name + "_driver"
|
||||||
|
@ -198,7 +199,10 @@ static func create_snap(
|
||||||
driver.state = GrabState.SNAP
|
driver.state = GrabState.SNAP
|
||||||
driver.target = p_target
|
driver.target = p_target
|
||||||
driver.primary = p_grab
|
driver.primary = p_grab
|
||||||
driver.global_transform = p_grab.by.global_transform * p_grab.transform.inverse()
|
#driver.global_transform = p_pos.global_transform * p_grab.transform.inverse()
|
||||||
|
driver.global_transform = p_grab.by.global_transform * p_pos.transform.inverse()
|
||||||
|
#driver.global_transform = p_pos.global_transform #p_grab.by.global_transform * p_pos.transform.inverse()
|
||||||
|
#driver.global_transform = Transform3D.IDENTITY
|
||||||
|
|
||||||
# Snapped to grab-point so report arrived
|
# Snapped to grab-point so report arrived
|
||||||
p_grab.set_arrived()
|
p_grab.set_arrived()
|
||||||
|
@ -206,8 +210,13 @@ static func create_snap(
|
||||||
# Add the driver as a neighbor of the target as RemoteTransform3D nodes
|
# Add the driver as a neighbor of the target as RemoteTransform3D nodes
|
||||||
# cannot be descendands of the targets they drive.
|
# cannot be descendands of the targets they drive.
|
||||||
p_target.get_parent().add_child(driver)
|
p_target.get_parent().add_child(driver)
|
||||||
|
#p_target.position = Vector3(1,1,1)
|
||||||
|
#driver.position = Vector3(1,1,1)
|
||||||
|
#p_target.global_position = Vector3.ZERO
|
||||||
driver.remote_path = driver.get_path_to(p_target)
|
driver.remote_path = driver.get_path_to(p_target)
|
||||||
|
|
||||||
|
#driver.transform = p_pos.transform
|
||||||
|
|
||||||
driver._update_weight()
|
driver._update_weight()
|
||||||
|
|
||||||
# Return the driver
|
# Return the driver
|
||||||
|
|
|
@ -256,7 +256,7 @@ func drop_and_free():
|
||||||
|
|
||||||
|
|
||||||
# Called when this object is picked up
|
# Called when this object is picked up
|
||||||
func pick_up(by: Node3D) -> void:
|
func pick_up(by : Node3D, other_by : Node3D) -> void:
|
||||||
# Skip if not enabled
|
# Skip if not enabled
|
||||||
if not enabled:
|
if not enabled:
|
||||||
return
|
return
|
||||||
|
@ -308,7 +308,7 @@ func pick_up(by: Node3D) -> void:
|
||||||
|
|
||||||
# Find a suitable primary hand grab
|
# Find a suitable primary hand grab
|
||||||
var by_grab_point := _get_grab_point(by, null)
|
var by_grab_point := _get_grab_point(by, null)
|
||||||
|
|
||||||
# Construct the grab driver
|
# Construct the grab driver
|
||||||
if by.picked_up_ranged:
|
if by.picked_up_ranged:
|
||||||
if ranged_grab_method == RangedMethod.LERP:
|
if ranged_grab_method == RangedMethod.LERP:
|
||||||
|
@ -316,10 +316,11 @@ func pick_up(by: Node3D) -> void:
|
||||||
_grab_driver = XRToolsGrabDriver.create_lerp(self, grab, ranged_grab_speed)
|
_grab_driver = XRToolsGrabDriver.create_lerp(self, grab, ranged_grab_speed)
|
||||||
else:
|
else:
|
||||||
var grab := Grab.new(grabber, self, by_grab_point, false)
|
var grab := Grab.new(grabber, self, by_grab_point, false)
|
||||||
_grab_driver = XRToolsGrabDriver.create_snap(self, grab)
|
_grab_driver = XRToolsGrabDriver.create_snap(self, grab,other_by)
|
||||||
else:
|
else:
|
||||||
var grab := Grab.new(grabber, self, by_grab_point, true)
|
var grab := Grab.new(grabber, self, by_grab_point, true)
|
||||||
_grab_driver = XRToolsGrabDriver.create_snap(self, grab)
|
#var sal := Grab.new()
|
||||||
|
_grab_driver = XRToolsGrabDriver.create_snap(self, grab,other_by)
|
||||||
|
|
||||||
# Report picked up and grabbed
|
# Report picked up and grabbed
|
||||||
picked_up.emit(self)
|
picked_up.emit(self)
|
||||||
|
|
|
@ -40,7 +40,7 @@ func request_highlight(_from, _on) -> void:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# Called by XRToolsFunctionPickup when this is picked up by a controller
|
# Called by XRToolsFunctionPickup when this is picked up by a controller
|
||||||
func pick_up(by: Node3D) -> void:
|
func pick_up(by: Node3D, another: Node3D) -> void:
|
||||||
# Get the ID to save the grab handle under
|
# Get the ID to save the grab handle under
|
||||||
var id = by.get_instance_id()
|
var id = by.get_instance_id()
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_resource type="Theme" load_steps=3 format=3 uid="uid://bfjhdxefw3nxu"]
|
[gd_resource type="Theme" load_steps=3 format=3 uid="uid://b85lk4d2qs3dv"]
|
||||||
|
|
||||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_qmc8q"]
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_qmc8q"]
|
||||||
bg_color = Color(0.171637, 0.171637, 0.171637, 1)
|
bg_color = Color(0.171637, 0.171637, 0.171637, 1)
|
||||||
|
|
BIN
scenes/wand/wand.blend
Normal file
BIN
scenes/wand/wand.blend
Normal file
Binary file not shown.
BIN
scenes/wand/wand.glb
Normal file
BIN
scenes/wand/wand.glb
Normal file
Binary file not shown.
36
scenes/wand/wand.glb.import
Normal file
36
scenes/wand/wand.glb.import
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="scene"
|
||||||
|
importer_version=1
|
||||||
|
type="PackedScene"
|
||||||
|
uid="uid://dj0kcmhbtkguv"
|
||||||
|
path="res://.godot/imported/wand.glb-e6585b0d67898b878dc9a82158bce5ed.scn"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://scenes/wand/wand.glb"
|
||||||
|
dest_files=["res://.godot/imported/wand.glb-e6585b0d67898b878dc9a82158bce5ed.scn"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
nodes/root_type=""
|
||||||
|
nodes/root_name=""
|
||||||
|
nodes/apply_root_scale=true
|
||||||
|
nodes/root_scale=1.0
|
||||||
|
nodes/import_as_skeleton_bones=false
|
||||||
|
meshes/ensure_tangents=true
|
||||||
|
meshes/generate_lods=true
|
||||||
|
meshes/create_shadow_meshes=true
|
||||||
|
meshes/light_baking=1
|
||||||
|
meshes/lightmap_texel_size=0.2
|
||||||
|
meshes/force_disable_compression=false
|
||||||
|
skins/use_named_skins=true
|
||||||
|
animation/import=true
|
||||||
|
animation/fps=30
|
||||||
|
animation/trimming=false
|
||||||
|
animation/remove_immutable_tracks=true
|
||||||
|
animation/import_rest_as_RESET=false
|
||||||
|
import_script/path=""
|
||||||
|
_subresources={}
|
||||||
|
gltf/naming_version=1
|
||||||
|
gltf/embedded_image_handling=1
|
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue