Jump to content
Hypnomatic

Quick and fun projectile path tracing!

Recommended Posts

Thanks for clearing that up, I was unsure where exactly where to put the bottom lines.

BUT....

I still can't get the thing to work. I have been trying to use scripts all weekend and i'm not having much joy. As I said in my post before i'm not stupid and can normally figure things out for myself, but this is really making me bang my head against the wall. I'm 100% sure I am doing everything right. I even went back and checked to see if I was saving the sqf as a text doc by mistake.

Anyway I don't want to waste much more of your time, you obviously have things to do other than helping people on the forums that should be able to help themselves.

I'll post this lot anyway just in case you see an obvious mistake. (as there clearly is one somewhere on my behalf)

My exact code in notepad++

        [_this, (position(_this select 6))] spawn { 
           private["_params","_initialPos","_bullet","_index","_positions"]; 
           //Vars and Params 
           _params     = _this select 0; 
           _initialPos = _this select 1; 
           _bullet     = _params select 6; 
           _index      = count firedBullets; 
           _positions  = [_initialPos]; 

           //Assemble the array of positions and push it to the global array 
           waitUntil { 
               if (isNull _bullet) exitWith {true}; 
               _positions set [count _positions, position _bullet]; 
               firedBullets set [_index, _positions]; 
           }; 
       }; 
   }] 
};   

[soldier1] call hyp_fnc_traceFire; 

My soldier in editor

http://www.partyviberadio.com/forums/attachments/chat/85715d1380455813-hey-team-2013-09-29_00001.jpg (142 kB)

The sqf file in the mission folder

http://www.partyviberadio.com/forums/attachments/chat/85716d1380455814-hey-team-script-pic.png (150 kB)

As I say if you are too busy and fed up then I don't blame you.

All the best

Good vibes

Share this post


Link to post
Share on other sites

I see a few probable causes for your issue, but I think the easiest way to help you is to just post a working mission, so you can see what's needed. So here's what's in my mission:

https://github.com/hypnomatic/ARMA_Examples/tree/master/TracerExample_v0-0-1.Altis

There you'll see the init.sqf and mission.sqm files, as well as a zip of the entire mission. So either copy the contents of those files into yours, or drop the folder that's inside the zip file in the same directory as all of your other editor missions.

Share this post


Link to post
Share on other sites
Hey Hypnomatic, will this work on AI as well?

Yep, it should work with no problem on any soldier/vehicle/unit in general.

Later this week I may change this up a bit to make a variant that's more feasible for general use, just in case anyone would want to use it for more general gameplay purposes. Something to the effect of specifying the color of lines for particular units/vehicles/sides, decreasing the rate at which positions are taken to make it less demanding when a ton of lines are out, adding a max distance to track bullets so those shot into the air aren't traced forever, that type of thing.

Share this post


Link to post
Share on other sites

Sounds good. Our group is actually looking to debug some potential AI issues with this. The changes you are thinking would be great.

Share this post


Link to post
Share on other sites

OP has also been updated with relevant info:

UPDATE 10/6/2013:

So, over the past few days I've more or less completely rewritten this code to add all the optional functionality I could think of. I'm going to list all of the changes in a moment, but now it is worth noting that all of my discussion before page 3 is technically out of date: It'll still technically work, but the code samples found in them should NOT be trusted.

Now onto the changes: I've reworked the function so now it has a total of 6 optional parameters, each with default values. The syntax and parameters are now:

[_unit, _color, _lifetime, _interval, _maxDistance, _maxDuration] call hyp_fnc_traceFire;

  • 0: _unit - Unit or vehicle to trace the projectiles of. Defaults to the player if no other parameter is specified.
  • 1: _color - Color array for all lines fired by this unit. This is an array formatted as [r,g,b,a], with each value being between 0 and 1. (BIS wiki page)
  • 2: _lifetime - Maximum number of seconds the projectile's line should linger after firing. Note that this timer starts at the same time as maxDuration, but is not checked until after the script finishes drawing a line. This can be thought of as a lower bound for how long a line will exist, as all lines will persist AT LEAST for lifetime's duration.
  • 3: _interval - Number of frames to skip between adding each segment of the line. Defaults to skipping no frames, so the lines are updated every frame.
  • 4: _maxDistance - Maximum distance from the initial position a projectile's line should be updated. Defaults to no maximum.
  • 5: _maxDuration - Maximum number of seconds from firing a projectile's line should be updated. Defaults to no maximum.

