Redo main scene
Much simpler XR setup based on Bastiaan Olij's Dev stream 58 Correctly applied bone deformation in Mi-2 model
This commit is contained in:
parent
9ebb025f8a
commit
4ddccdaf62
15 changed files with 181 additions and 104 deletions
19
project/aircraft/aircraft.gd
Normal file
19
project/aircraft/aircraft.gd
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
extends Node3D
|
||||
|
||||
@onready var connector = $MarshConnector
|
||||
@onready var skeleton = $"Mi-2/Armature/Skeleton3D"
|
||||
@onready var attitude_root = $AttitudeRoot
|
||||
|
||||
@onready var bone_cg: int = skeleton.find_bone("BodyCG")
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
var target: Transform3D = 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()
|
||||
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()
|
||||
1
project/aircraft/aircraft.gd.uid
Normal file
1
project/aircraft/aircraft.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cx30pr7kn4c74
|
||||
26
project/aircraft/aircraft.tscn
Normal file
26
project/aircraft/aircraft.tscn
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://bj1s0g7ixjw71"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cx30pr7kn4c74" path="res://aircraft/aircraft.gd" id="1_l4uib"]
|
||||
[ext_resource type="PackedScene" uid="uid://cux4tju0ovvly" path="res://assets/mi2/Mi-2.glb" id="1_mrxe8"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_mrxe8"]
|
||||
|
||||
[node name="Aircraft" type="Node3D"]
|
||||
script = ExtResource("1_l4uib")
|
||||
|
||||
[node name="Mi-2" parent="." instance=ExtResource("1_mrxe8")]
|
||||
|
||||
[node name="Łopata" parent="Mi-2/Armature/Skeleton3D" index="16"]
|
||||
material_override = SubResource("StandardMaterial3D_mrxe8")
|
||||
|
||||
[node name="AttitudeRoot" type="Node3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 2.4, 0)
|
||||
|
||||
[node name="XROrigin3D" type="XROrigin3D" parent="AttitudeRoot"]
|
||||
transform = Transform3D(-1, 0, -8.74227e-08, 0, 0.999999, 0, 8.74228e-08, 0, -0.999999, 0.214, -0.721897, 1.53478)
|
||||
|
||||
[node name="XRCamera3D" type="XRCamera3D" parent="AttitudeRoot/XROrigin3D"]
|
||||
|
||||
[node name="MarshConnector" type="MarshConnector" parent="."]
|
||||
|
||||
[editable path="Mi-2"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue