drawIcon3D: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
(Notes reformat)
Line 57: Line 57:


<h3 style='display:none'>Notes</h3>
<h3 style='display:none'>Notes</h3>
<dl class='command_description'>
 
<!-- Note Section BEGIN -->
<!-- Note Section BEGIN -->
<dd class="notedate">Posted on August 31, 2013
<dl class="command_description">
<dt class="note">'''[[User:Killzone_Kid|Killzone_Kid]]'''
<dd class="notedate">Posted on August 31, 2013</dd>
<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]]. Use additional [[ASLToAGL]] if needed.
<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]]. Use additional [[ASLToAGL]] if needed.


To draw smooth moving icon for a moving object use [[visiblePosition]] and [[visiblePositionASL]] accordingly.
To draw smooth moving icon for a moving object use [[visiblePosition]] and [[visiblePositionASL]] accordingly.<br/><br/>


<dd class="notedate">Posted on September 23, 2013
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].
<dt class="note">'''[[User:Killzone_Kid|Killzone_Kid]]'''
</dd>
<dd class="note">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]:
</dl>


<dl class="command_description">
<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.<br/><br/>


<dd class="notedate">Posted on April 19, 2014
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/><br/>
<dt class="note">'''[[User:AgentRevolution|AgentRev]]'''
<dd class="note">Just a little precision to KK's first comment, this command expects '''[[PositionASLW]]''' over the sea, not regular ASL. Luckily, [[modelToWorld]] returns ATL over land and ASLW over sea, so if you want the icon to stay the the same place, you should use this snippet to find the correct position:
<br/>
<br/>
<code>_pos = visiblePositionASL _object;
_pos set [2, (_object modelToWorld [0,0,0]) select 2];</code>


 
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.
<!-- Note Section END -->
</dd>
</dl>
</dl>


Line 169: Line 168:
<dd class="notedate">Posted on February 11, 2016 - 07:37 (UTC)</dd>
<dd class="notedate">Posted on February 11, 2016 - 07:37 (UTC)</dd>
<dt class="note">[[User:Ranwer|Ranwer]]</dt>
<dt class="note">[[User:Ranwer|Ranwer]]</dt>
<dd class="note">You can also use [[getPosWorld]], 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", { <br> _pos = getPosWorld player;<br> 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"];<br>}];</code>
<code>addMissionEventHandler ["Draw3D", { <br> _pos = getPosWorld player;<br> 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"];<br>}];</code>
</dd>
</dl>
<!-- DISCONTINUE Notes -->
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on March 24, 2018 - 18:05 (UTC)</dd>
<dt class="note">[[User:AgentRev|AgentRev]]</dt>
<dd class="note">
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.
</dd>
</dd>
</dl>
</dl>
<!-- DISCONTINUE Notes -->
<!-- DISCONTINUE Notes -->

Revision as of 21:10, 24 March 2018

Hover & click on the images for description

Description

Description:
Draws an ingame icon at a given position. Command has to be executed each frame. Use onEachFrame or addMissionEventHandler "Draw3D"
Groups:
Uncategorised

Syntax

Syntax:
drawIcon3D [texture, color, pos, width, height, angle, text, shadow, textSize, font, textAlign, drawSideArrows]
Parameters:
[texture, color, pos, width, height, angle, text, shadow, textSize, font, textAlign, drawSideArrows]: Array
texture: String
color: Color
pos: PositionAGL
width: Number
height: Number
angle: Number
text: String - (optional)
shadow: Number - (optional) - 0 = none, 1 = shadow, 2 = outline
textSize: Number - (optional)
font: String - (optional)
textAlign: String - (optional) - left, center, right...
drawSideArrows: Boolean - (optional) - Draw arrows at edge of screen when icon moves off screen.
Return Value:
Nothing

Examples

Example 1:
Icon and text:onEachFrame { drawIcon3D ["targetIcon.paa", [1,1,1,1], getPos cursorTarget, 1, 1, 45, "Target", 1, 0.05, "TahomaB"]; };
Example 2:
Just text: addMissionEventHandler ["Draw3D", { drawIcon3D ["", [1,0,0,1], position cursorTarget, 0, 0, 0, "Target", 1, 0.05, "PuristaMedium"]; }];

Additional Information

See also:
drawLine3D

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

Notes

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. Use additional ASLToAGL if needed. To draw smooth moving icon for a moving object use visiblePosition and visiblePositionASL accordingly.

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.

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.

Bottom Section

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 April 11, 2015 - 07:36 (UTC)
Killzone Kid
Doesn't work when showHUD false, textAlign is broken, drawSideArrows will turn if angle is not 0 [1]
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", {
_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"];
}];