Now, all of these options may be a bit confusing, so let me offer an example or two:

[player, [1,0,0,1], 3, 2, nil, 3] call hyp_fnc_traceFire; 

Can be thought of as saying:

Track every projectile of:

the player,

with a red line,

that will last for at least 3 seconds,

that is updated every third frame (ie 2 frames skipped between each update),

with no limit on distance,

but will not be updated for more than 3 seconds.

Now, if you want to completely omit a parameter so the default value is used, you have two options. You can either pass nil in place of that parameter, as in the example, which is ARMA's equivalent of "nothing". If you only want to pass specify a unit, and use the defaults for everything else, simply omitting all unwanted parameters like so:

[player] call hyp_fnc_traceFire;

However note that this only works if you want to leave out all parameters after the ones you specify. So if I wanted to specify a player and a max duration, I would need to pass:

[player, nil, nil, nil, nil, 5] call hyp_fnc_traceFire;

If you don't really mess with scripts much, this may be a bit tough to wrap your head around, so I'll be happy to answer any questions you may have.

The code:

Link to raw: https://raw.github.com/hypnomatic/ARMA_Examples/master/Tracers%20Script/Tracer_v0-2-1.sqf

/*
General init for the tracer function
*/
hyp_var_tracer_tracedUnits = [];

addMissionEventHandler ["Draw3D", { //On every frame...
   {
       private["_unit"];
       _unit = _x;
       {
           private["_positions","_color"];
           _positions = _unit getVariable [format["hyp_var_tracer_projectile_%1", _x], []];
           _color     = _unit getVariable ["hyp_var_tracer_color", [1,0,0,1]];
           for "_i" from 0 to (count _positions) - 2 do {
               drawLine3D [_positions select _i, _positions select (_i + 1), _color]; //...draw lines connecting the positions on the path that the bullet took...
           };
       } forEach ( _unit getVariable["hyp_var_tracer_activeIndexes", []] ); //...For every bullet fired by a given unit,...
   } forEach hyp_var_tracer_tracedUnits; //...for every unit being traced
}];

//Adding of the option to manually clear lines.  If you don't want the addaction, simply remove these 4 lines
player addAction["Clear Lines", {
   {
       [_x] call hyp_fnc_traceFireClear;
   } forEach hyp_var_tracer_tracedUnits;
}]; //Clears the lines of all drawn projectiles


/*
Syntax: 
   [_unit, _color, _lifetime, _interval, _maxDistance, _maxDuration] call hyp_fnc_traceFire;
Params: 
   _unit:        Either a vehicle or unit.  (Default player)
   _color:       Color array for the lines. (Default [1,0,0,1])
   _lifetime:    Duration after landing to keep the line drawn.  (Default -1, for indefinite duration)
   _interval:    Number of frames to wait between recording locations (Default 0 for record on every frame)
   _maxDistance: Maximum Distance from origin point to record positions (Default -1, for no max)
   _maxDuration: Maximum Duration from time of firing to record posiitons (Default -1, for no max)
Return Value:
   Scalar: The ID of the "fired" EventHandler that was added.
*/

hyp_fnc_traceFire = {
   private["_this","_unit","_color","_lifetime","_interval","_maxDistance","_maxDuration","_eventHandle"];
   _unit        = [_this, 0, player, [objNull]] call BIS_fnc_param;
   _color       = [_this, 1, [1,0,0,1], [[]], [4]] call BIS_fnc_param;
   _lifetime    = [_this, 2, -1, [0]] call BIS_fnc_param;
   _interval    = [_this, 3, 0, [0]] call BIS_fnc_param;
   _maxDistance = [_this, 4, -1, [0]] call BIS_fnc_param;
   _maxDuration = [_this, 5, -1, [0]] call BIS_fnc_param;

   //Ensure that lifetime is at least as long as the maxDuration:
   //if (_lifetime < _maxDuration) then {_lifetime = _maxDuration;};

   _unit setVariable ["hyp_var_tracer_color", _color];
   _unit setVariable ["hyp_var_tracer_lifetime", _lifetime];
   _unit setVariable ["hyp_var_tracer_interval", _interval];
   _unit setVariable ["hyp_var_tracer_maxDistance", _maxDistance];
   _unit setVariable ["hyp_var_tracer_maxDuration", _maxDuration];
   _unit setVariable ["hyp_var_tracer_currentIndex", 0];
   _unit setVariable ["hyp_var_tracer_activeIndexes", []];

   _eventHandle = _unit addEventHandler ["fired", {
       [_this, (position(_this select 6))] spawn hyp_fnc_traceFireEvent;
   }];
   _unit setVariable ["hyp_var_tracer_eventHandle", _eventHandle];
   hyp_var_tracer_tracedUnits set [count hyp_var_tracer_tracedUnits, _unit];
};  

