Added new commands to alter flock dynamics in realtime. Updated README.md

pull/1/merge
Jak Daniels 2015-01-03 21:34:16 +00:00
parent 220d5de92b
commit 3f3cefc2ae
3 changed files with 123 additions and 24 deletions

View File

@ -89,23 +89,28 @@ namespace Flocking
}
public float MaxSpeed {
get {return m_maxSpeed;}
get {return m_maxSpeed;}
set { m_maxSpeed = value; }
}
public float MaxForce {
get {return m_maxForce;}
get {return m_maxForce;}
set { m_maxForce = value; }
}
public float NeighbourDistance {
get {return m_neighbourDistance;}
get {return m_neighbourDistance;}
set { m_neighbourDistance = value; }
}
public float DesiredSeparation {
get {return m_desiredSeparation;}
get {return m_desiredSeparation;}
set { m_desiredSeparation = value; }
}
public float Tolerance {
get {return m_tolerance;}
get {return m_tolerance;}
set { m_tolerance = value; }
}

View File

@ -264,7 +264,17 @@ namespace Flocking
} else if (cmd.StartsWith ("stats")) {
HandleShowStatsCmd (m_name, args);
} else if (cmd.StartsWith ("prim")) {
HandleSetPrimCmd (m_name, args);
HandleSetPrimCmd (m_name, args);
} else if (cmd.StartsWith("speed")) {
HandleSetMaxSpeedCmd(m_name, args);
} else if (cmd.StartsWith("force")) {
HandleSetMaxForceCmd(m_name, args);
} else if (cmd.StartsWith("distance")) {
HandleSetNeighbourDistanceCmd(m_name, args);
} else if (cmd.StartsWith("separation")) {
HandleSetDesiredSeparationCmd(m_name, args);
} else if (cmd.StartsWith("tolerance")) {
HandleSetToleranceCmd(m_name, args);
} else if (cmd.StartsWith ("framerate")) {
HandleSetFrameRateCmd (m_name, args);
}
@ -293,10 +303,15 @@ namespace Flocking
AddCommand ("enable", "", "Enable Birds Flocking", HandleEnableCmd);
AddCommand ("disable", "", "Disable Birds Flocking", HandleDisableCmd);
AddCommand ("size", "num", "Adjust the size of the flock ", HandleSetSizeCmd);
AddCommand ("stats", "", "show flocking stats", HandleShowStatsCmd);
AddCommand ("prim", "name", "set the prim used for each bird to that passed in", HandleSetPrimCmd);
AddCommand ("framerate", "num", "[debugging] only update birds every <num> frames", HandleSetFrameRateCmd);
}
AddCommand ("stats", "", "Show flocking stats", HandleShowStatsCmd);
AddCommand ("prim", "name", "Set the prim used for each bird to that passed in", HandleSetPrimCmd);
AddCommand ("speed", "num", "Set the maximum velocity each bird may achieve", HandleSetMaxSpeedCmd);
AddCommand("force", "num", "Set the maximum force each bird may accelerate", HandleSetMaxForceCmd);
AddCommand("distance", "num", "Set the maximum distance that other birds are to be considered in the same flock as us", HandleSetNeighbourDistanceCmd);
AddCommand("separation", "num", "How far away from other birds we would like to stay", HandleSetDesiredSeparationCmd);
AddCommand("tolerance", "num", "How close to the edges of things can we get without being worried", HandleSetToleranceCmd);
AddCommand("framerate", "num", "[debugging] only update birds every <num> frames", HandleSetFrameRateCmd);
}
private bool ShouldHandleCmd ()
{
@ -407,7 +422,72 @@ namespace Flocking
m_view.Clear();
}
}
}
}
public void HandleSetMaxSpeedCmd(string module, string[] args)
{
if (ShouldHandleCmd())
{
float maxSpeed = (float)Convert.ToDecimal(args[1]);
lock (m_sync)
{
m_model.MaxSpeed = maxSpeed;
m_log.InfoFormat("[{0}]: Birds maximum speed is set to {1} in region {2}.", m_name, maxSpeed, m_scene.RegionInfo.RegionName);
}
}
}
public void HandleSetMaxForceCmd(string module, string[] args)
{
if (ShouldHandleCmd())
{
float maxForce = (float)Convert.ToDecimal(args[1]);
lock (m_sync)
{
m_model.MaxForce = maxForce;
m_log.InfoFormat("[{0}]: Birds maximum force is set to {1} in region {2}.", m_name, maxForce, m_scene.RegionInfo.RegionName);
}
}
}
public void HandleSetNeighbourDistanceCmd(string module, string[] args)
{
if (ShouldHandleCmd())
{
float neighbourDistance = (float)Convert.ToDecimal(args[1]);
lock (m_sync)
{
m_model.NeighbourDistance = neighbourDistance;
m_log.InfoFormat("[{0}]: Birds neighbour distance is set to {1} in region {2}.", m_name, neighbourDistance, m_scene.RegionInfo.RegionName);
}
}
}
public void HandleSetDesiredSeparationCmd(string module, string[] args)
{
if (ShouldHandleCmd())
{
float desiredSeparation = (float)Convert.ToDecimal(args[1]);
lock (m_sync)
{
m_model.DesiredSeparation = desiredSeparation;
m_log.InfoFormat("[{0}]: Birds desired separation is set to {1} in region {2}.", m_name, desiredSeparation, m_scene.RegionInfo.RegionName);
}
}
}
public void HandleSetToleranceCmd(string module, string[] args)
{
if (ShouldHandleCmd())
{
float tolerance = (float)Convert.ToDecimal(args[1]);
lock (m_sync)
{
m_model.Tolerance = tolerance;
m_log.InfoFormat("[{0}]: Birds tolerance is set to {1} in region {2}.", m_name, tolerance, m_scene.RegionInfo.RegionName);
}
}
}
#endregion

