Jump to content
0Y0

Question about vector slope.

Recommended Posts

Hi all.

 

Such a question... We have a 3D vector. Which is located on a perfectly flat surface. 

 

Through the "surfaceNormal" command, we can find out the vector perpendicular to the surface. And with a perfectly flat surface, it is "[0,0,1]". The angle between our vector and the perpendicular vector to the surface must be constant.

And the question itself .. what to do if our surface is at an angle to the horizon?

 

 

Let me explain what I do. Here is a video where the fragments of the explosion are made of fish, for clarity.

The scattering of fragments has a certain structure. And I want that during explosions on an inclined surface, the scattering of fragments would remain in the same structure, but the whole structure should be parallel to the slope of the surface.

 

 

Share this post


Link to post
Share on other sites
58 minutes ago, pierremgi said:

Could you elaborate? What is your code for your explosion? Are you using setParticleParams? (see parameters, especially the last one)

 

 

No)

 

if ((!isServer) or (((agltoasl _this) select 2) < 0) or (PiR_frags_on == 0)) exitWith {}; 


params ["_position","_frag", "_count", "_speed", "_xv", "_yv", "_zv"];

_count = round ((10 + (random 10)) * PiR_frags_on); 

_position = [(_this select 0), (_this select 1), ((_this select 2))];

IF ((_position select 2) > 2) then {

	for "_i" from 1 to (_count) do {

	 _speed = 100 + (random 100);

	 _xv = selectrandom [random -1, random 1];
	 _yv = selectrandom [random -1, random 1];
	 _zv = selectrandom [random -1, random 1];		

		IF ( str (lineIntersectsSurfaces [agltoasl _position, agltoasl [((_position) select 0) + (_xv * 5),((_position) select 1) + (_yv * 5),((_position) select 2) + 0.05 + (_zv * 5)]]) == "[]") Then {

		 _frag = "PIR_frags_light" createVehicle _position;
		 _frag setpos [(_position select 0), (_position select 1), ((_position select 2) + 0.05)];;
		 _frag setvelocity [(_xv * _speed), (_yv * _speed), (_zv * _speed)];
		};
	};
} ELSE {

	for "_i" from 1 to (_count / 2) do {

	 _speed = 100 + (random 100);

	 _xv = selectrandom [random -1, random 1];
	 _yv = selectrandom [random -1, random 1];
	 _zv = abs ((sqrt ( _xv ^ 2 + _yv ^ 2)) * (tan (selectrandom [random 45, 180 - (random 45)])));		

		IF ( str (lineIntersectsSurfaces [agltoasl _position, agltoasl [((_position) select 0) + (_xv * 5),((_position) select 1) + (_yv * 5),((_position) select 2) + 0.05 + (_zv * 5)]]) == "[]") Then {

		 _frag = "PIR_frags_light" createVehicle _position;
		 _frag setpos [(_position select 0), (_position select 1), ((_position select 2) + 0.05)];;
		 _frag setvelocity [(_xv * _speed), (_yv * _speed), (_zv * _speed)];
		};
	};
};

 

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

×