Home   Help Search Login Register  

Author Topic: Drawing a square with markers at any angle. Killing me all week!!  (Read 1011 times)

0 Members and 1 Guest are viewing this topic.

Offline L!nk

  • Members
  • *
Ok, basically what I want to do is create a marker on each corner of a building at any angle. This is very advance for me because it involves alot of sin,cos,tan calculations.
This is what I have so far:

---------------------------------------------------------------------------------------------------------
_dir = getdir building01;

_posx01 = ((position building01 select 0) + (5*(sin _dir)) + (5*(cos _dir)));
_posy01 = ((position building01 select 1) + (5*(cos _dir)) - (5*(sin _dir)));
_temp01 = createMarkerLocal [(format ["%1%2","Marker01",0]),[_posx01,_posy01]];
_temp01 setMarkerShapeLocal "ICON";

_posx02 = ((position building01 select 0) + (5*(sin _dir)) - (5*(cos _dir)));
_posy02 = ((position building01 select 1) + (5*(cos _dir)) + (5*(sin _dir)));
_temp02 = createMarkerLocal [(format ["%1%2","Marker02",1]),[_posx02,_posy02]];
_temp02 setMarkerShapeLocal "ICON";

_posx03 = ((position building01 select 0) - (5*(sin _dir)) + (5*(cos _dir)));
_posy03 = ((position building01 select 1) - (5*(cos _dir)) - (5*(sin _dir)));
_temp03 = createMarkerLocal [(format ["%1%2","Marker03",2]),[_posx03,_posy03]];
_temp03 setMarkerShapeLocal "ICON";

_posx04 = ((position building01 select 0) - (5*(sin _dir)) - (5*(cos _dir)));
_posy04 = ((position building01 select 1) - (5*(cos _dir)) + (5*(sin _dir)));
_temp04 = createMarkerLocal [(format ["%1%2","Marker04",3]),[_posx04,_posy04]];
_temp04 setMarkerShapeLocal "ICON";
---------------------------------------------------------------------------------------------------------

The 5's in the script is the size of the building. (this will vary)
Just keep in mind that this markers must be created dependend on the angle of the building.

The "x" is where I want the markers to be...

x           x
  l---------l
  l         l
  l         l
  l         l
  l---------l
x            x

If the building is rotates at any angle:

      x             x
       /----------/
      /          /
     /          /
    /          /
   /----------/
x              x

You probable need a very good math mark for this(I wish I did).
Please help.

thx in advance
L!nk

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Lets say your building is a 10x20 one, and your building is named building1, then use modelToWorld command and dont care any more about building rotation as the coordinates there are in object coordinates:

Code: [Select]
// upper-left corner:
_coords = building1 modelToWorld [-5,10,0];
// lower-right corner:
_coords = building1 modelToWorld [5,-10,0];

Offline L!nk

  • Members
  • *
Sorry, did not recognize this command in ArmA. Always wondered what it does. Now I know and thanx alot.

L!nk

Offline Tajin

  • Members
  • *
I'd do it like that.:
Code: [Select]
_box = boundingBox building1;
_x1 =(_box select 0) select 0;
_y1 =(_box select 0) select 1;
_x2 =(_box select 1) select 0;
_y2 =(_box select 1) select 1;
_temp01 = createMarkerLocal ["Marker01",building1 modelToWorld [_x1,_y1,0]];
_temp02 = createMarkerLocal ["Marker02",building1 modelToWorld [_x1,_y2,0]];
_temp03 = createMarkerLocal ["Marker03",building1 modelToWorld [_x2,_y1,0]];
_temp04 = createMarkerLocal ["Marker04",building1 modelToWorld [_x2,_y2,0]];
_temp01 setMarkerShapeLocal "ICON";
_temp02 setMarkerShapeLocal "ICON";
_temp03 setMarkerShapeLocal "ICON";
_temp04 setMarkerShapeLocal "ICON";


Saves you the hassle of having to adjust the coordinates on your own.