1
Fork 0
mirror of https://github.com/redstrate/Physis.git synced 2025-04-24 05:27:45 +00:00
physis/src/cmp.rs

76 lines
1.8 KiB
Rust
Raw Normal View History

// SPDX-FileCopyrightText: 2023 Joshua Goins <josh@redstrate.com>
// SPDX-License-Identifier: GPL-3.0-or-later
2023-07-06 17:34:14 -04:00
use std::io::{Cursor, Seek, SeekFrom};
use binrw::BinRead;
use binrw::binrw;
use crate::ByteSpan;
2023-07-06 17:34:14 -04:00
#[binrw]
#[br(little)]
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct RacialScalingParameters {
2023-12-02 19:55:13 -05:00
/// Male minimum height
2023-07-06 17:34:14 -04:00
pub male_min_size: f32,
2023-12-02 19:55:13 -05:00
/// Male maximum height
2023-07-06 17:34:14 -04:00
pub male_max_size: f32,
2023-12-02 19:55:13 -05:00
/// Male minimum tail size
2023-07-06 17:34:14 -04:00
pub male_min_tail: f32,
2023-12-02 19:55:13 -05:00
/// Male maximum tail size
2023-07-06 17:34:14 -04:00
pub male_max_tail: f32,
2023-12-02 19:55:13 -05:00
/// Female minimum height
2023-07-06 17:34:14 -04:00
pub female_min_size: f32,
2023-12-02 19:55:13 -05:00
/// Female maximum height
2023-07-06 17:34:14 -04:00
pub female_max_size: f32,
2023-12-02 19:55:13 -05:00
/// Female minimum tail size
2023-07-06 17:34:14 -04:00
pub female_min_tail: f32,
2023-12-02 19:55:13 -05:00
/// Female maximum tail size
2023-07-06 17:34:14 -04:00
pub female_max_tail: f32,
2023-12-02 19:55:13 -05:00
/// Minimum bust size on the X-axis
2023-07-06 17:34:14 -04:00
pub bust_min_x: f32,
2023-12-02 19:55:13 -05:00
/// Minimum bust size on the Y-axis
2023-07-06 17:34:14 -04:00
pub bust_min_y: f32,
2023-12-02 19:55:13 -05:00
/// Minimum bust size on the Z-axis
2023-07-06 17:34:14 -04:00
pub bust_min_z: f32,
2023-12-02 19:55:13 -05:00
/// Maximum bust size on the X-axis
2023-07-06 17:34:14 -04:00
pub bust_max_x: f32,
2023-12-02 19:55:13 -05:00
/// Maximum bust size on the Y-axis
2023-07-06 17:34:14 -04:00
pub bust_max_y: f32,
2023-12-02 19:55:13 -05:00
/// Maximum bust size on the Z-axis
2023-07-06 17:34:14 -04:00
pub bust_max_z: f32
}
#[derive(Debug)]
pub struct CMP {
2023-12-02 19:55:13 -05:00
/// The racial scaling parameters
2023-07-06 17:34:14 -04:00
pub parameters: Vec<RacialScalingParameters>
}
impl CMP {
2023-12-02 19:55:13 -05:00
/// Parses an existing CMP file.
pub fn from_existing(buffer: ByteSpan) -> Option<CMP> {
2023-07-06 17:34:14 -04:00
let mut cursor = Cursor::new(buffer);
2023-07-30 08:58:59 -04:00
cursor.seek(SeekFrom::Start(0x2a800)).unwrap();
2023-07-06 17:34:14 -04:00
let rem = buffer.len() - cursor.position() as usize;
let entries = rem / std::mem::size_of::<RacialScalingParameters>();
let mut parameters = vec![];
2023-07-30 08:58:59 -04:00
for _ in 0..entries {
2023-07-06 17:34:14 -04:00
parameters.push(RacialScalingParameters::read(&mut cursor).unwrap());
}
Some(CMP {
parameters
})
}
}