View File

@ -29,7 +29,7 @@ provided which should be edited and copied to the correct place above.
Here is an example config:
;; Set the Birds settings per named region
;; Set the Birds settings per named region
[Test Region 1]
@ -51,7 +51,8 @@ Here is an example config:
Various runtime commands control the flocking module behaviour - described below. These can either be invoked
from the Console or in world by directing them to a chat channel. You can specify which channel to use in the .ini:
from the Console or in world by directing them to a chat channel either from the client's Local Chat or via a script.
You can specify which channel to use in the .ini:
BirdsChatChannel = 118 the chat channel to listen for Bird commands on
@ -59,18 +60,31 @@ from the Console or in world by directing them to a chat channel. You can specif
Runtime Commands
The following commands, which can either be issued on the Console, or via a chat channel in-world, control the behaviour
of the flock at runtime
The following commands, which can be issued on the Console or via in-world chat or scripted chat on the BirdsChatChannel
to control the birds at runtime:
birds-stop or /118 stop ;stop all birds flocking
birds-start or /118 start ;start all birds flocking
birds-enable or /118 enable ;enable the flocking simulation if disabled
birds-disable or /118 disable ;stop all birds and remove them from the scene
birds-size <num> or /118 size <num> ;change the size of the flock
birds-prim <name> or /118 prim <name> ;change the bird prim to one already rezzed in the scene
birds-framerate <num> or /118 framerate <num> ;only update the flock positions every <num> frames
;only really useful for photography and debugging bird
;behaviour
birds-stop or /118 stop ;stop all birds flocking
birds-start or /118 start ;start all birds flocking
birds-enable or /118 enable ;enable the flocking simulation if disabled
birds-disable or /118 disable ;stop all birds and remove them from the scene
birds-prim <name> or /118 prim <name> ;change the bird prim to a prim already rezzed in the scene
birds-stats or /118 stats ;show some statistics (needs work)
birds-framerate <num> or /118 framerate <num> ;only update the flock positions every <num> frames
;only really useful for photography and debugging bird
;behaviour
These commands are great for playing with the flock dynamics in real time:
birds-size <num> or /118 size <num> ;change the size of the flock
birds-speed <num> or /118 speed <num> ;change the maximum velocity each bird may achieve
birds-force <num> or /118 force <num> ;change the maximum force each bird may accelerate
birds-distance <num> or /118 distance <num> ;change the maximum distance that other birds are to be considered in the same flock as us
birds-separation <num> or /118 separation <num> ;sets how far away from other birds we would like to stay
birds-tolerance <num> or /118 tolerance <num> ;sets how close to the edges of things can we get without being worried
Of course if distance is less than separation then the birds will never flock. The other way around and they will always
eventually form one or more flocks.
Bird prims