chore: initial commit

main
Anna Clemens 4 months ago
commit f635a85401
Signed by: ascclemens
GPG Key ID: 0B391D8F06FCD9E0

2
.gitignore vendored

@ -0,0 +1,2 @@
/target
/Cargo.lock

@ -0,0 +1,14 @@
[package]
name = "sqpack"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
default = []
read = []
write = []
[dependencies]
binrw = "0.10"

@ -0,0 +1,5 @@
pub extern crate binrw;
pub use self::model::*;
pub mod model;

@ -0,0 +1,148 @@
#[derive(Debug)]
#[cfg_attr(feature = "read", derive(binrw::BinRead), br(little, repr = u32))]
#[cfg_attr(feature = "write", derive(binrw::BinWrite), bw(little, repr = u32))]
#[repr(u32)]
pub enum FileKind {
Empty = 1,
Standard = 2,
Model = 3,
Texture = 4,
}
#[derive(Debug)]
#[cfg_attr(feature = "read", derive(binrw::BinRead), br(little, repr = i32))]
#[cfg_attr(feature = "write", derive(binrw::BinWrite), bw(little, repr = i32))]
#[repr(i32)]
pub enum LodLevel {
All = -1,
Highest = 0,
High = 1,
Low = 2,
Max = 3,
}
#[derive(Debug)]
#[cfg_attr(feature = "read", derive(binrw::BinRead), br(little))]
#[cfg_attr(feature = "write", derive(binrw::BinWrite), bw(little))]
pub struct SqPackFileInfoHeader {
pub size: u32,
pub kind: FileKind,
pub raw_file_size: u32,
}
#[derive(Debug)]
#[cfg_attr(feature = "read", derive(binrw::BinRead), br(little))]
#[cfg_attr(feature = "write", derive(binrw::BinWrite), bw(little))]
pub struct SqPackFileInfo {
pub _unk_0: [u32; 2],
pub number_of_blocks: u32,
}
#[derive(Debug)]
#[cfg_attr(feature = "read", derive(binrw::BinRead), br(little))]
#[cfg_attr(feature = "write", derive(binrw::BinWrite), bw(little))]
pub struct DatStdFileBlockInfos {
pub offset: u32,
pub compressed_size: u16,
pub uncompressed_size: u16,
}
#[derive(Debug)]
#[cfg_attr(feature = "read", derive(binrw::BinRead), br(little))]
#[cfg_attr(feature = "write", derive(binrw::BinWrite), bw(little))]
pub struct DatBlockHeader {
pub size: u32,
pub _unk_0: u32,
pub compressed_size: u32,
pub uncompressed_size: u32,
}
#[derive(Debug)]
#[cfg_attr(feature = "read", derive(binrw::BinRead), br(little))]
#[cfg_attr(feature = "write", derive(binrw::BinWrite), bw(little))]
pub struct LodBlock {
pub compressed_offset: u32,
pub compressed_size: u32,
pub decompressed_size: u32,
pub block_offset: u32,
pub block_count: u32,
}
#[derive(Debug)]
#[cfg_attr(feature = "read", derive(binrw::BinRead), br(little))]
#[cfg_attr(feature = "write", derive(binrw::BinWrite), bw(little))]
pub struct ReferenceBlockRange {
pub begin: u32,
pub end: u32,
}
#[derive(Debug)]
#[cfg(all(feature = "read", feature = "write"))]
#[derive(binrw::BinRead, binrw::BinWrite)]
pub struct ModelSectionInfo<T>
where T: binrw::BinRead + binrw::BinWrite<Args=()>,
<T as binrw::BinRead>::Args: Default,
{
pub stack: T,
pub runtime: T,
pub vertex_buffer: [T; 3],
pub edge_geometry_vertex_buffer: [T; 3],
pub index_buffer: [T; 3],
}
#[derive(Debug)]
#[cfg(all(feature = "write", not(feature = "read")))]
#[derive(binrw::BinWrite)]
pub struct ModelSectionInfo<T>
where T: binrw::BinWrite<Args=()>,
{
pub stack: T,
pub runtime: T,
pub vertex_buffer: [T; 3],
pub edge_geometry_vertex_buffer: [T; 3],
pub index_buffer: [T; 3],
}
#[derive(Debug)]
#[cfg(all(feature = "read", not(feature = "write")))]
#[derive(binrw::BinRead)]
pub struct ModelSectionInfo<T>
where T: binrw::BinRead,
<T as binrw::BinRead>::Args: Default,
{
pub stack: T,
pub runtime: T,
pub vertex_buffer: [T; 3],
pub edge_geometry_vertex_buffer: [T; 3],
pub index_buffer: [T; 3],
}
#[derive(Debug)]
#[cfg(not(any(feature = "read", feature = "write")))]
pub struct ModelSectionInfo<T> {
pub stack: T,
pub runtime: T,
pub vertex_buffer: [T; 3],
pub edge_geometry_vertex_buffer: [T; 3],
pub index_buffer: [T; 3],
}
#[derive(Debug)]
#[cfg_attr(feature = "read", derive(binrw::BinRead), br(little))]
#[cfg_attr(feature = "write", derive(binrw::BinWrite), bw(little))]
pub struct ModelBlock {
pub number_of_blocks: u32,
pub used_number_of_blocks: u32,
pub version: u32,
pub size: ModelSectionInfo<u32>,
pub compressed_size: ModelSectionInfo<u32>,
pub offset: ModelSectionInfo<u32>,
pub block_index: ModelSectionInfo<u16>,
pub block_num: ModelSectionInfo<u16>,
pub vertex_declaration_num: u16,
pub material_num: u16,
pub num_lods: u8,
pub index_buffer_streaming_enabled: u8,
pub edge_geometry_enabled: u8,
pub padding: u8,
}
Loading…
Cancel
Save