hyp_fnc_traceFireEvent = {
   private["_this","_params","_initialPos","_unit","_projectile","_color","_lifetime","_interval","_maxDistance",
           "_maxDuration","_startTime","_skippedFrames","_positions","_projIndex","_activeIndexes"];
   _params        = _this select 0;
   _initialPos    = _this select 1;
   _unit          = _params select 0;
   _projectile    = _params select 6;
   _color         = _unit getVariable "hyp_var_tracer_color";
   _lifetime      = _unit getVariable "hyp_var_tracer_lifetime";
   _interval      = _unit getVariable "hyp_var_tracer_interval";
   _maxDistance   = _unit getVariable "hyp_var_tracer_maxDistance";
   _maxDuration   = _unit getVariable "hyp_var_tracer_maxDuration";
   _startTime     = diag_tickTime;
   _skippedFrames = _interval; //Number of frames since last full operation.  Starts at interval value to record first position
   _positions     = [_initialPos]; 
   _projIndex     = -1;
   _activeIndexes = [];

   _projIndex     = _unit getVariable "hyp_var_tracer_currentIndex"; //Get the index to assign to the bullet
   _unit setVariable ["hyp_var_tracer_currentIndex", _projIndex + 1]; //Increment index for next bullet

   //Initialize final array into which all positions for the current projectile will be stored...
   _unit setVariable [format["hyp_var_tracer_projectile_%1", _projIndex], _positions]; 
   //...Then update the activeIndexes to indicate that the projectile is active
   _activeIndexes = _unit getVariable "hyp_var_tracer_activeIndexes";
   _activeIndexes set [count _activeIndexes, _projIndex];
   _unit setVariable ["hyp_var_tracer_activeIndexes", _activeIndexes];
   _activeIndexes = nil; //Completely nil this variable just as a safety measure, as the data it holds may be outdated now

   //Loop to run as long as the projectile's line is being updated
   waitUntil {
       //First, handle skipping frames on an interval
       if (_interval != 0 && _skippedFrames < _interval) exitWith {_skippedFrames = _skippedFrames + 1; false}; //Check and handle if frame should be skipped
       if (_interval != 0) then {_skippedFrames = 0;}; //Reset skipped frame counter on recording a frame
       //Next, check if the bullet still exists
       if (isNull _projectile) exitWith {true};
       //Finally, handle the duration and distance checks
       if (_maxDuration != -1 && ((diag_tickTime - _startTime) >= _maxDuration)) exitWith {true}; //Break loop if duration for tracking has been exceeded
       if (_maxDistance != -1 && ((_initialPos distance _projectile) >= _maxDistance)) exitWith {true}; //Break loop if distance for tracking has been exceeded

       //Now, checks have all been run, so let's do the actual bullet tracking stuff
       _positions set [count _positions, position _projectile];
       _unit setVariable [format["hyp_var_tracer_projectile_%1", _projIndex], _positions];
   };

   //Now, if a lifetime is specified, wait until it has elapsed, then delete all data for that projectile
   if (_lifetime != -1) then {
       waitUntil {(diag_tickTime - _startTime) >= _lifetime};
       //Remove the current projectile's index from the activeIndexes...
       _activeIndexes = _unit getVariable "hyp_var_tracer_activeIndexes";
       _activeIndexes = _activeIndexes - [_projIndex];
       _unit setVariable ["hyp_var_tracer_activeIndexes", _activeIndexes];
       //... Then delete the data for the projectile itself
       _unit setVariable [format["hyp_var_tracer_projectile_%1", _projIndex], nil]; //Delete the projectile's data
   };
};

//Clears all lines created by a given unit manually
hyp_fnc_traceFireClear = {
   private["_this","_unit"];
   _unit = _this select 0;
   {
       _unit setVariable [format["hyp_var_tracer_projectile_%1", _x], nil];
   } forEach (_unit getVariable ["hyp_var_tracer_activeIndexes", []]);
   _unit setVariable ["hyp_var_tracer_activeIndexes", []];
};

