drawIcon3D: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "</dd> </dl>" to "</dd> </dl>") |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
Line 7: | Line 7: | ||
|descr= Draws an ingame icon at a given position. Command has to be executed each frame. Use [[addMissionEventHandler]] "Draw3D" which is executed each frame and if user can see the drawing. In order for the results of this command to be visible through a [[camCreate | custom camera]], enable HUD with [[cameraEffectEnableHUD]]. [[showHUD]] [[false]] will hide icon drawing. In order for arrows to appear, the icon texture should exist. The arrows size is proportionate to icon size. | |descr= Draws an ingame icon at a given position. Command has to be executed each frame. Use [[addMissionEventHandler]] "Draw3D" which is executed each frame and if user can see the drawing. In order for the results of this command to be visible through a [[camCreate | custom camera]], enable HUD with [[cameraEffectEnableHUD]]. [[showHUD]] [[false]] will hide icon drawing. In order for arrows to appear, the icon texture should exist. The arrows size is proportionate to icon size. | ||
{{Feature | Informative | The values passed for the icon width and height are multipliers for "activeWidth" and "activeHeight" set in config. So for example, if one needs to create an icon half screen wide ([[safeZoneW]] / 2) and half screen tall ([[safeZoneH]] / 2), divide these by config values respectfully: | {{Feature | Informative | | ||
* The visibility of the icon could be affected when some of the HUD properties are hidden. For more information see [[showHUD]] page. | |||
* The values passed for the icon width and height are multipliers for "activeWidth" and "activeHeight" set in config. So for example, if one needs to create an icon half screen wide ([[safeZoneW]] / 2) and half screen tall ([[safeZoneH]] / 2), divide these by config values respectfully: | |||
<code>_iconWidth {{=}} ([[safeZoneW]] / 2) / [[getNumber]] ([[configFile]] >> "CfgInGameUI" >> "Cursor" >> "activeWidth");</code> | <code>_iconWidth {{=}} ([[safeZoneW]] / 2) / [[getNumber]] ([[configFile]] >> "CfgInGameUI" >> "Cursor" >> "activeWidth");</code> | ||
<code>_iconHeight {{=}} ([[safeZoneH]] / 2) / [[getNumber]] ([[configFile]] >> "CfgInGameUI" >> "Cursor" >> "activeHeight");</code | <code>_iconHeight {{=}} ([[safeZoneH]] / 2) / [[getNumber]] ([[configFile]] >> "CfgInGameUI" >> "Cursor" >> "activeHeight");</code> | ||
}} | |||
| | |s1= [[drawIcon3D]] [texture, color, position, width, height, angle, text, shadow, textSize, font, textAlign, drawSideArrows, offsetX, offsetY] | ||
| | |p1= texture: [[String]] - icon image | ||
| | |p2= color: | ||
* [[Array]] in format [[Color|Color (RGBA)]] - icon color | |||
* [[Array]] of [[Array]]s in format [[Color|Color (RGBA)]]: icon and text color {{Since|arma3|2.04|y}} | |||
| | |p3= position: [[Array]] - icon world position in [[PositionAGL]] format | ||
| | |p4= width: [[Number]] - icon width (see description note) | ||
| | |p5= height: [[Number]] - icon height (see description note) | ||
| | |p6= angle: [[Number]] - icon rotation angle | ||
| | |p7= text (Optional, default: ""): [[String]] - text label to display next to icon. | ||
| | |p8= shadow (Optional, default: 0): [[Number]] or [[Boolean]] | ||
* 0 = none | * 0 = none | ||
* 1 = shadow (not used in this context, used in UI context) | * 1 = shadow (not used in this context, used in UI context) | ||
Line 39: | Line 39: | ||
* [[false]] - none. | * [[false]] - none. | ||
| | |p9= textSize (Optional, default: size of system): [[Number]] - the size of the text | ||
| | |p10= font (Optional, default: "RobotoCondensed"): [[String]] - font class name from CfgFontFamilies | ||
| | |p11= textAlign (Optional, default: "center"): [[String]] - can be one of: | ||
* "left" | |||
* "center" | |||
* "right" | |||
| | |p12= drawSideArrows (Optional, default: [[false]]): [[Boolean]] - [[true]] to draw arrows and the text label at edge of screen when icon moves off screen | ||
| | |p13= {{GVI|arma3|2.04}} offsetX: [[Number]] - (Optional, default: 0) x offset for the icon text | ||
| | |p14= {{GVI|arma3|2.04}} offsetY: [[Number]] - (Optional, default: 0) y offset for the icon text | ||
|r1= [[Nothing]] | |r1= [[Nothing]] | ||
Line 62: | Line 65: | ||
}];</code> | }];</code> | ||
|x3=<code>iconPos = [[player]] [[getPos]] [10, 0] [[vectorAdd]] [0,0,2]; | |x3= <code>iconPos = [[player]] [[getPos]] [10, 0] [[vectorAdd]] [0,0,2]; | ||
[[addMissionEventHandler]] ["draw3D", | [[addMissionEventHandler]] ["draw3D", | ||
{ | { | ||
Line 89: | Line 92: | ||
[ | [ | ||
"\a3\ui_f\data\IGUI\Cfg\Radar\radar_ca.paa", | "\a3\ui_f\data\IGUI\Cfg\Radar\radar_ca.paa", | ||
[1,0,0,1], | |||
pos, | |||
1 * _k, | |||
1 * _k, | 1 * _k, | ||
0, | |||
[[name]] [[player]], | |||
0, | |||
0.04 * _k, | |||
"RobotoCondensed", | |||
"right", | "right", | ||
[[true]], | [[true]], | ||
Line 113: | Line 116: | ||
<dd class="notedate">Posted on August 31, 2013</dd> | <dd class="notedate">Posted on August 31, 2013</dd> | ||
<dt class="note">[[User:Killzone_Kid|Killzone_Kid]]</dt> | <dt class="note">[[User:Killzone_Kid|Killzone_Kid]]</dt> | ||
<dd class="note">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]]. <br> | <dd class="note">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]].<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]. | 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> | </dd> | ||
<dt></dt> | <dt></dt> | ||
<dd class="notedate">Posted on April 19, 2014</dd> | <dd class="notedate">Posted on April 19, 2014</dd> | ||
<dt class="note">[[User:AgentRevolution|AgentRev]]</dt> | <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]]. | <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 <tt>size / ([[getResolution]] select 5)</tt><br> | |||
Width, height, and textSize are proportional to the user's interface size, which can optionally be compensated against via <tt>size / ([[getResolution]] select 5)</tt><br> | Additionally, width and height are inversely proportional to the <tt>fovLeft</tt> and <tt>fovTop</tt> parameters from the user's [[Profile|ArmaProfile]], and AFAIK those parameters are not retrievable via scripting. | ||
For example, a <tt>fovTop</tt> 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. | |||
Additionally, width and height are inversely proportional to the <tt>fovLeft</tt> and <tt>fovTop</tt> parameters from the user's [[Profile|ArmaProfile]], and AFAIK those parameters are not retrievable via scripting. For example, a <tt>fovTop</tt> 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> | </dd> | ||
Line 131: | Line 133: | ||
<dt class="note">[[User:DreadedEntity|DreadedEntity]]</dt> | <dt class="note">[[User:DreadedEntity|DreadedEntity]]</dt> | ||
<dd class="note"> | <dd class="note"> | ||
[[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", | <code>["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]];</code> | ||
Shown text will be '''Dreaded\nEntity'''. '''(A3 1.32.127785)'''<br><br> | Shown text will be '''Dreaded\nEntity'''. '''(A3 1.32.127785)'''<br><br> | ||
Line 143: | Line 144: | ||
<code>["uniqueID", "onEachFrame", | <code>["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]];</code> | ||
'''(A3 1.32.127785)''' | '''(A3 1.32.127785)''' | ||
</dd> | </dd> | ||
Line 160: | Line 161: | ||
<dt class="note">[[User:Iceman77|Iceman77]]</dt> | <dt class="note">[[User:Iceman77|Iceman77]]</dt> | ||
<dd class="note"> | <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. | 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 = []; | <code>DEADPILOTS = []; | ||
{ | { | ||
[[if]] (getText ([[configFile]] >> "CfgVehicles" >> typeOf _x >> "textSingular") == "pilot") [[then]] | |||
{ | |||
DEADPILOTS [[pushBack]] _x; | |||
} forEach allDeadMen; | }; | ||
} [[forEach]] [[allDeadMen]]; | |||
addMissionEventHandler ["Draw3D", { | [[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> | </code> | ||
Line 194: | Line 197: | ||
<dt class="note">[[User:Ranwer|Ranwer]]</dt> | <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> | <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", { | <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> | </dd> | ||
</dl> | </dl> |
Revision as of 14:59, 19 June 2021
Description
- Description:
- Draws an ingame icon at a given position. Command has to be executed each frame. Use addMissionEventHandler "Draw3D" which is executed each frame and if user can see the drawing. In order for the results of this command to be visible through a custom camera, enable HUD with cameraEffectEnableHUD. showHUD false will hide icon drawing. In order for arrows to appear, the icon texture should exist. The arrows size is proportionate to 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 image
- color:
- Array in format Color (RGBA) - icon color
- Array of Arrays in format Color (RGBA): icon and text color Template:Since
- position: Array - icon world position in PositionAGL format
- width: Number - icon width (see description note)
- height: Number - icon height (see description note)
- angle: Number - icon rotation angle
- text (Optional, default: ""): String - text label to display next to icon.
- shadow (Optional, default: 0): Number or Boolean
- textSize (Optional, default: size of system): Number - the size of the text
- font (Optional, default: "RobotoCondensed"): String - font class name from CfgFontFamilies
- textAlign (Optional, default: "center"): String - can be one of:
- "left"
- "center"
- "right"
- drawSideArrows (Optional, default: false): Boolean - true to draw arrows and the text label at edge of screen when icon moves off screen
- 2.04 offsetX: Number - (Optional, default: 0) x offset for the icon text
- 2.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 getPosASL cursorTarget, 1, 1, 45, "Target", 1, 0.05, "TahomaB"]; }];
- Example 2:
- Just text:
addMissionEventHandler ["Draw3D", { drawIcon3D ["", [1,0,0,1], ASLToAGL getPosASL 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 v 2.03.147270
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
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
- Posted on August 31, 2013
- Killzone_Kid
- 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. - Posted on April 19, 2014
- AgentRev
- 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. - Posted on October 23, 2014 - 02:42 (UTC)
- DreadedEntity
-
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) - Posted on November 13 (2014)
- Iceman77
-
Here's a practical example combining both drawLine3D and drawIcon3D. Note: You may want to use visiblePosition instead of getPos for moving objects.
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; }; }];
- Posted on February 11, 2016 - 07:37 (UTC)
- Ranwer
- You can also use getPosWorld (for X and Y only, but not Z), which works splendid in script performance. Here is an example:
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" ]; }];