Gamestudio Links
Zorro Links
Newest Posts
Zorro tutorial ideas?
by mistery. 10/21/26 05:28
Avoid "log\ - delete old files" message
by Martin_HH. 10/20/26 07:23
Missing PnL files in zOpen child processes
by DonQuijote. 10/19/26 11:11
ZorroGPT
by TipmyPip. 10/15/26 08:28
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
2 registered members (mistery, henrybane), 5,957 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
JimSimons, julienp, julienper, KelleyAbbey, Yopachi
19246 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