Skip to content
This repository has been archived by the owner on Apr 28, 2021. It is now read-only.

setting one RenderObject not visible halts animation of another #235

Open
goretkin opened this issue Nov 29, 2017 · 5 comments
Open

setting one RenderObject not visible halts animation of another #235

goretkin opened this issue Nov 29, 2017 · 5 comments

Comments

@goretkin
Copy link

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
Copy link
Author

goretkin commented Nov 29, 2017

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.

@SimonDanisch
Copy link
Member

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

@goretkin
Copy link
Author

And thank you for being so responsive!

@goretkin
Copy link
Author

goretkin commented Dec 4, 2017

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?

@SimonDanisch
Copy link
Member

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 ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants