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

mesh vs HyperRectangle transformed differently #234

Open
goretkin opened this issue Nov 28, 2017 · 1 comment
Open

mesh vs HyperRectangle transformed differently #234

goretkin opened this issue Nov 28, 2017 · 1 comment

Comments

@goretkin
Copy link

I don't understand what's going on. I'd expect the two squares to move the same way.
glvisualize_surprise

using GeometryTypes
using GLVisualize, GLAbstraction, Reactive, GLWindow, GLFW, Colors

using StaticArrays

# 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, color)
  vis = visualize(ro, model=model_matrix, color=color)
  _view(vis, window, camera = :orthographic_pixel)
  return vis
end

window = glscreen()
window.color = RGBA(0.04f0, 0.02f0, 0.05f0, 1f0)

width = 100.0

timesignal = loop(linspace(0f0,1f0,360), 60)
rotation_angle  = const_lift(*, timesignal, 2f0*pi)
tx__world__shape = Signal(eye(SMatrix{4,4,Float32}))
# copy signal
foreach(x->push!(tx__world__shape, rotationmatrix_z(x)), rotation_angle)

# change plotting order to see if it matters
ro = HyperRectangle{2,Float32}([-width/2,-width/2],[width,width])
viz1 = plot(ro, tx__world__shape, RGBA(0.0f0,0.5f0, 0.5f0, 0.7f0))
viz2 = plot(polygon_mesh([vertices(ro)[[1,2,4,3]]...]), tx__world__shape, RGBA(0.5f0,0.5f0, 0.0f0, 0.7f0))

@async renderloop(window)
@SimonDanisch
Copy link
Member

Ah viz1 is rendered as a sprite, which has the option scale_primitive, which you need to set to true. This transforms the whole billboard, with false I will only multiply the position by the model matrix.
I included this basically for text rendering, where you rather want to transform the position and not the whole rectangle... I might rewrite this code soon and plan to make those things a bit more consistent!

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