Better weather system
by Blake LaPierre · in Torque Game Engine · 02/15/2003 (11:15 pm) · 10 replies
I'm going to start working on a better weather system than what is currently provided. I will be incorporating the tgeDayNight code into it(with some modifications that I have done).
What I have so far:
-Better looking rain, unless I'm doing something wrong(which I'm pretty sure I'm not) the rain that you can currently make is not so good. I'm thinking something along the lines of the Anarchy Online rain, or maybe one like Asheron's Call.
-Storm system. This will be the main part of my system. The user will be able to call in a storm that will bring in some storm clouds, lower the ambient light, start the raining, maybe bring in some fog. User will also need to be able to stop the rain and the clouds will clear up and it will be sunny again.
-Fog in the early morning. User can have fog appear in the early morning/dusk/sunrise or whenever actually.
Those are just some basics that I would like to have for my game. Any other ideas that you would like to see? Anyone want to help with anything? Send me an email at instinc1@gte.net if you would like to.
When I finish it this will be a resource for everyone.
What I have so far:
-Better looking rain, unless I'm doing something wrong(which I'm pretty sure I'm not) the rain that you can currently make is not so good. I'm thinking something along the lines of the Anarchy Online rain, or maybe one like Asheron's Call.
-Storm system. This will be the main part of my system. The user will be able to call in a storm that will bring in some storm clouds, lower the ambient light, start the raining, maybe bring in some fog. User will also need to be able to stop the rain and the clouds will clear up and it will be sunny again.
-Fog in the early morning. User can have fog appear in the early morning/dusk/sunrise or whenever actually.
Those are just some basics that I would like to have for my game. Any other ideas that you would like to see? Anyone want to help with anything? Send me an email at instinc1@gte.net if you would like to.
When I finish it this will be a resource for everyone.
#2
02/16/2003 (6:20 am)
Will you be building off of the existing (broken?) storm code?
#3
This includes the calls to turn on/off Stormclouds, Turn on/off stormfog.
The rest of the storm paramaters are call dependant.
02/16/2003 (11:05 am)
The current storm code isn't broken... it is missing the scripting components.This includes the calls to turn on/off Stormclouds, Turn on/off stormfog.
The rest of the storm paramaters are call dependant.
#4
02/16/2003 (11:49 am)
There is existing storm code? Where is it at? I haven't seen anyone talking about it or seen any resources on it so I didn't think it existed.
#5
holodeck.st.usm.edu/vrcomputing/vrc_t/tutorials/
I've made the snow and rain work, I got to lightning, but then got distracted.
The author of this tutorial complains about sound not working, this may or may not have been to do with the OpenAL compatibility issue with certain versions of Torque, although I've never had a problem, I haven't tried to get the sounds to work with this particular tutorial (e.g.: thunder)
Cheers,
James
02/16/2003 (2:33 pm)
Its called "precipitation". I found a howto on the web here:holodeck.st.usm.edu/vrcomputing/vrc_t/tutorials/
I've made the snow and rain work, I got to lightning, but then got distracted.
The author of this tutorial complains about sound not working, this may or may not have been to do with the OpenAL compatibility issue with certain versions of Torque, although I've never had a problem, I haven't tried to get the sounds to work with this particular tutorial (e.g.: thunder)
Cheers,
James
#6
02/16/2003 (2:57 pm)
No, there is actually 'some' storm code in the engine. I believe it's part of the sky class but I'm not sure on that.
#7
(I called the functions broken because on the HEAD I was using, causing storms to roll in made a LOT of debugging info come up... And the code didn't seem to work quite right... Weird fog activity and such.)
edit: The specific functions I'm talking about live in precipitation and are called updateStorm and startStorm. But mostly they live in terrain/sky.cc and they're called things like stormOn, stormOff, etc. (around line 255). They work... sort of. They're the key to dynamic weather, though.
02/16/2003 (10:41 pm)
Yeah, that sounds about right.(I called the functions broken because on the HEAD I was using, causing storms to roll in made a LOT of debugging info come up... And the code didn't seem to work quite right... Weird fog activity and such.)
edit: The specific functions I'm talking about live in precipitation and are called updateStorm and startStorm. But mostly they live in terrain/sky.cc and they're called things like stormOn, stormOff, etc. (around line 255). They work... sort of. They're the key to dynamic weather, though.
#8
However, rain doesn't take the rolling of the camera into account, and for some strange reason it comes inside buildings even when using portals.
Other then these bugs fixed I would offcourse love it to make this dynamic so you can call in a storm.
02/16/2003 (11:27 pm)
I have textured rain/snow with sound, textured lightning with sound and it can even strike the player. This with no engine changes at all. However, rain doesn't take the rolling of the camera into account, and for some strange reason it comes inside buildings even when using portals.
Other then these bugs fixed I would offcourse love it to make this dynamic so you can call in a storm.
#9
Just do a search for precipitation
02/17/2003 (12:12 am)
gee folks, with a little searching you can get all that working, even with sound and without inside buildings by just searching the resources - I have it all working on both Win and Mac...Just do a search for precipitation
#10
As for the debug info. That was in T2 also and you can edit the source to remove the output.
02/17/2003 (10:18 am)
Here is a random weather script I had origionally written for T2, it works for Torque also, you must provide the WAV files and .DML /Texture files.As for the debug info. That was in T2 also and you can edit the source to remove the output.
datablock AudioProfile(Universal_Rain_Light_1)
{
filename = "~/data/sounds/rain_light_1.wav";
description = AudioLooping2d;
};
datablock PrecipitationData(Rain)
{
type = 0;
soundProfile = "Universal_Rain_Light_1";
materialList = "~/data/images/raindrops.dml";
sizeX = 0.2;
sizeY = 0.45;
movingBoxPer = 0.35;
divHeightVal = 1.5;
sizeBigBox = 1;
topBoxSpeed = 20;
frontBoxSpeed = 30;
topBoxDrawPer = 0.5;
bottomDrawHeight = 40;
skipIfPer = -0.3;
bottomSpeedPer = 1.0;
frontSpeedPer = 1.5;
frontRadiusPer = 0.5;
};
datablock PrecipitationData(Rain1)
{
type = 0;
materialList = "~/data/images/raindrops.dml";
sizeX = 0.2;
sizeY = 0.45;
movingBoxPer = 0.35;
divHeightVal = 1.5;
sizeBigBox = 1;
topBoxSpeed = 20;
frontBoxSpeed = 30;
topBoxDrawPer = 0.5;
bottomDrawHeight = 40;
skipIfPer = -0.3;
bottomSpeedPer = 1.0;
frontSpeedPer = 1.5;
frontRadiusPer = 0.5;
};
datablock PrecipitationData(Snow)
{
type = 1;
materialList = "~/data/images/snowflakes.dml";
sizeX = 0.20;
sizeY = 0.20;
movingBoxPer = 0.35;
divHeightVal = 1.5;
sizeBigBox = 1;
topBoxSpeed = 20;
frontBoxSpeed = 30;
topBoxDrawPer = 0.5;
bottomDrawHeight = 40;
skipIfPer = -0.3;
bottomSpeedPer = 1.0;
frontSpeedPer = 1.5;
frontRadiusPer = 0.5;
};
function Sky::setStormClouds(%obj, %inStartT, %inLengthT, %outStartT, %outLengthT)
{
if(%inStartT < %outStartT)
%obj.stormCloudsShow(false);
else
%obj.stormCloudsShow(true);
%obj.schedule(%inStartT*1000, "stormClouds", 1, %inLengthT);
%obj.schedule(%outStartT*1000, "stormClouds", 0, %outLengthT);
}
function Sky::setStormFog(%obj, %inStartT, %inLengthT, %inPer, %outStartT, %outLengthT, %outPer)
{
if(%inStartT < %outStartT)
%obj.stormFogShow(false);
else
%obj.stormFogShow(true);
%obj.schedule(%inStartT*1000, "stormFog", %inPer, %inLengthT);
%obj.schedule(%outStartT*1000, "stormFog", %outPer, %outLengthT);
}
function Precipitation::setStorm(%obj, %inStartT, %inLengthT, %inPer, %outStartT, %outLengthT, %outPer)
{
if(%inStartT < %outStartT)
%obj.stormShow(false);
else
%obj.stormShow(true);
%obj.schedule(%inStartT*1000, "stormPrecipitation", %inPer, %inLengthT);
%obj.schedule(%outStartT*1000, "stormPrecipitation", %outPer, %outLengthT);
}
function newStorm()
{
%stormstart = getrandom(120);
%stormend = %stormstart + getrandom(120,240);
%rainstart = %stormstart + getrandom(35,90);
%lightstart = %stormstart + getrandom(0,45);
%lightning = getrandom(100);
%drops = getrandom(1000,4000);
%radius = getrandom(80,150);
echo("End: " @ %stormend @ " Start: " @ %stormstart @ " Rain: " @ %rainstart @ " LStart: " @ %lightstart @ " Lightning: " @ %lightning);
%ma = nametoid(MissionArea);
%x = getword(%ma.area,0);
%y = getword(%ma.area,1);
%w = getword(%ma.area,2);
%h = getword(%ma.area,3);
%x1 = %x + (%w/2);
%y1 = %y + (%h/2);
%z1 = 200;
%obj = new Precipitation(Precipitation) {
position = %x1 SPC %y1 SPC %z1;
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "Rain1";
lockCount = "0";
homingCount = "0";
percentage = "1";
color1 = "0.400000 0.450000 0.480000 1.000000";
color2 = "-1.000000 0.000000 0.000000 1.000000";
color3 = "-1.000000 0.000000 0.000000 1.000000";
offsetSpeed = "0.25";
minVelocity = "1.25";
maxVelocity = "4";
maxNumDrops = %drops;
maxRadius = %radius;
};
MissionGroup.add(%obj);
%obj.stormShow(false);
Sky.setStormClouds(%stormstart, 60, %stormend, 60);
Sky.setStormFog(%stormstart, 60, 1, %stormend, 40, 0);
Precipitation.setStorm(%rainstart, 30, 1, %stormend, 40, 0);
%obj.schedule(%rainstart*1000,"soundon",%stormend);
%obj.schedule((%stormend+40)*1000,"delete");
if(%lightning <= 50){
%obj.schedule(%lightstart*1000,"newlightning",%stormend,(%rainstart-%lightstart));
}
schedule((%stormend+60)*1000,0,"newstorm");
}
function Precipitation::soundon(%this,%stormend)
{
%ma = nametoid(MissionArea);
%x = getword(%ma.area,0);
%y = getword(%ma.area,1);
%w = getword(%ma.area,2);
%h = getword(%ma.area,3);
%x1 = %x + (%w/2);
%y1 = %y + (%h/2);
%w1 = %w * 1.5;
%h1 = %h * 1.5;
%z1 = 200;
%z2 = 300;
%obj = new AudioEmitter(Rain) {
position = %x1 SPC %y1 SPC %z1;
rotation = "1 0 0 0";
scale = "1 1 1";
profile = "Universal_Rain_Light_1";
useProfileDescription = "1";
outsideAmbient = "1";
volume = "1";
isLooping = "1";
is3D = "0";
minDistance = "20";
maxDistance = "100";
coneInsideAngle = "360";
coneOutsideAngle = "360";
coneOutsideVolume = "1";
coneVector = "0 0 1";
loopCount = "-1";
minLoopGap = "0";
maxLoopGap = "0";
type = "EffectAudioType";
};
MissionGroup.add(%obj);
%obj.schedule(%stormend*1000,"delete");
}
function Precipitation::newlightning(%this,%stormend,%rainstart)
{
%strikes = getrandom(2,10);
%ma = nametoid(MissionArea);
%x = getword(%ma.area,0);
%y = getword(%ma.area,1);
%w = getword(%ma.area,2);
%h = getword(%ma.area,3);
%x1 = %x + (%w/2);
%y1 = %y + (%h/2);
%w1 = %w * 1.5;
%h1 = %h * 1.5;
%z1 = 200;
%z2 = 300;
%obj = new Lightning() {
position = %x1 SPC %y1 SPC %z1;
rotation = "1 0 0 0";
scale = %w1 SPC %h1 SPC z2;
dataBlock = "DefaultStorm";
lockCount = "0";
homingCount = "0";
strikesPerMinute = %strikes;
strikeWidth = "2.5";
chanceToHitTarget = "0.5";
strikeRadius = "20";
boltStartRadius = "20";
color = "1.000000 1.000000 1.000000 1.000000";
fadeColor = "0.100000 0.100000 1.000000 1.000000";
useFog = "1";
};
MissionGroup.add(%obj);
%obj.schedule((%stormend+40)*1000,"delete");
%obj.schedule(%rainstart*1000,"varyspm");
}
function lightning::varyspm(%this)
{
%strikes = getrandom(2,30);
%rndtime = getrandom(15,30);
%this.strikesPerMinute = %strikes;
%this.schedule(%rndtime*1000,"varyspm");
}
Torque Owner Very Interactive Person