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

Grids.jl: ticks label and such

Open loicspace opened this issue 7 years ago • 16 comments

Hi Simon!

I finally have some time to get back to some development for my spacecraft constellation tool and I am wanting to plot 2D technical data over time (e.g. altitude of spacecraft over time) and having it being animated side by side with the rendering of the spacecraft path around the Earth, with a time slider. And all of that is completely possible thanks to the awesome GLVizsalize.

However, I would need to have the technical data plots (2D line + 2D point) on a grid with axis ticks and ticks labels (and ideally title and/or legend). It seems that Grids.jl in the Examples folder has some of that, the ticking parts, but the ticks label is incomplete. Do you have a working version of that somewhere?

P.S. Congrats on the release of Maki-E!

loicspace avatar Nov 07 '17 18:11 loicspace

You ask at the right time! In Makie this should already work nicely, and since it's just a high level wrapper around GLVisualize, whatever you already have should work side by side with it ;) Btw, i also added textured meshes as part of Makie. I can see if I can't just tag the current, unfinished but finished enough for your use case, state of Makie, so that it's a bit easier to install!

SimonDanisch avatar Nov 07 '17 20:11 SimonDanisch

oohhhh I was going to play with Makie soon but it sounds like I should just do that right away. Not sure what the tagging involves for the install as I am quite sadly un-proficient with git, but I should figure it out. I see that there are no examples yet in Makie, my code is currently using GLVisualize syntax (glscreen, visualize, _view, renderloop), it is not immediate to me how to incorporate with Makie. I am looking at the "atomics" and that looks helpful tho. (Happy to share code if that helps)

Cheers, Loic

P.S. Does Makie also happen to have gtk support ;) ?

loicspace avatar Nov 07 '17 20:11 loicspace

I am quite sadly un-proficient with git, but I should figure it out.

Well, the Pkg commands in the readme should do the trick, if the involved repositories aren't dirty! There are some examples, and the docs also tell you quite a bit: https://gist.github.com/SimonDanisch/8f5489cffaf6b89c9a3712ba3eb12a84

For interop, just do:

using MakiE, GLVisualize
scene = Scene() # replaces: screen = glscreen();@async renderloop(screen)
screen = scene[:screen] # the normal Screen type that glscreen creates
_view(visualize(...), screen)

SimonDanisch avatar Nov 07 '17 22:11 SimonDanisch

Oh I see. The checkout for GLvisualize and GLAbstraction went thru but it broke my current code:

ERROR: LoadError: BoundsError: attempt to access (-0.12163732f0, -0.6711466f0, 0.0014587811f0)
  at index [4]