//Completely removes this script from a unit
hyp_fnc_traceFireRemove = {
   private["_this","_unit"];
   _unit = _this select 0;

   _unit removeEventHandler ["fired", (_unit getVariable ["hyp_var_tracer_eventHandle", 0])];
   {
       _unit setVariable [format["hyp_var_tracer_projectile_%1", _x], nil];
   } forEach (_unit getVariable ["hyp_var_tracer_activeIndexes", []]);
   _unit setVariable ["hyp_var_tracer_color", nil];
   _unit setVariable ["hyp_var_tracer_lifetime", nil];
   _unit setVariable ["hyp_var_tracer_interval", nil];
   _unit setVariable ["hyp_var_tracer_maxDistance", nil];
   _unit setVariable ["hyp_var_tracer_maxDuration", nil];
   _unit setVariable ["hyp_var_tracer_currentIndex", nil];
   _unit setVariable ["hyp_var_tracer_activeIndexes", []];
   _unit setVariable ["hyp_var_tracer_eventHandle", nil];
};

Also, a quick and easy solution for tracking different factions:

{ 
   if (faction _x == "OPF_F") then { 
       [_x, [1,0,0,1], 3, 2, nil, 3] call hyp_fnc_traceFire;  
   }; 
   if (faction _x == "BLU_F") then { 
       [_x, [0,0,1,1], 3, 2, nil, 3] call hyp_fnc_traceFire;  
   }; 
   if (faction _x in ["IND_F", "IND_G_F", "CIV_F"]) then { 
       [_x, [0,1,0,1], 3, 2, nil, 3] call hyp_fnc_traceFire;  
   }; 
} forEach allUnits;  

This will draw a faction-appropriately colored line that lasts 3 seconds for every bullet fired by every unit on the map.

Edited by Hypnomatic

Share this post


Link to post
Share on other sites

Hi Hypnomatic,

Great script all in all, thanks for releasing it! I did a slight modification of this for a video I worked up regarding Arma's ballistics. The caveat is that for it to work correctly, it's best to slow down time when using it. The modified script can be found here.

The changes are so that it shows color-coding on the trail, based on the percentage of the bullet's muzzle velocity at any given point during flight.

Red = >75% muzzle velocity remaining

Yellow = >50%

Green = >25%

Blue = <25%

White = <10%

The video I made with it is this:

Share this post


Link to post
Share on other sites

Nice vid too. But for all the merits of 7.62 and penetration, never underestimate the potential of 9mm rounds in providing suppression around corners, Andrew. I imagine the colour-coded KI visualisation of the modified script you've produced would reveal this to be less dangerous than it looks though. :D

Anyway, I've not taken the chance to thank Hypnomatic for this script before and I really should, as it's proven to be an extremely useful tool in addon making for me. I've used it in a research and development capacity in several areas of addon development, ranging from calibrating ballistics for new ammunition, magazine and muzzle accessory types, through to assisting in generating BDC reticle textures for scope attachments. I'm sure there are many more uses for it in developing weapon systems and solid structures for Arma 3 as well (checking fire geometry LODs etc.).

I really can't recommend it enough as a part of an addon-maker's debugging toolbox.

Share this post


Link to post
Share on other sites

Simply brilliant, will use this in the future, many thanks !!!

Edited by Nanucq

Share this post


Link to post
Share on other sites

I saw someone has released this on the steam workshop. Just wondering if it is someone trying to absorb your credit.

Share this post


Link to post
Share on other sites

Hmm, using Dsylexi's script, neither the static HMG, the mounted HMG on the Hunter and Marshall or the mounted Browning 50. cal on the FIA offroad truck produce colored trajectory.

Share this post


Link to post
Share on other sites
Hi Hypnomatic,

Great script all in all, thanks for releasing it! I did a slight modification of this for a video I worked up regarding Arma's ballistics. The caveat is that for it to work correctly, it's best to slow down time when using it. The modified script can be found here.

The changes are so that it shows color-coding on the trail, based on the percentage of the bullet's muzzle velocity at any given point during flight.

Red = >75% muzzle velocity remaining

Yellow = >50%

Green = >25%

Blue = <25%

White = <10%

The video I made with it is this:

Wow! I can imagine now a group of people standing in a room surronding someone. The person pretends to surrender or whatever and gets down prone. Bullets then come flying through and kill everyone whos standing!

---------- Post added at 02:47 ---------- Previous post was at 02:44 ----------

I saw someone has released this on the steam workshop. Just wondering if it is someone trying to absorb your credit.

It will be taken down if the author want credit and the mission maker doesn't give him any.

---------- Post added at 03:06 ---------- Previous post was at 02:47 ----------

