<crowd> ‐ A crowd of interacting agents controlled by targets and obstacles
Name | Type | Defaults |
---|---|---|
id | ID | None (required) |
size | INTEGER | None (required) |
nbSteps | INTEGER | None (required) |
source_choice | STRING (random, sequential) | random |
target_choice | STRING (random, sequential) | random |
linear_step | FLOAT | None (required) |
sociability | FLOAT | None (required) |
minimal_vital_space | FLOAT | None (required) |
move_3D | STRING | false |
rotation_amplification | FLOAT | None (required) |
update_rate | INTEGER | None (required) |
interaction | STRING (false, contact) | false |
interaction_threshold | FLOAT | 0.0 |
selection_threshold | FLOAT | 0.0 |
wanted_agent | INTEGER | 0 |
The element crowd defines a crowd of agents. The integer value of the size attribute defines the number of agents contained in the crowd.
Each agent is defined by its location on a terrain that is either a sphere or a quad in the current version of VC. On a quad terrain, the motion is a flat motion, while it is a spherical one on a sphere.
The motion of an agent on the terrain begins at its source. First, the agent reaches a list of intermediary targets, one after another in a sequential order. Then its ultimate goal is its final target. When the agent reaches its final target, it resumes its motion by starting again from its source as many times as its number of cycles (see Figure 5-5). The integer value nbSteps of the nbSteps attribute defines the number of targets reached by an agent in a single cycle (nbSteps-1 intermediary targets and one final target). In Figure 5-5, the agent cycle is made of four steps: three intermediary targets and one final target.
Quad obstacles can be used to block the motion of an agent on its way to a target or to an intermediary target. The agent will make use of avoidance strategies to walk round the obstacle and reach its goal. If the agent has no goal (no final target), obstacles can be used to restrict its motion to a limited area.
To sum up, the element crowd must have elements in its scope in order to define the target motion of its agents:
The element obstacles defines volumes that will block the motion of a crowd. This element has one integer attribute size that defines the number of leaf nodes expected as child nodes of this element. The vertical projections of the volumes' bounding boxes are used to control the agent motions.
The element sources defines quads that will be used as locations for starting the motion of an agent. This element has one integer attribute size that defines the number of quad nodes expected as child nodes of this element. The exact location of the birth is a randomly chosen point inside the source quad.
The element intermediary targets define volumes that will serve as temporary targets to the agents of a crowd, before they reach their final target. This element has one integer attribute size that defines the number of leaf nodes expected as child nodes of this element. The vertical projections of the volumes' bounding boxes are used to compute the remaining distance between an agent and its target.
The element targets defines volumes that will serve as final targets to the agents of a crowd. This element has one integer attribute size that defines the number of leaf nodes expected as child nodes of this element. The vertical projections of the volumes' bounding boxes are used to compute the remaining distance between the agent and its target.
The element terrain defines a surface that will serve as motion support for the agents of a crowd. This element expects a either a sphere or a quad as child node. The agent motion is defined with respect to the type of motion support: a quad terrain entails plane motion, whereas a sphere entails a spherical motion.
Each agent in a crowd has (1) a source, the place where it will be located at its birth, (2) an optional target, its final goal, and (3) optional intermediary targets, its intermediary goal(s). Since the number of sources, targets, and intermediary targets can be different from the number of agents and since there is no explicit mapping from agents to sources, there is an automatic procedure for the assignment of sources, targets, and intermediary targets to agents.
Two modes of assignment are chosen: random or sequential. The string of the attributes source_choice and target_choice define the assignment mode chosen respectively for sources, and for targets and intermediary targets. In the random mode a source or target number is randomly chosen between 1 and the number of sources or targets. These numbers are given by the size attributes of the child elements, respectively, sources, intermediaryTargets, and targets (see previous section). In the sequential mode, source or target numbers are sequentially selected: agent number n is assigned source or target number n modulus the number of sources or targets.
The case of intermediary targets is slightly different. First, the number of intermediary targets per step must be calculated: it is the total number of intermediary targets divided by the number of steps (nbSteps attribute) minus 1. For instance, if the number of steps is 4 and the number of intermediary targets is 15 (our example below), the number of intermediary targets per step is 5. Then the selection of the intermediary targets is performed as above but in a step by step fashion. In our example, the intermediary targets for step 1 are chosen between 1 and 5, for step 2 between 6 and 10, and for step 3 between 11 and 15.
The number of cycles made by each agent is defined by the element cycleDistribution. This element has one integer attribute size that defines the number of pairs of integers expected as content of this element. Each pair is made of a number of cycles followed by a number of agents. The pair 2/800 means that 800 agents will make two cycles. The total of the numbers of agents must be equal to the number of agents contained in the crowd, the value of the attribute size of the crowd element. In the example below, there are 1000 agents, 100 will make one cycle, 800 will make 2, and 100 will make 3.
To sum up, the element crowd must have the following element in its scope in order to define the distribution of the cycle numbers:
The element cycleDistribution gives the size of the groups of agents that have the same number of cycles. Its content is made of pairs of integers: size of the group/number of cycles of agents in this group. This element has one integer attribute size that defines the number of agent groups.
The local motion of an agent is such that it comes closer to its current target if it has a target, or it is a random variation from its current direction if it does not have any target. The value of the elementary step that represents the distance between its current position and its new position is defined by the float value of the linear_step attribute.
This goal-oriented motion is however modified by obstacles and interactions with other agents. In case of obstacles, the agent tries to move sideways in order to avoid the obstacle. In the case of agent interaction, the agent tries to avoid or to come closer to other agents, depending on its own nature.
An agent can either be attractive or repulsive. In the first case it tries to come closer to its nearest neighbor, while in the second case, it tries to move away from it. The ratio of attractive agents is defined by the float value of the sociability attribute. It represents the percentage of attractive agents: if this value is equal to 1.0, all the agents are attractive, and if this value is equal to 0.0, all the agents are repulsive.
In the case of an attractive agent, and additional parameter is taken into account, the float value of the minimal_vital_space attribute. An attractive agent tries to get closer to its closest neighbor unless its distance to its nearest neighbor is lower than this minimal threshold.
If the value of the move_3D attribute is true, the agent can move above or under the crowd terrain. It will however modify it height when it comes close to a target in order to reach its target height. If the value is above_terrain, vertical motion will be restricted to positive y values. If the value is under_terrain, vertical motion will be restricted to negative y values. If the value of the move_3D attribute is false, vertical motion is not possible.
The value of the rotation_amplification is a multiplicative factor that controls the orientation of the agent with respect to its target. If its value is equal to 1.0, the agent faces its motion direction. If its value is equal to 0.0, the agent moves facing a constant direction.
The graphical aspect of an agent is defined by the media-objects embedded in the element child. The element element contains the nodes that will be displayed in turn to render the agents animation. The integer value size of the attribute size of this element defines the number of key positions. In addition, the integer value element_states of the attribute element_states of this element defines the number of states that this agent can have, and thus its number of graphical aspects.
An agent is animated by defining a set of size nodes that represent the agent in size key positions. These nodes are displayed in turn in a cyclic way from node 1 to node size. The change of key position is made every update_rate frame (the value of the attribute update_rate). The agent has the same number of key positions in each of its states. Thus, size×element_states nodes are necessary to animate an agent through size key positions in element_states states.
The default value for the attribute element_states is 1 and there can be up to four states. The first one corresponds to the agent in its normal state, the second one represents it in its selectable state (when the user is closer to the agent than the selection threshold), the third one represents it in its selected state (when the user is closer to the agent than the interaction threshold, and the agent exchanges information with the user), and last, the fourth state corresponds to a killed element.
The element element must contain size×element_states nodes. The first size nodes are used to display the agent in its normal state, the nodes from size+1 to 2×size are used to display the agent in its selectable state, etc.
In order to avoid uniformity in agent animation, the rank of the first key position displayed when an agent is activated is randomly chosen between 1 and the number of key positions.
Each crowd has a schedule element that defines the initialization of agent motion and its termination mode. The values of the begin and dur attributes define the beginning and the duration of agent initialization. The function of time is used to control the number of agents activated at a certain time. The before and fill attributes are used to control the appearance of agents before and after their activation, as for any other node controlled by a scheduler.
To sum up, the element crowd must have the following elements in its scope in order to define the graphic animation of its agents:
The element schedule defines the number of activated agents as a function of time. It also defines the visual aspects of the agents before and after their activation.
The element element defines the set of nodes that will be displayed in turn in order to render the animation of the agents. This element has two integer attributes: size defines the number of key positions and element_states defines the number of possible states for agents in this crowd.
VC allows for an interaction mechanism with agents in a crowd controlled by the distance between the agents and the current user. The interaction is aimed at recognizing a preselected agent inside a crowd.
The string attribute interaction can have two values false and contact. In the first case, no interaction with agents is possible. In the second case, interaction occurs if the distance between the current user and an agent is lower than the float value of the selection_threshold attribute. In this case, the agent gets into a selectable state and its visual aspect changes accordingly (see above).
A second step in interaction occurs if the distance between the current user and an agent is lower than the float value of the interaction_threshold attribute. In this case, the agent gets in a selected state and its visual aspect changes accordingly (see above). The integer value of the wanted_agent attribute defines the index of the individual that is looked for through the interactions.
The following elements must occur in crowd:
schedule with begin, dur, mode, before, and fill attributes,
cycleDistribution with size attribute,
obstacles with size attribute,
sources with size attribute,
intermediaryTargets with size attribute,
targets with size attribute,
terrain,
element with size and element_states attributes.
In addition, a crowd can contain a viewpoint bound to one of its agents (at the same location and with the same orientation in space as this agent).
The example below defines a crowd of 1000 agents with a minimal distance to other agents of 0.04 and a motion step of 0.00003. 20% of the agents are attractive and 80% of them are repulsive. A cycle is made of four steps guided by three intermediary targets and a final target. Targets and intermediary targets are chosen in a sequential mode and sources in a random mode. Motion is made at the surface of a sphere and interaction is enabled in order to look for the agent number 5.
The agents are activated between time 0 and 5 (with t0.25 as function of time). After their activation, the agents remain in their final position. 100 agents make 1 cycle, 800 make 2 cycles, and 100 make 3 cycles. There are 23 obstacles, 15 intermediary targets (5 for each step) and 1000 final targets (one for each agent).
Agent animation is made in 12 key positions and four states are possible (normal, selectable, selected, or killed). It is therefore necessary to define 48 elements. The change of key position is made every frame.
<crowd id="crowd_of_commuters" size="1000" minimal_vital_space="0.04" linear_step="0.00003" sociability="0.2" nbSteps="4" update_rate="1" target_choice="sequential" move_3D="false" interaction="contact" interaction_threshold=".8" selection_threshold=".4" wanted_agent="5"> <schedule begin="0" dur="5" mode="polynomial" param_sinus_polynom="0.25" before="show" fill="freeze"/> <cycleDistribution size="3"> 1 100 2 800 3 100 </cycleDistribution> <obstacles size="23"> <repeat begin="1" end="8" step="1" id="n"> <node id="wall_#{#n}" displayed="false"> <quad id="wal_quad_#{#n}"> ... quad description ... </quad> </node> </repeat> <repeat begin="1" end="5" step="1" id="n"> <node id="metro_M2_{#n}" displayed="false"> <quad id="metro_M2_#{#n}"> ... quad description ... </quad> </node> <node id="metro_M2b_{#n}" displayed="false"> <quad id="metro_M2b_#{#n}"> ... quad description ... </quad> </node> <node id="metro_M3_{#n}" displayed="false"> <quad id="metro_M3_#{#n}"> ... quad description ... </quad> </node> </repeat> </obstacles> <sources size="5"> <repeat begin="1" end="5" step="1" id="n"> <node id="machine_line_{#n}" displayed="false"> <quad id="machine_line_quad_#{#n}"> ... quad description ... </quad> </node> </repeat> </sources> <intermediaryTargets size="15"> <repeat begin="1" end="5" step="1" id="n"> <node id="machine_line_begin_{#n}" displayed="false"> <quad id="machine_line_begin_quad_#{#n}"> ... quad description ... </quad> </node> </repeat> <repeat begin="1" end="5" step="1" id="n"> <node id="machine_line_middle_{#n}" displayed="false"> <quad id="machine_line_middle_quad_#{#n}"> ... quad description ... </quad> </node> </repeat> <repeat begin="1" end="5" step="1" id="n"> <node id="machine_line_end_{#n}" displayed="false"> <quad id="machine_line_end_quad_#{#n}"> ... quad description ... </quad> </node> </repeat> </intermediaryTargets> <targets size="1000"> <repeat begin="1" end="10" step="1" id="n"> <repeat begin="1" end="20" step="1" id="pPrime"> <repeat begin="1" end="5" step="1" id="p"> <!-- sets the z value --> <set id="z" float_value="((-8 + ({#p} * 3))+ ({#pPrime} * 0.09))"> <!-- sets the x value --> <set id="x" float_value="(-9.5+({#n}*0.2))"> <node id="seat_#{#p}-{#pPrime}/{#n}" displayed="false"> <quad id="machine_line_end_quad_#{#n}"> ... quad description ... </quad> </node> </set> </set> </repeat> </repeat> </repeat> </targets> <terrain> <node id="earth_sphere" displayed="false"> <sphere id="sphere_#1" radius="({#earthRadius}+0.0001)" sky_sphere="false" segments="100"> ... sphere description ... </sphere> </node> </terrain> <element size="12" element_states="4"> <node id="interpolator_agent"> <use xlink:href="bib/foule/commuter1_texture.xml:#node body #1" /> </node> ... 47 additional nodes ... </element> </crowd>