Stacktrace:
 [1] next(::GLVisualize.TransformationIterator{Array{GeometryTypes.Point{3,Float32},1},Array{GeometryTypes.Vec{3,Float32},1},Array{GeometryTypes.Point{3,Float32},1}}, ::Tuple{Int64,Int64,Int64}) at /home/loic/.julia/v0.6/GLVisualize/src/types.jl:216
 [2] GeometryTypes.HyperRectangle{3,Float32}(::GLVisualize.TransformationIterator{Array{GeometryTypes.Point{3,Float32},1},Array{GeometryTypes.Vec{3,Float32},1},Array{GeometryTypes.Point{3,Float32},1}}, ::GeometryTypes.HyperRectangle{3,Float32}) at /home/loic/.julia/v0.6/GLVisualize/src/boundingbox.jl:48
 [3] GeometryTypes.HyperRectangle{3,Float32}(::GLVisualize.Instances{GeometryTypes.HomogenousMesh{GeometryTypes.Point{3,Float32},GeometryTypes.Face{3,GeometryTypes.OffsetInteger{-1,UInt32}},GeometryTypes.Normal{3,Float32},Void,Void,Void,Void},Array{GeometryTypes.Point{3,Float32},1},Array{GeometryTypes.Vec{3,Float32},1},Array{GeometryTypes.Point{3,Float32},1}}) at /home/loic/.julia/v0.6/GLVisualize/src/boundingbox.jl:24
 [4] map(::Type{T} where T, ::Reactive.Signal{GLVisualize.Instances{GeometryTypes.HomogenousMesh{GeometryTypes.Point{3,Float32},GeometryTypes.Face{3,GeometryTypes.OffsetInteger{-1,UInt32}},GeometryTypes.Normal{3,Float32},Void,Void,Void,Void},Array{GeometryTypes.Point{3,Float32},1},Array{GeometryTypes.Vec{3,Float32},1},Array{GeometryTypes.Point{3,Float32},1}}}) at /home/loic/.julia/v0.6/Reactive/src/operators.jl:32
 [5] macro expansion at /home/loic/.julia/v0.6/GLAbstraction/src/GLUtils.jl:183 [inlined]
 [6] meshparticle(::Tuple{GeometryTypes.HomogenousMesh{GeometryTypes.Point{3,Float32},GeometryTypes.Face{3,GeometryTypes.OffsetInteger{-1,UInt32}},GeometryTypes.Normal{3,Float32},Void,Void,Void,Void},Reactive.Signal{Array{GeometryTypes.Point{3,Float32},1}}}, ::GLAbstraction.Style{:default}, ::Dict{Symbol,Any}) at /home/loic/.julia/v0.6/GLVisualize/src/visualize/particles.jl:271
 [7] _default(::Tuple{GeometryTypes.HomogenousMesh{GeometryTypes.Point{3,Float32},GeometryTypes.Face{3,GeometryTypes.OffsetInteger{-1,UInt32}},GeometryTypes.Normal{3,Float32},Void,Void,Void,Void},Reactive.Signal{Array{GeometryTypes.Point{3,Float32},1}}}, ::GLAbstraction.Style{:default}, ::Dict{Symbol,Any}) at /home/loic/.julia/v0.6/GLVisualize/src/visualize/particles.jl:188
 [8] default(::Any, ::Any, ::Any) at /home/loic/.julia/v0.6/GLVisualize/src/visualize_interface.jl:4
 [9] visualize(::Any, ::GLAbstraction.Style{:default}, ::Dict{Symbol,Any}) at /home/loic/.julia/v0.6/GLVisualize/src/visualize_interface.jl:21
 [10] (::GLVisualize.#kw##visualize)(::Array{Any,1}, ::GLVisualize.#visualize, ::Any, ::Symbol) at ./<missing>:0
 [11] #constelVis#9(::Bool, ::Bool, ::Bool, ::Function, ::GLWindow.Screen, ::Reactive.Signal{Float32}, ::LinSpace{Float32}, ::Float64, ::Plots.#frame, ::ctk.CentralBody, ::Array{ctk.Spacecraft,1}, ::Array{Any,1}, ::Array{Array,1}, ::Float64) at /home/loic/Tools/ctk/src/CTKvis.jl:89
 [12] (::ctk.#kw##constelVis)(::Array{Any,1}, ::ctk.#constelVis, ::GLWindow.Screen, ::Reactive.Signal{Float32}, ::LinSpace{Float32}, ::Float64, ::Function, ::ctk.CentralBody, ::Array{ctk.Spacecraft,1}, ::Array{Any,1}, ::Array{Array,1}, ::Float64) at ./<missing>:0
 [13] postVisualize(::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}}, ::Array{ctk.Spacecraft,1}, ::ctk.CentralBody, ::Function, ::DataFrames.DataFrame, ::DataFrames.DataFrame) at /home/loic/Tools/ctk/src/CTKvis.jl:379
 [14] stationkeeping(::Array{ctk.Spacecraft,1}, ::Array{Int64,1}, ::ctk.CentralBody, ::String, ::String, ::Int64, ::Float64, ::Float64, ::Float64, ::Float64, ::Int64, ::Int64, ::String, ::Int64, ::Int64, ::Int64, ::ctk.Settings) at /home/loic/Tools/ctk/src/ctk.jl:502
 [15] include_from_node1(::String) at ./loading.jl:569
 [16] include(::String) at ./sysimg.jl:14
while loading /home/loic/Tools/ctk/main_ctk_v2.jl, in expression starting on line 189

which happens here:

points = visualize((scMesh, pt_sc), rotation=pt_sc, scale=scale, color=col_sc)

where scMesh is a .obj loaded as scMesh = loadasset(scfile) and pt_sc is a collection of Point3f0

I reverted for now as I am working on that code, I may set up a parallel Julia install to play with Makie

loicspace avatar Nov 07 '17 23:11 loicspace

That must be an old version of GLVisualize! I'm guessing it was dirty and you didn't check out the correct branch?

SimonDanisch avatar Nov 07 '17 23:11 SimonDanisch

hmmm I don't think so:

