Package populus :: Module Formation :: Class AvatarUnit
[frames] | no frames]

Class AvatarUnit


An avatar unit is a formation unit represented by an avatar.

This is a basic formation unit, means that is forbidden to add or remove other units to it.


Note: This class has the role of a Leaf Component into the Composite design pattern. Moreover, it is also an Adapter class of the class Avatar.

Instance Methods
 
__init__(self, avatar)
Create an AvatarUnit and assign an avatar to it.
int
getNumUnits(self)
Always 0 for an AvatarUnit
Vec3
position(self)
Return the unit position.
Vec3
direction(self)
Return the unit forward vector.
float
radius(self)
Return the unit radius.
tuple
bounds(self)
Return the AABB of the unit.
float
speed(self)
Return unit speed.
 
goTo(self, point)
Move the unit to a given point.
 
update(self, dt)
Update the avatar unit.
 
annotate(self)
Annotate units bounds.

Inherited from FormationUnit: add, getUnit, remove, turnTo

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties

Inherited from object: __class__

Method Details

__init__(self, avatar)
(Constructor)

 

Create an AvatarUnit and assign an avatar to it.

Parameters:
  • avatar (Avatar) - An avatar that will be joined to a formation.
Overrides: object.__init__

getNumUnits(self)

 

Always 0 for an AvatarUnit

Returns: int
Always 0 by definition.
Overrides: FormationUnit.getNumUnits

position(self)

 

Return the unit position.

Returns: Vec3
The position in global coordinates of the avatar unit.
Overrides: FormationUnit.position

direction(self)

 

Return the unit forward vector.

Returns: Vec3
The forward vector in global coordinates.
Overrides: FormationUnit.direction

radius(self)

 

Return the unit radius.

Returns: float
The radius of the avatar unit.
Overrides: FormationUnit.radius

bounds(self)

 

Return the AABB of the unit.

Returns: tuple
The AABB as a tuple of two points.
Overrides: FormationUnit.bounds

speed(self)

 

Return unit speed.

Returns: float
The speed of the avatar unit.
Overrides: FormationUnit.speed

goTo(self, point)

 

Move the unit to a given point.

Parameters:
  • point (Point) - The destination point in global coordinates.
Overrides: FormationUnit.goTo

update(self, dt)

 

Update the avatar unit.

Parameters:
  • dt - Delta time since the simulation step.
Overrides: FormationUnit.update

Note: Avatars are updated by the Main Engine. This method doens't do anything.