Skip to content

Commit

Permalink
Add basis vector-object to better see Quat-interpolation issues
Browse files Browse the repository at this point in the history
Video: https://youtu.be/61QawNpJeOA
May be related to: godotengine/godot#40592

This version skips 3/4 of the lines (="keyframes") of the source (*.LOScript) files. You can change this using "readLineSkip" in LOScriptReplayer.gd.
  • Loading branch information
GNSS-Stylist committed Sep 8, 2020
1 parent 379f31f commit eb2f181
Show file tree
Hide file tree
Showing 11 changed files with 638 additions and 74 deletions.
103 changes: 103 additions & 0 deletions BasisTraces.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
extends ImmediateGeometry

# Declare member variables here. Examples:
# var a = 2
# var b = "text"

var tipXHistory = []
var tipYHistory = []
var tipZHistory = []

const tipHistoryLength = 1000

# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
var interpolatedTipX = get_node("../LOSolver_Interpolated/Basis/XAxisTip")
var interpolatedTipY = get_node("../LOSolver_Interpolated/Basis/YAxisTip")
var interpolatedTipZ = get_node("../LOSolver_Interpolated/Basis/ZAxisTip")

if (tipXHistory.size() == 0 or
interpolatedTipX.global_transform.origin != tipXHistory[tipXHistory.size()-1] or
interpolatedTipY.global_transform.origin != tipYHistory[tipYHistory.size()-1] or
interpolatedTipZ.global_transform.origin != tipZHistory[tipZHistory.size()-1]
):
tipXHistory.push_back(interpolatedTipX.global_transform.origin)
tipYHistory.push_back(interpolatedTipY.global_transform.origin)
tipZHistory.push_back(interpolatedTipZ.global_transform.origin)

while tipXHistory.size() > tipHistoryLength:
tipXHistory.pop_front()
while tipYHistory.size() > tipHistoryLength:
tipYHistory.pop_front()
while tipZHistory.size() > tipHistoryLength:
tipZHistory.pop_front()

clear()

begin(Mesh.PRIMITIVE_POINTS)
set_color(Color(0.5,0,0,1))
for coords in tipXHistory:
add_vertex(coords)
end()

begin(Mesh.PRIMITIVE_POINTS)
set_color(Color(0,0.5,0,1))
for coords in tipYHistory:
add_vertex(coords)
end()

begin(Mesh.PRIMITIVE_POINTS)
set_color(Color(0,0,0.5,1))
for coords in tipZHistory:
add_vertex(coords)
end()

var PreATipX = get_node("../LOSolver_Object_Pre_A/BasisTips/XAxisTip")
var PreATipY = get_node("../LOSolver_Object_Pre_A/BasisTips/YAxisTip")
var PreATipZ = get_node("../LOSolver_Object_Pre_A/BasisTips/ZAxisTip")

var ATipX = get_node("../LOSolver_Object_A/BasisTips/XAxisTip")
var ATipY = get_node("../LOSolver_Object_A/BasisTips/YAxisTip")
var ATipZ = get_node("../LOSolver_Object_A/BasisTips/ZAxisTip")

var BTipX = get_node("../LOSolver_Object_B/BasisTips/XAxisTip")
var BTipY = get_node("../LOSolver_Object_B/BasisTips/YAxisTip")
var BTipZ = get_node("../LOSolver_Object_B/BasisTips/ZAxisTip")

var PostBTipX = get_node("../LOSolver_Object_Post_B/BasisTips/XAxisTip")
var PostBTipY = get_node("../LOSolver_Object_Post_B/BasisTips/YAxisTip")
var PostBTipZ = get_node("../LOSolver_Object_Post_B/BasisTips/ZAxisTip")

begin(Mesh.PRIMITIVE_LINE_STRIP)
set_color(Color(0,0,0,1))
add_vertex(PreATipX.global_transform.origin)
add_vertex(ATipX.global_transform.origin)
add_vertex(BTipX.global_transform.origin)
add_vertex(PostBTipX.global_transform.origin)
end()

begin(Mesh.PRIMITIVE_LINE_STRIP)
set_color(Color(0,0,0,1))
add_vertex(PreATipY.global_transform.origin)
add_vertex(ATipY.global_transform.origin)
add_vertex(BTipY.global_transform.origin)
add_vertex(PostBTipY.global_transform.origin)
end()

begin(Mesh.PRIMITIVE_LINE_STRIP)
set_color(Color(0,0,0,1))
add_vertex(PreATipZ.global_transform.origin)
add_vertex(ATipZ.global_transform.origin)
add_vertex(BTipZ.global_transform.origin)
add_vertex(PostBTipZ.global_transform.origin)
end()

func clearHistory():
tipXHistory.clear()
tipYHistory.clear()
tipZHistory.clear()
172 changes: 172 additions & 0 deletions DebugIndicator.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
[gd_scene load_steps=21 format=2]

[sub_resource type="CylinderMesh" id=1]
top_radius = 0.05
bottom_radius = 0.05
height = 0.8
radial_segments = 8
rings = 1

