@@ -67,9 +67,9 @@ function get_systemtype(sys)
67
67
eval (meta. type)
68
68
end
69
69
70
- function get_color (sys, sol, default)
70
+ function get_color (sys, sol, default, var_name = :color )
71
71
try
72
- Makie. RGBA (sol (sol. t[1 ], idxs= collect (sys. color ))... )
72
+ Makie. RGBA (sol (sol. t[1 ], idxs= collect (getproperty ( sys, var_name) ))... )
73
73
catch
74
74
if default isa AbstractVector
75
75
Makie. RGBA (default... )
@@ -505,6 +505,38 @@ function render!(scene, ::typeof(BodyBox), sys, sol, t)
505
505
true
506
506
end
507
507
508
+ function render! (scene, :: typeof (UniversalSpherical), sys, sol, t)
509
+ sphere_diameter = Float32 (sol (sol. t[1 ], idxs= sys. sphere_diameter))
510
+ sphere_color = get_color (sys, sol, [1 , 0.2 , 1 , 0.9 ], :sphere_color )
511
+ rod_width = Float32 (sol (sol. t[1 ], idxs= sys. rod_width))
512
+ rod_height = Float32 (sol (sol. t[1 ], idxs= sys. rod_height))
513
+ rod_color = get_color (sys, sol, [0 , 0.1 , 1 , 0.9 ], :rod_color )
514
+ cylinder_length = Float32 (sol (sol. t[1 ], idxs= sys. cylinder_length))
515
+ cylinder_diameter = Float32 (sol (sol. t[1 ], idxs= sys. cylinder_diameter))
516
+ cylinder_color = get_color (sys, sol, [1 , 0.2 , 0 , 1 ], :cylinder_color )
517
+
518
+ # NOTE: the rod is not currently drawn as a box and the revolute cylinders are not drawn at all
519
+ r_0a = get_fun (sol, collect (sys. frame_a. r_0))
520
+ r_0b = get_fun (sol, collect (sys. frame_b. r_0))
521
+ thing = @lift begin
522
+ r1 = Point3f (r_0a ($ t))
523
+ r2 = Point3f (r_0b ($ t))
524
+ origin = r1
525
+ extremity = r2
526
+ Makie. GeometryBasics. Cylinder (origin, extremity, rod_width/ 2 )
527
+ end
528
+ mesh! (scene, thing; color= rod_color, specular = Vec3f (1.5 ))
529
+
530
+ # render a sphere for the sperical joint at frame_b
531
+ thing = @lift begin
532
+ r2 = Point3f (r_0b ($ t))
533
+ Sphere (r2, sphere_diameter/ 2 )
534
+ end
535
+ mesh! (scene, thing; color= sphere_color, specular = Vec3f (1.5 ))
536
+
537
+ true
538
+ end
539
+
508
540
function render! (scene, :: typeof (Damper), sys, sol, t)
509
541
r_0a = get_fun (sol, collect (sys. frame_a. r_0))
510
542
r_0b = get_fun (sol, collect (sys. frame_b. r_0))
0 commit comments