Skip to content

Commit

Permalink
better handling of transparency
Browse files Browse the repository at this point in the history
  • Loading branch information
baggepinnen committed Oct 30, 2024
1 parent 8e3f8c1 commit 091d9a6
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions ext/Render.jl
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ function render!(scene, ::typeof(FixedTranslation), sys, sol, t)
radius = Float32(sol($t, idxs=sys.radius))
Makie.GeometryBasics.Cylinder(origin, extremity, radius)
end
mesh!(scene, thing; color, specular = Vec3f(1.5), shininess=20f0, diffuse=Vec3f(1), transparency=true)
mesh!(scene, thing; color, specular = Vec3f(1.5), shininess=20f0, diffuse=Vec3f(1), transparency=color.alpha != 1)
true
end

Expand All @@ -630,7 +630,7 @@ function render!(scene, ::typeof(BodyShape), sys, sol, t)
extremity = r2
Makie.GeometryBasics.Cylinder(origin, extremity, radius)
end
mesh!(scene, thing; color, specular = Vec3f(1.5), transparency=true)
mesh!(scene, thing; color, specular = Vec3f(1.5), transparency=color.alpha != 1)
elseif shape == "box"
Rfun = get_rot_fun(sol, sys.frame_a)

Expand All @@ -652,7 +652,7 @@ function render!(scene, ::typeof(BodyShape), sys, sol, t)
origin = Vec3f(0, -width/2, -height/2)
extent = Vec3f(length, width, height)
thing = Makie.Rect3f(origin, extent)
m = mesh!(scene, thing; color, specular = Vec3f(1.5), transparency=true)
m = mesh!(scene, thing; color, specular = Vec3f(1.5), transparency=color.alpha != 1)
on(t) do t
r1 = Point3f(r_0a(t))
R = Rfun(t)
Expand Down Expand Up @@ -690,7 +690,7 @@ function render!(scene, ::typeof(BodyShape), sys, sol, t)
# Makie.GeometryBasics.Sphere((r1+r2) ./ 2, 0.1f0)
# end
# mesh!(scene, thing, color=:purple)
true
false
end


Expand Down Expand Up @@ -965,7 +965,7 @@ function render!(scene, ::typeof(P.Body), sys, sol, t)
point = Point3f(coords..., 0)
Sphere(point, Float32(radius))
end
mesh!(scene, thing; color, specular = Vec3f(1.5), shininess=20f0, diffuse=Vec3f(1))
mesh!(scene, thing; color, specular = Vec3f(1.5), shininess=20f0, diffuse=Vec3f(1), transparency=color.alpha != 1)
false
end

Expand All @@ -983,7 +983,7 @@ function render!(scene, ::Union{typeof(P.FixedTranslation), typeof(P.BodyShape)}
radius = Float32(sol($t, idxs=sys.radius))
Makie.GeometryBasics.Cylinder(origin, extremity, radius)
end
mesh!(scene, thing; color, specular = Vec3f(1.5), shininess=20f0, diffuse=Vec3f(1))
mesh!(scene, thing; color, specular = Vec3f(1.5), shininess=20f0, diffuse=Vec3f(1), transparency=color.alpha != 1)
true
end

Expand All @@ -1000,7 +1000,7 @@ function render!(scene, ::typeof(P.Prismatic), sys, sol, t)
radius = Float32(sol($t, idxs=sys.radius))
Makie.GeometryBasics.Cylinder(origin, extremity, radius)
end
mesh!(scene, thing; color, specular = Vec3f(1.5), shininess=20f0, diffuse=Vec3f(1))
mesh!(scene, thing; color, specular = Vec3f(1.5), shininess=20f0, diffuse=Vec3f(1), transparency=color.alpha != 1)
true
end

Expand Down Expand Up @@ -1029,7 +1029,7 @@ function render!(scene, ::typeof(P.Revolute), sys, sol, t)
p2 = Point3f(O - length*n_w)
Makie.GeometryBasics.Cylinder(p1, p2, radius)
end
mesh!(scene, thing; color, specular = Vec3f(1.5), shininess=20f0, diffuse=Vec3f(1))
mesh!(scene, thing; color, specular = Vec3f(1.5), shininess=20f0, diffuse=Vec3f(1), transparency=color.alpha != 1)
true
end

Expand Down Expand Up @@ -1083,7 +1083,7 @@ function render!(scene, ::Union{typeof(P.SimpleWheel), typeof(P.SlipBasedWheelJo
p2 = Point3f(O - width*n_w)
Makie.GeometryBasics.Cylinder(p1, p2, radius)
end
mesh!(scene, thing; color, specular = Vec3f(1.5), shininess=20f0, diffuse=Vec3f(1))
mesh!(scene, thing; color, specular = Vec3f(1.5), shininess=20f0, diffuse=Vec3f(1), transparency=color.alpha != 1)
true
end

Expand Down Expand Up @@ -1126,7 +1126,7 @@ function render!(scene, ::typeof(Multibody.BoxVisualizer), sys, sol, t)
origin = Vec3f(-length/2, -width/2, -height/2) + r_shape
extent = Vec3f(length, width, height)
thing = Makie.Rect3f(origin, extent)
m = mesh!(scene, thing; color, specular = Vec3f(1.5))
m = mesh!(scene, thing; color, specular = Vec3f(1.5), transparency=color.alpha != 1)
on(t) do t
r1 = Point3f(r_0a(t))
R = Rfun(t)
Expand All @@ -1149,7 +1149,7 @@ function render!(scene, ::typeof(Multibody.SphereVisualizer), sys, sol, t)
point = Point3f(coords)
Sphere(point, Float32(radius))
end
mesh!(scene, thing; color, specular = Vec3f(1.5), shininess=20f0, diffuse=Vec3f(1))
mesh!(scene, thing; color, specular = Vec3f(1.5), shininess=20f0, diffuse=Vec3f(1), transparency=color.alpha != 1)
end

function render!(scene, ::typeof(Multibody.CylinderVisualizer), sys, sol, t)
Expand All @@ -1174,7 +1174,7 @@ function render!(scene, ::typeof(Multibody.CylinderVisualizer), sys, sol, t)
origin = r1
extremity = r2
thing = Makie.GeometryBasics.Cylinder(origin, extremity, radius)
m = mesh!(scene, thing; color, specular = Vec3f(1.5), shininess=20f0, diffuse=Vec3f(1), transparency=true)
m = mesh!(scene, thing; color, specular = Vec3f(1.5), shininess=20f0, diffuse=Vec3f(1), transparency=color.alpha != 1)


on(t) do t
Expand Down

0 comments on commit 091d9a6

Please sign in to comment.