Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 10:32
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
6 registered members (AndrewAMD, alibaba, fairtrader, ozgur, TipmyPip, Quad), 604 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 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 | chip programmers | 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