drawIcon3D: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\|seealso= *\[\[([^ ]+)\]\], \[\[([^ ]+)\]\]" to "|seealso= $1 $2")
m (Text replacement - "AgentRevolution" to "AgentRev")
 
(13 intermediate revisions by 4 users not shown)
Line 5: Line 5:


|gr1= Interaction
|gr1= Interaction
|eff= local


|descr= Draws an icon at the given position in the game world. This command has to be executed every frame. Use the [[Arma 3: Mission Event Handlers#Draw3D|Draw3D]] Mission Event Handler (which is executed every frame if the user can see the icon).<br>
|descr= Draws an icon at the given position in the game world. This command has to be executed every frame. Use the [[Arma 3: Mission Event Handlers#Draw3D|Draw3D]] Mission Event Handler (which is executed every frame if the user can see the icon).<br>
In order for the results of this command to be visible through a [[camCreate|custom camera]], enable HUD with [[cameraEffectEnableHUD]].<br>
In order for the results of this command to be visible through a [[camCreate|custom camera]], enable HUD with [[cameraEffectEnableHUD]].<br>
{{ic|[[showHUD]] [[false]]}} will hide the icon drawn by this command.<br>
<sqf inline>showHUD false</sqf> will hide the icon drawn by this command.<br>
In order for arrows to appear, the icon texture should exist. The arrow size is proportionate to the icon size.
In order for arrows to appear, the icon texture should exist. The arrow size is proportionate to the icon size.


{{Feature | Informative | To avoid flickering and ensure visual fidelity, always use the [[Position#Formats|visual]] (render time scope) variant of position commands, such as [[getPosASLVisual]].}}
{{Feature|informative|
 
* To avoid flickering and ensure visual fidelity, always use the [[Position#Formats|visual]] (render time scope) variant of position commands, such as [[getPosASLVisual]].
{{Feature | Informative | The ''width'' and ''height'' parameters are multipliers for {{hl|activeWidth}} and {{hl|activeHeight}} set in config. So for example, if one needs to create an icon half the screen wide ({{ic|[[safeZoneW]] / 2}}) and half the screen tall ({{ic|[[safeZoneH]] / 2}}), divide these by the config values respectfully:
* The ''width'' and ''height'' parameters are multipliers for {{hl|activeWidth}} and {{hl|activeHeight}} set in config. So for example, if one needs to create an icon half the screen wide (<sqf inline>safeZoneW / 2</sqf>) and half the screen tall (<sqf inline>safeZoneH / 2</sqf>), divide these by the according config values: <sqf>
<div><code>_iconWidth {{=}} ([[safeZoneW]] / 2) / [[getNumber]] ([[configFile]] >> "CfgInGameUI" >> "Cursor" >> "activeWidth");
private _iconWidth = (safeZoneW / 2) / getNumber (configFile >> "CfgInGameUI" >> "Cursor" >> "activeWidth");
_iconHeight {{=}} ([[safeZoneH]] / 2) / [[getNumber]] ([[configFile]] >> "CfgInGameUI" >> "Cursor" >> "activeHeight");</code></div>
private _iconHeight = (safeZoneH / 2) / getNumber (configFile >> "CfgInGameUI" >> "Cursor" >> "activeHeight");
</sqf>
}}
}}


|s1= [[drawIcon3D]] [texture, color, position, width, height, angle, text, shadow, textSize, font, textAlign, drawSideArrows, offsetX, offsetY]
|s1= [[drawIcon3D]] [texture, color, position, width, height, angle, text, shadow, textSize, font, textAlign, drawSideArrows, offsetX, offsetY]


|p1= texture: [[String]] - Icon texture
|p1= texture: [[String]] - icon texture


|p2= color:  
|p2= color:
* [[Array]] format [[Color|Color (RGBA)]] - Icon color
* [[Array]] format [[Color|Color (RGBA)]] - icon color
* {{GVI|arma3|2.04}} [[Array]] of two [[Array]]s format [[Color|Color (RGBA)]] - Icon and text color
* {{GVI|arma3|2.04|size= 0.75}} [[Array]] of two [[Array]]s format [[Color|Color (RGBA)]] - Icon and text color


|p3= position: [[Array]] format [[Position#PositionAGL|PositionAGL]] - Icon position
|p3= position: [[Array]] format [[Position#PositionAGL|PositionAGL]] - icon position


|p4= width: [[Number]] - Icon width
|p4= width: [[Number]] - icon width


|p5= height: [[Number]] - Icon height
|p5= height: [[Number]] - icon height


|p6= angle: [[Number]] - Icon rotation angle
|p6= angle: [[Number]] - icon rotation angle


|p7= text (Optional, default: ""): [[String]] - Text label to display next to the icon
|p7= text: [[String]] - (Optional, default "") text label to display next to the icon


|p8= shadow (Optional, default: 0):
|p8= shadow: (Optional, default 0)
*[[Number]] -
* [[Number]]:
** '''0:''' No shadow
** '''0:''' no shadow
** '''1:''' Shadow (not used in this context, used in UI context)
** '''1:''' shadow (not used in this context, used in UI context)
** '''2:''' Outline
** '''2:''' outline
* [[Boolean]] -
* [[Boolean]]:
** [[true]] - Outline
** [[true]] - outline
** [[false]] - No shadow
** [[false]] - no shadow


|p9= textSize (Optional, default: size of system): [[Number]] - Size of the text
|p9= textSize: [[Number]] - (Optional, default size of system) text size


|p10= font (Optional, default: "RobotoCondensed"): [[String]] - Font class name from CfgFontFamilies (see {{HashLink|FXY File Format#Available Fonts}})
|p10= font: [[String]] - (Optional, default "RobotoCondensedBold") font class name from {{hl|CfgFontFamilies}} (see {{Link|FXY File Format#Available Fonts}})


|p11= textAlign (Optional, default: "center"): [[String]] - Text alignment. Available options:
|p11= textAlign: [[String]] - (Optional, default "center") text alignment, can be one of:
* "left"
* "left"
* "center"
* "center"
* "right"
* "right"


|p12= drawSideArrows (Optional, default: [[false]]): [[Boolean]] - [[true]] to draw arrows and the text label at edge of screen when the icon moves off the screen
|p12= drawSideArrows: [[Boolean]] - (Optional, default [[false]]) [[true]] to draw arrows and the text label at edge of screen when the icon moves off the screen


|p13= offsetX (Optional, default: 0): [[Number]] - X offset for the icon text
|p13= offsetX: [[Number]] - (Optional, default 0) X offset for the icon text
|p13since= arma3 2.04
|p13since= arma3 2.04


|p14= offsetY (Optional, default: 0): [[Number]] - Y offset for the icon text
|p14= offsetY: [[Number]] - (Optional, default 0) Y offset for the icon text
|p14since= arma3 2.04
|p14since= arma3 2.04


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


|x1= Icon and text:<code>[[addMissionEventHandler]] ["Draw3D", {
|x1= Icon and text:
[[drawIcon3D]] ["targetIcon.paa", [1,1,1,1], [[ASLToAGL]] [[getPosASLVisual]] [[cursorTarget]], 1, 1, 45, "Target", 1, 0.05, "TahomaB"];
<sqf>
}];</code>
addMissionEventHandler ["Draw3D", {
drawIcon3D ["targetIcon.paa", [1,1,1,1], ASLToAGL getPosASLVisual cursorTarget, 1, 1, 45, "Target", 1, 0.05, "TahomaB"];
}];
</sqf>


|x2= Just text:
|x2= Just text:
<code>[[addMissionEventHandler]] ["Draw3D", {
<sqf>
[[drawIcon3D]] ["", [1,0,0,1], [[ASLToAGL]] [[getPosASLVisual]] [[cursorTarget]], 0, 0, 0, "Target", 1, 0.05, "PuristaMedium"];
addMissionEventHandler ["Draw3D", {
}];</code>
drawIcon3D ["", [1,0,0,1], ASLToAGL getPosASLVisual cursorTarget, 0, 0, 0, "Target", 1, 0.05, "PuristaMedium"];
}];
</sqf>


|x3= <code>iconPos = [[player]] [[getPos]] [10, 0] [[vectorAdd]] [0,0,2];
|x3= <sqf>
[[addMissionEventHandler]] ["draw3D",  
iconPos = player getPos [10, 0] vectorAdd [0,0,2];
addMissionEventHandler ["draw3D",
{
{
[[drawIcon3D]]
drawIcon3D
[
[
"\a3\ui_f\data\IGUI\Cfg\Radar\radar_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\Radar\radar_ca.paa",
Line 83: Line 92:
5,
5,
5,
5,
[[getDirVisual]] [[player]],
getDirVisual player,
"COMPASS",
"COMPASS",
0,
0,
Line 89: Line 98:
"PuristaMedium",
"PuristaMedium",
"center",
"center",
[[true]]
true
];
];
}];</code>
}];
</sqf>


|x4=Since Arma 3 v 2.03.147270<code>pos = [[player]] [[getPos]] [10, 0] [[vectorAdd]] [0,0,2];
|x4= Since {{GVI|arma3|2.04}}
[[addMissionEventHandler]] ["draw3D",  
<sqf>
pos = player getPos [10, 0] vectorAdd [0,0,2];
addMissionEventHandler ["draw3D",
{
{
_k = 10 / ([[player]] [[distance]] pos);
_k = 10 / (player distance pos);
[[drawIcon3D]]
drawIcon3D
[
[
"\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,
1 * _k,  
1 * _k,
0,  
0,
[[name]] [[player]],  
name player,
0,  
0,
0.04 * _k,  
0.04 * _k,
"RobotoCondensed",
"RobotoCondensed",
"right",  
"right",
[[true]],  
true,
0.005 * _k,
0.005 * _k,
-0.035 * _k
-0.035 * _k
];
];
}];</code>
}];
</sqf>


|seealso= [[drawLine3D]] [[getMissionPath]] [[showHUD]], [[cameraEffectEnableHUD]]
|seealso= [[drawLine3D]] [[getMissionPath]] [[showHUD]] [[cameraEffectEnableHUD]]
}}
}}


<dl class="command_description">
{{Note
|user= Killzone_Kid
|timestamp= 20130831095100
|text= As command syntax indicates, this command expects icon position in format [[Position#PositionAGL|PositionAGL]] meaning that over the land it expects [[Position#PositionATL|PositionATL]] and over the sea [[Position#PositionASLW|PositionASLW]].<br>
This command works well with addon textures, however getting it to display mission textures is a bit tricky. Follow {{Link|http://killzonekid.com/arma-scripting-tutorials-mission-root/|this guide}}.
}}


<dt></dt>
{{Note
<dd class="notedate">Posted on August 31, 2013</dd>
|user= AgentRev
<dt class="note">[[User:Killzone_Kid|Killzone_Kid]]</dt>
|timestamp= 20140419223500
<dd class="note">As command syntax indicates, this command expects icon position in format [[Position#PositionAGL|PositionAGL]] meaning that over the land it expects [[Position#PositionATL|PositionATL]] and over the sea [[Position#PositionASLW|PositionASLW]].<br>
|text= 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]].<br>
This command works well with addon textures, however getting it to display mission textures is a bit tricky. Follow [http://killzonekid.com/arma-scripting-tutorials-mission-root/ this guide].
</dd>
 
<dt></dt>
<dd class="notedate">Posted on April 19, 2014</dd>
<dt class="note">[[User:AgentRevolution|AgentRev]]</dt>
<dd class="note">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]].<br>
Width, height, and textSize are proportional to the user's interface size, which can optionally be compensated against via {{hl|size / ([[getResolution]] select 5)}}<br>
Width, height, and textSize are proportional to the user's interface size, which can optionally be compensated against via {{hl|size / ([[getResolution]] select 5)}}<br>
Additionally, width and height are inversely proportional to the {{hl|fovLeft}} and {{hl|fovTop}} parameters from the user's [[Profile|ArmaProfile]], and AFAIK those parameters are not retrievable via scripting.
Additionally, width and height are inversely proportional to the {{hl|fovLeft}} and {{hl|fovTop}} parameters from the user's [[Profile|ArmaProfile]], and AFAIK those parameters are not retrievable via scripting.
For example, a {{hl|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.
For example, a {{hl|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.
</dd>
}}


<dt></dt>
{{Note
<dd class="notedate">Posted on October 23, 2014 - 02:42 (UTC)</dd>
|user= DreadedEntity
<dt class="note">[[User:DreadedEntity|DreadedEntity]]</dt>
|timestamp= 20141023024200
<dd class="note">
|text= [[drawIcon3D]] and [[BIS_fnc_addStackedEventHandler]] work well together.<br>
[[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>
<code>["uniqueID", "onEachFrame",  
<sqf>
["uniqueID", "onEachFrame",
{
{
[[drawIcon3D]] ["myIcon.jpg", [1,1,1,0.5], [[getPos]] [[player]], 1, 1, 0, [[format]] ["%1\n%2", "Dreaded", "Entity"]];
drawIcon3D ["myIcon.jpg", [1,1,1,0.5], getPos player, 1, 1, 0, format ["%1\n%2", "Dreaded", "Entity"]];
}] [[call]] [[BIS_fnc_addStackedEventHandler]];</code>
}] call BIS_fnc_addStackedEventHandler;
</sqf>
Shown text will be '''Dreaded\nEntity'''. '''(A3 1.32.127785)'''<br><br>
Shown text will be '''Dreaded\nEntity'''. '''(A3 1.32.127785)'''<br><br>


The "text" parameter must be a string. You cannot use [[Structured_Text]].<br>
The "text" parameter must be a string. You cannot use [[Structured_Text]].<br>
<code>["uniqueID", "onEachFrame",  
<sqf>
["uniqueID", "onEachFrame",
{
{
[[drawIcon3D]]
drawIcon3D
[
[
"myIcon.jpg",
"myIcon.jpg",
[1,1,1,0.5],
[1,1,1,0.5],
[[getPos]] [[player]],
getPos player,
1,
1,
1,
1,
0,
0,
[[parseText]] [[format]] ["<t size='1.25' font='PuristaLight' color='#ff0000'>%1%2</t>", Dreaded, Entity]
parseText format ["<t size='1.25' font='PuristaLight' color='#ff0000'>%1%2</t>", Dreaded, Entity]
];
];
}] [[call]] [[BIS_fnc_addStackedEventHandler]];</code>
}] call BIS_fnc_addStackedEventHandler;
</sqf>
'''(A3 1.32.127785)'''
'''(A3 1.32.127785)'''
</dd>
}}
 
<dt></dt>
<dd class="notedate">Posted on November 13 (2014)</dd>
<dt class="note">[[User:Iceman77|Iceman77]]</dt>
<dd class="note">
Here's a practical example combining both drawLine3D and drawIcon3D. Note: You may want to use visiblePosition instead of getPos for moving objects.
<code>DEADPILOTS = [];
{
[[if]] (getText ([[configFile]] >> "CfgVehicles" >> typeOf _x >> "textSingular") == "pilot") [[then]]
{
DEADPILOTS [[pushBack]] _x;
};
} [[forEach]] [[allDeadMen]];
 
[[addMissionEventHandler]] ["Draw3D", {
[[if]] (
{
[[player]] [[distance]] _x <= 15
} [[count]] DEADPILOTS > 0
) [[then]] {
{
_corpsePos = [[getPos]] _x;
[[if]] ([[player]] [[distance]] _corpsePos <= 15) [[then]]
{
_line1_start = _corpsePos;
_line1_end = [(_line1_start [[select]] 0), (_line1_start [[select]] 1), 0.5];
_line2_start = [(_line1_end [[select]] 0), (_line1_end [[select]] 1) + 0.5, (_line1_end [[select]] 2)];
[[drawLine3D]] [_line1_start, _line1_end, [0,0,0,0.5]];
[[drawLine3D]] [_line1_end, _line2_start, [0,0,0,0.5]];
[[drawIcon3D]] ["\a3\ui_f\data\gui\cfg\hints\BasicLook_ca.paa", [0,0,0,0.5], _line2_start, 0.75, 0.75, 0];
};
} [[forEach]] DEADPILOTS;
};
}];
</code>
</dd>
 
<dt><dt>
<dd class="notedate">Posted on February 11, 2016 - 07:37 (UTC)</dd>
<dt class="note">[[User:Ranwer|Ranwer]]</dt>
<dd class="note">You can also use [[getPosWorld]] (for X and Y only, but not Z), which works splendid in script performance. Here is an example:<br>
<code>addMissionEventHandler ["Draw3D", {
[[private]] _pos = [[getPosWorld]] [[player]];
[[drawIcon3D]] [
"a3\ui_f\data\gui\Rsc\RscDisplayArsenal\radio_ca.paa",
[1,1,1,1],
[_pos [[select]] 0, _pos [[select]] 1, 1],
0.8,
0.8,
0,
[[name]] [[player]],
1,
0.0315,
"EtelkaMonospacePro"
];
}];</code>
</dd>


<dt><dt>
{{Note
<dd class="notedate">Posted on 22 March 22, 2016 - 20:42 (CEST)</dd>
|user= PierreMGI
<dt class="note">[[User:pierremgi|PierreMGI]]</dt>
|timestamp= 20160322203800
<dd class="note">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.
|text= 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.
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!
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:  
Here is a way to restrict this command to your screen display:
in a onEachFramed context:
in a onEachFramed context:
<code>{{cc|{{arma3}}}}
<sqf>
unitsToDisplay = [[allUnits]];
unitsToDisplay = allUnits;
[[addMissionEventHandler]] ["EachFrame", {
addMissionEventHandler ["EachFrame", {
[[private]] _offset = [0,0,0];
private _offset = [0,0,0];
{
{
[[private]] _screenPosition = [[worldToScreen]] ([[_x]] [[modelToWorldVisual]] _offset);
private _screenPosition = worldToScreen (_x modelToWorldVisual _offset);
[[if]] (_screenPosition [[isEqualTo]] []) [[exitWith]] {};
if (_screenPosition isEqualTo []) then { continue };
{{cc|&lt; your drawIcon3D treatment here &gt;}}
// < your drawIcon3D treatment here >
} [[foreach]] unitsToDisplay
} foreach unitsToDisplay
}];
}];
</code>
</sqf>
Tested with +100 units, equally spread on a disk. (Note: FPS depend also on environment in map. Choose a "desert" for that).
Tested with +100 units, equally spread on a disk. (Note: FPS depend also on environment in map. Choose a "desert" for that).
</dd>
}}
 
</dl>

Latest revision as of 23:07, 4 May 2024

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"
  • "center"
  • "right"
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.png2.04
offsetX: Number - (Optional, default 0) X offset for the icon text
since Arma 3 logo black.png2.04
offsetY: Number - (Optional, default 0) Y offset for the icon text
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.png2.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 ]; }];

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)
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).