mirror of
https://codeberg.org/icewind/vmdl.git
synced 2026-06-04 00:54:14 +02:00
converters for angles to cgmath
This commit is contained in:
parent
30e1ac4795
commit
4be7e6db0a
1 changed files with 27 additions and 1 deletions
|
|
@ -1,7 +1,7 @@
|
|||
use crate::{ModelError, StringError};
|
||||
use arrayvec::ArrayString;
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use cgmath::Vector3;
|
||||
use cgmath::{Deg, Euler, Rad, Vector3};
|
||||
use std::fmt;
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::ops::{Add, Mul};
|
||||
|
|
@ -95,6 +95,12 @@ pub struct Quaternion {
|
|||
pub w: f32,
|
||||
}
|
||||
|
||||
impl From<Quaternion> for cgmath::Quaternion<f32> {
|
||||
fn from(q: Quaternion) -> Self {
|
||||
[q.x, q.y, q.z, q.w].into()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Zeroable, Pod)]
|
||||
#[repr(C)]
|
||||
pub struct RadianEuler {
|
||||
|
|
@ -103,6 +109,26 @@ pub struct RadianEuler {
|
|||
pub z: f32,
|
||||
}
|
||||
|
||||
impl From<RadianEuler> for Euler<Rad<f32>> {
|
||||
fn from(e: RadianEuler) -> Self {
|
||||
Euler {
|
||||
x: Rad(e.x),
|
||||
y: Rad(e.y),
|
||||
z: Rad(e.z),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RadianEuler> for Euler<Deg<f32>> {
|
||||
fn from(e: RadianEuler) -> Self {
|
||||
Euler {
|
||||
x: Rad(e.x).into(),
|
||||
y: Rad(e.y).into(),
|
||||
z: Rad(e.z).into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Fixed length, null-terminated string
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct FixedString<const LEN: usize>(ArrayString<LEN>);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue