Jump to content

Recommended Posts

Guest

Hello guys,

It's me again with my dumb questions.

As I saw recently a topic about snow I was wondering why Arma does not have some. If I remember well VBS support it (YouTube showcases) so why not Arma ?

There are already few systems out there that uses script that spawns particles but don't get me wrong this is huge gpu consumming and an fps killer. And it causes problems like in buildings. So I know all the rendering are client sided that's obvious but can we port all the calculations on the server side like not spawning snow in buildings but keep spawning it outside etc. Since some objects have physx why not use a physx object representing a snowflake then spawn it far in the sky an appling a random velocity depending on the wind. The objects will be stopped by building rooftops and it will act way more like real snow.

Well, that was just to talk about snow. :)

Kisses from a wild snowy baguette. #nohomo

Share this post


Link to post
Share on other sites

I wonder what performance will we get, when we create snowflakes with createSimpleObject and custom *.p3d files.

Share this post


Link to post
Share on other sites
Guest

Yeah, that could be something to try but if I remeber well createSimpleObject has no physx.

Share this post


Link to post
Share on other sites

Yeah, that could be something to try but if I remeber well createSimpleObject has no physx.

 

Supported features include collision. You don't need physx, you dont need to interact with it. I mean, snow will be more like rain, just for atmosphere / effect. You dont need to create snowballs from it, or do you ?

Share this post


Link to post
Share on other sites
Guest

Supported features include collision. You don't need physx, you dont need to interact with it. I mean, snow will be more like rain, just for [/size]atmosphere / effect. You dont need to create snowballs from it, or do you ?

Right. :D

Edit : Still there will be a lot of objects, I really wonder how Arma could handle that.

Share this post


Link to post
Share on other sites

Here is little snipped to check snow with createSimpleObject

 

usage:

[player] execVM "snow.sqf";

snow.sqf

params ["_object"];

while { true } do 
{
    _radius = random 15; //adjust radius
    _height = 15 + random 10; //adjust height

    _position = [(getPos _object select 0) + (sin (random 360)) * _radius, (getPos _object select 1) + (cos (random 360)) * _radius, (getPos _object select 2) + _height];
    _snowflake = createSimpleObject ["a3\weapons_f\ammo\Handgrenade.p3d", _position];

    _objects = lineIntersectsWith [ 
        [(getPosASL _snowflake) select 0, (getPosASL _snowflake) select 1, (getPosASL _snowflake) select 2], 
        [(getPosASL _snowflake) select 0, (getPosASL _snowflake) select 1, 0], 
        _snowflake, 
        _snowflake,
        false
    ];

    if(count(_objects) > 0) then 
    { 
        deleteVehicle _snowflake; 
    }
    else 
    {
        [_snowflake] spawn 
        {
            params ["_snowflake"];
            while { !isTouchingGround _snowflake } do 
            {
                _snowflake setPos [getPos _snowflake select 0, getPos _snowflake select 1, (getPos _snowflake select 2) - 0.01];
                sleep 0.01;
            };
            deleteVehicle _snowflake; 
         };
    };

    sleep 0.1;
};

I am open to suggestions, improvements. 

Share this post


Link to post
Share on other sites

I'd like to hear a status report from someone testing it out â†â†â†â†â†â†â†â†â†â†

Share this post


Link to post
Share on other sites
Guest

Nade rain :DDD

Share this post


Link to post
Share on other sites
Guest

So you are setting the pos yourself. That's why I was talking about physx with gravity.

Share this post


Link to post
Share on other sites

So you are setting the pos yourself. That's why I was talking about physx with gravity.

 

If simple object had physx, then solution would be simplier, as we can use this:

_snowflake addEventHandler ["EpeContact", { deleteVehicle _this select 0; }];

where if snowflake is in collision with something (hit roof of building or tree), it will delete it self (perish).

Share this post


Link to post
Share on other sites
Guest

Yeah and for the movement part a little setVelocity with a random factor to imitate the wind ;)

Share this post


Link to post
Share on other sites

Killzone_kid had video with snow NOT falling in buildings. But he did not share. Tho I think his method is heavy on performance so thats why he did not released it.

Share this post


Link to post
Share on other sites

Nice, would love to see the video. Wish someone better at coding than me could figure this out. Did he post how he did it somewhere?

Share this post


Link to post
Share on other sites

Wow that looks perfect.. And doesn't seem laggy at all? Would love to try this out. You think you can get the codes from him?

Share this post


Link to post
Share on other sites

Yeah i have tried it. But it still snows in buildings i think. Also i'm not really looking for snow storms but just subtle snowing.

Share this post


Link to post
Share on other sites

Blatant promotion: TPW MODS (TPW FOG) has a snow function which spawns snowflakes around the player as long as the player is not in a building.  

 

Here's modified version which doesn't rely on the other variables in TPW FOG. 

