Game Audio Module
A C++ audio system using miniaudio with Python bindings
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
audio::Vec3 Struct Reference

3D vector for spatial audio positioning More...

#include <vec3.h>

Public Member Functions

 Vec3 ()
 Default constructor (initializes to origin)
 
 Vec3 (float x, float y, float z)
 Constructor with components.
 
float Distance (const Vec3 &other) const
 Calculate distance to another point.
 
float DistanceSquared (const Vec3 &other) const
 Calculate squared distance to another point (faster, no sqrt)
 
float Length () const
 Get the length of the vector.
 
float LengthSquared () const
 Get the squared length of the vector (faster, no sqrt)
 
void Normalize ()
 Normalize the vector in place.
 
Vec3 Normalized () const
 Get a normalized copy of the vector.
 
bool operator!= (const Vec3 &other) const
 
Vec3 operator* (float scalar) const
 
Vec3operator*= (float scalar)
 
Vec3 operator+ (const Vec3 &other) const
 
Vec3operator+= (const Vec3 &other)
 
Vec3 operator- (const Vec3 &other) const
 
Vec3operator-= (const Vec3 &other)
 
Vec3 operator/ (float scalar) const
 
Vec3operator/= (float scalar)
 
bool operator== (const Vec3 &other) const
 

Public Attributes

float x
 X component.
 
float y
 Y component.
 
float z
 Z component.
 

Detailed Description

3D vector for spatial audio positioning

Represents a position or direction in 3D space. This is engine-agnostic and can be used with any game engine by converting from the engine's vector type to Vec3.

The Vec3 struct uses simple x, y, z float components, making it easy to convert from any engine's vector type (e.g., Basilisk Engine nodes, Unity Vector3, Unreal FVector, etc.).

Example conversion from a game engine node:

// If your engine node has position as (x, y, z) tuple or struct
auto node_pos = node.get_position();
audio::Vec3 audio_pos(node_pos.x, node_pos.y, node_pos.z);
audio.SetSoundPosition(sound, audio_pos);
Definition audio_group.cpp:7
3D vector for spatial audio positioning
Definition vec3.h:46

Constructor & Destructor Documentation

◆ Vec3() [1/2]

audio::Vec3::Vec3 ( )
inline

Default constructor (initializes to origin)

◆ Vec3() [2/2]

audio::Vec3::Vec3 ( float  x,
float  y,
float  z 
)
inline

Constructor with components.

Parameters
xX component
yY component
zZ component

Member Function Documentation

◆ Distance()

float audio::Vec3::Distance ( const Vec3 other) const
inline

Calculate distance to another point.

Parameters
otherOther point
Returns
float Distance between points

◆ DistanceSquared()

float audio::Vec3::DistanceSquared ( const Vec3 other) const
inline

Calculate squared distance to another point (faster, no sqrt)

Parameters
otherOther point
Returns
float Squared distance between points

◆ Length()

float audio::Vec3::Length ( ) const
inline

Get the length of the vector.

Returns
float Length of the vector

◆ LengthSquared()

float audio::Vec3::LengthSquared ( ) const
inline

Get the squared length of the vector (faster, no sqrt)

Returns
float Squared length of the vector

◆ Normalize()

void audio::Vec3::Normalize ( )
inline

Normalize the vector in place.

◆ Normalized()

Vec3 audio::Vec3::Normalized ( ) const
inline

Get a normalized copy of the vector.

Returns
Vec3 Normalized vector

◆ operator!=()

bool audio::Vec3::operator!= ( const Vec3 other) const
inline

◆ operator*()

Vec3 audio::Vec3::operator* ( float  scalar) const
inline

◆ operator*=()

Vec3 & audio::Vec3::operator*= ( float  scalar)
inline

◆ operator+()

Vec3 audio::Vec3::operator+ ( const Vec3 other) const
inline

◆ operator+=()

Vec3 & audio::Vec3::operator+= ( const Vec3 other)
inline

◆ operator-()

Vec3 audio::Vec3::operator- ( const Vec3 other) const
inline

◆ operator-=()

Vec3 & audio::Vec3::operator-= ( const Vec3 other)
inline

◆ operator/()

Vec3 audio::Vec3::operator/ ( float  scalar) const
inline

◆ operator/=()

Vec3 & audio::Vec3::operator/= ( float  scalar)
inline

◆ operator==()

bool audio::Vec3::operator== ( const Vec3 other) const
inline

Member Data Documentation

◆ x

float audio::Vec3::x

X component.

◆ y

float audio::Vec3::y

Y component.

◆ z

float audio::Vec3::z

Z component.


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