The jet's main gun penetration has problems, thanks to this script we can now see problems and fix them!

It appears like gravity is not taken into account yet with penetration. And water penetration has not yet been worked on.

Edited by ProGamer

Share this post


Link to post
Share on other sites

thanks!

one interesting observation - using this mod is reveals that sometime bullets seem to bounce off air. its usually after double tapping a shot. perhaps its the function drawing the line a little higher than it should be.

http://i41.tinypic.com/s4xj4k.jpg (278 kB)

Share this post


Link to post
Share on other sites

@Dslyecxi:

Awesome video again. I've implemented a variant of your change into the main release, toggle-able with the 7th parameter. Also good note about the slowing of time, I never really thought about that, but it makes sense seeing as each bullet's positions are recorded on every rendered frame.

@da12thMonkey, Nanucq:

Thanks for the support!

@thelog, ProGamer:

Hmmph, in general I'm writing this script to be open for anyone to use however they see fit, so long as credit is given. That said, that mission seems to be effectively a showcase for my script, which seems unnecessary now that I have a mission I can personally keep up to date. I'll ask him about taking it down now that I have mine up.

@twisted:

Do you have any particular interval set? There are occasional visual bugs with the lines if they ricochet early on, as the bullet is moving so fast that the recorded positions are still fairly far apart. I want to say that that is caused by my script and not an actual ARMA bug.

And now for the Update news that I added to the OP:

UPDATE 10/26/2013:

As some of you may have seen, Dslyecxi recently made a video that featured a modified version of this script, where the color of the line was reflective of the velocity of the bullet at that moment. He posted his modifications, which are now implemented in the main script! To activate it, pass true as the seventh parameter, like so:

[player, nil, nil, nil, nil, nil, true] call hyp_fnc_traceFire;

Note that as it stands, enabling the velocity-based coloring will override whatever color you specify in the second parameter. I have an idea or two of ways to fix it, but wanted to get this update out there first.

Also, I completely forgot that the Steam Workshop was a thing, so I published a very simple mission with this script, and Tonic's Virtual Ammobox System and Virtual Vehicle Spawner enabled here:

http://steamcommunity.com/sharedfiles/filedetails/?id=189421090

If there are any problems with the Steam Workshop mission, please mention them to me, as I very rarely actually publish missions, just scripts.

Edited by Hypnomatic

Share this post


Link to post
Share on other sites
thanks!

one interesting observation - using this mod is reveals that sometime bullets seem to bounce off air. its usually after double tapping a shot. perhaps its the function drawing the line a little higher than it should be.

As I understand it, this is happening because the first position of the bullet (tracked in the fired eventHandler) is traced to the first recorded position from the tracking script, which is spawned. There's a slight delay between the shot happening and the data being recorded. It's entirely possible for a bullet to go out, ricochet, and begin a new trajectory before that first data point is captured. The script then connects the dots - the bullet at the muzzle, and the first recorded location, so it looks like you see in your screenshot. If you set up the exact same scenario and then slow down time (ie with setAcctime 0.125) you will not see that behavior happen - it'll be a proper trace. This is made worse at lower framerates. TLDR: If you want to see the most accurate trajectory representation possible, you need to slow down time.

Share this post


Link to post
Share on other sites

This mod really opens your eyes to the hard work BIS put into the game. So much fun to use too.

Share this post


Link to post
Share on other sites

Any one got a non steam download link.. i cant download via workshop (its trolling me yet again)

Share this post


Link to post
Share on other sites

Dslyecxi's completely right, and to help illustrate his point, I temporarily added a line of code to draw icons above every recorded position:

http://i.imgur.com/EW3SCZc.jpg

In this image, the bullet on the left was fired at normal gamespeed, and the bullet on the right was fired at 0.1 gamespeed. To reiterate, the positions of active bullets are updated every time the game renders a frame. So at 60 FPS, there will be 60 of these icons, or 60 joints in the line for every second of travel. Note just how far apart these lines can get due to the high initial velocity of the bullet. and how a ricochet early on may cause misleading lines. Slowing the time improved this significantly however.

@Raven:

Here's a zip of the mission currently released on the Steam Workshop. Note that this is the editor folder of it, so you would place it with those missions and open it in the editor.

https://github.com/hypnomatic/ARMA_Examples/raw/master/Tracers%20Script/TracerExample_v0-0-1.Altis.zip

Also, worth noting that the code in this, and the mission released on the steam workshop, is a bit modified from the currently posted code. It's not nearly as clean behind the scenes as I would like, so I'm going to rewrite a few things before updating the code in the OP.

