Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
5 registered members (Dico, AndrewAMD, TipmyPip, NewbieZorro, Grant), 15,791 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
How to add wind to affect snow direction? #249491
02/02/09 20:13
02/02/09 20:13
Joined: Feb 2009
Posts: 11
T
ToyLetBowl Offline OP
Newbie
ToyLetBowl  Offline OP
Newbie
T

Joined: Feb 2009
Posts: 11
how do i incoporate the wind effect such that i can choose the wind direction to affect the diretion of snow?


Aye Carumba~
Re: How to add wind to affect snow direction? [Re: ToyLetBowl] #249496
02/02/09 20:43
02/02/09 20:43
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Use a vector which models the direction and the strength (through the length) of your wind. Then apply this time_step-scaled vector each frame on your snow particles.

Re: How to add wind to affect snow direction? [Re: HeelX] #249917
02/04/09 20:33
02/04/09 20:33
Joined: Feb 2009
Posts: 11
T
ToyLetBowl Offline OP
Newbie
ToyLetBowl  Offline OP
Newbie
T

Joined: Feb 2009
Posts: 11
Hi HeelX thanks for the reply but is it possible to help me with the coding as i am new to the programming world sorry for the trouble


Aye Carumba~
Re: How to add wind to affect snow direction? [Re: ToyLetBowl] #249959
02/05/09 07:42
02/05/09 07:42
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Hi, this should work:

Code:
VECTOR vecWind;
VECTOR vecWindTarget;

void weatherWind ()
{
	double directionChangeTimer = 0;
	double jitterTimer = 0;

	while (1) {

     	// Big direction and strength change after time
		if (directionChangeTimer <= 0) {

			directionChangeTimer = random(10) * 16; // Define new change interval

			// Rotate and scale target
			VECTOR* r = vector(15 - random(30), 15 - random(30), 0);
			ang_add(&vecWindTarget, r);
			vec_normalize(&vecWindTarget, 2 - random(1.5));
		}

		// Jitter
		if (jitterTimer <= 0) {

			jitterTimer = random(1) * 16; // Define new jitter interval

			// Slightly rotate the target vector
			VECTOR* r = vector(2 - random(4), 2 - random(4), 0);
			ang_add(&vecWindTarget, r);
		}

		// Let the wind vector smoothly transist towards the target vector
		vec_lerp(&vecWind, &vecWind, &vecWindTarget, 0.1 * time_step);

		// Count the timers down
		directionChangeTimer -= time_step;
		jitterTimer -= time_step;

		wait(1);
	}
}


Just call once the function and use the wind vector!


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1