Update the ForestWindEmitter field: Direction
by Nils Eikelenboom · in Torque 3D Professional · 04/17/2013 (11:13 am) · 6 replies
I am trying to update the direction field of a ForestWindEmitter with for example:
But for some reason it doesn't work. All other fields like gustStrength, gustFrequency, etc. update just fine with this method. I thought this was defined in forestWindEmitter.cpp with mWindDirection or did I miss something?
myForestWindEmitter.direction = "1 0 0"; myForestWindEmitter.applyChanges();
But for some reason it doesn't work. All other fields like gustStrength, gustFrequency, etc. update just fine with this method. I thought this was defined in forestWindEmitter.cpp with mWindDirection or did I miss something?
#2
I have added this to that list:
No errors, but it still uses the default value "0 0 0". Is there perhaps anything more I can do to fix this?
04/17/2013 (12:22 pm)
Thanks @Richard,I have added this to that list:
addField( "direction", TypePoint3F, Offset( mWindDirection, ForestWindEmitter ), "The direction of the wind." );
No errors, but it still uses the default value "0 0 0". Is there perhaps anything more I can do to fix this?
#3
04/17/2013 (12:45 pm)
delete
#4

...it says ra-di-al!!! So I deleted the nonsense above.
Really shouldn't try to solve a problem at 4am
04/17/2013 (10:17 pm)
First I thought I had to turn it into a radial emitter to have a direction, but d'oh...
...it says ra-di-al!!! So I deleted the nonsense above.
Really shouldn't try to solve a problem at 4am
#5
04/18/2013 (8:20 am)
That depends - if 4am is the start of your day then it's acceptable. If 4am is the end of a 47 hour code-fest then it's probably not advisable....
#6
I took the radial emitter anyway and placed it outside the map. It's not that accurate as it would be with a global direction, but free beer for the ones that really notice :)
04/18/2013 (6:34 pm)
@Richard; The day was starting at 4am (Birds tweeting and all) but it was the end of my.I took the radial emitter anyway and placed it outside the map. It's not that accurate as it would be with a global direction, but free beer for the ones that really notice :)
function setWind(%scale, %direction)
{
if(isObject(theWind))
{
if(isObject(theTerrain))
{
// *** Wind scale settings ***
if(%scale < 0)
{
%scale = -%scale;
echo("No negative values for setWind()");
}
if(%scale > 12)
{
%scale = 12;
echo("12 is the maximum value for setWind()");
}
%prevScale = $windScale;
$windScale = %scale;
// *** Getting data ***
%wind = theWind.getID();
%terrain = theTerrain.getID();
%unit = %terrain.squareSize * %terrain.baseTexSize;
%unit *= 0.5;
%height = %unit / 2;
%radius = %unit * 6.5;
%position = 1 SPC 1 SPC %height;
$windRotation = "0 0"; // For GroundCover
// *** Wind Direction ***
switch$(%direction)
{
case "N":
%position = -%unit SPC %unit SPC %height;
$windRotation = "1 0";
case "NE":
%position = -%unit SPC 3*%unit SPC %height;
$windRotation = "1 -1";
case "E":
%position = %unit SPC 3*%unit SPC %height;
$windRotation = "0 -1";
case "SE":
%position = 3*%unit SPC 3*%unit SPC %height;
$windRotation = "-1 -1";
case "S":
%position = 3*%unit SPC %unit SPC %height;
$windRotation = "-1 0";
case "SW":
%position = 3*%unit SPC -%unit SPC %height;
$windRotation = "-1 1";
case "W":
%position = %unit SPC -%unit SPC %height;
$windRotation = "0 1";
case "NW":
%position = -%unit SPC -%unit SPC %height;
$windRotation = "1 1";
}
// echo("WindEmitter position: " @ %position);
// *** Update sound ***
%soundObj = $windSound;
%soundVol = %soundObj.getVolume();
%soundVol *= 100;
%soundFade = $windData[12,%scale];
%soundFade -= %soundVol;
%step = 100;
if(%soundFade > 50)
{
%step = 70;
}
soundFader(%soundObj, %soundVol, %soundFade, %step);
// *** Update wind emitter ***
%wind.position = %position;
%wind.windEnabled = "1";
%wind.strength = $windData[1,%scale];
%wind.radius = %radius;
%wind.gustStrength = $windData[2,%scale];
%wind.gustFrequency = $windData[3,%scale];
%wind.gustYawAngle = $windData[4,%scale];
%wind.gustYawFrequency = $windData[5,%scale];
%wind.gustWobbleStrength = $windData[6,%scale];
%wind.turbulenceStrength = $windData[7,%scale];
%wind.turbulenceFrequency = $windData[8,%scale];
%wind.applyChanges();
return true;
}
else
{
error("No terrain found for setWind()");
return false;
}
}
else
{
error("No existing ForestWindEmitter found for setWind()");
return false;
}
}
Torque Owner Richard Ranft
Roostertail Games
void ForestWindEmitter::initPersistFields() { // Initialise parents' persistent fields. Parent::initPersistFields(); addGroup( "ForestWind" ); addField( "windEnabled", TypeBool, Offset( mEnabled, ForestWindEmitter ), "Determines if the emitter will be counted in wind calculations." ); addField( "radialEmitter", TypeBool, Offset( mRadialEmitter, ForestWindEmitter ), "Determines if the emitter is a global direction or local radial emitter." ); addField( "strength", TypeF32, Offset( mWindStrength, ForestWindEmitter ), "The strength of the wind force." ); addField( "radius", TypeF32, Offset( mWindRadius, ForestWindEmitter ), "The radius of the emitter for local radial emitters." ); addField( "gustStrength", TypeF32, Offset( mWindGustStrength, ForestWindEmitter ), "The maximum strength of a gust." ); addField( "gustFrequency", TypeF32, Offset( mWindGustFrequency, ForestWindEmitter ), "The frequency of gusting in seconds." ); addField( "gustYawAngle", TypeF32, Offset( mWindGustYawAngle, ForestWindEmitter ), "The amount of degrees the wind direction can drift (both positive and negative)." ); addField( "gustYawFrequency", TypeF32, Offset( mWindGustYawFrequency, ForestWindEmitter ), "The frequency of wind yaw drift, in seconds." ); addField( "gustWobbleStrength", TypeF32, Offset( mWindGustWobbleStrength, ForestWindEmitter ), "The amount of random wobble added to gust and turbulence vectors." ); addField( "turbulenceStrength", TypeF32, Offset( mWindTurbulenceStrength, ForestWindEmitter ), "The strength of gust turbulence." ); addField( "turbulenceFrequency", TypeF32, Offset( mWindTurbulenceFrequency, ForestWindEmitter ), "The frequency of gust turbulence, in seconds." ); addField( "hasMount", TypeBool, Offset( mHasMount, ForestWindEmitter ), "Determines if the emitter is mounted to another object." ); endGroup( "ForestWind" ); }Note the conspicuous absense of "direction"....