mirror of
https://codeberg.org/icewind/vmdl.git
synced 2026-06-03 16:44:11 +02:00
bone transform wip
This commit is contained in:
parent
31fc82bbdb
commit
b731b7aab1
6 changed files with 67 additions and 23 deletions
|
|
@ -6,7 +6,7 @@ pub mod vtx;
|
|||
pub mod vvd;
|
||||
|
||||
pub use crate::mdl::Mdl;
|
||||
use crate::mdl::TextureInfo;
|
||||
use crate::mdl::{Bone, TextureInfo};
|
||||
pub use crate::vtx::Vtx;
|
||||
use crate::vvd::Vertex;
|
||||
pub use crate::vvd::Vvd;
|
||||
|
|
@ -137,6 +137,10 @@ impl Model {
|
|||
pub fn name(&self) -> &str {
|
||||
self.mdl.name.as_str()
|
||||
}
|
||||
|
||||
pub fn bones(&self) -> impl Iterator<Item = &Bone> {
|
||||
self.mdl.bones.iter()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct SkinTable<'a> {
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ mod raw;
|
|||
|
||||
pub use raw::header::*;
|
||||
pub use raw::header2::*;
|
||||
pub use raw::*;
|
||||
use std::mem::size_of;
|
||||
|
||||
use crate::mdl::raw::{BodyPartHeader, Bone, MeshHeader, MeshTexture, ModelHeader};
|
||||
use crate::vvd::Vertex;
|
||||
use crate::{
|
||||
read_indexes, read_relative, read_relative_iter, FixedString, ModelError, ReadRelative,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
use crate::{ModelError, StringError};
|
||||
use arrayvec::ArrayString;
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use cgmath::{Deg, Euler, Rad, Vector3};
|
||||
use cgmath::{Deg, Euler, Rad, Rotation3, Vector3};
|
||||
use std::f32::consts::PI;
|
||||
use std::fmt;
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::ops::{Add, Mul};
|
||||
|
|
@ -101,6 +102,23 @@ impl From<Quaternion> for cgmath::Quaternion<f32> {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<cgmath::Quaternion<f32>> for Quaternion {
|
||||
fn from(q: cgmath::Quaternion<f32>) -> Self {
|
||||
Quaternion {
|
||||
x: q.v.x,
|
||||
y: q.v.y,
|
||||
z: q.v.z,
|
||||
w: q.s,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Quaternion> for cgmath::Matrix4<f32> {
|
||||
fn from(q: Quaternion) -> Self {
|
||||
cgmath::Quaternion::from(q).into()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, Zeroable, Pod)]
|
||||
#[repr(C)]
|
||||
pub struct RadianEuler {
|
||||
|
|
@ -129,6 +147,21 @@ impl From<RadianEuler> for Euler<Deg<f32>> {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<RadianEuler> for cgmath::Quaternion<f32> {
|
||||
fn from(value: RadianEuler) -> Self {
|
||||
// angles are applied in roll, pitch, yaw order
|
||||
cgmath::Quaternion::from_angle_y(Rad(value.x))
|
||||
* cgmath::Quaternion::from_angle_x(Rad(value.y))
|
||||
* cgmath::Quaternion::from_angle_z(Rad(-value.z))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RadianEuler> for Quaternion {
|
||||
fn from(value: RadianEuler) -> Self {
|
||||
cgmath::Quaternion::from(value).into()
|
||||
}
|
||||
}
|
||||
|
||||
/// Fixed length, null-terminated string
|
||||
#[derive(Debug, Clone, Default, Copy)]
|
||||
pub struct FixedString<const LEN: usize>(ArrayString<LEN>);
|
||||
|
|
|
|||
|
|
@ -215,6 +215,7 @@ impl StripHeader {
|
|||
#[repr(C)]
|
||||
#[repr(packed)]
|
||||
pub struct Vertex {
|
||||
// these index into the mesh's vert[origMeshVertID]'s bones
|
||||
pub bone_weight_indexes: [u8; 3],
|
||||
pub bone_count: u8,
|
||||
pub original_mesh_vertex_id: u16,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue