Jump to content
JB47394

Draw circle on terrain in script

Recommended Posts

Does anyone know if the ability to draw circles onto the terrain (not the map) is available to scripts?  Zeus does this when placing fire support, and I'd love to use that same ability to demarcate interesting regions.  I've seen it done on one of Quicksilver's servers, but the mission file was encrypted so I don't know the technique that was used.  Perhaps it was a server-side mod.

Share this post


Link to post
Share on other sites

There will be another method  but i am not good enough with arma math  at all.
 

_distance = 20;
_direction = 0;
_step = 2;
for "_i" from 0 to (360 -_step) step _step do {
"Sign_Arrow_F" createVehicle (player getRelPos [_distance, _direction+_step]);
_direction= _direction+_step;
};

This could be better with _step setted automatically according with _distance value to keep always the same distance between signs, but like i said math is abstract for me.

  • Like 2

Share this post


Link to post
Share on other sites
8 minutes ago, davidoss said:

There will be another method  but i am not good enough with arma math  at all.
 


_distance = 20;
_direction = 0;
_step = 2;
for "_i" from 0 to 358 step _step do {
"Sign_Arrow_F" createVehicle (player getRelPos [_distance, _direction+2]);
_direction= _direction+2;
};

This could be better with _step setted automatically according with _distance value to keep always the same distance between signs, but like i said math is abstract for me.

 

For using proper math you'd use something like this:

_centerPos = getPosATL player;
_centerPos params ["_centerPosX","_centerPosY"];
_distance = 20;
_angle = 2;//will place objects every 2°

for "_i" from 0 to (360-_angle) step _angle do {
	"Sign_Arrow_F" createVehicle [_distance*cos(_i) + _centerPosX,_distance*sin(_i) + _centerPosY];
};

rlIFxSH.png

 

Basic formula to get positions of a circle.

 

Cheers

  • Like 4
  • Thanks 1

Share this post


Link to post
Share on other sites

Very nice and preety much the same effect. How about to keep static distance betwean signs with any distance?

Would be that an "advanced" math? :eh:

Share this post


Link to post
Share on other sites
48 minutes ago, davidoss said:

Very nice and preety much the same effect. How about to keep static distance betwean signs with any distance?

Would be that an "advanced" math? :eh:

No idea if there's a formula (might be) for it and if the thread starter actually needs it.

My geometry lessons are in the distant past, heh.

 

Cheers

Share this post


Link to post
Share on other sites
1 hour ago, davidoss said:

Very nice and preety much the same effect. How about to keep static distance betwean signs with any distance?

Would be that an "advanced" math? :eh:

 

Not really! The distance between points is proportional to the radius: the ark length =   2* 3.14* radius * angle°/360°

You just have to define how much points you want in accordance with radius.

Say One point each degree at 100 m are spaced every 2 *3.14*100/360 (on ark). For 200 m you'll need twice points: 2* 3.14*200/720.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Holy Shit, my head.. auuu

How about to use dynamic angle  according to the radius?

Share this post


Link to post
Share on other sites
2 hours ago, davidoss said:

Very nice and preety much the same effect. How about to keep static distance betwean signs with any distance?

Would be that an "advanced" math? :eh:

I've got something, gimme a minute.

Share this post


Link to post
Share on other sites
19 minutes ago, Harzach said:

I've got something, gimme a minute.

19 minutes ago, heh...

Maybe you'll make it within a minute on mercury.

 

Cheers

  • Like 1
  • Haha 2

Share this post


Link to post
Share on other sites
9 minutes ago, Grumpy Old Man said:

19 minutes ago, heh...

Maybe you'll make it within a minute on mercury.

 

Cheers

 

It was a minute of arc, so 1/60° = 2 * 3.14 / (360*60)  in rad

  • Haha 2

Share this post


Link to post
Share on other sites

OK, so maybe this will take a bit longer. I thought I had a snippet that did this, but I might have accidentally deleted it a while back. It was something I used to create another script, but I ended up not retaining the equal-distance feature. Now where did I put that slide rule...

Share this post


Link to post
Share on other sites

From @Grumpy Old Man code, something like:

_centerPos = getPosATL player;

_centerPos params ["_centerPosX","_centerPosY"];

_distance = 200; // or what you want

_ratio = 100; // you want an arrow each 1° at 100m

_angle = _ratio/_distance;    // this will place an arrow every 0.5° at 200 m, 0.25° at 400m,... so the roughly the same "length of arc" or distance between arrows at any distance.

for "_i" from 0 to (360-_angle) step _angle do {

  "Sign_Arrow_F" createVehicle [_distance*cos(_i) + _centerPosX,_distance*sin(_i) + _centerPosY];

};

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

OK! Forgot I used it in another mission. Here it is abstracted:

//nul = [_radius,_width] execVM "circle.sqf";

params ["_radius","_width"];

_pos = getPos player; 
_pos params ["_px","_py" ]; 

_index = 0;

_circ = floor ((2 * pi) * _radius);
_radials = floor (_circ / _width);
_factor = (360 / _radials);

for "_i" from 0 to (_radials - 1) do 
{ 
    _ix = (_i * _factor); 
    _yaw = (180 - _ix); // yaw-pitch-roll need to be adjusted depending on object and orientation
    _roll = 0; 
    _pitch = 0; 
   
    _dirx = sin(_yaw) * cos(_roll); 
    _diry = cos(_yaw) * cos(_roll); 
    _dirz = sin(_roll); 
    _upx = cos(_yaw) * cos(_roll) * sin(_pitch); 
    _upy = sin(_yaw) * cos(_roll) * sin(_pitch); 
    _upz = cos(_roll) * cos(_pitch); 
    
    _ox = (_radius * cos _ix); 
    _oy = (_radius * sin _ix); 
    
    _obj = createSimpleObject ["A3\Structures_F\Civ\Ancient\AncientPillar_F.p3d",[0,0,0]]; 
    _obj setVectorDirAndUp [[_dirx,_diry,_dirz],[_upx,_upy,_upz]]; 
    _obj setPosATL [_px + _ox, _py + _oy, -0.2];
    _index = _index +1;
};

