<?xml version="1.0" ?>
<ForceFieldFunctions>
	<ForceField Name="Empty">
		<Radius Name="1"
			Position="5,0,0" >Not assigned</Radius>
		<Radius Name="2"
			Position="5,5,0" >Not assigned</Radius>
		<Radius Name="3"
			Position="-5,0,0" >Not assigned</Radius>
		<Description>Zero force. Use it to start with an empty function</Description>
		<Function>
function CalculateForce()
   -- Function must return a vector, which is a force
   return CVector.ZERO;
end</Function>
	</ForceField>
	<ForceField Name="Pushing away from the center">
		<Radius Name="1" Position="0,80,0" >Maximum strength</Radius>
		<Radius Name="2" Position="50,0,0" >Radius of the affected area</Radius>
		<Radius Name="3" Position="-5,0,0" >Not used</Radius>
		<Description>This force field pushes everything away from the center. The closer to the center of the field an object is, the larger the force is.</Description>
		<Function>function CalculateForce()
  -- Get distance from the center
  Distance = FieldCenter - Pos;
  -- Nothing to do if it is too far
  if(Distance:length() > Radius2)then return CVector.ZERO; end;
  -- Copy to get the direction
  Dir = CVector(Distance);
  -- Make it a unit vector
  Dir:normalize();
  -- Return strength inversely proportional to the distance from the center
  return -Dir * Radius1 / Distance:length();
end</Function>
	</ForceField>
	<ForceField Name="Pulling toward the center">
		<Radius Name="1" Position="0,80,0" >Maximum strength</Radius>
		<Radius Name="2" Position="50,0,0" >Outer radius of the affected area</Radius>
		<Radius Name="3" Position="-5,0,0" >Inside radius of the affected area</Radius>
		<Description>This force pulls everything in toward the center. The closer to the center of the field an object is, the larger the force is.</Description>
		<Function>function CalculateForce()
  -- Get distance from the center
  Distance = FieldCenter - Pos;
  -- Nothing to do if it is too far
  if(Distance:length() &gt; Radius2 or Distance:length() &lt; Radius3)then return CVector.ZERO; end;
  -- Copy to get the direction
  Dir = CVector(Distance);
  -- Make it a unit vector
  Dir:normalize();
  -- Return strength inversely proportional to the distance from the center
  return Dir * Radius1 / Distance:length();
end</Function>
	</ForceField>
	<ForceField Name="Wind in a given direction">
		<Description>Creates wind in a given direction.

Use Radius1 to set the direction and strength of the wind.</Description>
		<Function>-- CONSTANT_FUNCTION --
function CalculateForce()
  -- Direction of the wind depends on the position of the Radius1
  Direction = Radius1Pos - FieldCenter;
  -- Make it a direction 
  Direction:normalize();
  -- Strength of the field depends on the Radius1
  return Direction * Radius1 * 0.1;
end
</Function>
		<Radius Name="1" Position="60,0,0">Direction and strength of the wind</Radius>
		<Radius Name="2" Position="-5,0,0">Not used</Radius>
		<Radius Name="3" Position="0,-5,0">Not used</Radius>
	</ForceField>
	<ForceField Name="Wind from right to left">
		<Description>Wind from right to left.

This wind adds stability to the canopy, but if it's too strong it will push the canopy back.

Radius1 changes the strength of the wind.</Description>
		<Function>-- CONSTANT_FUNCTION --
function CalculateForce()
	return - CVector.UNIT_X * Radius1 * 0.1;
end</Function>
		<Radius Name="1" Position="0,-30,0">Wind strength</Radius>
		<Radius Name="2" Position="-5,-5,0">Not used</Radius>
		<Radius Name="3" Position="5,-5,0">Not used</Radius>
	</ForceField>
	<ForceField Name="Circular">
		<Radius Name="1" Position="0,80,0" >Strength of the wind</Radius>
		<Radius Name="2" Position="50,0,0" >Outside radius of the affected area</Radius>
		<Radius Name="3" Position="10,0,0" >Inside radius of the affected area</Radius>
		<Description>This force field creates a wind that moves in a circle around the center.
Use Radius1 to set the speed of the wind. Use Radius2 to set the radius of the affected area.

Remove minus in the return section to make rotation counter-clockwise.</Description>
		<Function>function CalculateForce()
  -- Get distance from the center
  Distance = FieldCenter - Pos;
  -- Nothing to do if it is too far
  if(Distance:length() &gt; Radius2 or Distance:length() &lt; Radius3)then return CVector.ZERO; end;
  -- Cross product between the Distance and UNIT_Z
  -- will give the direction of the force
  Dir = Distance:cross(CVector.UNIT_Z);
  -- Make it a direction
  Dir:normalize();
  -- Return strength inversely proportional to the distance from the center
  return - Dir * Radius1 * 0.1;
end</Function>
	</ForceField>
	
	<ForceFieldTiming Name="Constant">
		<Description>No change with the time</Description>
		<Function>function Update()
	-- Does not return anything
end</Function>
	</ForceFieldTiming>
	<ForceFieldTiming Name="Sinus wave">
		<Description>Changing wind strength with a period</Description>
		<Function>
-- Assuming that Radius1 controls the strength of the wind
-- NOTICE: movement of Radius1 will not affect the oscillations any more,
-- unless this dialog is shown again, but movement of Radius3 should change,
-- the period of oscillation.
MaxFieldStrength = Radius1;
-- Period of the sin wave in seconds
Period = Radius3;
function Update()
    Radius1 = MaxFieldStrength * math.sin(Time * Period * 0.1);
end</Function>
	</ForceFieldTiming>
</ForceFieldFunctions>
