Skip to content

Shape

A geometrical closed 3D shape.

Inherited by the following classes: SparkyStudios::Audio::Amplitude::BoxShape, SparkyStudios::Audio::Amplitude::CapsuleShape, SparkyStudios::Audio::Amplitude::ConeShape, SparkyStudios::Audio::Amplitude::SphereShape

Detailed Description

A Shape defines a zone in the world where game objects (listener, sound sources, entities, etc.) can be localized. Shapes are used in many places of the engine, like to define a sound attenuation shape or to build a room.

Public Functions

Type Name
virtual bool Contains (const Entity & entity) const
Checks if the given entity is contained in this shape.
virtual bool Contains (const Listener & listener) const
Checks if the given listener is contained in this shape.
virtual bool Contains (const AmVector3 & location) const = 0
Checks if the given position is contained in this shape.
AmVector3 GetDirection () const
Gets the position of this shape in the 3D environment.
const AmVector3 & GetLocation () const
Gets the position of this shape in the 3D environment.
const AmMatrix4 & GetLookAt () const
Gets the LookAt transformation matrix for this shape.
const Orientation & GetOrientation () const
Gets the orientation of this shape.
virtual AmReal32 GetShortestDistanceToEdge (const Entity & entity) const
Gets the shortest distance to the edge of this shape.
virtual AmReal32 GetShortestDistanceToEdge (const Listener & listener) const
Gets the shortest distance to the edge of this shape.
virtual AmReal32 GetShortestDistanceToEdge (const AmVector3 & location) const = 0
Gets the shortest distance to the edge of this shape.
AmVector3 GetUp () const
Gets the up vector of the zone.
void SetLocation (const AmVector3 & location)
Sets the location of this shape in the 3D environment.
void SetOrientation (const Orientation & orientation)
Sets the orientation of this shape.
Shape ()
Constructs a new Shape .
virtual ~Shape () = default
Default destructor.

Public Static Functions

Type Name
std::shared_ptr< Shape > Create (const ShapeDefinition * definition)
Creates a new Shape from a definition.

Protected Attributes

Type Name
AmVector3 m_location
Represents the 3D position of an object in space.
AmMatrix4 m_lookAtMatrix
The look-at matrix representing a transformation in 3D space.
bool m_needUpdate
Indicates whether an update is required.
Orientation m_orientation
Represents the orientation of an object in 3D space.

Protected Functions

Type Name
virtual void Update () = 0
Updates the internal state of the shape.
void UpdateIfNeeded () const
Performs an update of the internal state if needed.

Public Functions Documentation

Contains[1/3]

Checks if the given entity is contained in this shape.

virtual bool Amplitude::Shape::Contains (
    const Entity & entity
) const

Parameters:

  • entity The entity to check.

Returns:

true if the shape contains the entity, false otherwise.

Contains[2/3]

Checks if the given listener is contained in this shape.

virtual bool Amplitude::Shape::Contains (
    const Listener & listener
) const

Parameters:

  • listener The listener to check.

Returns:

true if the shape contains the listener, false otherwise.

Contains[3/3]

Checks if the given position is contained in this shape.

virtual bool Amplitude::Shape::Contains (
    const AmVector3 & location
) const = 0

Parameters:

  • location The 3D position to check.

Returns:

true if the shape contains the given position, false otherwise.

GetDirection

Gets the position of this shape in the 3D environment.

AmVector3 Amplitude::Shape::GetDirection () const

Returns:

The shape's position.

GetLocation

Gets the position of this shape in the 3D environment.

const AmVector3 & Amplitude::Shape::GetLocation () const

Returns:

The shape's position.

GetLookAt

Gets the LookAt transformation matrix for this shape.

const AmMatrix4 & Amplitude::Shape::GetLookAt () const

Returns:

The look-at transformation matrix.

GetOrientation

Gets the orientation of this shape.

const Orientation & Amplitude::Shape::GetOrientation () const

Returns:

The orientation of this shape.

GetShortestDistanceToEdge[1/3]

Gets the shortest distance to the edge of this shape.

virtual AmReal32 Amplitude::Shape::GetShortestDistanceToEdge (
    const Entity & entity
) const

Parameters:

  • entity The entity used to calculate the distance.

Returns:

The shortest distance from the entity location to the edge of this shape. If negative, the given entity in outside the shape.

GetShortestDistanceToEdge[2/3]

Gets the shortest distance to the edge of this shape.

virtual AmReal32 Amplitude::Shape::GetShortestDistanceToEdge (
    const Listener & listener
) const

Parameters:

  • listener The listener used to calculate the distance.

Returns:

The shortest distance from the listener location to the edge of this shape. If negative, the given listener in outside the shape.

GetShortestDistanceToEdge[3/3]

Gets the shortest distance to the edge of this shape.

virtual AmReal32 Amplitude::Shape::GetShortestDistanceToEdge (
    const AmVector3 & location
) const = 0

Parameters:

  • location The location from which calculate the distance.

Returns:

The shortest distance from the location to the edge of this shape. If negative, the given location in outside the shape.

GetUp

Gets the up vector of the zone.

AmVector3 Amplitude::Shape::GetUp () const

Returns:

The up vector.

SetLocation

Sets the location of this shape in the 3D environment.

void Amplitude::Shape::SetLocation (
    const AmVector3 & location
) 

Parameters:

  • location The shape location.
SetOrientation

Sets the orientation of this shape.

void Amplitude::Shape::SetOrientation (
    const Orientation & orientation
) 

Parameters:

  • orientation The new orientation.
Shape

Constructs a new Shape .

Amplitude::Shape::Shape () 
~Shape

Default destructor.

virtual Amplitude::Shape::~Shape () = default

Public Static Functions Documentation

Create

Creates a new Shape from a definition.

static std::shared_ptr< Shape > Amplitude::Shape::Create (
    const ShapeDefinition * definition
) 

Parameters:

  • definition The definition of the shape generated from a flatbuffer binary.

Warning:

This method is intended for internal usage only.

Protected Attributes Documentation

m_location

Represents the 3D position of an object in space.

AmVector3 SparkyStudios::Audio::Amplitude::Shape::m_location;
m_lookAtMatrix

The look-at matrix representing a transformation in 3D space.

AmMatrix4 SparkyStudios::Audio::Amplitude::Shape::m_lookAtMatrix;
m_needUpdate

Indicates whether an update is required.

bool SparkyStudios::Audio::Amplitude::Shape::m_needUpdate;
m_orientation

Represents the orientation of an object in 3D space.

Orientation SparkyStudios::Audio::Amplitude::Shape::m_orientation;

Protected Functions Documentation

Update

Updates the internal state of the shape.

virtual void Amplitude::Shape::Update () = 0

This pure virtual function must be implemented by derived classes to perform custom updates whenever modifications occur, such as changes to the shape's position, orientation, or other parameters. It is intended to synchronize the internal data or perform computations necessary for the shape's functionality.

Note:

The engine calls this method internally when parameters like location or orientation are modified.

UpdateIfNeeded

Performs an update of the internal state if needed.

inline void Amplitude::Shape::UpdateIfNeeded () const

The documentation for this class was generated from the following file: include/SparkyStudios/Audio/Amplitude/Math/Shape.h