drawIcon3D: Difference between revisions

From Bohemia Interactive Community
No edit summary
No edit summary
 
(28 intermediate revisions by 3 users not shown)
Line 66: Line 66:


|r1= [[Nothing]]
|r1= [[Nothing]]


|s2= [[drawIcon3D]] icon
|s2= [[drawIcon3D]] icon
|s2since= arma3 2.22
|s2since= arma3 2.22


|p21= icon: [[HashMap]] - hashmap structure in the following format (CaSeSeNsItIvE):<br>
|p21= icon: [[HashMap]] - hashmap structure in the following '''case-sensitive''', @-prefixed format:
<u>Required Params</u>
* @position: [[Array]] - the only mandatory parameter, can be one of the following formats:
* @position - [[Array]], can be one of the following:
** [x, y, (z:0)] - [[Position#Position2D|Position2D]] or [[Position#PositionAGL|PositionAGL]]
** [x,y,(z:0)] - [[PositionAGL]]
** [object, offsetZ]
** [object, offsetZ]
** [object, selection, (offsetZ:0), (lodIndex:memory)]
*** object: [[Object]]
<u>Optional Params</u>
*** offsetZ: [[Number]] vertical offset
* @texture - [[String]] icon image
** [object, selection, offsetZ, lodIndex]
* @size - [[Number]] texture sizeH, the sizeW is automatic, based on keepAspecRatio = true
*** object: [[Object]]
* @font - [[String]] global font name. Default: system default
*** selection: [[String]] - model selection, see [[animationNames]], [[selectionNames]]
* @color - [[Array]] in [r,g,b,a] format
*** offsetZ: [[Number]] - (Optional, default 0) vertical offset
* @shadow - [[Boolean]] [[true]] to outline, [[false]] no shadow
*** lodIndex: [[Number]] - (Optional, default Memory LOD index, see [[allLODs]])
* @fade - [[Array]] in format [distMin, distMax] start and end distance of icon fade
* @texture: [[String]] - (Optional, default "") icon image
* @dynamic - [[Boolean]] [[true]] to change icon size dynamically with percieved view distance [[false]] static size Default: [[false]]
* @size: [[Number]] - (Optional) texture sizeH, the sizeW is automatic, based on original texture dimensions (To find texture width use [[getTextureInfo]])
* @drawArrows - [[Boolean]] [[true]] to draw side out of view arrows and text for static icons. Default: [[false]]
* @font: [[String]] - (Optional) global font name. Default current system font.
* @offsetX - [[Number]] x offset in screen units. >0 offset right, <0 offset left
* @color: [[Color]] - (Optional, default White) icon color
* @offsetY - [[Number]] y offset in screen units. >0 offset down, <0 offset up
* @arrowColor: [[Color]] - (Optional, default @color) arrow color
* @hardAlpha - [[Number]] 0...1 global alpha override for entire icon. Default: -1
* @shadow: [[Boolean]] - (Optional, default [[false]]) [[true]] to outline, [[false]] no shadow
* @checkVisibility - [[Boolean]] [[true]] the icon will be obstructed by objects, smoke and vegetation Default: [[false]]
* @fade: [[Array]] - (Optional, default [-1, -1]) in format [distMin, distMax] start and end distance of icon fade
* @arrowText - [[Array]] text to draw next to side arrows in format [text, (size:system), (offsetXCoef:0), (offsetYCoef:0), (color:[1,1,1,1]), (shadow:false)] offsetCoef changes spacing between arrows and text
* @dynamic: [[Boolean]] - (Optional, default [[false]]) [[true]] to change icon size dynamically with percieved view distance [[false]] static size
* @texts - [[Array]] multiple visible texts in format <nowiki>[</nowiki>[text, (size:system), (offsetX:0), (offsetY:0), (color:[1,1,1,1]), (shadow:false)],...]
* @drawArrows: [[Boolean]] - (Optional, default [[false]]) [[true]] to draw side out of view arrows and text for static icons only. Always [[false]] if @dynamic [[true]]
* @offsetX: [[Number]] - (Optional, default 0) x offset in screen units. > 0 offset right, < 0 offset left (always 0 if @drawArrows [[true]])
* @offsetY: [[Number]] - (Optional, default 0) y offset in screen units. > 0 offset down, < 0 offset up (always 0 if @drawArrows [[true]])
* @hardAlpha: [[Number]] - (Optional, default -1) 0..1 global alpha override for entire icon
* @checkVisibility: [[Boolean]] - (Optional, default [[false]]) [[true]] the icon will be obstructed by objects, smoke and vegetation
* @arrowText: [[Array]] - (Optional, default []) text to draw next to side arrows for static icons only in format [text, size, offsetXCoef, offsetYCoef, color, shadow]:
** text: [[String]] - text to show next to arrow
** size: [[Number]] - (Optional, default current system font size) text height in screen units (To find text width use [[getTextWidth]])
** offsetXCoef: [[Number]] - (Optional, default 1) X-spacing coefficient between arrows and text
** offsetYCoef: [[Number]] - (Optional, default 1) Y-spacing coefficient between arrows and text
** color: [[Color]] (Optional, default White) text color  
** shadow: [[Boolean]] (Optional, default [[false]]) [[true]] to outline, [[false]] no shadow
* @texts: [[Array]] of [[Array]]s - (Optional, default []) multiple visible texts in format <nowiki>[</nowiki>[text, size, offsetX, offsetY, color, shadow], ...]:
** text: [[String]] - text to show
** size: [[Number]] - (Optional, default current system font size) text height in screen units (To find text width use [[getTextWidth]])
** offsetX: [[Number]] - (Optional, default 0) x offset in screen units. > 0 offset right, < 0 offset left
** offsetY: [[Number]] - (Optional, default 0) y offset in screen units. > 0 offset down, < 0 offset up
** color: [[Color]] (Optional, default White) text color  
** shadow: [[Boolean]] (Optional, default [[false]]) [[true]] to outline, [[false]] no shadow
* @progress: [[Array]] - (Optional, default []) progress bar in format [width, height, offsetX, offsetY, colorFG, colorBG]:
** width: [[Number]] - width of the progress bar in screen units (width < height - vertical bar)
** height: [[Number]] - height of the progress bar in screen units (height <= width - horizontal bar)
** offsetX: [[Number]] - (Optional, default 0) x offset
** offsetY: [[Number]] - (Optional, default 0) y offset
** colorFG: [[Color]] - (Optional, default White) forground color
** colorBG: [[Color]] - (Optional, default Grey) background color
* @progressValue: [[Number]] - (Optional, default -1) progress bar progress in 0...1 range. -1 - progress bar is not drawn


|r2= [[Nothing]]
|r2= [[Nothing]]


|x1= Icon and text:
|x1= Icon and text:
<sqf>
<sqf>
addMissionEventHandler ["Draw3D", {
addMissionEventHandler ["Draw3D", {
drawIcon3D ["targetIcon.paa", [1,1,1,1], ASLToAGL getPosASLVisual cursorTarget, 1, 1, 45, "Target", 1, 0.05, "TahomaB"];
drawIcon3D ["targetIcon.paa", [1, 1, 1, 1], ASLToAGL getPosASLVisual cursorTarget, 1, 1, 45, "Target", 1, 0.05, "TahomaB"];
}];
}];
</sqf>
</sqf>
Line 107: Line 129:
<sqf>
<sqf>
addMissionEventHandler ["Draw3D", {
addMissionEventHandler ["Draw3D", {
drawIcon3D ["", [1,0,0,1], ASLToAGL getPosASLVisual cursorTarget, 0, 0, 0, "Target", 1, 0.05, "PuristaMedium"];
drawIcon3D ["", [1, 0, 0, 1], ASLToAGL getPosASLVisual cursorTarget, 0, 0, 0, "Target", 1, 0.05, "PuristaMedium"];
}];
}];
</sqf>
</sqf>
Line 118: Line 140:
[
[
"\a3\ui_f\data\IGUI\Cfg\Radar\radar_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\Radar\radar_ca.paa",
[0,0,1,1],
[0, 0, 1, 1],
iconPos,
iconPos,
5,
5,
Line 142: Line 164:
[
[
"\a3\ui_f\data\IGUI\Cfg\Radar\radar_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\Radar\radar_ca.paa",
[1,0,0,1],
[1, 0, 0, 1],
pos,
pos,
1 * _k,
1 * _k,
Line 157: Line 179:
];
];
}];
}];
</sqf>
|x5= Since {{GVI|arma3|2.22}}
<sqf>
removeAllMissionEventHandlers "Draw3D";
deleteVehicle flagA;
flagA = createVehicle ["Flag_AAF_F", position player, [], 0, "NONE"];
icon = createHashMapFromArray
[
["@position", [flagA, 5]],
["@texture", "\A3\Data_F\Flags\Flag_AAF_CO.paa"],
["@texts", [["Sector Alpha", 0.025, 0, 0.05, [1,1,0,1]]]],
["@size", 0.05],
["@drawArrows", true],
["@arrowText", ["A", 0.1, 0.3, 0.3, [1,1,0,1]]],
["@fade", [10, 100]],
["@arrowColor", [0,1,0,1]],
["@progress", [0.005, 0.05, -0.01, 0, [0.8,0.8,0,1], [0,0.6,0,0.6]]],
["@progressValue", 0.67]
];
addMissionEventHandler ["Draw3D", {drawIcon3D icon}];
</sqf>
</sqf>


