Ability to 'lock' the world to the display (disable zoom / drag)

71 views
Skip to first unread message

Auke van Leeuwen

unread,
Jul 21, 2023, 7:24:42 AM7/21/23
to GAMA
Hello,

I'm rather new to Gama / GAML, but I've developed a plugin to be able to deal with events coming in via TUIO. One of the things to tackle is the fact that the coordinate system of the TUIO events is different than the 'coordinate' system of the Gama world/simulation. from the TUIO events I'm getting basically a coordinate system of (0,0) → (1,1) relative to the display.  If I want to map to that to the Gama 'world' (bear with me with the glossary, this is all kind of new to me). I have (at least) two challenges:

  1. I want the world to be full screen (✅), but also the aspect ratio (of the world) should match the display's aspect ratio. I've hardcoded it now, but was wondering if I can actually retrieve that somehow?
    1. If not possible in GAML, I can maybe retrieve it in the plugin as well. If you have some pointers for that: would be great.
  2. If I put something on the TUIO table, even the slightest drag of somebodies fingers are moving or zooming the world, this breaks the entire coordinate mapping obviously. 
    1. Can I either: disable this behaviour (preferred)
    2. Do I have some other information available of where the 'world' is relative to the 'display'?

(2) is of bigger importance than (1) btw: I can live with the hard-coding.

Kind regards,

Auke


lesquoy....@gmail.com

unread,
Jul 31, 2023, 4:11:41 AM7/31/23
to GAMA
Hello Auke,

For the first point, I don't think it's possible directly in gaml, but in java it's fairly easy to get a display's dimensions (and thus the ratio) so you can code your own gaml operators in your plugin to be able to get those dimensions in gaml. 
Here is the documentation about how to create gaml operators: https://gama-platform.org/wiki/DevelopingOperators
And here some pointers about how to get a display's dimensions in java: https://stackoverflow.com/questions/3680221/how-can-i-get-screen-resolution-in-java

Regarding the second point, I'm not really sure you can do anything in a gaml plugin about it. If you want to disable the event of the table then you will have to check how to do it on the table/with the table API. However, and maybe that's what you are looking for, it is possible to lock a gama display, which means that it is not possible anymore to move around the world, zoom etc.. To do so, you can click on the small lock in the toolbar on top of your display:
lock.png
Another solution in code in your gaml model by defining a camera for your display and setting its "locked" facet to true.
Here is the documentation of the camera statement: https://gama-platform.org/wiki/Statements#camera

Regards,

Baptiste

Auke van Leeuwen

unread,
Jul 31, 2023, 6:56:55 AM7/31/23
to GAMA
Thanks for you answer.

I can't believe I missed that - quite obvious - lock symbol. Still a question about the programmatic behaviour of that though:

I can only define a camera for an OpenGL view. My main purpose will probably be a 2d view usually. I don't seem to be able to construct a camera for a 2d model (perhaps logical, as panning isn't really a thing at least). That also doesn't seem to allow me to lock the 2d view programmatically. Is that correct?

Also: I'm trying the following in 3d to mimic 2d essentially, but it doesn't seem to lock anything?

experiment TUIOtest type: gui autorun: true {
float minimum_cycle_duration <- 0.5 #second;
output {

display view type: 3d background: #yellow axes: false fullscreen: true {
camera 'my_camera' location: #from_above locked: true;
species Square aspect:base position: {0,0} size: {1, 1};
// species Tag aspect:base position: {0,0} size: {1, 1};
}
}
}

About the resolutions: thanks for the pointers. I need to look into how that works with multiple monitors and the mapping on views/displays I guess, but these are problems for later.

--
Auke

lesquoy....@gmail.com

unread,
Jul 31, 2023, 10:47:47 PM7/31/23
to GAMA
You are right, it is unfortunately not possible to lock a 2d display programmatically yet. The issue has been raised already (see here) but it's currently planned for the next major release (gama 2) which for sure won't happen this year.

For the camera problem, I think it is just because it's not set as the default camera. You can check that with the toolbar again by clicking on the downward facing arrow next to the camera:
Screenshot 2023-08-01 094151.png
Normally the one by default is called "default", unless you used the "camera" facet of your display.
To fix this you can just change the name of your camera to "default".

Baptiste
Reply all
Reply to author
Forward
0 new messages