julia> Pkg.status()
23 required packages:
 - ArrayFire                     0.1.0
 - ArrayViews                    0.6.4
 - Atom                          0.6.2
 - BlackBoxOptim                 0.3.0
 - Evolutionary                  0.1.2
 - FixedSizeArrays               0.2.5
 - GLVisualize                   0.6.1+             sd/makie
[cut] 
147 additional packages: 
 [cut]
 - FreeTypeAbstraction           0.1.0
 - GLAbstraction                 0.5.1+             sd/makie
 [cut]
 - MakiE                         0.0.0-             master (unregistered)

Am I missing something? That does frequently happen...

loicspace avatar Nov 10 '17 00:11 loicspace

Ah I'm silly, it broke YOUR code... yes - there was one breaking change... I see what I can do about it tomorrow! ;)

SimonDanisch avatar Nov 10 '17 00:11 SimonDanisch

Would it work for you to use quaternions for rotations? After fixing the bug, I realized that in the GLSL shader, I actually can't differentiate between a quaternion and a 3D vector for rotations :( I could cheat, and template the shader on the julia side, but that's always a bit ugly! I could also automatically convert any vec3 to a quaternion on my side, I guess ;)

SimonDanisch avatar Nov 13 '17 12:11 SimonDanisch

hmmm I don't see why not. I'd just have to convert from 3D vec to quaternions, as you mention at the end of your message. There must be something out there to do just that I imagine.

loicspace avatar Nov 13 '17 21:11 loicspace

Yes, I should have some piece of code flying around doing exactly that....

SimonDanisch avatar Nov 13 '17 21:11 SimonDanisch

Okay I pushed a couple of fixes to the sd/makie branch.. it's not perfect, but hopefully recovers most of the functionality. let me know if something is still not working

SimonDanisch avatar Nov 14 '17 14:11 SimonDanisch

So, that indeed fixed the error but I think there might be a math error in the conversion -- or the convention is different from before -- or, and that's very possible, I'm missing something. I just got back to running some of those sims with the code as is, in the pic below the magenta cones represent the field of view of the spacecraft camera. ctkcov_bug

It is rendered with a cone primitive using:

fov = visualize((fovMesh, inst), rotation=inst, color=col_fov)

where inst is the signal to the position of the spacecraft with respect to the center of the Earth. It is literally a copy of the signal that is used to render the spacecraft themselves. Nominally, I'd expect that rotation to align the primitives with the rotation vector (thus, the cones would be directed towards the earth, and that was the behavior before). I naively tried to flip the sign on that just in case, but that did not help. Am I missing something?

loicspace avatar Dec 13 '17 00:12 loicspace

As much as I hate to derail the conversation, @loicspace, what tools did you use to make that GUI? I'm trying to do something as GUI intensive (although in a different domain) and what you've made looks great!

CrashBurnRepeat avatar Dec 13 '17 05:12 CrashBurnRepeat

@loicspace I can reproduce this, sorry seems like I had bad tests for this...Let me fix it

SimonDanisch avatar Dec 13 '17 10:12 SimonDanisch

Should be fixed in 2740f592950c3cacf977e80d369cc6c2a4a4969d - master is now the branch to be on for Makie.

Did you figure out how to do textured meshes with GLVisualize?! :) And this is GTK right? How is it not segfaulting? :D Or is this somehow stitched together, so GLVisualize actually runs in an external window?

SimonDanisch avatar Dec 13 '17 10:12 SimonDanisch

@SimonDanisch Nice -- it is indeed fixed :)

Did you figure out how to do textured meshes with GLVisualize?! :)

Nope, I have not played with the new stuff yet. The Earth on this plot is kinda that I guess tho, just a sphere plotted as a surface with colors taken from a png.

And this is GTK right? How is it not segfaulting? :D Or is this somehow stitched together, so GLVisualize actually runs in an external window?

Yup, this is GTK, I don't know why it is not segfaulting. From the beginning, it did not and I have not yet isolated why. Between the GUI and the actual simulation module (where all the plotting routines are) it's a lot of code and I'm still trying to understand how it is different from the MWEs we're playing with. Maybe the "isolation": I have one module for the GUI, one for the actual "stuff"...So this is in fact using the gtk+glvisualize prototype.

@CrashBurnRepeat Thanks, although the credit goes to the Julia gurus. The GUI itself (left part) is built with GTK.jl and the visualization is made with GLVisualize. The integration of the two together is what Simon and I are talking about above and more in depth there #195. It is still somewhat experimental and you can find some code there as well.

loicspace avatar Dec 13 '17 18:12 loicspace