Line 181: Line 224:
|user= DreadedEntity
|user= DreadedEntity
|timestamp= 20141023024200
|timestamp= 20141023024200
|text= [[drawIcon3D]] and [[BIS_fnc_addStackedEventHandler]] work well together.<br>
|text= <spoiler>[[drawIcon3D]] and [[BIS_fnc_addStackedEventHandler]] work well together.<br>
Using formatting commands with [[drawIcon3D]] will not work, instead, they will be added to the string.<br>
Using formatting commands with [[drawIcon3D]] will not work, instead, they will be added to the string.<br>
<sqf>
<sqf>
Line 207: Line 250:
}] call BIS_fnc_addStackedEventHandler;
}] call BIS_fnc_addStackedEventHandler;
</sqf>
</sqf>
'''(A3 1.32.127785)'''
'''(A3 1.32.127785)'''</spoiler>
{{Feature|obsolete}}
}}
}}


{{Note
{{Note

Latest revision as of 13:25, 1 November 2025

Hover & click on the images for description

Description

Description:
Draws an icon at the given position in the game world. This command has to be executed every frame. Use the Draw3D Mission Event Handler (which is executed every frame if the user can see the icon).
In order for the results of this command to be visible through a custom camera, enable HUD with cameraEffectEnableHUD.
showHUD false will hide the icon drawn by this command.
In order for arrows to appear, the icon texture should exist. The arrow size is proportionate to the icon size.
Groups:
Interaction

Syntax

Syntax:
drawIcon3D [texture, color, position, width, height, angle, text, shadow, textSize, font, textAlign, drawSideArrows, offsetX, offsetY]
Parameters:
texture: String - icon texture
color:
position: Array format PositionAGL - icon position
width: Number - icon width
height: Number - icon height
angle: Number - icon rotation angle
text: String - (Optional, default "") text label to display next to the icon
shadow: (Optional, default 0)
  • Number:
    • 0: no shadow
    • 1: shadow (not used in this context, used in UI context)
    • 2: outline
  • Boolean:
textSize: Number - (Optional, default size of system) text size
font: String - (Optional, default "RobotoCondensedBold") font class name from CfgFontFamilies (see FXY File Format - Available Fonts)
textAlign: String - (Optional, default "center") text alignment, can be one of:
  • "left" - aligns the end of text line with the given position (text appears to the left of the position)
  • "right" - aligns the beginning of text line with the given position (text appears to the right of the position)
  • "center" - aligns the middle of text line with the given position (text appears central to the position)
drawSideArrows: Boolean - (Optional, default false) true to draw arrows and the text label at edge of screen when the icon moves off the screen
since Arma 3 logo black.png 2.04
offsetX: Number - (Optional, default 0) X offset for the icon text
since Arma 3 logo black.png 2.04
offsetY: Number - (Optional, default 0) Y offset for the icon text
Return Value:
Nothing

Alternative Syntax

Syntax:
drawIcon3D icon
Parameters:
icon: HashMap - hashmap structure in the following case-sensitive, @-prefixed format:
  • @position: Array - the only mandatory parameter, can be one of the following formats:
  • @texture: String - (Optional, default "") icon image
  • @size: Number - (Optional) texture sizeH, the sizeW is automatic, based on original texture dimensions (To find texture width use getTextureInfo)
  • @font: String - (Optional) global font name. Default current system font.
  • @color: Color - (Optional, default White) icon color
  • @arrowColor: Color - (Optional, default @color) arrow color
  • @shadow: Boolean - (Optional, default false) true to outline, false no shadow
  • @fade: Array - (Optional, default [-1, -1]) in format [distMin, distMax] start and end distance of icon fade
  • @dynamic: Boolean - (Optional, default false) true to change icon size dynamically with percieved view distance false static size
  • @drawArrows: Boolean - (Optional, default false) true to draw side out of view arrows and text for static icons only. Always false if @dynamic true
  • @offsetX: Number - (Optional, default 0) x offset in screen units. > 0 offset right, < 0 offset left (always 0 if @drawArrows true)
  • @offsetY: Number - (Optional, default 0) y offset in screen units. > 0 offset down, < 0 offset up (always 0 if @drawArrows true)
  • @hardAlpha: Number - (Optional, default -1) 0..1 global alpha override for entire icon
  • @checkVisibility: Boolean - (Optional, default false) true the icon will be obstructed by objects, smoke and vegetation
  • @arrowText: Array - (Optional, default []) text to draw next to side arrows for static icons only in format [text, size, offsetXCoef, offsetYCoef, color, shadow]:
    • text: String - text to show next to arrow
    • size: Number - (Optional, default current system font size) text height in screen units (To find text width use getTextWidth)
    • offsetXCoef: Number - (Optional, default 1) X-spacing coefficient between arrows and text
    • offsetYCoef: Number - (Optional, default 1) Y-spacing coefficient between arrows and text
    • color: Color (Optional, default White) text color
    • shadow: Boolean (Optional, default false) true to outline, false no shadow
  • @texts: Array of Arrays - (Optional, default []) multiple visible texts in format [[text, size, offsetX, offsetY, color, shadow], ...]:
    • text: String - text to show
    • size: Number - (Optional, default current system font size) text height in screen units (To find text width use getTextWidth)
    • offsetX: Number - (Optional, default 0) x offset in screen units. > 0 offset right, < 0 offset left
    • offsetY: Number - (Optional, default 0) y offset in screen units. > 0 offset down, < 0 offset up
    • color: Color (Optional, default White) text color
    • shadow: Boolean (Optional, default false) true to outline, false no shadow
  • @progress: Array - (Optional, default []) progress bar in format [width, height, offsetX, offsetY, colorFG, colorBG]:
    • width: Number - width of the progress bar in screen units (width < height - vertical bar)
    • height: Number - height of the progress bar in screen units (height <= width - horizontal bar)
    • offsetX: Number - (Optional, default 0) x offset
    • offsetY: Number - (Optional, default 0) y offset
    • colorFG: Color - (Optional, default White) forground color
    • colorBG: Color - (Optional, default Grey) background color
  • @progressValue: Number - (Optional, default -1) progress bar progress in 0...1 range. -1 - progress bar is not drawn
Return Value:
Nothing

Examples

Example 1:
Icon and text:
addMissionEventHandler ["Draw3D", { drawIcon3D ["targetIcon.paa", [1, 1, 1, 1], ASLToAGL getPosASLVisual cursorTarget, 1, 1, 45, "Target", 1, 0.05, "TahomaB"]; }];
Example 2:
Just text:
addMissionEventHandler ["Draw3D", { drawIcon3D ["", [1, 0, 0, 1], ASLToAGL getPosASLVisual cursorTarget, 0, 0, 0, "Target", 1, 0.05, "PuristaMedium"]; }];
Example 3:
iconPos = player getPos [10, 0] vectorAdd [0,0,2]; addMissionEventHandler ["draw3D", { drawIcon3D [ "\a3\ui_f\data\IGUI\Cfg\Radar\radar_ca.paa", [0, 0, 1, 1], iconPos, 5, 5, getDirVisual player, "COMPASS", 0, 0.3, "PuristaMedium", "center", true ]; }];
Example 4:
Since Arma 3 logo black.png 2.04
pos = player getPos [10, 0] vectorAdd [0,0,2]; addMissionEventHandler ["draw3D", { _k = 10 / (player distance pos); drawIcon3D [ "\a3\ui_f\data\IGUI\Cfg\Radar\radar_ca.paa", [1, 0, 0, 1], pos, 1 * _k, 1 * _k, 0, name player, 0, 0.04 * _k, "RobotoCondensed", "right", true, 0.005 * _k, -0.035 * _k ]; }];
Example 5:
Since Arma 3 logo black.png 2.22
removeAllMissionEventHandlers "Draw3D"; deleteVehicle flagA; flagA = createVehicle ["Flag_AAF_F", position player, [], 0, "NONE"]; icon = createHashMapFromArray [ ["@position", [flagA, 5]], ["@texture", "\A3\Data_F\Flags\Flag_AAF_CO.paa"], ["@texts", [["Sector Alpha", 0.025, 0, 0.05, [1,1,0,1]]]], ["@size", 0.05], ["@drawArrows", true], ["@arrowText", ["A", 0.1, 0.3, 0.3, [1,1,0,1]]], ["@fade", [10, 100]], ["@arrowColor", [0,1,0,1]], ["@progress", [0.005, 0.05, -0.01, 0, [0.8,0.8,0,1], [0,0.6,0,0.6]]], ["@progressValue", 0.67] ]; addMissionEventHandler ["Draw3D", {drawIcon3D icon}];

Additional Information

See also:
drawLine3D getMissionPath showHUD cameraEffectEnableHUD

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Killzone_Kid - c
Posted on Aug 31, 2013 - 09:51 (UTC)
As command syntax indicates, this command expects icon position in format PositionAGL meaning that over the land it expects PositionATL and over the sea PositionASLW.
This command works well with addon textures, however getting it to display mission textures is a bit tricky. Follow this guide.
AgentRev - c
Posted on Apr 19, 2014 - 22:35 (UTC)
You should rely exclusively on modelToWorldVisual for a moving object's icon position if you want it to accurately stay at the correct height over the sea. It computes faster than ASLToAGL.
Width, height, and textSize are proportional to the user's interface size, which can optionally be compensated against via size / (getResolution select 5)
Additionally, width and height are inversely proportional to the fovLeft and fovTop parameters from the user's ArmaProfile, and AFAIK those parameters are not retrievable via scripting. For example, a fovTop higher than the default value of 0.75 will make all 3D icons smaller vertically. I'm not sure if this is a bug or by design, however it is definitely annoying to take into account.
DreadedEntity - c
Posted on Oct 23, 2014 - 02:42 (UTC)

drawIcon3D and BIS_fnc_addStackedEventHandler work well together.
Using formatting commands with drawIcon3D will not work, instead, they will be added to the string.

["uniqueID", "onEachFrame", { drawIcon3D ["myIcon.jpg", [1,1,1,0.5], getPos player, 1, 1, 0, format ["%1\n%2", "Dreaded", "Entity"]]; }] call BIS_fnc_addStackedEventHandler;

Shown text will be Dreaded\nEntity. (A3 1.32.127785)

The "text" parameter must be a string. You cannot use Structured_Text.

["uniqueID", "onEachFrame", { drawIcon3D [ "myIcon.jpg", [1,1,1,0.5], getPos player, 1, 1, 0, parseText format ["<t size='1.25' font='PuristaLight' color='#ff0000'>%1%2</t>", Dreaded, Entity] ]; }] call BIS_fnc_addStackedEventHandler;

(A3 1.32.127785)

🕖
This information is obsolete.


PierreMGI - c
Posted on Mar 22, 2016 - 20:38 (UTC)
If you want to use this command, on each frame, with plenty of objects or entities to mark, you can manage conditions in order to reduce the number of CPU operations. One of the most demanding CPU resource is probably a DrawIcon3D treatment for these objects/entities because even if not displayed (like for objects behind player), the CPU calculates the icons in the defined radius of your nearEntities / nearestObjects command. Don't stay with a simple radius condition (disk selecting entities or nearestObjects) which calculates all, then useless (not displayed), icons! Here is a way to restrict this command to your screen display: in a onEachFramed context:
unitsToDisplay = allUnits; addMissionEventHandler ["EachFrame", { private _offset = [0,0,0]; { private _screenPosition = worldToScreen (_x modelToWorldVisual _offset); if (_screenPosition isEqualTo []) then { continue }; // < your drawIcon3D treatment here > } foreach unitsToDisplay }];
Tested with +100 units, equally spread on a disk. (Note: FPS depend also on environment in map. Choose a "desert" for that).