This doesn't happen if both shapes are transformed by the same signal.
using GeometryTypes
using GLVisualize, GLAbstraction, Reactive, GLWindow, GLFW, Colors
using StaticArrays
width = 100.0
# vertices need to be GeometryTypes.Vec{2,T}}
function polygon_mesh(vertices, z=0)
# mesh with fixed z
fs = polygon2faces(map(Point, vertices))
vs = map(x->Point{3}(x[1],x[2],z), vertices)
return GLNormalMesh(vertices=vs, faces=fs)
end
function plot(ro, model_matrix=eye(SMatrix{4,4}), color=RGBA(1.0, 1.0, 1.0, 1.0))
vis = visualize(ro, model=model_matrix, color=color)
_view(vis, window, camera = :orthographic_pixel)
return vis
end
cone_points = [Vec(0.0, 0.0), Vec(3*width, 2*width), Vec(3*width, -2*width)]
box_points = width/2 * [[-1, -1], [-1, 1], [1, 1], [1, -1]]
box_points = [Vec(p...) for p in box_points]
window = glscreen()
window.color = RGBA(0.04f0, 0.02f0, 0.05f0, 1f0)
timesignal = loop(linspace(0f0,1f0,360), 60)
rotation_angle = const_lift(*, timesignal, 2f0*pi)
txgl__world__box = Signal(eye(SMatrix{4,4,Float32})) # tx__world__robot
foreach(x->push!(txgl__world__box, rotationmatrix_z(x)), rotation_angle)
txgl__box__cone = Signal(translationmatrix(Vec(width/3, 0, 0)))
txgl__world__cone = map(*, txgl__world__box, txgl__box__cone)
box_viz = plot(polygon_mesh(box_points), txgl__world__box, RGBA(0.0f0,0.5f0, 0.5f0, 0.7f0))
cone_viz = plot(polygon_mesh(cone_points), txgl__world__cone, RGBA(0.7f0, 0.7f0, 0.0f0, 0.3f0))
@async renderloop(window)