Move cyclic stick visually
This commit is contained in:
parent
c83135a67b
commit
ab91016524
2 changed files with 18 additions and 8 deletions
|
|
@ -1,19 +1,30 @@
|
|||
extends Node3D
|
||||
|
||||
@onready var connector = $MarshConnector
|
||||
@onready var skeleton = $"Mi-2/Armature/Skeleton3D"
|
||||
@onready var attitude_root = $AttitudeRoot
|
||||
## Rotation of cyclic stick model for full control deflection, in degrees
|
||||
@export var range_cyclic: float = 30
|
||||
|
||||
@onready var connector: MarshConnector = $MarshConnector
|
||||
@onready var skeleton: Skeleton3D = $"Mi-2/Armature/Skeleton3D"
|
||||
@onready var attitude_root: Node3D = $AttitudeRoot
|
||||
|
||||
@onready var bone_cg: int = skeleton.find_bone("BodyCG")
|
||||
@onready var bone_cyclic: int = skeleton.find_bone("Cyclic")
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
var target: Transform3D = connector.get_aircraft()
|
||||
var target := connector.get_aircraft()
|
||||
position = target.origin
|
||||
|
||||
# Add the rotation to the bone
|
||||
var rest = skeleton.get_bone_rest(bone_cg).basis.get_rotation_quaternion()
|
||||
var attitude = target.basis.get_rotation_quaternion()
|
||||
# Add the rotation to the correct bone for rotation around CG
|
||||
var rest := skeleton.get_bone_rest(bone_cg).basis.get_rotation_quaternion()
|
||||
var attitude := target.basis.get_rotation_quaternion()
|
||||
skeleton.set_bone_pose_rotation(bone_cg, attitude * rest)
|
||||
|
||||
# Rotate other children (not using BoneAttachment3D due to jitter)
|
||||
attitude_root.rotation = target.basis.get_euler()
|
||||
|
||||
# Rotate the cyclic stick bone
|
||||
var cyclic := connector.get_cyclic()
|
||||
var cyc_rest := skeleton.get_bone_rest(bone_cyclic).basis.get_rotation_quaternion()
|
||||
var cyc_angles_rad := cyclic * deg_to_rad(range_cyclic)
|
||||
var cyc_att := Quaternion.from_euler(Vector3(cyc_angles_rad.y, cyc_angles_rad.x, 0))
|
||||
skeleton.set_bone_pose_rotation(bone_cyclic, cyc_att * cyc_rest)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue