SteeringBehaviors
SB_Behaviors
Methods:
- Align (V As SB_Vehicle, RadiusAround As Float) As SB_Vector2D
Returns a steering vector that aligns the vehicle with other nearby vehicles of its group.
RadiusAround: Radius of the area to be searched for other vehicles.
- Arrive (Seeker As SB_Vehicle, Destination As SB_Vector2D, ArrivalRadius As Float) As SB_Vector2D
Returns a steering vector that reduces the seeker's velocity as it approaches the given destination.
ArrivalRadius: Radius of the arrival area in which the vehicle decelerates.
- AvoidObstacles (V As SB_Vehicle, VehicleSize As Float, Obstacles As SB_Obstacles, RadiusAround As Float) As SB_Vector2D
Returns a steering vector that aims to avoid the obstacles in the vehicle's path.
VehicleSize: Largest dimension of the vehicle.
Obstacles: Obstacles to avoid.
RadiusAround: Radius of the area to be searched for obstacles.
- Cohere (V As SB_Vehicle, RadiusAround As Float) As SB_Vector2D
Returns a steering vector that directs the vehicle toward the other vehicles of its group.
RadiusAround: Radius of the area to be searched for other vehicles.
- Combine (V As SB_Vehicle, SteeringVectors() As SB_Vector2D) As SB_Vector2D
Combines the specified steering vectors.
- Evade (Fleer As SB_Vehicle, Predator As SB_Vehicle) As SB_Vector2D
Returns a steering vector fleeing from the given predator.
- Flee (Fleer As SB_Vehicle, Undesired As SB_Vector2D) As SB_Vector2D
Returns a steering vector that flees the given location.
- FollowPath (Seeker As SB_Vehicle, Waypoints() As SB_Vector2D, WaypointRadius As Float, WithArrival As Boolean, ArrivalRadius As Float) As SB_Vector2D
Returns a steering vector that seeks the waypoints of a predefined path.
Waypoints(): Array of waypoints.
WaypointRadius: Radius of each waypoint. When the seeker enters this radius, the next waypoint is selected.
WithArrival: If True, the selected behavior is Arrive. If False, it is Seek.
ArrivalRadius: Radius of the arrival area in which the vehicle decelerates. Relevant when WithArrival=True.
- Pursue (Pursuer As SB_Vehicle, Quarry As SB_Vehicle) As SB_Vector2D
Returns a steering vector that seeks the future location of the given quarry.
- Seek (Seeker As SB_Vehicle, Desired As SB_Vector2D) As SB_Vector2D
Returns a steering vector that seeks the desired location.
- Separate (V As SB_Vehicle, DistanceBetween As Float) As SB_Vector2D
Returns a steering vector that keeps the vehicle at a certain distance from other vehicles of its group.
DistanceBetween: Distance between the vehicles.
- Wander (Wanderer As SB_Vehicle, Radius As Float, MaxChange As Double, MaxAngle As Double) As SB_Vector2D
Returns a steering vector that moves the vehicle randomly.
To determine the new direction, a circle is drawn in front of the vehicle and a random point
is picked along its circumference. This keeps the vehicle's movement from appearing jittery.
Radius: Radius of the "wander circle"
MaxChange: Maximum amount of change in angle (radians)
MaxAngle: Maximum steering angle (radians)
SB_Group
Methods:
- AddVehicle (vehicle As SB_Vehicle) As Boolean
Adds the given vehicle to this group.
A vehicle may belong to only one group. If it belongs already to another group, it is removed before being added to this group.
- Clear
Removes all vehicles from this group.
- Contains (vehicle As SB_Vehicle) As Boolean
Returns True if the given vehicle belongs to this group.
- GetNearVehicles (V As SB_Vehicle, Distance As Float, VisionAngle As Double) As List
Returns a list of vehicles whose distance from the vehicle is less than the specified distance.
V: Vehicle used as center for search.
Distance: Maximum distance from V.
VisionAngle: Angle in radians of the visual field. Only vehicles in the visual field of V will be taken into account.
Set this value to 0 (or 2 * Pi) for a circular view.
- Initialize
Initializes a new group of vehicles. Groups are used by the functions: Align, Cohere, Separate, and View.
- ListAll As List
Returns a list with all vehicles belonging to this group.
- RemoveVehicle (vehicle As SB_Vehicle) As Boolean
Removes the given vehicle from this group.
Properties:
- IsInitialized As Boolean [read only]
SB_Obstacle
Fields:
- SHAPE_4WALLS As Byte
- SHAPE_CIRCLE As Byte
- SHAPE_RECT As Byte
Methods:
- CreateCircle (Radius As Float, CenterPosition As SB_Vector2D, Impassable As Boolean)
Creates a circular obstacle.
Radius: Radius of the circle.
CenterPosition: Position of the center of the circle.
Impassable: If True, a vehicle cannot pass through this obstacle.
- CreateFourWalls (Width As Float, Height As Float, CenterPosition As SB_Vector2D, Impassable As Boolean)
Creates a rectangular area surrounded by four walls. Each wall is an obstacle.
This may be used to prevent vehicles from going off screen.
Width,Height: Dimensions of the rectangular area.
CenterPosition: Position of the center of the rectangular area.
Impassable: If True, a vehicle cannot pass through the walls.
- CreateRect (Width As Float, Height As Float, CenterPosition As SB_Vector2D, Impassable As Boolean)
Creates a rectangular obstacle.
Width,Height: Dimensions of the rectangle.
CenterPosition: Position of the center of the rectangle.
Impassable: If True, a vehicle cannot pass through this obstacle.
- GetDistanceTo (Position As SB_Vector2D) As Float
Returns the distance between the given position and the closest boundary of this obstacle.
0 = collision/overlapping.
Properties:
- Bottom As Float [read only]
- Height As Float
- Impassable As Boolean [read only]
- IsInitialized As Boolean [read only]
- Left As Float [read only]
- Position As SB_Vector2D
Gets/sets the center position.
- Radius As Float
- Right As Float [read only]
- ShapeType As Byte [read only]
- Tag As Object
- Top As Float [read only]
- Width As Float
SB_Obstacles
Methods:
- AddObstacle (Obstacle As SB_Obstacle)
- Contains (Obstacle As SB_Obstacle) As Boolean
- GetNearObstacles (Pos As SB_Vector2D, Distance As Float) As Map
Returns a Map containing the obstacles whose distance from the position is less than the specified distance.
Map key = obstacle, Map value = distance to obstacle.
Pos: Position used as center for search.
Distance: Maximum distance from Pos.
- Initialize
- ListAll As List
Returns a list with all obstacles.
- RemoveAllObstacles
- RemoveObstacle (Obstacle As SB_Obstacle)
Properties:
- IsInitialized As Boolean [read only]
SB_Vector2D
Methods:
- Add (v As SB_Vector2D) As SB_Vector2D
Adds the given vector to this vector.
- AngleWith (vOther As SB_Vector2D) As Double
Calculates the angle in radians between this vector and another vector.
- Clone (v As SB_Vector2D)
Copies X and Y of another vector.
- Cross (v As SB_Vector2D) As Float
Calculates the cross product of two vectors.
- Deg2Rad (Degrees As Double) As Double
Converts degrees to radians.
- Divide (by As Float) As SB_Vector2D
Divides the vector by a float value.
- Dot (v As SB_Vector2D) As Float
Calculates the dot product of two vectors.
- Initialize (X As Float, Y As Float)
Initializes an object that represents a position or a vector in two-dimensional space.
- Multiply (by As Float) As SB_Vector2D
Multiplies the vector by a float value.
- Negate As SB_Vector2D
Returns the negation of this vector.
- Normalize As SB_Vector2D
Returns a vector of length 1.0 with the same direction as this vector.
- Project (vOnto As SB_Vector2D) As SB_Vector2D
Projects this vector onto the given vector.
- Rad2Deg (Radians As Double) As Double
Converts radians to degrees.
- Subtract (v As SB_Vector2D) As SB_Vector2D
Subtracts the given vector from this vector.
- equals (obj As Object) As Boolean
Determines equality to three decimal places.
Properties:
- Angle As Double
Gets/sets the angle in radians of this vector.
- IsInitialized As Boolean [read only]
- Length As Float
Gets/sets the length of this vector.
- SquaredLength As Float [read only]
Gets the squared length of this vector.
- X As Float
- Xdip As Float [read only]
Returns the X position * density.
- Y As Float
- Ydip As Float [read only]
Returns the Y position * density.
SB_Vehicle
Methods:
- Clone (V As SB_Vehicle)
Copies all data of another vehicle except its group.
- GetAngleWith (Position As SB_Vector2D) As Double
Returns the angle in radians between this vehicle and the given position.
Negative = the given position is on the left.
Positive = the given position is on the right.
< PI / 2 = the given position is in front.
> PI / 2 = the given position is behind.
- GetDistanceTo (Position As SB_Vector2D) As Float
Returns the distance between this vehicle and the given position.
- Initialize (Mass As Float, Position As SB_Vector2D, Velocity As SB_Vector2D)
- Move
Adds the vehicle velocity to its current position.
- Steer (SteeringForce As SB_Vector2D)
Applies a steering force to the vehicle velocity.
This steering force is limited by MaxForce, then divided by the vehicle mass.
- Steer2 (SteeringForce As SB_Vector2D)
Applies a steering force to the vehicle velocity.
This steering force is divided by the vehicle mass, then limited by MaxForce.
Properties:
- FuturePosition As SB_Vector2D [read only]
Computes the future position based on the current velocity.
- IsInitialized As Boolean [read only]
- Mass As Float
- MaxForce As Float
Gets/sets the maximum amount of change in velocity (default = 1.5).
- MaxSpeed As Float
Gets/sets the maximum allowable velocity (default = 1.5).
- Position As SB_Vector2D
- Tag As Object
- Velocity As SB_Vector2D
- Waypoint As Int
Gets/sets the current waypoint when the selected behavior is FollowPath.