//SNOW FX    
tpw_fog_fnc_snow =
    {
    private ["_pos","_highpos","_snowemitter"];    
    while {true} do
        {
        if (overcast > 0.4 && alive player) then 
            {
            0 setrain 0;
            _pos = eyepos player;
            _highpos = [_pos select 0,_pos select 1,(_pos select 2) + 10];
            if (!(lineintersects [_pos,_highpos]) || vehicle player != player || (eyepos player) select 2 < 0) then 
                {
                _snowEmitter = "#particlesource" createVehicleLocal getpos player;
                _snowEmitter setParticleCircle [0.0, [0, 0, 0]];
                _snowEmitter setParticleRandom [0, [10, 10, 7], [0, 0, 0], 0, 0.01, [0, 0, 0, 0.1], 0, 0];
                _snowEmitter setParticleParams [["\A3\data_f\ParticleEffects\Universal\Universal", 16, 12, 13,1], "","Billboard", 1, 7, [0,0,0], [0,0,0], 1, 0.0000001, 0.000, 1.7,[0.07],[[1,1,1,1]],[0,1], 0.2, 1.2, "", "", vehicle player];
                _snowEmitter setDropInterval 0.001;  
                _snowEmitter attachto [vehicle player,[0,0,8]];
                sleep 2;
                deletevehicle _snowemitter;
                };
            };
        sleep 1;    
        };    
    };

Hope this helps.

  • Like 2

Share this post


Link to post
Share on other sites

Yes, but when player enter building the snow stop falling, so when you enter for example a small hut, snow just dissapear and when go out it will start. That is not realistic. Snow must fall outside, when you are in building, that is "discussion" in this thread.

Share this post


Link to post
Share on other sites

Ahh my bad, didn't get exactly what you were asking. Please forgive me for @#$%ing trying.

 

I guess a system that switched to placing numerous small snow particle emitters around the bounding box of a building when  player entered it would work, but would indeed be a bit heavier.

Share this post


Link to post
Share on other sites

Killzone_kid's script looks perfect. I read on his vid's that he haven't released it because it wasn't finished. But that was two years ago.. If anyone could get in contact with him that would be great. I tried writing him a message on youtube but haven't gotten an answer yet..

Share this post


Link to post
Share on other sites

So I had a play around a bit more and the following code works pretty well and doesn't hammer the CPU too hard. Instead of spawning a single large snow emitter around the player and switching it off if the player is undercover, it now updates multiple positions around the player and spawns a smaller snow emitter at each position if the position is not under cover. It's a bit of a balancing act and not 100% perfect, occasionally you'll see a snowflake inside.

 

I'll be incorporating this concept into TPW FOG shortly, but feel free to knock yourself out in the mean time.

// Localised snow emitter
fnc_emitter =
	{
	private ["_pos","_logic","_snowemitter"];
	_pos = _this select 0;
	_logic = "logic" createVehicleLocal getpos player;
	_snowEmitter = "#particlesource" createVehicleLocal getpos player;
	_snowEmitter attachto [_logic,[0,0,0]];
	_snowEmitter setParticleCircle [0.0, [0, 0, 0]];
	_snowEmitter setParticleRandom [0, [4,4,4], [0, 0, 0], 0, 0.01, [0, 0, 0, 0.1], 0, 0];
	_snowEmitter setParticleParams [["\A3\data_f\ParticleEffects\Universal\Universal", 16, 12, 13,1], "","Billboard", 1, 7, [0,0,0], [0,0,0], 1, 0.0000001, 0.000, 1.7,[0.07],[[1,1,1,1]],[0,1], 0.2, 1.2, "", "", _logic];
	_snowEmitter setDropInterval 0.01;  
	_logic setposasl _pos;
	sleep 0.5;
	deletevehicle _snowemitter;
	deletevehicle _logic; 	
	};

// Main loop			
_rad = 0;			
private ["_lowpos","_highpos","_spawnpos","_pos","_cover","_posx","_posy","_dist","_dir"];		
while {true} do
	{
	// Is player under cover?
	_pos = eyepos player;
	_cover = _pos vectoradd [0,0,30];
	if (lineintersects [_pos,_cover] || vehicle player != player) then
		{
		_rad = 12; // spawn emitters further away if under cover
		} else
		{
		_rad = 0;
		};
	
	// Random position for emitter
	_dir = random 360;
	_dist = _rad + random 25;
	_posx = _dist * sin _dir;
	_posy = _dist * cos _dir;

	// Is emitter spawn position under cover?	
	_lowpos = _pos vectoradd [_posx,_posy,0];
	_highpos = _pos vectoradd [_posx,_posy,30];
	if (!lineintersects [_lowpos,_highpos]) then
		{
		_spawnpos = _pos vectoradd [_posx,_posy,4];
		[_spawnpos] spawn fnc_emitter;
		};
	sleep 0.1;		
	};	

 

  • Like 1

Share this post


Link to post
Share on other sites

Nice good job, you kinda made it work. But FOR MY taste it's still too obvious how it spawn in. Check this one out:

 

 

I don't know whats possible to do with cpu in mind, but Killzone_kid's and this script seems to run very nicely while you don't seem to see the snow spawning in at all.

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

×