Jump to content
Sign in to follow this  
zapat

DrawIcon3d offset

Recommended Posts

I would like to make a dynamic vertical line to mark something in my mission (dynamic = moves where player is pointing).

In A2 I used a flagpole for this, but it doesn't work for far distances.

In A3 I opted for drawIcon3d (as you cannot set width for drawLine)

Problem: drawIcon3D draws the middle of the icon on given pos.

Problem 2: icon dimensions are in GUI space, possible position z-offset is in gameWorld meters.

So your drawn icon is a combination of a gameWorld position and a screen position.

Question: how could I offset Z of the icon that the bottom of it would be on given pos?

Share this post


Link to post
Share on other sites

Can you show a screenshot of the problem? Or some code to reproduce it.

Share this post


Link to post
Share on other sites

TryThisFnc =
{
  _pos = screenToWorld[0.5,0.5];
  drawIcon3D ["", [0,1,0,0.5], _pos, 0.1, 8, 0, "", 0, 0, "PuristaMedium"]; 
};

_id = ["tryThis", "onEachFrame", "TryThisFnc"] call BIS_fnc_addStackedEventHandler;

Now I would like the line to point to where the player points: that is set Z higher.

I would like to make the height of it change with distance, so a simple screenToWorld[0.5,0.3] doesn't work.

I am now thinking on making a custom icon with an arrow, where the bottom 50% is transparent.

Share this post


Link to post
Share on other sites

There should be something in this thread that will help you?

http://forums.bistudio.com/showthread.php?168525-Calculating-point-in-circle-circunference-gives-always-same-result

eg this keeps the text within the players FOV:

fnc_returnObjClass = 
{
   	_camDir = ([(positionCameraToWorld [0,0,0]), (positionCameraToWorld[0,0,1])] call BIS_fnc_vectorDiff);
   	_pos = ASLToATL ([eyePos player, _camDir] call BIS_fnc_vectorAdd);
       _class = typeOf cursorTarget;
drawIcon3D ["", [1,1,0,1],_pos, 0, 0, 0,_class, 2, 0.05, "PuristaMedium", "center"]; 
};
_id = ["retObjClassID", "onEachFrame", "fnc_returnObjClass"] call BIS_fnc_addStackedEventHandler;

Edited by Mattar_Tharkari

Share this post


Link to post
Share on other sites

Make the picture that is your icon have the point for ground contact be the centre of your image ??

rather than ...

arrow_btm.png have arrow_mid.png

Got to be easier than working out world to screen trig just for an icon placement ?

Or use a User texture 10m helper, we know that can be offset by 5m in the Z to get the right co-ords.

Both just mean you have to alpha channel your pic rather than (i presume) a whole coloured icon.

Share this post


Link to post
Share on other sites

Mattar_Tharkari: thanks this was a useful link indeed!

Although I have to agree with Larrow: the custom texture is the easiest solution, I came to this result as well.

Using this guide: http://killzonekid.com/arma-scripting-tutorials-mission-root/

(Why was this guy banned?!)

I could easily add a custom paa to my mission without any addons.

Anyways the sizing of these drawed icons are still not clear to me (what does their dimensions really mean: okay 5, but 5 what?), trial and error works though.

Share this post


Link to post
Share on other sites
Mattar_Tharkari: thanks this was a useful link indeed!

Although I have to agree with Larrow: the custom texture is the easiest solution, I came to this result as well.

Using this guide: http://killzonekid.com/arma-scripting-tutorials-mission-root/

(Why was this guy banned?!)

I could easily add a custom paa to my mission without any addons.

Anyways the sizing of these drawed icons are still not clear to me (what does their dimensions really mean: okay 5, but 5 what?), trial and error works though.

I would use the positionCameraToWorld method (+ an image with 50% empty space) just because it keeps the icon centered even if you aim at the sky, with screentoworld when you aim above the horizon (where there's no land), the position wont be where the player is aiming. The movement doesn't look 100% smooth, but neither it does when using screentoworld. But since I am not sure I fully understand what you need this may not be the perfect method for you.

I think the size is 1 : real icon size, 2 : double size, etc, so 5 would be 5 times the real icon size.

I am using killzonekid method too to use paa files on a mission, it works well. And I think he got banned because he downloaded a leaked version of dayz (and he said he did it here in the forums).

Edited by wok

Share this post


Link to post
Share on other sites
Anyways the sizing of these drawed icons are still not clear to me (what does their dimensions really mean: okay 5, but 5 what?),
Well just been having a play with this, it seems to be percentage of UI area based off of width divided by 2. It does not seem to matter what size the source image is eg:-

If i do a getResolution i get :-

screen 1440 , 900

ui 900 , 660

ratio 1.6

ui scale 0.55

Using a 100,100 pixel source image

If i draw an icon of 50,10 (just concentrating on the width for now (width, height) ), horizontally this will pretty much fill the screen ( 50 * 2 = 100%)

If i now take 50 and divide it by the screen ratio 1.6 i get 31.25, plugging this into the drawicon height pretty much fills the screen. 50, 31.25

If i now change the source image for an image that is 400,400 pixels, I get exactly the same effect with drawIcon at 50, 31.25

  • Like 1

Share this post


Link to post
Share on other sites

good info Larrow!

The ratio calculation is okay. I don't agree with the 50 being 50% though. On my 1280x800 with normal UI (747x560) I get 39x24 for a full icon.

Edit: now I lost it. With 1280x800, 907x680,1.6, 0.85 the full icon is 32x20

So how can the icons be made uniform in size (regardless of screen resolution and UI size)?

I just can't figure this out...

---------- Post added at 05:48 PM ---------- Previous post was at 04:26 PM ----------

Anyhow, a fast travel system is what I am working on. Naturally it is a part of a huge engine, I just included a quick teleport now.

https://drive.google.com/file/d/0BxjqGzmtx1GBNzVic0xEdEx1UzA/edit?usp=sharing

Edited by zapat

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×