A* Pathfinding Project  3.8.2
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
LightweightRVO Class Reference

Lightweight RVO Circle Example. More...

Detailed Description

Lightweight RVO Circle Example.

Lightweight script for simulating agents in a circle trying to reach their antipodal positions. This script, compared to using lots of RVOAgents shows the real power of the RVO simulator when little other overhead (e.g GameObjects) is present.

For example with this script, I can simulate 5000 agents at around 50 fps on my laptop (with desired simulation fps = 10 and interpolation, 2 threads) however when using prefabs, only instantiating the 5000 agents takes 10 seconds and it runs at around 5 fps.

This script will render the agents by generating a square for each agent combined into a single mesh with appropriate UV.

A few GUI buttons will be drawn by this script with which the user can change the number of agents.

Public Types

enum  RVOExampleType { Circle, Line, Point, RandomStreams }
 

Public Member Functions

void CreateAgents (int num)
 Create a number of agents in circle and restart simulation.
 
void OnGUI ()
 
void Start ()
 
void Update ()
 

Public Attributes

int agentCount = 100
 Number of agents created at start.
 
float agentTimeHorizon = 10
 How far in the future too look for agents.
 
bool debug = false
 Enable the debug flag for all agents.
 
float exampleScale = 100
 How large is the area where agents are placed.
 
int maxNeighbours = 10
 Max number of neighbour agents to take into account.
 
float maxSpeed = 2
 Max speed for an agent.
 
float neighbourDist = 15
 Max distance for other agents to take them into account.
 
float obstacleTimeHorizon = 10
 How far in the future too look for obstacles.
 
float radius = 3
 Agent radius.
 
Vector3 renderingOffset = Vector3.up*0.1f
 Offset from the agent position the actual drawn postition.
 
RVOExampleType type = RVOExampleType.Circle
 

Private Member Functions

float uniformDistance (float radius)
 

Static Private Member Functions

static Color HSVToRGB (float h, float s, float v)
 Converts an HSV color to an RGB color, according to the algorithm described at http://en.wikipedia.org/wiki/HSL_and_HSV.
 

Private Attributes

List< IAgentagents
 All agents handled by this script.
 
List< Color > colors
 Color for each agent.
 
List< Vector3 > goals
 Goals for each agent.
 
Vector3[] interpolatedVelocities
 
Mesh mesh
 Mesh for rendering.
 
Color[] meshColors
 
Pathfinding.RVO.Simulator sim
 Reference to the simulator in the scene.
 
int[] tris
 
Vector2[] uv
 
Vector3[] verts
 

Member Enumeration Documentation

Enumerator:
Circle 
Line 
Point 
RandomStreams 

Member Function Documentation

void CreateAgents ( int  num)

Create a number of agents in circle and restart simulation.

static Color HSVToRGB ( float  h,
float  s,
float  v 
)
staticprivate

Converts an HSV color to an RGB color, according to the algorithm described at http://en.wikipedia.org/wiki/HSL_and_HSV.

Parameters
h,s,vthe color to convert.
Returns
the RGB representation of the color.
void OnGUI ( )
void Start ( )
float uniformDistance ( float  radius)
private
void Update ( )

Member Data Documentation

int agentCount = 100

Number of agents created at start.

List<IAgent> agents
private

All agents handled by this script.

float agentTimeHorizon = 10

How far in the future too look for agents.

List<Color> colors
private

Color for each agent.

bool debug = false

Enable the debug flag for all agents.

float exampleScale = 100

How large is the area where agents are placed.

For e.g the circle example, it corresponds

List<Vector3> goals
private

Goals for each agent.

Vector3 [] interpolatedVelocities
private
int maxNeighbours = 10

Max number of neighbour agents to take into account.

float maxSpeed = 2

Max speed for an agent.

Mesh mesh
private

Mesh for rendering.

Color [] meshColors
private
float neighbourDist = 15

Max distance for other agents to take them into account.

float obstacleTimeHorizon = 10

How far in the future too look for obstacles.

float radius = 3

Agent radius.

Vector3 renderingOffset = Vector3.up*0.1f

Offset from the agent position the actual drawn postition.

Used to get rid of z-buffer issues

Reference to the simulator in the scene.

int [] tris
private
RVOExampleType type = RVOExampleType.Circle
Vector2 [] uv
private
Vector3 [] verts
private

The documentation for this class was generated from the following file: