Entity¶
class Entity
An Entity represents a spatially positioned object in the game.
Amplitude use entities to link sound to an object in the game. Each sounds played from an entity get the location and orientation data fom that entity.
The Entity
class is a lightweight reference to an EntityInternalState
object which is managed by the Engine
.
Functions¶
Name | Description |
---|---|
Entity | Creates an uninitialized Entity . |
Entity | Creates a wrapper instance over the provided state. |
Clear | Uninitializes this Entity . |
Valid | Checks whether this Entity has been initialized. |
GetId | Gets the ID of this Entity . |
GetVelocity | Gets the velocity of the Entity . |
SetLocation | Sets the location of this Entity . |
GetLocation | Gets the current location of this Entity . |
SetOrientation | Sets the orientation of this Entity . |
GetDirection | Gets the direction vector of the Entity . |
GetUp | Gets the up vector of the Entity . |
GetOrientation | Gets the orientation of the Entity . |
Update | Updates the state of this Entity . |
SetObstruction | Sets the obstruction level of sounds played by this Entity . |
SetOcclusion | Sets the occlusion level of sounds played by this Entity . |
SetDirectivity | Sets the directivity and sharpness of sounds played by this Entity . |
GetObstruction | Gets the obstruction level of sounds played by this Entity . |
GetOcclusion | Gets the occlusion level of sounds played by this Entity . |
GetDirectivity | Gets the directivity of sounds played by this Entity . |
GetDirectivitySharpness | Gets the directivity sharpness of sounds played by this Entity . |
SetEnvironmentFactor | Sets the environment factor for this Entity in the given environment. |
GetEnvironmentFactor | Gets the environment factor of this Entity for the given environment. |
GetEnvironments | Gets the list of environments where this Entity belongs or has visited. |
GetState | Returns the internal state of this Entity . |
Function Details¶
Clear¶
void Clear()
Uninitializes this Entity
.
Note that this does not destroy the internal state it references, it just removes this reference to it.
To completely destroy the Entity
, use RemoveEntity()
method of the Engine
instance.
Entity¶
Entity()
Creates an uninitialized Entity
.
An uninitialized Entity cannot provide location and orientation information, and therefore cannot play sounds.
To create an initialized Entity
, use the AddEntity()
method of the Engine
instance.
explicit Entity(EntityInternalState* state)
Creates a wrapper instance over the provided state.
- Parameter
state
- The internal state to wrap.
Warning
This constructor is for internal usage only.
GetDirection¶
[[nodiscard]] AmVec3 GetDirection() const
Gets the direction vector of the Entity
.
- Return
- The direction vector.
GetDirectivity¶
[[nodiscard]] AmReal32 GetDirectivity() const
Gets the directivity of sounds played by this Entity
.
- Return
- The directivity of sound sources.
GetDirectivitySharpness¶
[[nodiscard]] AmReal32 GetDirectivitySharpness() const
Gets the directivity sharpness of sounds played by this Entity
.
- Return
- The directivity sharpness of sounds played by this
Entity
.
GetEnvironmentFactor¶
[[nodiscard]] AmReal32 GetEnvironmentFactor(AmEnvironmentID environment) const
Gets the environment factor of this Entity
for the given environment.
- Parameter
environment
- The environment ID.
- Return
- The environment factor.
GetEnvironments¶
[[nodiscard]] const std::map<AmEnvironmentID, AmReal32>& GetEnvironments() const
Gets the list of environments where this Entity
belongs or has visited.
- Return
- The list of environments where this
Entity
belongs or has visited.
GetId¶
[[nodiscard]] AmEntityID GetId() const
Gets the ID of this Entity
.
- Return
- The
Entity
ID.
GetLocation¶
[[nodiscard]] const AmVec3& GetLocation() const
Gets the current location of this Entity
.
- Return
- The current location of this
Entity
.
GetObstruction¶
[[nodiscard]] AmReal32 GetObstruction() const
Gets the obstruction level of sounds played by this Entity
.
- Return
- The obstruction amount.
GetOcclusion¶
[[nodiscard]] AmReal32 GetOcclusion() const
Gets the occlusion level of sounds played by this Entity
.
- Return
- The occlusion amount.
GetOrientation¶
[[nodiscard]] const Orientation& GetOrientation() const
Gets the orientation of the Entity
.
- Return
- The entity's orientation.
GetState¶
[[nodiscard]] EntityInternalState* GetState() const
Returns the internal state of this Entity
.
- Return
- The
Entity
internal state.
Warning
This method is for internal usage only.
GetUp¶
[[nodiscard]] AmVec3 GetUp() const
Gets the up vector of the Entity
.
- Return
- The up vector.
GetVelocity¶
[[nodiscard]] const AmVec3& GetVelocity() const
Gets the velocity of the Entity
.
- Return
- The entity's velocity.
SetDirectivity¶
void SetDirectivity(AmReal32 directivity, AmReal32 sharpness) const
Sets the directivity and sharpness of sounds played by this Entity
.
- Parameter
directivity
- The directivity of the sound source, in the range [0, 1].
- Parameter
sharpness
- The directivity sharpness of the sound source, in the range [1, +INF]. Increasing this value increases the directivity towards the front of the source.
SetEnvironmentFactor¶
void SetEnvironmentFactor(AmEnvironmentID environment, AmReal32 factor) const
Sets the environment factor for this Entity
in the given environment.
- Parameter
environment
- The environment ID.
- Parameter
factor
- The environment factor.
SetLocation¶
void SetLocation(const AmVec3& location) const
Sets the location of this Entity
.
- Parameter
location
- The new location.
SetObstruction¶
void SetObstruction(AmReal32 obstruction) const
Sets the obstruction level of sounds played by this Entity
.
- Parameter
obstruction
- The obstruction amount.
SetOcclusion¶
void SetOcclusion(AmReal32 occlusion) const
Sets the occlusion level of sounds played by this Entity
.
- Parameter
occlusion
- The occlusion amount.
SetOrientation¶
void SetOrientation(const Orientation& orientation) const
Sets the orientation of this Entity
.
- Parameter
orientation
- The new orientation.
Update¶
void Update() const
Updates the state of this Entity
.
This method is called automatically by the Engine
on each frames to update the internal state of the Entity
Warning
This method is for internal usage only.
Valid¶
[[nodiscard]] bool Valid() const
Checks whether this Entity
has been initialized.
- Return
true
if thisEntity
is initialized,false
otherwise.