It's fairly comprehensive in that you can designate the exact orientation of the object you are using by changing the _yaw/_pitch/_roll values. It takes radius and width (width of object plus desired spacing) as params.

 

7XVtisy.jpg

 

fEyVmkV.jpg

 

RjHYcJ5.jpg

 

  • Like 2
  • Thanks 3

Share this post


Link to post
Share on other sites

I'm also sure there is a more elegant way to accomplish it, but I'm a ham-fisted dope.

  • Haha 1

Share this post


Link to post
Share on other sites

Also also, since those "helper" objects can be created as (or already are) simple objects, you can spawn a bunch of 'em, so you could set the _width to a very small number and maybe set the Z pos a little lower so that you have an essentially solid line.

Share this post


Link to post
Share on other sites
3 minutes ago, davidoss said:

Nice done. Well now we can use this for something else.

 

I originally put it together for a dynamic "Tower Defense" mission. It spawns rings of HESCO, concertina wire, tank traps, whatever. The full code also allows for openings in the defense rings for units to pass through as the defenders fall back/aggressors move in.

9JATE50.jpg

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Yea if you have math calculations in little finger you can "make arma great again"

Share this post


Link to post
Share on other sites

I eventually figured out what I was after.  Here are two functions that create and delete a circle on the ground.  Because it's just a bunch of objects in a circle, it's much like @Harzach's solution, except that I can simplify things because I'm using decals, not objects.

As a result of the particular object I'm using, the line segments are always white and always 4 meters long, so large circles can generate hundreds of simple objects.  That said, I haven't seen a significant performance hit on my 1070ti with as many as 400 segments.  I did, however, include a way to draw a segmented circle (the _spacing parameter on TEST_CreateCircle).  If anyone knows of a p3d for other line segments in vanilla ARMA, I'd appreciate hearing about them.

TEST_CreateCircle =
{
	params ["_center", "_radius", ["_spacing", 1, [0]]];

	private _segment = createSimpleObject ["a3\roads_f\Decals\Decal_white_line_F.p3d", _center];
	private _bounds = boundingBoxReal _segment;
	private _lineLength = (_bounds select 1 select 1) - (_bounds select 0 select 1);
	deleteVehicle _segment;

	private _circumference = 2 * _radius * pi;
	private _segmentCount = ceil (_circumference / _lineLength);
	private _stepAngle = 360 / _segmentCount;

	private _segments = [];
	private _angle = 0;
	for "_i" from 1 to _segmentCount step _spacing do
	{
		_angle = _i * _stepAngle;
		_segment = createSimpleObject ["a3\roads_f\Decals\Decal_white_line_F.p3d", AGLtoASL (_center vectorAdd [sin _angle * _radius, cos _angle * _radius, 0])];
		_segment setDir (_angle + 90);

		_segments pushBack _segment;
	};

	_segments
};

TEST_DeleteCircle =
{
	params ["_lines"];

	{ deleteVehicle _x } forEach _lines;
};

//mycircle = [getpos player, 400, 5] call TEST_CreateCircle;
//[mycircle] call TEST_DeleteCircle

One thing that I found interesting was that if I created the simple objects with AGL coordinates (simple objects are supposed to get ASL coordinates) then they'll show up, but line segments close to the camera won't be drawn.  At least, that was the behavior I got while drawing circles at Altis's main airport.  I mention it in case anyone else has seen strange behavior in their simple object decals (e.g. roads and such).

  • Like 1

Share this post


Link to post
Share on other sites
On 4/19/2019 at 7:31 PM, JB47394 said:

I eventually figured out what I was after. 

Ah, this was a fun one, glad you found a solution. Decals, of course!

Share this post


Link to post
Share on other sites

If you see something in our missions just ask the mission maker 🙂

 

On 10/6/2018 at 11:21 PM, JB47394 said:

  I've seen it done on one of Quicksilver's servers, but the mission file was encrypted so I don't know the technique that was used.  Perhaps it was a server-side mod.

 

our solution isn't as sexy as all that math, but its simple and efficient:

 

https://github.com/auQuiksilver/Apex-Framework/blob/master/Apex_framework.terrain/code/functions/fn_config.sqf#L295

 

We used them to create those pretty terrain circles:

126060A1BB4820A6105E4AFE20B7C5771F89E0E1

 

C1668878A523043ACE80BEE1FBA756D3C4FEB663

 

6929696BC6D1C9FE9D77BDD4A7C98539FFBB3B60

 

 

  • Like 5
  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks, Quicksilver.  It's good to learn how you guys created the circles.  Unfortunately, we have circles of arbitrary radius, so we'll have to stick to our object-intensive approach.

For those curious, Quicksilver creates a single, vanilla, simple object.  They are colored by faction and come in 100, 200 and 500 meter sizes.  Here's a 100m one for East (colored red).

createSimpleObject ["a3\Modules_F_Curator\Multiplayer\surfaceSectorEast100m.p3d", _positionASL]

There are surfaceSectorEast, surfaceSectorWest, surfaceSectorCiv, etc. p3ds in modules_f_curator.pbo

  • Thanks 1

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

×