tryteyker 28 Posted August 6, 2016 Hi, I've got a script ready to go that draws an objects bounding box on the map (with a marker), but it's not working quite right. A3 in general has pretty generous bounding boxes, especially with buildings, but this function expands them by quite a bit which leads to some issues. Comparison picture, with the left end of the bounding box that is drawn on map marked in red, and the actual bounding box displayed in green (boundingBoxReal) and blue (boundingBox) (http://killzonekid.com/arma-3-bounding-box-utility/): http://images.akamai.steamusercontent.com/ugc/1617175662587958314/9872DB01F114FBAB8458F44B09BA81E67F8D7EBF/ I'm using a CUP building in the above example because they generally have better bounding boxes. This is the script that draws the marker: /* * Author: Kingsley * Draws the object bounding box on the map * * Arguments: * 0: Object <OBJECT> * 1: Color <STRING> * 2: Alpha <FLOAT> * * Return Value: * None * * Example: * [this, "ColorBlack", 0.5] call ARC_fnc_drawOnMap; * * Public: Yes */ if (!isServer) exitWith {}; params [ ["_object", objNull, [objNull]], ["_color", "ColorBlack", [""]], ["_alpha", 0.75, [0.00]] ]; private _box = boundingBoxReal _object; private _pos = getPos _object; private _uname = format ["bounding_box_marker_%1", str _pos]; private _marker = createMarker [_uname, _pos]; _marker setMarkerPos _pos; _marker setMarkerBrush "Solid"; _marker setMarkerShape "RECTANGLE"; _marker setMarkerColor _color; _marker setMarkerAlpha _alpha; _marker setMarkerDir (getDir _object); _marker setMarkerSize [ (_object modelToWorldVisual (_box select 0)) distance (_object modelToWorldVisual [(_box select 1 select 0), (_box select 0 select 0), (_box select 0 select 0)]), (_object modelToWorldVisual (_box select 0)) distance (_object modelToWorldVisual [(_box select 0 select 0), (_box select 0 select 0), (_box select 1 select 2)]) ]; nil I haven't written it and to be honest I'm terrible at this whole modelToWorld stuff so I have no idea how to fix it. Share this post Link to post Share on other sites
pedeathtrian 99 Posted August 6, 2016 Rectangular marker's position is it geometrical center, while object's position is not necessarily coincide with its bounding box geometrical center. Hence the shift (probably). Anyway it would not hurt to calculate bounding box center for marker position. Replace line 28 with this: private _pos = (getPos _object) vectorAdd (((_box select 0) vectorAdd (_box select 1)) vectorMultiply 0.5); This will add correction for it if needed. You don't really need those modelToWorldVisual conversions, so replace lines 39-42 with this: _marker setMarkerSize [ abs ((_box select 0 select 0) - (_box select 1 select 0)), abs ((_box select 0 select 1) - (_box select 1 select 1)) ]; Share this post Link to post Share on other sites
killzone_kid 1326 Posted August 6, 2016 Why not use BIS_fnc_boundingBoxMarker Description: Creates marker on object with size of object's bounding box The marker could be global, in which case its name would be "boundingBoxMarker_<objectNetId>" Or local, in which case its name would be "_boundingBoxMarker_<objectNetId>" Advanced option allows to chose marker color, brush, alpha and locality as well as provides method to delete marker Parameter(s): _this: OBJECT - object for which to creare marker OR _this: ARRAY in format: 0: OBJECT - object for which to create marker 1: BOOLEAN - marker locality. true - global, false - local. Default: true 2: STRING - marker color. Default: "ColorBlack" 3: STRING - marker brush. Default: "Solid" 4: NUMBER - marker alpha. Default: 1 OR _this: ARRAY in format: 0: BOOLEAN - true: delete global marker, false: delete local marker 1: OBJECT - object for which to delete marker Returns: STRING - name of the marker or "" in delete mode Example 1: _blackGlobalMarker = car call BIS_fnc_boundingBoxMarker; // create default black global marker for car Example 2: _redLocalMarker = [car, false, "ColorRed", "SolidFull", 0.7] call BIS_fnc_boundingBoxMarker; // create/update local red marker for car Example 3: [false, car] call BIS_fnc_boundingBoxMarker; // delete local marker for car Share this post Link to post Share on other sites
tryteyker 28 Posted August 6, 2016 Well that's a really good question actually, it works properly at least. Thanks for that, didn't know it existed. Share this post Link to post Share on other sites