audionimbus/geometry/
vector3.rs

1/// A point or vector in 3D space.
2///
3/// Steam Audio uses a right-handed coordinate system, with the positive x-axis pointing right, the positive y-axis pointing up, and the negative z-axis pointing ahead.
4/// Position and direction data obtained from a game engine or audio engine must be properly transformed before being passed to any Steam Audio API function.
5#[derive(Copy, Clone, Debug, PartialEq)]
6pub struct Vector3 {
7    /// The x-coordinate.
8    pub x: f32,
9
10    /// The y-coordinate.
11    pub y: f32,
12
13    /// The z-coordinate.
14    pub z: f32,
15}
16
17impl Vector3 {
18    pub fn new(x: f32, y: f32, z: f32) -> Self {
19        Self { x, y, z }
20    }
21}
22
23impl Default for Vector3 {
24    fn default() -> Self {
25        Self {
26            x: 0.0,
27            y: 0.0,
28            z: 0.0,
29        }
30    }
31}
32
33impl From<[f32; 3]> for Vector3 {
34    fn from(vector: [f32; 3]) -> Self {
35        Self {
36            x: vector[0],
37            y: vector[1],
38            z: vector[2],
39        }
40    }
41}
42
43impl From<Vector3> for audionimbus_sys::IPLVector3 {
44    fn from(vector: Vector3) -> Self {
45        Self {
46            x: vector.x,
47            y: vector.y,
48            z: vector.z,
49        }
50    }
51}
52
53impl From<audionimbus_sys::IPLVector3> for Vector3 {
54    fn from(vector: audionimbus_sys::IPLVector3) -> Self {
55        Self {
56            x: vector.x,
57            y: vector.y,
58            z: vector.z,
59        }
60    }
61}