[sub_resource type="SpatialMaterial" id=2]
albedo_color = Color( 1, 0, 0, 1 )

[sub_resource type="CylinderMesh" id=3]
top_radius = 0.001
bottom_radius = 0.1
height = 0.2
radial_segments = 8
rings = 1

[sub_resource type="SpatialMaterial" id=4]
albedo_color = Color( 1, 0, 0, 1 )

[sub_resource type="SpatialMaterial" id=5]
albedo_color = Color( 0, 1, 0, 1 )

[sub_resource type="CylinderMesh" id=6]
material = SubResource( 5 )
top_radius = 0.05
bottom_radius = 0.05
height = 0.8
radial_segments = 8

[sub_resource type="CylinderMesh" id=7]
top_radius = 0.001
bottom_radius = 0.1
height = 0.2
radial_segments = 8
rings = 1

[sub_resource type="SpatialMaterial" id=8]
albedo_color = Color( 0, 1, 0, 1 )

[sub_resource type="CylinderMesh" id=9]
top_radius = 0.05
bottom_radius = 0.05
height = 0.8
radial_segments = 8
rings = 1

[sub_resource type="SpatialMaterial" id=10]
albedo_color = Color( 0, 0, 1, 1 )

[sub_resource type="SpatialMaterial" id=11]
albedo_color = Color( 0, 0, 1, 1 )

[sub_resource type="CylinderMesh" id=12]
material = SubResource( 11 )
top_radius = 0.001
bottom_radius = 0.1
height = 0.2
radial_segments = 8
rings = 1

[sub_resource type="CylinderMesh" id=13]
top_radius = 0.02
bottom_radius = 0.02
height = 50.0
radial_segments = 8
rings = 1

[sub_resource type="SpatialMaterial" id=14]
albedo_color = Color( 1, 0, 0, 1 )

[sub_resource type="SpatialMaterial" id=15]
render_priority = 1
flags_transparent = true
albedo_color = Color( 1, 0, 0, 0.690196 )
uv1_scale = Vector3( 200, 200, 1 )

[sub_resource type="CubeMesh" id=16]
material = SubResource( 15 )
size = Vector3( 10, 10, 0.001 )

[sub_resource type="SpatialMaterial" id=17]
albedo_color = Color( 0, 1, 0, 1 )

[sub_resource type="CylinderMesh" id=18]
material = SubResource( 17 )
top_radius = 0.025
bottom_radius = 0.025
height = 4.0
radial_segments = 8
rings = 1

[sub_resource type="SpatialMaterial" id=19]
albedo_color = Color( 0, 0, 1, 1 )

[sub_resource type="CylinderMesh" id=20]
material = SubResource( 19 )
top_radius = 0.025
bottom_radius = 0.025
height = 4.0
radial_segments = 8
rings = 1

[node name="DebugIndicator" type="Spatial"]

[node name="DirectionalLight" type="DirectionalLight" parent="."]
visible = false
editor_only = true

[node name="XAxis" type="MeshInstance" parent="."]
transform = Transform( -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0, 1, 0.4, 0, 0 )
mesh = SubResource( 1 )
material/0 = SubResource( 2 )

[node name="XAxisTipCone" type="MeshInstance" parent="."]
transform = Transform( -1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 0, 0, 1, 0.9, 0, 0 )
mesh = SubResource( 3 )
material/0 = SubResource( 4 )

[node name="YAxis" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.4, 0 )
mesh = SubResource( 6 )
material/0 = null

[node name="YAxisTipCone" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.9, 0 )
mesh = SubResource( 7 )
material/0 = SubResource( 8 )

[node name="ZAxis" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0.4 )
mesh = SubResource( 9 )
material/0 = SubResource( 10 )

[node name="ZAxisTipCone" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0.9 )
mesh = SubResource( 12 )
material/0 = null

[node name="XAxisLong" type="MeshInstance" parent="."]
transform = Transform( -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0, 0, 1, 25, 0, 0 )
visible = false
mesh = SubResource( 13 )
material/0 = SubResource( 14 )

[node name="XYPlane" type="MeshInstance" parent="."]
visible = false
mesh = SubResource( 16 )
material/0 = null

[node name="RefAngleA" type="MeshInstance" parent="."]
transform = Transform( 0.866025, -0.5, 0, 0.5, 0.866025, 0, 0, 0, 1, -1, 1.732, 0 )
visible = false
mesh = SubResource( 18 )
material/0 = null

[node name="RefAngleB" type="MeshInstance" parent="."]
transform = Transform( -0.866026, -0.5, 0, 0.5, -0.866026, 0, 0, 0, 1, -1, -1.732, 0 )
visible = false
mesh = SubResource( 20 )
material/0 = null

[node name="XAxisTip" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0 )

[node name="YAxisTip" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0 )

[node name="ZAxisTip" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1 )
Loading

0 comments on commit eb2f181

Please sign in to comment.