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

mesh vs HyperRectangle transformed differently #234

@goretkin

Description

@goretkin

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions