GLVisualize.jl icon indicating copy to clipboard operation
GLVisualize.jl copied to clipboard

setting one RenderObject not visible halts animation of another

Open goretkin opened this issue 6 years ago • 5 comments

This doesn't happen if both shapes are transformed by the same signal.

glvisualize_visibility

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)

goretkin avatar Nov 29 '17 05:11 goretkin

And in one case, setting an object not visible caused another object to have its model be the identity transform, but I wasn't able to recreate that again.

goretkin avatar Nov 29 '17 05:11 goretkin

Oh that seems very wrong... I'll look into it! Btw, thanks for all these nice MWEs :)

SimonDanisch avatar Nov 29 '17 10:11 SimonDanisch

And thank you for being so responsive!

goretkin avatar Nov 29 '17 13:11 goretkin

As a stop-gap measure, is there any way to do GLVisualize animations without using the Reactive signals? By "manually" setting the transformation matrices, for example?

goretkin avatar Dec 04 '17 17:12 goretkin

How exactly do you mean that? You can always just not pass signals and use the set_arg! function, or just overwrite the value yourself... renderobject.uniforms is just a dictionary and if you add you values, they will get picked up the next time you render a frame ;)

SimonDanisch avatar Dec 04 '17 17:12 SimonDanisch