In this post I’m going to continue with GUI tutorials and show Arma 3 ability to work with objects as part of GUI. But before this I’d like to say my big thanks to Mindstorm for his donation and support!

Hey man, Thx for your awesome tutorials. You posted a video about a rotating minimap some time ago. Any chance you will be releasing to code to it soon? I’d really love to get my hands on that :) . ~ Mindstorm

Thank you, man! Personally I would rather prefer for Bohemia to add this type of map control in addition to existing map controls. As it stands my workaround requires a rather large image of the area, which is overlayed on map, which means this minimap can only cover small area. It is a little bit impractical at the moment, not to mention that I haven’t even attempted to add all bells and whistles to it (dynamic markers). But I promise when I have something ready to share I will :) .

Ok, Arma 3D controls. There are about 4 types of those, type 80-83, but I personally experimented the most with CT_OBJECT_CONTAINER (type = 82;) and found it to be quite sufficient for my needs. Also with other types the model would render white for the first time, it is like it wasn’t quite preloaded or something, and with type 82 this did not happen.

If your usual 2D controls go inside class Controls in your main Rsc class, 3D controls go inside class Objects. I’m just going to go ahead and paste the sample config I used in the following video so that I can explain what does what.

class MyDrink { idd = -1; movingEnable = 0; enableSimulation = 1; class Objects { class Can { onObjectMoved = "systemChat str _this"; idc = -1; type = 82; model = "\A3\Structures_F\Items\Food\Can_V3_F.p3d"; scale = 1; direction[] = {0, -0.35, -0.65}; up[] = {0, 0.65, -0.35}; //position[] = {0,0,0.2}; optional x = 0.5; y = 0.5; z = 0.2; //positionBack[] = {0,0,1.2}; optional xBack = 0.5; yBack = 0.5; zBack = 1.2; inBack = 1; enableZoom = 1; zoomDuration = 0.001; }; }; };

Go ahead, copy paste it in description.ext, execute createDialog “MyDrink”; then drag and double click on the can. I’ve added onObjectMoved event handler, which is used with objects to demonstrate what you can expect from it.

Any object can be dragged with your mouse by default. If you want to disable this behaviour, the only way is to disable the control all together. Disabling 3D control just makes it non-interactable. The bad news is that although Bohemia announced implementation of enable param for config so that you could simply enable = 0; the control, it doesn’t work. The good news is that you can enable/disable control with script command ctrlEnable, which you can either use later or immediately during the Rsc loading. For example to disable class Can you would need to add the following to the class MyDrink:

onLoad = "_this select 0 displayCtrl -1 ctrlEnable false";

This would disable both drag and double click behaviour. Double click behavior is also controlled by enableZoom param. If you look in the config above, you can see there is position and positionBack or x,y,z and xBack,yBack,zBack. When zoom is enabled (‘zoom’ is inappropriate name for this functionality) double click will change position of the 3D control between default and xBack position. If one of the positions have your control closer to the screen, then it would look like it is zoomed. But really it is just a toggle between 2 position presets. z param in config (z, zBack or in position array {x,y,z}) will define how far from the screen your object is, while x and y will define horizontal and vertical positioning. So if z is the same for both, there will be no ‘zoom’.

Also once you stop dragging control, it will save its new position as you could see from the video. I personally don’t like the whole implementation of it as there is no way of disabling drag but leaving the double click as it seems.

zoomDuration is like ctrlCommit for change of the position. With zoomDuration = 1; for example it will take 1 second for the control to change positions on double click, and if you also moved it before, it might follow some spastic trajectory from one position to another. This is why I set mine to 0.001 for quasi instant change. You cannot use 0 for instant change, it will just disable “zoom” feature all together. A bug? Perhaps, but I wouldn’t swear. This 3D control implementation leaves a lot to be desired.

position[] and positionBack[] is almost the same as x,y,z and xBack,yBack,zBack only centre of screen in the former is 0,0 and in the latter 0.5, 0.5. For example position[] = {0,0,1}; is the same as x=0.5; y=0.5; z=1; You can use either, but if you use both, position[] and positionBack[] will be used over x,y,z and xBack,yBack,zBack. The latter is also compatible with scripted version of 3D control positioning ctrlPosition and ctrlSetPosition. Bearing in mind y and z are usually swapped, x=0.5; y=0.5; z=1; will translate to ctrlSetPosition [0.5,1,0.5];

inBack param defines what position to use for the control initially. inBack=1; obviously means you want it to start at xxxBack position. scale will make your object bigger or smaller in relation to its original size, for this you can use ctrlModelScale and ctrlSetModelScale.

direction[] and up[] are your vectorDir and vectorUp of the model. The difference is that y and z are swapped around. So for example,  [0,0,1]  in script would translate to  {0,1,0} in config. ctrlSetModelDirAndUp command can be used to set your objects orientation, for example ctrlSetModelDirAndUp [[0,1,0],[0,0,1]]; would be the equivalent of direction[] = {0,0,1}; up[] = {0,1,0}; in config.

model is the path to the model file. You can copy model path from config for the class of the object that you wish to use. Use ctrlModel to return current model for the control, ctrlSetModel to set a new one. Additionally you can get orientation of the model with ctrlModelDirAndUp.

That’s about it. I am just going to also include earlier video when I tried to copy a composition of several objects into GUI:


EDIT: ctrlModelUp, and ctrlModelDirection are now ctrlModelDirAndUp, ctrlSetDirection is now ctrlSetModelDirAndUp. ctrlModelSide is removed. New commands are ctrlModelScale and ctrlSetModelScale.