Gamestudio Links
Zorro Links
Newest Posts
Camera always moves upwards?
by NeoDumont. 01/12/26 09:39
Alpaca Plugin v1.5.2 Release
by kzhao. 01/11/26 13:42
Alpaca Plugin v1.4.0
by kzhao. 01/11/26 13:38
separating groups of 3 digits by a comma
by joe_kane. 01/11/26 00:01
MRC.c and WFO
by joe_kane. 01/10/26 23:58
BarOffset (default = 940 for daily bars?
by joe_kane. 01/10/26 23:46
NOMAX undeclared identifier.
by Petra. 01/09/26 21:12
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (AndrewAMD, Quad), 3,103 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
promfast, joe_kane, Namitha_NN, Syndrela, agasior
19190 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