Home   Help Search Login Register  

Author Topic: Manually drawing on the map  (Read 2731 times)

0 Members and 1 Guest are viewing this topic.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Manually drawing on the map
« on: 22 Aug 2007, 19:49:06 »
OK, I'm trying to build a simple drawing program to allow MP players to draw free-hand on a map control (Among other things). The specific commands are drawEllipse, drawIcon, drawLine, drawRectangle and drawArrow, but, for the life of me, I can't get anything visible to appear. Has anyone actually managed to manually draw anything on a map control with these commands, because I'm clearly missing something obvious?

I'll make and upload an example mission if anyone thinks that might help, but I'm hoping someone has used at least one of these commands before and can just point me in the direction of an example script.

Don't worry, I don't need any help with recording/managing/broardcasting the drawings...just how to make visible marks on a map ;(
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Re: Manually drawing on the map
« Reply #1 on: 23 Aug 2007, 09:31:05 »
I've read a few topics that seem to indicate that nobody knows how to get those to work.  Maybe someone will come around and contradict that, but I have my doubts.
Everything I have released for ARMA can be found here.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Manually drawing on the map
« Reply #2 on: 23 Aug 2007, 11:01:57 »
What you try to do should be quite easy to achieve as Ellipses, Icons, Rectangles and Arrows are already present as marker types.

Lines are a bit more tricky, to draw them, once you have the start and end point do the following:
- Calculate the 2D distance between start and end point
- Calculate angle between start and end point
- Calculate the center position between start and end point
Code: [Select]
_dist2d = sqrt(((_endpos select 0)-(_startpos select 0))^2+((_endpos select 1)-(_startpos select 1))^2);
_ang = ((_endpos select 0)-(_startpos select 0)) atan2 ((_endpos select 1)-(_startpos select 1));
_center = [(_startpos select 0)+sin(_ang)*_dist2d/2,(_startpos select 1)+cos(_ang)*_dist2d/2]

- Now create a marker, rectangle type
- Change its size, use the desired line width in meters and the height being the calculated _dist2d, for example [10, _dist2d]
- Place the new marker in the _center position: "newlinemarker" setMarkerPosLocal _center;
- Change the direction of the new marker to _ang: "newlinemarker" setMarkerDirLocal _ang;

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Manually drawing on the map
« Reply #3 on: 23 Aug 2007, 11:23:37 »
Thanks for the rectangular "line" idea, Mandoble; not something I would have considered (duh!), but I'm sure your suggestion will allow me to do everything I wanted to do. Pity the already implemented drawLine is disabled, broken or just improperly documented, but I suppose the community is used to complicated workarounds.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Manually drawing on the map
« Reply #4 on: 23 Aug 2007, 11:49:10 »
More than problably the marker solution is much better than using any working drawXXXX command, as you may move markers at will as well as delete them if needed, change their colors, sizes, angles, positions. But the drawXXXX commands, even working, dont return any object you may handle, alter or delete later. With the markers you have an added advantage as markers may be global or local. You may create something like a PDA where different players may draw different things and the result is shared by everybody. Makers give you also the advantage of using text.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Manually drawing on the map
« Reply #5 on: 23 Aug 2007, 11:58:55 »
Well, one of the things I'd tried with the drawXXX commands was to redraw them every frame, though it didn't help. This would get over the whole problem of moving and deleting, assuming they were implemented in this way. Who knows, though?

Although markers may be global, I want my shared drawable map to be used in MP which would rather mean I have to manage the transfer of markers myself. No problem though, since I have the framework in place; it was only the actual drawing of the lines that I couldn't work out. The other advantage of manually communicating positions rather than creating dozens of global markers is vastly reduced bandwidth use.

**Edit**

Some slight errors in Mando's (admittedly untested) code, but otherwise worked fine:
Code: [Select]
_markerName = "newlinemarker";
createMarkerLocal [_markerName, _center];
_markerName setMarkerShapeLocal "RECTANGLE";
_markerName setMarkerSizeLocal [2, _dist2d / 2]; // 4m wide line
_markerName setMarkerDirLocal _angle;

The map drawing is working in MP, at least at a basic level, and will be in my SPON Scripts release which is coming very soon... http://www.ofpec.com/forum/index.php?topic=30129.0
« Last Edit: 25 Aug 2007, 13:38:03 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)