Also, the Steam Workshop mission has been updated with a few new features!

UPDATE 10/28/2013:

- Increased number of wooden panels, added a handful of other buildings and materials to test on. I'm going to release a more official testing ground at some point, but I didn't want to delay the release any longer.

- Now there is a desk featuring a laptop at which you may customize your settings! You can swap between several different modes of tracing bullets, to find the one that best suites your situation.

- Added the option to slow time. Activate the actions at the laptop, then use your action menu when you want to adjust time!

- I "think" I implemented multiplayer support. Don't have anyone online at the moment to test it with, however it in theory should work perfectly. Probably. If not, I'll surely have it fixed tomorrow.

If you notice any bugs or problems, please be sure to point them out!

Thanks!

Share this post


Link to post
Share on other sites

Great script, thanks for this.

I had to remove it from my test missions because I was spending too much time shooting bullets into things instead of testing the mission! :D

Share this post


Link to post
Share on other sites

Honestly one of my favourite bit if custom content for A3 yet. Maybe add an option within the laptop menu to add the option to spawn things such as people and objects? (for the steam version ofc)

Thanks again.

Share this post


Link to post
Share on other sites

If anyone wants those colors to be interpolated here is modified Draw3D handler.

Its useless and takes so much time to compute. D:

addMissionEventHandler ["Draw3D", {
   {
       private["_unit","_vecAddVec","_vecMulConst"];
       _vecAddVec = { // might be faster than bis's arbitrary array length functions
		_v1 = _this select 0;
		_v2 = _this select 1;
		[(_v1 select 0)+(_v2 select 0), (_v1 select 1)+(_v2 select 1), (_v1 select 2)+(_v2 select 2), (_v1 select 3)+(_v2 select 3)];    
	};
	_vecMulConst = {
		_v1 = _this select 0;
		_v2 = _this select 1;
		[(_v1 select 0)*_v2, (_v1 select 1)*_v2, (_v1 select 2)*_v2, (_v1 select 3)*_v2];    
	};
       _unit = _x;
       {
           private["_positions","_color","_muzzleVelocity"];
           _positions = _unit getVariable [format["hyp_var_tracer_projectile_%1", _x], []];
           _color     = _unit getVariable ["hyp_var_tracer_color", [1,0,0,1]];
           _muzzleVelocity = _positions select 0 select 1;

           //Colors from Dslyecxi's awesome color tracking modification            
           private ["_colors","_ratios","_startColor","_startRatio","_endColor","_endRatio"];					
		_colors = [ [1,0,0,1], [.5,.5,0,1], [0,1,0,1], [0,0,1,1], [1,1,1,1] ]; 
		_ratios = [ 1.0      , 0.75       , 0.5      , 0.25     , 0.0       ];

           for "_i" from 0 to (count _positions) - 2 do {

               if (_unit getVariable ["hyp_var_tracer_trackVel", false]) then {
                   private["_currentVelocity","_currentRatio"];
                   _currentVelocity = (_positions select _i) select 1;
                   _currentRatio = _currentVelocity / _muzzleVelocity;

				// find closest two points									
				for "_y" from 0 to (count _ratios -1) do {
					if(_ratios select _y>=_currentRatio) then {
						_startColor=_colors select _y;
						_startRatio=_ratios select _y;
					};
				};									
				for "_y" from (count _ratios) -1 to 0 step -1 do {
					if(_ratios select _y<=_currentRatio) then {
						_endColor=_colors select _y;
						_endRatio=_ratios select _y;
					};
				};

				// same color / ratio no need to interpolate															
				if(_startRatio==_endRatio) then {
					_color = _startColor;
				} else {
					// interpolate closest two points					
					_currentRatio = (_currentRatio-_endRatio) / (_startRatio-_endRatio); // scale ratio to 1,0 range   
                    _color =[
						([_startColor,_currentRatio] call _vecMulConst), 
						([_endColor,1-_currentRatio] call _vecMulConst)
					] call _vecAddVec;
				};

               };

               drawLine3D [_positions select _i select 0, _positions select (_i + 1) select 0, _color];
           };
       } forEach ( _unit getVariable["hyp_var_tracer_activeIndexes", []] );
   } forEach hyp_var_tracer_tracedUnits;
}];

It looks fancy though.

http://img200.imageshack.us/img200/406/66w.png

http://i.imgur.com/T14y3K6.png

Edited by aeroson

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

×