Gamestudio Links
Zorro Links
Newest Posts
ZorroGPT
by TipmyPip. 02/26/26 21:35
WFO Training with parallel cores Zorro64
by Martin_HH. 02/26/26 16:03
Zorro version 3.0 prerelease!
by TipmyPip. 02/25/26 16:38
Camera always moves upwards?
by clonman. 02/21/26 09:29
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
5 registered members (TipmyPip, alx, Martin_HH, Enayn, 1 invisible), 5,131 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
the1, alx, ApprenticeInMuc, PatrickH90, USER0328
19200 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